From 073762c9db51759d0685f5fa94560fa34914aaa4 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 26 May 2023 11:46:35 +0530 Subject: [PATCH 001/343] updated versions for apim 420 and jdk 17 --- .../pom.xml | 19 +- .../pom.xml | 16 +- .../pom.xml | 1 - .../pom.xml | 7 +- .../pom.xml | 12 +- .../pom.xml | 6 +- .../APIManagementProviderServiceImpl.java | 53 +-- .../pom.xml | 5 +- .../pom.xml | 5 +- .../pom.xml | 1 - .../extension/service/KeyMgtServiceImpl.java | 2 +- .../pom.xml | 11 +- .../publisher/APIPublisherServiceImpl.java | 4 +- .../org.wso2.carbon.apimgt.handlers/pom.xml | 7 +- .../pom.xml | 7 +- .../pom.xml | 1 - components/apimgt-extensions/pom.xml | 38 +- .../pom.xml | 7 +- .../pom.xml | 11 +- .../pom.xml | 6 +- .../pom.xml | 17 +- .../pom.xml | 11 +- .../pom.xml | 7 +- components/application-mgt/pom.xml | 34 +- .../pom.xml | 20 +- .../pom.xml | 26 +- .../pom.xml | 50 ++- ...CertificateManagementServiceImplTests.java | 15 +- components/certificate-mgt/pom.xml | 38 +- .../pom.xml | 16 +- .../pom.xml | 5 +- .../pom.xml | 6 +- .../pom.xml | 25 +- .../pom.xml | 5 + .../pom.xml | 7 +- .../pom.xml | 9 +- .../pom.xml | 8 +- .../pom.xml | 13 +- .../pom.xml | 7 +- .../pom.xml | 80 ++-- .../pom.xml | 1 - .../handlers/ScopeValidationHandler.java | 1 - .../pom.xml | 15 +- .../pom.xml | 7 +- .../pom.xml | 6 +- .../pom.xml | 11 +- .../pom.xml | 15 +- .../pom.xml | 10 +- .../pom.xml | 7 +- .../pom.xml | 28 +- .../pom.xml | 7 +- components/policy-mgt/pom.xml | 38 +- .../pom.xml | 21 +- .../pom.xml | 9 +- .../pom.xml | 5 +- .../pom.xml | 86 ++-- .../pom.xml | 11 +- .../pom.xml | 4 + .../pom.xml | 5 +- .../pom.xml | 26 +- .../interceptor/PermissionScopeHandler.java | 2 +- .../pom.xml | 9 +- .../webapp-authenticator-framework/pom.xml | 38 +- .../pom.xml | 5 +- .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 5 +- .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 5 +- .../pom.xml | 1 - .../pom.xml | 7 +- .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - pom.xml | 420 ++++++++++-------- 96 files changed, 801 insertions(+), 649 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index b2ddd8fa17..6f81d027e8 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -37,10 +37,7 @@ maven-compiler-plugin - - 1.8 - 1.8 - + maven-war-plugin @@ -61,7 +58,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 compile @@ -97,9 +93,8 @@ provided - org.apache.cxf + org.apache.cxf.wso2 cxf-bundle - 3.0.0-milestone2 test @@ -133,9 +128,10 @@ - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + org.wso2.carbon.identity.inbound.auth.oauth2 @@ -333,6 +329,11 @@ io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common provided + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.application.mgt.common + provided + diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index e72e7b62b9..0e921289d8 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -117,15 +117,22 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.common + provided + + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.application.mgt.common + provided org.wso2.carbon org.wso2.carbon.utils - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + org.wso2.carbon @@ -147,7 +154,6 @@ org.apache.httpcomponents.wso2 httpclient - 4.1.1.wso2v1 compile @@ -191,8 +197,8 @@ provided - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test 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 e19cb9e0f3..438fb28d72 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 @@ -41,7 +41,6 @@ org.apache.velocity velocity - 1.7 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 6fde8fc060..58e0ac2d1a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -43,8 +43,10 @@ org.eclipse.osgi.services - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + javax.ws.rs @@ -60,7 +62,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 364b6be7fe..a3dcb68c37 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -159,21 +159,21 @@ org.wso2.carbon.registry.core provided + + org.wso2.orbit.javax.xml.bind + jaxb-api + + org.apache.maven.plugins maven-compiler-plugin - - UTF-8 - ${wso2.maven.compiler.source} - ${wso2.maven.compiler.target} - + org.apache.maven.plugins maven-war-plugin - 2.2 ${project.artifactId} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 279733d44a..48ad10e3eb 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -47,8 +47,10 @@ org.wso2.carbon.utils - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.wso2.carbon.apimgt diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 338af5a1e2..b73ea49b7e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2018 - 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -83,9 +83,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe try { APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); - Application application = apiConsumer.getApplicationsByName(username, applicationName, ""); + Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); if (application != null) { - apiConsumer.removeApplication(application, username); + // todo:apim - apiConsumer.removeApplication(application, username); } } catch (APIManagementException e) { throw new APIManagerException("Failed to remove api application : " + applicationName, e); @@ -108,30 +108,30 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } try { APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); - Application application = apiConsumer.getApplicationsByName(username, applicationName, ""); + Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); int applicationId = 0; Subscriber subscriber = null; if (application == null) { - subscriber = apiConsumer.getSubscriber(username); + subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); if (subscriber == null) { // create subscriber - apiConsumer.addSubscriber(username, ""); - subscriber = apiConsumer.getSubscriber(username); + // todo:apim - apiConsumer.addSubscriber(username, ""); + subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); } //create application application = new Application(applicationName, subscriber); application.setTier(ApiApplicationConstants.DEFAULT_TIER); application.setGroupId(""); application.setTokenType("OAUTH"); - apiConsumer.addApplication(application, username); - application = apiConsumer.getApplicationsByName(username, applicationName, ""); + // todo:apim - apiConsumer.addApplication(application, username); + application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); } else { - subscriber = apiConsumer.getSubscriber(username); + subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); } Set subscribedAPIs = - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); + null; // todo:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); log.info("Already subscribed API count: " + subscribedAPIs.size()); @@ -141,7 +141,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (tags != null && tags.length > 0) { for (String tag : tags) { boolean startedTenantFlow = false; - Set apisWithTag = apiConsumer.getAPIsWithTag(tag, tenantDomain); + Set apisWithTag = null; // todo:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); /** * From APIM 4.0.0, APIs published in the super tenant can only be listed by @@ -164,7 +164,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe ". Caused by to inability to get super tenant username", e); } - apisWithTag = apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + apisWithTag = null; // todo:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); startedTenantFlow = true; } @@ -176,10 +176,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean subscriptionExist = false; if (subscribedAPIs.size() > 0) { for (SubscribedAPI subscribedAPI : subscribedAPIs) { - if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { - subscriptionExist = true; - break; - } + // todo:apim +// if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { +// subscriptionExist = true; +// break; +// } } } if (!subscriptionExist && !tempApiIds.contains(id)) { @@ -218,7 +219,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe * Oauth app for a child tenant. */ for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { - apiConsumer.addSubscription(apiTypeWrapper, username, application); + // todo:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); } } } @@ -249,8 +250,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIAdmin apiAdmin = new APIAdminImpl(); String keyManagerId = null; try { - List keyManagerConfigurations = apiAdmin - .getKeyManagerConfigurationsByTenant(tenantDomain); + List keyManagerConfigurations = null; // todo:apim - apiAdmin +// .getKeyManagerConfigurationsByTenant(tenantDomain); if (keyManagerConfigurations != null) { for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { keyManagerId = keyManagerConfigurationDTO.getUuid(); @@ -269,10 +270,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + "\"username\":\"" + username + "\"}"; - Map keyDetails = apiConsumer - .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", - allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", - jsonString, keyManagerId, tenantDomain); + Map keyDetails = null; // todo:apim - apiConsumer +// .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", +// allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", +// jsonString, keyManagerId, tenantDomain); if (keyDetails != null) { ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); @@ -281,7 +282,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return apiApplicationKey; } throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); - } catch (APIManagementException e) { +// todo:apim - commected as it says never throw since we commented apim calls above +// } catch (APIManagementException e) { + } catch (Exception e) { throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); } } catch (APIManagementException e) { 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 7dd0c74914..47bdfcc258 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 @@ -40,8 +40,8 @@ provided - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided @@ -95,7 +95,6 @@ org.apache.felix maven-bundle-plugin - 5.1.7 true diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index e1d584a964..5561082608 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -17,10 +17,7 @@ maven-compiler-plugin - - 1.8 - 1.8 - + maven-war-plugin diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index aac78c17e4..c7d84703db 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - 5.1.7 true diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index f04f67704d..c7da98973b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -435,7 +435,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { try { APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance(); APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner); - return apiConsumer.getApplicationsByName(owner, applicationName, ""); + return null; // todo:apim - apiConsumer.getApplicationsByName(owner, applicationName, ""); } catch (APIManagementException e) { msg = "Error while trying to retrieve the application"; log.error(msg); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index e23a764fbb..2a45ffeea1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -64,8 +64,10 @@ org.wso2.carbon.core - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.wso2.carbon @@ -118,8 +120,8 @@ provided - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test @@ -143,7 +145,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 5b0f094a4c..c24e38fdd2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -240,7 +240,9 @@ public class APIPublisherServiceImpl implements APIPublisherService { // need remove the local scope and add as a shared scope if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, apiScope.getKey())) { - if (apiProvider.isScopeKeyAssignedLocally(apiIdentifier, apiScope.getKey(), tenantId)) { + //todo:apim + // if (apiProvider.isScopeKeyAssignedLocally(apiIdentifier, apiScope.getKey(), tenantId)) { + if (true) { // collect scope to move as shared scopes scopesToMoveAsSharedScopes.add(apiScope); } else { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml index 24ee2eb967..bb79290fd6 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml @@ -35,8 +35,10 @@ - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.apache.synapse @@ -70,7 +72,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 4ae55f3a63..c91bf08475 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -33,7 +33,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true @@ -132,8 +131,10 @@ feign-okhttp - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.eclipse.osgi diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml index 026c034c88..98240ce166 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml @@ -69,7 +69,6 @@ com.google.code.maven-replacer-plugin replacer - 1.5.2 diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 040f3a9ed0..ae5f8c040c 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -43,23 +43,23 @@ io.entgra.device.mgt.core.apimgt.extension.rest.api - - - - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml index 5ce4c88fa3..78dfa71168 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml @@ -39,7 +39,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true @@ -85,8 +84,10 @@ org.eclipse.equinox.common - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + commons-codec.wso2 diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml index 08e0e2561f..30cc4268e9 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml @@ -54,7 +54,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.8 compile @@ -84,7 +83,6 @@ org.codehaus.mojo exec-maven-plugin - 1.5.0 test @@ -139,9 +137,10 @@ provided - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + org.json.wso2 @@ -220,5 +219,9 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.application.mgt.addons + + commons-io.wso2 + commons-io + \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index d6cb21f583..d1c04250dd 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -76,8 +76,10 @@ org.eclipse.equinox.common - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + commons-codec.wso2 diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 2845ac4f9c..d7283553df 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -97,7 +97,6 @@ org.apache.maven.plugins maven-surefire-plugin - 2.18 src/test/resources/testng.xml @@ -134,8 +133,10 @@ test - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.wso2.carbon @@ -230,7 +231,6 @@ commons-validator commons-validator - 1.6 commons-collections @@ -246,7 +246,6 @@ cglib cglib-nodep - 3.2.7 compile @@ -256,30 +255,26 @@ mysql mysql-connector-java - 5.1.34 test xerces.wso2 xercesImpl - 2.8.1.wso2v2 test - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test commons-dbcp.wso2 commons-dbcp - 1.4.0.wso2v1 test commons-pool.wso2 commons-pool - 1.5.6.wso2v1 test diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/pom.xml index e791d72f25..c24c704833 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/pom.xml @@ -54,7 +54,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.8 compile @@ -84,7 +83,6 @@ org.codehaus.mojo exec-maven-plugin - 1.5.0 test @@ -139,9 +137,10 @@ provided - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + org.json.wso2 @@ -220,5 +219,9 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.application.mgt.addons + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.common + \ No newline at end of file diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml index b9ba8faf36..f1ca183fb5 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml @@ -54,7 +54,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.8 compile @@ -84,7 +83,6 @@ org.codehaus.mojo exec-maven-plugin - 1.5.0 test @@ -139,9 +137,10 @@ provided - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + org.json.wso2 diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 5d698230c1..4badfb0349 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -50,22 +50,22 @@ ${maven.checkstyle.vesion} - - - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - - - + + + + + + + + + + + + + + + + + diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index a0c91ef23c..e95c4cf732 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -37,10 +37,7 @@ maven-compiler-plugin - - 1.8 - 1.8 - + maven-war-plugin @@ -87,7 +84,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 compile @@ -117,7 +113,6 @@ org.codehaus.mojo exec-maven-plugin - 1.2.1 test @@ -160,9 +155,10 @@ test - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + io.entgra.device.mgt.core @@ -206,6 +202,14 @@ io.entgra.device.mgt.core.apimgt.annotations provided + + com.google.code.gson + gson + + + org.wso2.orbit.javax.xml.bind + jaxb-api + diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index e97cfa8bd0..d55518babd 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -37,10 +37,7 @@ maven-compiler-plugin - - 1.8 - 1.8 - + maven-war-plugin @@ -87,7 +84,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 compile @@ -117,7 +113,6 @@ org.codehaus.mojo exec-maven-plugin - 1.2.1 test @@ -164,9 +159,10 @@ provided - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + io.entgra.device.mgt.core @@ -207,6 +203,20 @@ io.entgra.device.mgt.core.apimgt.annotations provided + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.common + provided + + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.core + provided + + + org.wso2.orbit.javax.xml.bind + jaxb-api + diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index ddd6720485..668fb6352a 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -58,7 +58,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true @@ -126,7 +125,6 @@ org.apache.maven.plugins maven-surefire-plugin - 2.18 src/test/resources/testng.xml @@ -142,16 +140,22 @@ jacoco-maven-plugin ${jacoco.maven.plugin.version} + + + + + + + + + + + + - default-instrument + jacoco-initialize - instrument - - - - default-restore-instrumented-classes - - restore-instrumented-classes + prepare-agent @@ -165,12 +169,12 @@ ${basedir}/target/coverage-reports/site - - default-report-integration - - report-integration - - + + + + + + @@ -196,8 +200,8 @@ testng - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test @@ -217,8 +221,10 @@ test - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.wso2.orbit.org.bouncycastle @@ -270,6 +276,10 @@ slf4j-simple test + + org.wso2.orbit.javax.xml.bind + jaxb-api + diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplTests.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplTests.java index 0094110b1d..74d761f373 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplTests.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplTests.java @@ -45,7 +45,6 @@ import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagement import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import sun.misc.BASE64Encoder; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; @@ -54,6 +53,7 @@ import java.security.PrivateKey; import java.security.Security; import java.security.cert.*; import java.util.ArrayList; +import java.util.Base64; import java.util.List; /** @@ -180,7 +180,6 @@ public class CertificateManagementServiceImplTests extends BaseDeviceManagementC @Test(description = "This test case tests Signature verification of a Certificate against the keystore") public void testVerifySignature() throws KeystoreException, CertificateEncodingException, CMSException, IOException { - BASE64Encoder encoder = new BASE64Encoder(); //generate and save a certificate in the keystore X509Certificate x509Certificate = managementService.generateX509Certificate(); //Generate CMSdata @@ -191,7 +190,7 @@ public class CertificateManagementServiceImplTests extends BaseDeviceManagementC generator.addCertificates(store); CMSSignedData degenerateSd = generator.generate(new CMSAbsentContent()); byte[] signature = degenerateSd.getEncoded(); - boolean verifySignature = managementService.verifySignature(encoder.encode(signature)); + boolean verifySignature = managementService.verifySignature(Base64.getEncoder().encodeToString(signature)); Assert.assertNotNull(verifySignature); Assert.assertTrue(verifySignature); log.info("VerifySignature Test Successful"); @@ -262,11 +261,11 @@ public class CertificateManagementServiceImplTests extends BaseDeviceManagementC @Test(description = "This test case tests generation of signed Certificate from a CSR") public void testGetSignedCertificateFromCSR() throws KeystoreException { CSRGenerator csrGeneration = new CSRGenerator(); - BASE64Encoder encoder = new BASE64Encoder(); // Generate key pair KeyPair keyPair = csrGeneration.generateKeyPair("RSA", 1024); byte[] csrData = csrGeneration.generateCSR("SHA256WithRSA", keyPair); - X509Certificate signedCertificateFromCSR = managementService.getSignedCertificateFromCSR(encoder.encode(csrData)); + X509Certificate signedCertificateFromCSR = managementService.getSignedCertificateFromCSR( + Base64.getEncoder().encodeToString(csrData)); Assert.assertNotNull(signedCertificateFromCSR); Assert.assertEquals(signedCertificateFromCSR.getType(), CertificateManagementConstants.X_509); log.info("GetSignedCertificateFromCSR Test Successful"); @@ -303,9 +302,8 @@ public class CertificateManagementServiceImplTests extends BaseDeviceManagementC @Test(description = "This test case tests converting a pem file to X509 Certificate") public void testPemToX509Certificate() throws IOException, KeystoreException { File caCert = new File(CA_CERT_PEM); - BASE64Encoder encoder = new BASE64Encoder(); byte[] caBytes = FileUtils.readFileToByteArray(caCert); - X509Certificate certificate = managementService.pemToX509Certificate(encoder.encode(caBytes)); + X509Certificate certificate = managementService.pemToX509Certificate(Base64.getEncoder().encodeToString(caBytes)); Assert.assertNotNull(certificate); Assert.assertEquals(certificate.getType(), CertificateManagementConstants.X_509); log.info("PemToX509Certificate Test Successful"); @@ -313,7 +311,6 @@ public class CertificateManagementServiceImplTests extends BaseDeviceManagementC @Test(description = "This test case tests extracting Certificate from the header Signature") public void testExtractCertificateFromSignature() throws KeystoreException, CertificateEncodingException, CMSException, IOException, DeviceManagementException { - BASE64Encoder encoder = new BASE64Encoder(); DeviceConfigurationManager.getInstance().initConfig(); //generate and save a certificate in the keystore X509Certificate x509Certificate = managementService.generateX509Certificate(); @@ -325,7 +322,7 @@ public class CertificateManagementServiceImplTests extends BaseDeviceManagementC generator.addCertificates(store); CMSSignedData degenerateSd = generator.generate(new CMSAbsentContent()); byte[] signature = degenerateSd.getEncoded(); - X509Certificate certificate = managementService.extractCertificateFromSignature(encoder.encode(signature)); + X509Certificate certificate = managementService.extractCertificateFromSignature(Base64.getEncoder().encodeToString(signature)); Assert.assertNotNull(certificate); Assert.assertEquals(certificate.getType(), CertificateManagementConstants.X_509); log.info("ExtractCertificateFromSignature Test Successful"); diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 137bd4040d..51691757c9 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -38,23 +38,23 @@ io.entgra.device.mgt.core.certificate.mgt.cert.admin.api - - - - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 283d9b9743..5bd1ca25cb 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -41,17 +41,12 @@ maven-scr-plugin + org.apache.maven.plugins maven-compiler-plugin - - 1.8 - 1.8 - - 2.3.2 org.apache.felix maven-bundle-plugin - 1.4.0 true @@ -141,8 +136,10 @@ org.wso2.carbon.core - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.wso2.carbon @@ -216,9 +213,8 @@ test - javax.xml.bind + org.wso2.orbit.javax.xml.bind jaxb-api - test diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index 71b60f8381..70a9a195a3 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -64,9 +64,10 @@ - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index cd3da29c98..3b8a1bbd9e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -101,8 +101,10 @@ - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + com.google.code.gson diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 82f53ee287..dd6554598e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -36,13 +36,11 @@ + org.apache.maven.plugins maven-compiler-plugin - - 1.8 - 1.8 - + org.apache.maven.plugins maven-war-plugin WEB-INF/lib/*cxf*.jar @@ -99,7 +97,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 compile @@ -129,7 +126,6 @@ org.codehaus.mojo exec-maven-plugin - 1.2.1 test @@ -156,11 +152,17 @@ provided - org.apache.cxf + org.apache.cxf.wso2 cxf-bundle - 3.0.0-milestone2 - test + + + + + + + + org.apache.cxf cxf-bundle-jaxrs @@ -192,9 +194,10 @@ - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + io.entgra.device.mgt.core diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index 8a5d35696c..253f7c86bb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -99,6 +99,11 @@ com.google.code.gson gson + + org.wso2.orbit.javax.xml.bind + jaxb-api + + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 3e774609ae..c011c1acaf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -37,10 +37,7 @@ maven-compiler-plugin - - 1.8 - 1.8 - + maven-war-plugin @@ -99,7 +96,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 compile @@ -129,7 +125,6 @@ org.codehaus.mojo exec-maven-plugin - 1.2.1 test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index eac71008d5..8d473781ab 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -165,8 +165,9 @@ io.entgra.device.mgt.core.device.mgt.common - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided org.wso2.carbon @@ -187,8 +188,8 @@ - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 12dd685758..5b805b3b55 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -87,8 +87,8 @@ test - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test @@ -136,6 +136,10 @@ org.apache.sling.testing.osgi-mock test + + org.wso2.orbit.javax.xml.bind + jaxb-api + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 4ed6e7b2b8..7d9e3da088 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -41,17 +41,12 @@ maven-scr-plugin + org.apache.maven.plugins maven-compiler-plugin - - 1.8 - 1.8 - - 2.3.2 org.apache.felix maven-bundle-plugin - 1.4.0 true @@ -118,8 +113,10 @@ org.wso2.carbon.core - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.wso2.carbon diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index d836b5d79e..954c10e8ff 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -59,8 +59,10 @@ org.wso2.carbon.core - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.wso2.carbon @@ -93,7 +95,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 9f1cc8619f..b04e6492c9 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -73,44 +73,44 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - file:src/test/resources/log4j.properties - - - src/test/resources/testng.xml - - - - - 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 - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -124,8 +124,8 @@ org.eclipse.osgi.services - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api org.wso2.carbon diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 054f9ed910..1198fd3b9a 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -68,7 +68,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java index 97df2786f7..9799e8d8b8 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java @@ -27,7 +27,6 @@ import org.wso2.carbon.identity.oauth.cache.OAuthCacheKey; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; import org.wso2.carbon.identity.oauth2.dao.TokenManagementDAO; import org.wso2.carbon.identity.oauth2.dao.TokenManagementDAOImpl; -import org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO; import org.wso2.carbon.identity.oauth2.model.AccessTokenDO; import org.wso2.carbon.identity.oauth2.model.ResourceScopeCacheEntry; import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 468996abc4..249ef62aec 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -121,8 +121,10 @@ commons-codec - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.testng @@ -146,8 +148,8 @@ - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test @@ -160,6 +162,10 @@ powermock-api-mockito test + + org.wso2.orbit.javax.xml.bind + jaxb-api + @@ -171,7 +177,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml index 5757801392..51e8460173 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml @@ -47,8 +47,10 @@ org.wso2.carbon.core - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.wso2.carbon.identity.framework @@ -85,7 +87,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 7011b3e319..8cc5123ab6 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -33,8 +33,10 @@ - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.testng diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 7767cdc8b7..d92821cfc6 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -238,8 +238,8 @@ provided - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test @@ -253,9 +253,10 @@ provided - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + org.wso2.carbon @@ -352,7 +353,7 @@ provided - javax.xml.bind + org.wso2.orbit.javax.xml.bind jaxb-api test diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 46083a1667..62d02c301c 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -23,7 +23,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true @@ -86,8 +85,9 @@ org.eclipse.equinox.common - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided io.entgra.device.mgt.core @@ -97,5 +97,14 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.policy.mgt.core + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.common + + + org.wso2.carbon + org.wso2.carbon.user.core + provided + diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 20b2c9298f..c32695d6b2 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -25,7 +25,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true @@ -79,13 +78,18 @@ org.eclipse.equinox.common - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided io.entgra.device.mgt.core io.entgra.device.mgt.core.policy.mgt.common + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.common + diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 6477371b8b..2ac8356ba7 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -42,7 +42,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true @@ -102,8 +101,10 @@ org.eclipse.equinox.common - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.testng diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index c9760e3e98..c31384c31d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -42,7 +42,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true @@ -83,7 +82,6 @@ org.apache.maven.plugins maven-surefire-plugin - 2.18 file:src/test/resources/log4j.properties @@ -132,8 +130,10 @@ org.eclipse.equinox.common - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.wso2.carbon @@ -181,6 +181,15 @@ io.entgra.device.mgt.core.policy.mgt.common + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.common + + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.core + + @@ -196,12 +205,11 @@ mysql mysql-connector-java - 5.1.34 test - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test @@ -214,14 +222,12 @@ commons-dbcp.wso2 commons-dbcp - 1.4.0.wso2v1 test commons-pool.wso2 commons-pool - 1.5.6.wso2v1 test @@ -246,6 +252,10 @@ io.entgra.device.mgt.core.server.bootup.heartbeat.beacon test + + org.wso2.orbit.javax.xml.bind + jaxb-api + diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml index c138d56414..3059b92749 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml @@ -43,7 +43,6 @@ org.apache.felix maven-bundle-plugin - 1.4.0 true @@ -97,8 +96,10 @@ org.eclipse.equinox.common - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + io.entgra.device.mgt.core diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index a17978dc66..5c5043ece5 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -41,24 +41,24 @@ - - - - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index e056b0a6a2..4349157706 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -243,9 +243,10 @@ provided - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + org.wso2.carbon @@ -340,19 +341,19 @@ com.google.guava guava - ${guava.version} + provided - org.json + org.json.wso2 json - ${json.version} + provided - com.fasterxml.jackson.core + org.wso2.orbit.com.fasterxml.jackson.core jackson-databind - ${fasterxml.jackson.version} + provided @@ -371,8 +372,8 @@ test - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test @@ -406,7 +407,7 @@ test - javax.xml.bind + org.wso2.orbit.javax.xml.bind jaxb-api test diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 129b9b310b..8511e83f69 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -103,9 +103,10 @@ provided - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + org.wso2.carbon @@ -134,6 +135,10 @@ org.wso2.carbon.ntask.core provided + + org.wso2.orbit.javax.xml.bind + jaxb-api + \ No newline at end of file diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 3046dbcbc9..1011141e50 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -84,9 +84,10 @@ provided - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + io.entgra.device.mgt.core diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 6cdaa2fcee..b25f17413a 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -80,44 +80,44 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - file:src/test/resources/log4j.properties - - - src/test/resources/testng.xml - - - - - 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 - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -131,8 +131,10 @@ org.eclipse.osgi.services - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.wso2.carbon @@ -174,6 +176,10 @@ commons-collections.wso2 commons-collections + + org.wso2.orbit.javax.xml.bind + jaxb-api + diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 801d901a8e..e04ee7b273 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -37,10 +37,7 @@ maven-compiler-plugin - - 1.8 - 1.8 - + maven-war-plugin @@ -61,7 +58,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 compile @@ -134,9 +130,10 @@ provided - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + io.entgra.device.mgt.core diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 422c6a00e5..6b59870558 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -90,6 +90,10 @@ swagger-annotations provided + + org.wso2.orbit.javax.xml.bind + jaxb-api + diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index d277b6289f..8b6bc1f41a 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -99,9 +99,10 @@ - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided + org.wso2.carbon diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 160f2b3094..dc3826357b 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -81,7 +81,6 @@ org.codehaus.mojo exec-maven-plugin - 1.4.0 test @@ -319,5 +318,30 @@ httpmime compile + + commons-fileupload.wso2 + commons-fileupload + + + commons-lang + commons-lang + + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common + provided + + + javax.websocket + javax.websocket-api + + + xerces.wso2 + xercesImpl + + + org.json.wso2 + json + \ No newline at end of file diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java index 6d363cb4b3..974231dc9f 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java @@ -22,7 +22,7 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; import org.json.JSONObject; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 8b5c951f6a..3083d062f7 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -254,8 +254,8 @@ commons-codec - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 test @@ -281,13 +281,16 @@ org.wso2.carbon javax.cache.wso2 - 4.6.3-m5 test org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth.stub + + org.wso2.carbon + org.wso2.carbon.base + diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 49ab101908..316f49a919 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -37,23 +37,23 @@ io.entgra.device.mgt.core.webapp.authenticator.framework - - - - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 767a64e491..47ffaa7795 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -60,8 +60,8 @@ ${cxf.version} - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 @@ -69,7 +69,6 @@ maven-resources-plugin - 2.6 copy-resources 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 91223f189e..d8beb4374a 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 @@ -41,7 +41,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index a1f97282cb..9bf539951e 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -45,7 +45,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 6056225fb8..9cdd5f9e48 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -44,7 +44,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 13402261d4..3b7e131862 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -61,7 +61,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml index e60e41a11e..6f2ae848bd 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml @@ -45,7 +45,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index 028f6998b9..9f8f8b4940 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -47,7 +47,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 4130f33b6a..57cc63ea67 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -60,8 +60,8 @@ ${cxf.version} - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 @@ -69,7 +69,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 391a9e379a..d2b9cc6553 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -73,7 +73,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index d33f4f3724..71072922c1 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -47,7 +47,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 67df35fb5f..60734677e6 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -44,7 +44,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index a7755227c6..a1b700bd6d 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -47,7 +47,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 1a3f2947e7..2779d21ec7 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -44,7 +44,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 487610ac59..9b660889a8 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -44,7 +44,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index c1618dc366..43b3dde6fb 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -44,7 +44,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 09f69cfa8c..8014092801 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -44,7 +44,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 03139cbf87..5d2c978a74 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -47,7 +47,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index cd3d512f57..f813b763a3 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -49,7 +49,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 9042c6ac7e..a0263bae1e 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -31,7 +31,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 5fc2b0ec18..4ca9d1a8af 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -62,7 +62,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml index 388ae4a1f5..154ccae674 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml @@ -80,7 +80,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 0bd010d5d2..3e69f94efd 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -37,8 +37,8 @@ - com.h2database.wso2 - h2-database-engine + org.wso2.orbit.com.h2database + h2 io.entgra.device.mgt.core @@ -80,7 +80,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index cd8ae0076e..f6e5d38608 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -51,7 +51,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 962616027b..b0962c8ec5 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -38,8 +38,10 @@ - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api + provided + org.testng @@ -59,7 +61,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index c28dd77f7a..3465606466 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -48,7 +48,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index f83dbe87ca..925f43997a 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -62,7 +62,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index dbe8c0d4f1..35982643df 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -46,7 +46,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 373a9fa675..4993d7a081 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -46,7 +46,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index d5768c90e9..3478f76af9 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -45,7 +45,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index eea430f6d0..a38d042939 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -50,7 +50,6 @@ org.apache.maven.plugins maven-resources-plugin - 2.6 copy-resources diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index bb4c779663..941bf1b64c 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -49,7 +49,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index 2b00b777dd..b35902a323 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -45,7 +45,6 @@ maven-resources-plugin - 2.6 copy-resources diff --git a/pom.xml b/pom.xml index 4b549f56a7..5504751710 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ org.wso2 wso2 - 1 + 1.3 @@ -625,11 +625,11 @@ org.eclipse.osgi.services ${eclipse.equinox.services.version} - - org.osgi.ut - org.eclipse.osgi - ${eclipse.equinox.services.version} - + + + + + @@ -830,11 +830,6 @@ - - org.wso2.carbon - org.wso2.carbon.logging - ${org.wso2.carbon.logging.version} - org.wso2.carbon org.wso2.carbon.core.services @@ -843,11 +838,11 @@ - - com.h2database.wso2 - h2-database-engine - ${orbit.version.h2.engine} - + + + + + org.wso2.orbit.com.h2database @@ -881,10 +876,9 @@ - javax.xml.bind + org.wso2.orbit.javax.xml.bind jaxb-api - ${jaxb.api.version} - test + ${version.org.wso2.orbit.javax.xml.bind} @@ -1186,41 +1180,41 @@ cxf-rt-transports-http ${cxf.version} - - org.apache.cxf - cxf-rt-bindings-soap - ${cxf.version} - - - org.apache.cxf - cxf-rt-databinding-jaxb - - - - - org.apache.cxf - cxf-rt-rs-extension-providers - ${cxf.version} - - - org.apache.cxf - cxf-rt-ws-security - ${cxf.version} - - - net.sf.ehcache - ehcache-core - - - org.apache.ws.security - wss4j - - - commons-logging - commons-logging - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1290,11 +1284,11 @@ - - org.wso2.carbon.identity.inbound.auth.saml2 - org.wso2.carbon.identity.sso.saml - ${identity.inbound.auth.saml.version} - + + + + + com.googlecode.json-simple.wso2 json-simple @@ -1365,6 +1359,11 @@ httpmime ${apache.http.mime.version} + + commons-lang + commons-lang + ${commons-lang.version} + commons-lang.wso2 commons-lang @@ -1390,11 +1389,11 @@ okhttp ${squareup.okhttp3.version} - - com.squareup.okio - okio - ${okio.version} - + + + + + io.github.openfeign feign-okhttp @@ -1432,6 +1431,11 @@ commons-httpclient ${commons.httpclient.version} + + org.apache.velocity + velocity + 1.7 + org.wso2.orbit.org.apache.velocity velocity @@ -1447,12 +1451,12 @@ commons-collections ${commons-collections.version} - - javax - javaee-web-api - 6.0 - provided - + + + + + + @@ -1463,11 +1467,11 @@ - - org.wso2.carbon.analytics-common - org.wso2.carbon.databridge.core - ${carbon.analytics.common.version} - + + + + + org.wso2.carbon.analytics-common org.wso2.carbon.event.stream.core @@ -1562,6 +1566,11 @@ httpcore ${httpcore.version} + + org.apache.httpcomponents.wso2 + httpclient + ${httpclient.wso2.version} + org.wso2.orbit.org.apache.httpcomponents httpclient @@ -1586,15 +1595,15 @@ ${eclipse.paho.version} - - commons-configuration - commons-configuration - ${commons-configuration.version} - + + + + + io.swagger swagger-annotations - ${swagger.annotations.version} + ${swagger.version} io.swagger @@ -1616,16 +1625,16 @@ org.wso2.carbon.event.output.adapter.core ${carbon.analytics.common.version} - - org.wso2.carbon.analytics - org.wso2.carbon.analytics.datasource.commons - ${carbon.analytics.version} - - - org.wso2.carbon.analytics - org.wso2.carbon.analytics.dataservice.commons - ${carbon.analytics.version} - + + + + + + + + + + org.wso2.carbon.analytics-common org.wso2.carbon.event.publisher.stub @@ -1887,6 +1896,32 @@ mockito-inline ${mokito.version} + + org.ops4j.pax.logging + pax-logging-api + ${pax.logging.api.version} + + + org.apache.cxf.wso2 + cxf-bundle + ${cxf-bundle.version} + test + + + commons-fileupload.wso2 + commons-fileupload + ${commons-fileupload.version} + + + cglib + cglib-nodep + 3.2.7 + + + org.wso2.carbon + javax.cache.wso2 + 4.6.3-m5 + @@ -1922,17 +1957,17 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + 3.8.1 UTF-8 - 1.8 - 1.8 + 17 + 17 org.apache.maven.plugins maven-war-plugin - 2.2 + 3.3.1 org.apache.maven.plugins @@ -1952,30 +1987,30 @@ org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + 3.8.1 UTF-8 - 1.8 - 1.8 + 17 + 17 - - org.apache.felix - maven-scr-plugin - 1.7.2 - - - generate-scr-scrdescriptor - - scr - - - - + + + + + + + + + + + + + org.apache.felix maven-bundle-plugin - 4.1.0 + 5.1.1 true NONE @@ -2016,7 +2051,13 @@ org.apache.maven.plugins maven-surefire-plugin - 2.18 + 2.22.0 + + + ${basedir}/target/coverage-reports/jacoco-ut.exec + + + org.apache.maven.plugins @@ -2033,6 +2074,26 @@ jacoco-maven-plugin ${jacoco.maven.plugin.version} + + org.codehaus.mojo + exec-maven-plugin + 1.4.0 + + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + com.google.code.maven-replacer-plugin + replacer + 1.5.2 + + + io.swagger + swagger-codegen-maven-plugin + 2.2.1 + @@ -2040,76 +2101,76 @@ 2.2.1 7.4.0 - 4.6.2 + 4.8.1 [4.5.0, 5.0.0) 5.1.2 - 1.3 - 3.1.3 - 4.4.9 + + + - [1.6.1.wso2v11, 1.7.0) - 1.6.1.wso2v11 + [1.6.1, 1.7.0) + 1.6.1-wso2v85 1.1.0-wso2v10 - 1.0.0.Final + - 0.12.8 - 1.5.6 - 1.5.6 - 1.5.6 - 1.5.6 + + + + + - 4.3.1 - 4.4.2 - 1.1.0 - 4.8.2 + + + + 4.13.1 3.6.200.v20130402-1505 3.3.100.v20120522-1822 - 3.9.1.v20140110-1610 + 3.8.1.v20120830-144521 - 1.2.140.wso2v3 + - 7.0.85.wso2v1 - 7.0.85.wso2v1 + 7.0.93.wso2v1 + 7.0.93.wso2v1 7.0.34.wso2v2 - 4.7.15 + - 5.18.187 - [5.2.0, 7.0.0) - 6.4.111 - 5.5.2 - 1.0.31 - [1.0.31, 2.0.0) + 5.24.8 + [5.14.0, 6.0.0) + 6.9.6 + + 2.1.1 + [2.1.1, 3.0.0) [5.14.0, 6.0.0) [6.0.0, 7.0.0) - [5.3.0, 6.0.0) + - 4.9.10 + 4.9.20 - 4.8.21 + 4.8.30 - 1.2.11-wso2v10 + 1.2.11-wso2v25 [1.2.11, 1.3.0) - 1.2.11.wso2v10 + 1.2.11-wso2v25 5.0.26-SNAPSHOT - 4.7.35 + 4.9.2 1.4.0.wso2v1 [1.4.0,2.0.0) 2.4.0.wso2v1 @@ -2117,31 +2178,31 @@ [2.6.0,3.0.0) - 9.0.174 + 9.28.116 [9.0.0, 10.0.0) - 5.2.34 - [5.2.34,6.0.0) + 5.3.5 + [5.3.0,6.0.0) 1.3.25 - [1.3.0,2.0.0) - 2.1.23 + + 2.3.5 - 4.7.39 + 4.8.13 ${carbon.registry.version} [4.7.0, 5.0.0) - 3.3.6 + 3.5.5 1.1.wso2v1 - 1.9.0 + 1.9.13 - 20220924 - 2.4.5 - 27.0.1-jre + + + 1.60.0.wso2v1 @@ -2153,17 +2214,17 @@ 3.0.0.wso2v1 1.3 - 2.8.5 + 2.9.1 31.0.1-jre 4.6.0 1.13.0 - 9.3.1 + 11.0 1.1.1 1.2 4.5.6 - 4.4.10 - 4.5.8 + 4.4.13 + 4.5.10 1.9 @@ -2171,7 +2232,7 @@ 2.0.4.wso2v4 - github-scm + 1.0.3.wso2v1 @@ -2180,15 +2241,16 @@ 4.3.1.wso2v2 [4.3.1, 5.0.0) - 4.3.3.wso2v1 + 4.4.16.wso2v1 3.1.0.wso2v2 + 4.2.5.wso2v1 1.7.0.wso2v1 2.4.0.wso2v1 3.2.0.wso2v1 (3.2.0, 3.3.0] - 1.8 + 5.1.34 @@ -2199,13 +2261,13 @@ 1.0.2 - 7.3.0.wso2v1 + 7.9.0.wso2v1 [7.3, 8) 2.0.1 - 1.5.10 - 1.6.1 + 1.6.9 + 4.0.1 @@ -2221,8 +2283,8 @@ 1.8.10.wso2v2 - 4.2.1 - [1.0.0, 1.1.0) + + 1.7.0 @@ -2235,13 +2297,13 @@ 2.1.7-wso2v227 - 1.5.11.wso2v15 + 1.5.11-wso2v18 1.5.1 - 9.3.1 + 11.0 [9.3.1,10.0.0) 1.0.1 @@ -2268,22 +2330,28 @@ 3.1.0 - 7.0.85 + 9.0.24 1.1 - 1.13.1 + - 5.1.13.RELEASE + 5.3.23 2.7.18 + 2.6.1.wso2v2 [1.6.0, 2.0.0) [1.2.0,1.3.0) 4.2.0 - 2.3.1 + 2.8.1.wso2v2 4.3.1.wso2v1 - 1.4.199.wso2v1 + 2.1.210.wso2v1 1.1.3 + + 1.11.2 + 2.3.1.wso2v1 + 2.4 + 1.2.2.wso2v1 From 6e0fe2e26e89f188e5a709bf48a9767807686659 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 1 Jun 2023 08:51:41 +0530 Subject: [PATCH 002/343] Integrate with APIM dev-portal APIs --- .../APIManagementProviderServiceImpl.java | 56 ++++++++++++++++++- .../extension/service/KeyMgtServiceImpl.java | 2 + .../publisher/APIPublisherServiceImpl.java | 4 +- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index d00f483fa4..1094fa3806 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -84,8 +84,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe try { APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +// curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" if (application != null) { // todo:apim - apiConsumer.removeApplication(application, username); + //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X DELETE "https://localhost:9443/api/am/devportal/v3/applications/896658a0-b4ee-4535-bbfa-806c894a4015" } } catch (APIManagementException e) { throw new APIManagerException("Failed to remove api application : " + applicationName, e); @@ -102,6 +104,37 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe String keyType, String username, boolean isAllowedAllDomains, String validityTime) throws APIManagerException { + +/* + +todo - Modify generateAndRetrieveApplicationKeys + +Check the existence of the API application. + +if Application is not exists + Create the Application + +If super tenants + Get set of tagged APIs +If the tenant domain is not super tenant + Get set of tagged APIs from super tenant space + +If new Application + Subscribed to tagged APIs +Else + Get all subscribed APIs of application + Filter out APIs and subscribed to APIs which can be subscribed + Filter -> Use set of tagged APis + Remove already subscribed APIs from the set + Subscribed to remaining APIs + +Get Application keys from application + If API keys are there return API keys + +Otherwise, Generate Application Keys and return them + + */ + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); if (StringUtils.isEmpty(username)) { username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + tenantDomain; @@ -109,15 +142,20 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe try { APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +// cnt rm +// // curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" int applicationId = 0; Subscriber subscriber = null; if (application == null) { subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); +// cnt rm if (subscriber == null) { // create subscriber // todo:apim - apiConsumer.addSubscriber(username, ""); +// cnt rm subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); +// cnt rm } //create application application = new Application(applicationName, subscriber); @@ -125,23 +163,30 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe application.setGroupId(""); application.setTokenType("OAUTH"); // todo:apim - apiConsumer.addApplication(application, username); +// cnt rm application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +// cnt rm } else { subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); +// cnt rm } Set subscribedAPIs = null; // todo:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); + //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/subscriptions?apiId=02e658e7-71c7-4b1d-a623-be145b789340" +// cnt rm + log.info("Already subscribed API count: " + subscribedAPIs.size()); // subscribe to apis. - Set tempApiIds = new HashSet<>(); APIConsumer apiConsumerAPIPublishedTenant = apiConsumer; if (tags != null && tags.length > 0) { for (String tag : tags) { boolean startedTenantFlow = false; Set apisWithTag = null; // todo:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); +// curl -k "https://localhost:9443/api/am/devportal/v3/apis" +// cnt rm /** * From APIM 4.0.0, APIs published in the super tenant can only be listed by @@ -165,11 +210,13 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } apisWithTag = null; // todo:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); +// cnt rm startedTenantFlow = true; } Set apiTypeWrapperList = new HashSet<>(); if (apisWithTag != null && apisWithTag.size() > 0) { + Set tempApiIds = new HashSet<>(); for (API apiInfo : apisWithTag) { String id = apiInfo.getId().getProviderName().replace("@", "-AT-") + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion(); @@ -177,6 +224,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (subscribedAPIs.size() > 0) { for (SubscribedAPI subscribedAPI : subscribedAPIs) { // todo:apim +// cnt rm // if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { // subscriptionExist = true; // break; @@ -220,6 +268,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe */ for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { // todo:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); +// cnt rm } } } @@ -250,8 +299,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIAdmin apiAdmin = new APIAdminImpl(); String keyManagerId = null; try { - List keyManagerConfigurations = null; // todo:apim - apiAdmin -// .getKeyManagerConfigurationsByTenant(tenantDomain); + List keyManagerConfigurations = null; // todo:apim - + // apiAdmin.getKeyManagerConfigurationsByTenant(tenantDomain); if (keyManagerConfigurations != null) { for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { keyManagerId = keyManagerConfigurationDTO.getUuid(); @@ -283,6 +332,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); // todo:apim - commected as it says never throw since we commented apim calls above +// cnt rm // } catch (APIManagementException e) { } catch (Exception e) { throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 4be11a8551..fdacd7fdd4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -436,6 +436,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance(); APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner); return null; // todo:apim - apiConsumer.getApplicationsByName(owner, applicationName, ""); + // // curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" + } catch (APIManagementException e) { msg = "Error while trying to retrieve the application"; log.error(msg); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 1e13a899c8..fda57d0d59 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -239,8 +239,8 @@ public class APIPublisherServiceImpl implements APIPublisherService { // need remove the local scope and add as a shared scope if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, apiScope.getKey())) { - //todo:apim - // if (apiProvider.isScopeKeyAssignedLocally(apiIdentifier, apiScope.getKey(), tenantId)) { + //resolve- todo:apim- resolve +// if (apiProvider.isScopeKeyAssignedLocally(apiIdentifier, apiScope.getKey(), tenantId)) { if (true) { // collect scope to move as shared scopes scopesToMoveAsSharedScopes.add(apiScope); From c98237dc6f188e8cdcd8e8e2ef8438369a5136ca Mon Sep 17 00:00:00 2001 From: Pasindu Rupasinghe Date: Thu, 1 Jun 2023 09:50:58 +0000 Subject: [PATCH 003/343] Implement service for consumer rest APIs Co-authored-by: Pasindu Rupasinghe Co-committed-by: Pasindu Rupasinghe --- .../rest/api/ConsumerRESTAPIServices.java | 64 +++ .../rest/api/ConsumerRESTAPIServicesImpl.java | 404 ++++++++++++++++++ .../rest/api/bean/APIMConsumer/APIKey.java | 41 ++ .../api/bean/APIMConsumer/Application.java | 143 +++++++ .../api/bean/APIMConsumer/Subscription.java | 106 +++++ .../rest/api/constants/Constants.java | 11 +- .../PublisherRESTAPIServiceComponent.java | 5 + 7 files changed, 773 insertions(+), 1 deletion(-) 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServicesImpl.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/bean/APIMConsumer/APIKey.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/bean/APIMConsumer/Application.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/bean/APIMConsumer/Subscription.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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java new file mode 100644 index 0000000000..0dd8783663 --- /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/ConsumerRESTAPIServices.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018 - 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.bean.APIMConsumer.APIKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +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.json.JSONObject; + +import java.util.List; +import java.util.Map; + +public interface ConsumerRESTAPIServices { + JSONObject getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Application application) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + JSONObject getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + JSONObject getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Map queryParam) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Subscription subscriptions) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + Subscription createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + List subscriptions) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + JSONObject getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java new file mode 100644 index 0000000000..383098dd3d --- /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/ConsumerRESTAPIServicesImpl.java @@ -0,0 +1,404 @@ +/* + * Copyright (c) 2018 - 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 com.google.gson.Gson; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +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 okhttp3.*; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + + private static final Log log = LogFactory.getLog(ConsumerRESTAPIServicesImpl.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 Gson gson = new Gson(); + private static final String host = System.getProperty(Constants.IOT_CORE_HOST); + private static final String port = System.getProperty(Constants.IOT_CORE_HTTPS_PORT); + private static final String endPointPrefix = Constants.HTTPS_PROTOCOL + Constants.SCHEME_SEPARATOR + host + + Constants.COLON + port; + + @Override + public JSONObject getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; + Request request = new Request.Builder() + .url(getAllApplicationsUrl) + .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 getAllApplications(apiApplicationKey, refreshedAccessToken, appName); + } 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(msg, e); + } + } + + @Override + public Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Application application) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; + + String applicationInfo = "{\n" + + " \"name\": \"" + application.getName() + "\",\n" + + " \"throttlingPolicy\": \"" + application.getThrottlingPolicy() + "\",\n" + + " \"description\": \"" + application.getDescription() + "\",\n" + + " \"tokenType\": \"" + application.getTokenType() + "\",\n" + + " \"groups\": " + gson.toJson(application.getGroups()) + ",\n" + + " \"attributes\": " + application.getAttributes().toString() + ",\n" + + " \"subscriptionScopes\": " + gson.toJson(application.getSubscriptionScopes()) + "\n" + + "}"; + + RequestBody requestBody = RequestBody.create(JSON, applicationInfo); + Request request = new Request.Builder() + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .post(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_CREATED == response.code()) { + return gson.fromJson(response.body().string(), Application.class); + } 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 createApplication(apiApplicationKey, refreshedAccessToken, application); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + 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(msg, e); + } + } + + @Override + public JSONObject getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; + 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 getAllSubscriptions(apiApplicationKey, refreshedAccessToken, applicationId); + } 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(msg, e); + } + } + + @Override + public JSONObject getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Map queryParams) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; + + for (Map.Entry query : queryParams.entrySet()) { + getAPIsURL = getAPIsURL + Constants.AMPERSAND + query.getKey() + Constants.EQUAL + query.getValue(); + } + + Request request = new Request.Builder() + .url(getAPIsURL) + .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 getAllApis(apiApplicationKey, refreshedAccessToken, queryParams); + } 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(msg, e); + } + } + + @Override + public Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Subscription subscriptions) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API; + + String subscriptionObject = "{\n" + + " \"applicationId\": \"" + subscriptions.getApplicationId() + "\",\n" + + " \"apiId\": \"" + subscriptions.getApiId() + "\",\n" + + " \"throttlingPolicy\": \"" + subscriptions.getThrottlingPolicy() + "\",\n" + + " \"requestedThrottlingPolicy\": \"" + subscriptions.getRequestedThrottlingPolicy() + "\"\n" + + "}"; + + RequestBody requestBody = RequestBody.create(JSON, subscriptionObject); + Request request = new Request.Builder() + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .post(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_CREATED == response.code()) { + return gson.fromJson(response.body().string(), Subscription.class); + } 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 createSubscription(apiApplicationKey, refreshedAccessToken, subscriptions); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + 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(msg, e); + } + } + + @Override + public Subscription createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + List subscriptions) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; + + String subscriptionsList = gson.toJson(subscriptions); + + RequestBody requestBody = RequestBody.create(JSON, subscriptionsList); + Request request = new Request.Builder() + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .post(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), Subscription.class); + } 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 createSubscriptions(apiApplicationKey, refreshedAccessToken, subscriptions); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + 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(msg, e); + } + } + + @Override + public APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + Constants.SLASH + applicationId + + "/generate-keys"; + + String keyInfo = "{\n" + + " \"validityPeriod\": 3600,\n" + + " \"additionalProperties\": {}\n" + + "}"; + + RequestBody requestBody = RequestBody.create(JSON, keyInfo); + Request request = new Request.Builder() + .url(getAllScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()) + .post(requestBody) + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), APIKey.class); + } 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 generateApplicationKeys(apiApplicationKey, refreshedAccessToken, applicationId); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + 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(msg, e); + } + } + + @Override + public JSONObject getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; + Request request = new Request.Builder() + .url(getAllKeyManagersUrl) + .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 getAllKeyManagers(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(msg, e); + } + } +} 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/bean/APIMConsumer/APIKey.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/APIMConsumer/APIKey.java new file mode 100644 index 0000000000..022f1831b4 --- /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/bean/APIMConsumer/APIKey.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018 - 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.bean.APIMConsumer; + +public class APIKey { + + private String apikey; + private int validityTime; + + public String getApikey() { + return apikey; + } + + public void setApikey(String apikey) { + this.apikey = apikey; + } + + public int getValidityTime() { + return validityTime; + } + + public void setValidityTime(int validityTime) { + this.validityTime = validityTime; + } +} 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/bean/APIMConsumer/Application.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/APIMConsumer/Application.java new file mode 100644 index 0000000000..4764f001b9 --- /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/bean/APIMConsumer/Application.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2018 - 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.bean.APIMConsumer; + +import org.json.JSONObject; + +import java.util.List; + +public class Application { + private String applicationId; + private String name; + private String throttlingPolicy; + private String description; + private String tokenType; + private String status; + private List groups; + private int subscriptionCount; + private List keys; + private JSONObject attributes; + private List subscriptionScopes; + private String owner; + private boolean hashEnabled; + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getThrottlingPolicy() { + return throttlingPolicy; + } + + public void setThrottlingPolicy(String throttlingPolicy) { + this.throttlingPolicy = throttlingPolicy; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getTokenType() { + return tokenType; + } + + public void setTokenType(String tokenType) { + this.tokenType = tokenType; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public List getGroups() { + return groups; + } + + public void setGroups(List groups) { + this.groups = groups; + } + + public int getSubscriptionCount() { + return subscriptionCount; + } + + public void setSubscriptionCount(int subscriptionCount) { + this.subscriptionCount = subscriptionCount; + } + + public List getKeys() { + return keys; + } + + public void setKeys(List keys) { + this.keys = keys; + } + + public JSONObject getAttributes() { + return attributes; + } + + public void setAttributes(JSONObject attributes) { + this.attributes = attributes; + } + + public List getSubscriptionScopes() { + return subscriptionScopes; + } + + public void setSubscriptionScopes(List subscriptionScopes) { + this.subscriptionScopes = subscriptionScopes; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public boolean isHashEnabled() { + return hashEnabled; + } + + public void setHashEnabled(boolean hashEnabled) { + this.hashEnabled = hashEnabled; + } +} 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java new file mode 100644 index 0000000000..edfbce6b6a --- /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/bean/APIMConsumer/Subscription.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2018 - 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.bean.APIMConsumer; + +import org.json.JSONObject; + +public class Subscription { + + private String subscriptionId; + private String applicationId; + private String apiId; + private JSONObject apiInfo; + private JSONObject applicationInfo; + private String throttlingPolicy; + private String requestedThrottlingPolicy; + private String status; + private String redirectionParams; + + public String getSubscriptionId() { + return subscriptionId; + } + + public void setSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + } + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public String getApiId() { + return apiId; + } + + public void setApiId(String apiId) { + this.apiId = apiId; + } + + public JSONObject getApiInfo() { + return apiInfo; + } + + public void setApiInfo(JSONObject apiInfo) { + this.apiInfo = apiInfo; + } + + public JSONObject getApplicationInfo() { + return applicationInfo; + } + + public void setApplicationInfo(JSONObject applicationInfo) { + this.applicationInfo = applicationInfo; + } + + public String getThrottlingPolicy() { + return throttlingPolicy; + } + + public void setThrottlingPolicy(String throttlingPolicy) { + this.throttlingPolicy = throttlingPolicy; + } + + public String getRequestedThrottlingPolicy() { + return requestedThrottlingPolicy; + } + + public void setRequestedThrottlingPolicy(String requestedThrottlingPolicy) { + this.requestedThrottlingPolicy = requestedThrottlingPolicy; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getRedirectionParams() { + return redirectionParams; + } + + public void setRedirectionParams(String redirectionParams) { + this.redirectionParams = redirectionParams; + } +} 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 5a577e3eb1..5ce6c023c9 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 @@ -24,6 +24,9 @@ public final class Constants { } public static final String EMPTY_STRING = ""; + public static final String AMPERSAND = "&"; + public static final String SLASH = "/"; + public static final String EQUAL = "="; public static final String CLIENT_NAME = "rest_api_publisher_code"; public static final String SERVER_USER = "WorkflowConfigurations.ServerUser"; public static final String SERVER_PASSWORD = "WorkflowConfigurations.ServerPassword"; @@ -34,7 +37,9 @@ public final class Constants { 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 apim:api_import_export apim:api_publish"; + public static final String SCOPES = "apim:api_create apim:api_view apim:shared_scope_manage apim:api_import_export " + + "apim:api_publish apim:admin apim:api_key apim:app_import_export apim:app_manage apim:store_settings " + + "apim:sub_alert_manage apim:sub_manage apim:subscribe openid"; 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"; @@ -65,6 +70,10 @@ public final class Constants { public static final String SCOPE_API_ENDPOINT = "/api/am/publisher/v2/scopes/"; public static final String API_ENDPOINT = "/api/am/publisher/v2/apis/"; public static final String GET_ALL_APIS = "/api/am/publisher/v2/apis?limit=1000"; + public static final String APPLICATIONS_API = "/api/am/devportal/v3/applications"; + public static final String SUBSCRIPTION_API = "/api/am/devportal/v3/subscriptions"; + public static final String DEV_PORTAL_API = "/api/am/devportal/v3/apis?limit=1000"; + public static final String KEY_MANAGERS_API = "/api/am/devportal/v2/key-managers"; } 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/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 index 799d5ee1c9..86cb5109e3 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/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 @@ -20,6 +20,8 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.internal; 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.ConsumerRESTAPIServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServicesImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -51,6 +53,9 @@ public class PublisherRESTAPIServiceComponent { bundleContext.registerService(APIApplicationServices.class.getName(), apiApplicationServices, null); PublisherRESTAPIDataHolder.getInstance().setApiApplicationServices(apiApplicationServices); + ConsumerRESTAPIServices consumerRESTAPIServices = new ConsumerRESTAPIServicesImpl(); + bundleContext.registerService(ConsumerRESTAPIServices.class.getName(), consumerRESTAPIServices, null); + if (log.isDebugEnabled()) { log.debug("API Application bundle has been successfully initialized"); } From 22f4da908f096123d31b8501873fc3eb47c4d1a2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 1 Jun 2023 17:13:51 +0530 Subject: [PATCH 004/343] Add Consumer REST API integration --- .../pom.xml | 6 ++++ ...ApplicationManagerExtensionDataHolder.java | 10 ++++++ ...ationManagerExtensionServiceComponent.java | 32 +++++++++++++++++++ .../internal/PublisherRESTAPIDataHolder.java | 11 +++++++ .../PublisherRESTAPIServiceComponent.java | 3 +- 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 9968446869..d9a1370d00 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -74,6 +74,11 @@ io.entgra.device.mgt.core.identity.jwt.client.extension provided + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.apimgt.extension.rest.api + + @@ -121,6 +126,7 @@ io.entgra.device.mgt.core.identity.jwt.client.extension.dto, io.entgra.device.mgt.core.identity.jwt.client.extension.exception, io.entgra.device.mgt.core.identity.jwt.client.extension.service, + io.entgra.device.mgt.core.apimgt.extension.rest.api, org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", org.wso2.carbon.registry.core.service;version="[1.0,2)", org.wso2.carbon.registry.indexing.service;version="${carbon.registry.imp.pkg.version.range}", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 8a4cf4f1a6..893e17034b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.apimgt.application.extension.internal; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; @@ -35,6 +36,7 @@ public class APIApplicationManagerExtensionDataHolder { private TenantRegistryLoader tenantRegistryLoader; private TenantIndexingLoader indexLoader; private JWTClientManagerService jwtClientManagerService; + private ConsumerRESTAPIServices consumerRESTAPIServices; private APIApplicationManagerExtensionDataHolder() { } @@ -103,4 +105,12 @@ public class APIApplicationManagerExtensionDataHolder { public void setJwtClientManagerService(JWTClientManagerService jwtClientManagerService) { this.jwtClientManagerService = jwtClientManagerService; } + + public ConsumerRESTAPIServices getConsumerRESTAPIServices() { + return consumerRESTAPIServices; + } + + public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + this.consumerRESTAPIServices = consumerRESTAPIServices; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 53dccb67d8..9e9166d11a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.apimgt.application.extension.internal; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -48,6 +49,12 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRealmService" * unbind="unsetRealmService" + * @scr.reference name="io.entgra.device.mgt.core.apimgt.extension.rest.api" + * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" + * cardinality="0..1" + * policy="dynamic" + * bind="setConsumerRESTAPIServices" + * unbind="unsetConsumerRESTAPIServices" */ public class APIApplicationManagerExtensionServiceComponent { @@ -113,4 +120,29 @@ public class APIApplicationManagerExtensionServiceComponent { } APIApplicationManagerExtensionDataHolder.getInstance().setRealmService(null); } + + /** + * Sets APIM Consumer REST API service. + * + * @param consumerRESTAPIServices An instance of ConsumerRESTAPIServices + */ + protected void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + if (log.isDebugEnabled()) { + log.debug("Setting Realm Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setConsumerRESTAPIServices(consumerRESTAPIServices); + } + + /** + * Unset APIM Consumer REST API service + * + * @param consumerRESTAPIServices An instance of ConsumerRESTAPIServices + */ + protected void unsetConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + if (log.isDebugEnabled()) { + log.debug("Unsetting Realm Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setConsumerRESTAPIServices(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/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 index 9a53757b0b..4995df95ef 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/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 @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.internal; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; public class PublisherRESTAPIDataHolder { @@ -26,6 +27,8 @@ public class PublisherRESTAPIDataHolder { private APIApplicationServices apiApplicationServices; private APIManagerConfigurationService apiManagerConfigurationService; + private ConsumerRESTAPIServices consumerRESTAPIServices; + private static PublisherRESTAPIDataHolder thisInstance = new PublisherRESTAPIDataHolder(); private PublisherRESTAPIDataHolder() { @@ -54,4 +57,12 @@ public class PublisherRESTAPIDataHolder { return apiManagerConfigurationService; } + public ConsumerRESTAPIServices getConsumerRESTAPIServices() { + return consumerRESTAPIServices; + } + + public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + this.consumerRESTAPIServices = consumerRESTAPIServices; + } + } 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/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 index 86cb5109e3..cb5c992664 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/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 @@ -40,7 +40,7 @@ import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; */ public class PublisherRESTAPIServiceComponent { - private static Log log = LogFactory.getLog(PublisherRESTAPIServiceComponent.class); + private static final Log log = LogFactory.getLog(PublisherRESTAPIServiceComponent.class); protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { @@ -55,6 +55,7 @@ public class PublisherRESTAPIServiceComponent { ConsumerRESTAPIServices consumerRESTAPIServices = new ConsumerRESTAPIServicesImpl(); bundleContext.registerService(ConsumerRESTAPIServices.class.getName(), consumerRESTAPIServices, null); + PublisherRESTAPIDataHolder.getInstance().setConsumerRESTAPIServices(consumerRESTAPIServices); if (log.isDebugEnabled()) { log.debug("API Application bundle has been successfully initialized"); From 2d37dcb340ed84c83e67d5f92db812f7be241787 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 6 Jun 2023 11:17:29 +0530 Subject: [PATCH 005/343] Add API app registering refactored code --- .../APIManagementProviderService.java | 5 +++ .../APIManagementProviderServiceImpl.java | 36 ++++++++++++++++++ ...ApplicationManagerExtensionDataHolder.java | 10 +++++ ...ationManagerExtensionServiceComponent.java | 38 +++++++++++++++++-- 4 files changed, 86 insertions(+), 3 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index a46dc715b7..d2d2fe4674 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -50,6 +50,11 @@ public interface APIManagementProviderService { String keyType, String username, boolean isAllowedAllDomains, String validityTime) throws APIManagerException; + ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) throws APIManagerException; + /** * Remove APIM Application. */ diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 1094fa3806..872d374c90 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -18,6 +18,11 @@ package io.entgra.device.mgt.core.apimgt.application.extension; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.RegistrationProfile; +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; @@ -96,6 +101,37 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } + @Override + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) throws APIManagerException { + + + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + + /* + + */ + + try { + consumerRESTAPIServices.getAllApplications(null, null, null); + } catch (APIServicesException e) { + e.printStackTrace(); + } catch (BadRequestException e) { + e.printStackTrace(); + } catch (UnexpectedResponseException e) { + e.printStackTrace(); + } + + return null; + + + } + + /** * {@inheritDoc} */ diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 893e17034b..1074edd9d7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.apimgt.application.extension.internal; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; @@ -37,6 +38,7 @@ public class APIApplicationManagerExtensionDataHolder { private TenantIndexingLoader indexLoader; private JWTClientManagerService jwtClientManagerService; private ConsumerRESTAPIServices consumerRESTAPIServices; + private APIApplicationServices apiApplicationServices; private APIApplicationManagerExtensionDataHolder() { } @@ -113,4 +115,12 @@ public class APIApplicationManagerExtensionDataHolder { public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { this.consumerRESTAPIServices = consumerRESTAPIServices; } + + public APIApplicationServices getApiApplicationServices() { + return apiApplicationServices; + } + + public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { + this.apiApplicationServices = apiApplicationServices; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 9e9166d11a..b2f82e6c31 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.apimgt.application.extension.internal; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -49,12 +50,18 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRealmService" * unbind="unsetRealmService" - * @scr.reference name="io.entgra.device.mgt.core.apimgt.extension.rest.api" + * @scr.reference name="apimgt.extension.ConsumerRESTAPIServices" * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" * cardinality="0..1" * policy="dynamic" * bind="setConsumerRESTAPIServices" * unbind="unsetConsumerRESTAPIServices" + * @scr.reference name="apimgt.extension.APIApplicationService" + * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices" + * cardinality="0..1" + * policy="dynamic" + * bind="setAPIApplicationServices" + * unbind="unsetAPIApplicationServices" */ public class APIApplicationManagerExtensionServiceComponent { @@ -128,7 +135,7 @@ public class APIApplicationManagerExtensionServiceComponent { */ protected void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { if (log.isDebugEnabled()) { - log.debug("Setting Realm Service"); + log.debug("Setting APIM Consumer REST API Service"); } APIApplicationManagerExtensionDataHolder.getInstance().setConsumerRESTAPIServices(consumerRESTAPIServices); } @@ -140,9 +147,34 @@ public class APIApplicationManagerExtensionServiceComponent { */ protected void unsetConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { if (log.isDebugEnabled()) { - log.debug("Unsetting Realm Service"); + log.debug("Unsetting APIM Consumer REST API Service"); } APIApplicationManagerExtensionDataHolder.getInstance().setConsumerRESTAPIServices(null); } + + /** + * Sets DCR REST API service. + * + * @param apiApplicationServices An instance of APIApplicationServices + */ + protected void setAPIApplicationServices(APIApplicationServices apiApplicationServices) { + if (log.isDebugEnabled()) { + log.debug("Setting DCR REST API Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setApiApplicationServices(apiApplicationServices); + } + + /** + * Unset DCR REST API service + * + * @param apiApplicationServices An instance of APIApplicationServices + */ + protected void unsetAPIApplicationServices(APIApplicationServices apiApplicationServices) { + if (log.isDebugEnabled()) { + log.debug("Unsetting DCR REST API Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setApiApplicationServices(null); + } + } From 1bb571acde84ab2b36dd36725d82131c2208ed03 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Tue, 6 Jun 2023 12:42:33 +0530 Subject: [PATCH 006/343] fixing dependency issues when installing on apim420 --- .../proxy/api/GrafanaAPIProxyService.java | 21 +- .../proxy/api/addons/ApiOriginFilter.java | 7 +- .../api/addons/ValidationInterceptor.java | 6 +- .../api/impl/GrafanaAPIProxyServiceImpl.java | 14 +- .../impl/util/GrafanaRequestHandlerUtil.java | 4 +- .../pom.xml | 14 +- .../pom.xml | 82 ++++-- .../GrafanaManagementServiceComponent.java | 12 +- .../pom.xml | 20 +- .../extension/AnalyticsArtifactsDeployer.java | 7 +- .../pom.xml | 29 +- .../pom.xml | 6 +- ...ApiApplicationRegistrationServiceImpl.java | 8 +- .../api/filter/ApiPermissionFilter.java | 9 +- .../extension/api/util/APIUtil.java | 8 +- .../pom.xml | 51 ++-- .../APIManagementProviderServiceImpl.java | 33 +-- .../extension/dto/ApiApplicationKey.java | 2 +- ...ApplicationManagerExtensionDataHolder.java | 2 +- ...ationManagerExtensionServiceComponent.java | 52 ++-- .../extension/util/APIManagerUtil.java | 4 +- .../pom.xml | 48 ++-- .../rest/api/APIApplicationServicesImpl.java | 14 +- .../rest/api/PublisherRESTAPIServices.java | 9 +- .../api/PublisherRESTAPIServicesImpl.java | 15 +- .../rest/api/constants/Constants.java | 8 +- .../PublisherRESTAPIServiceComponent.java | 23 +- .../rest/api/util/HttpsTrustManagerUtils.java | 24 +- .../pom.xml | 5 +- .../extension/api/KeyManagerService.java | 7 +- .../extension/api/KeyManagerServiceImpl.java | 7 +- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 4 +- .../pom.xml | 53 +++- .../KeyManagerConnectorConfiguration.java | 8 +- .../extension/KeyValidationHandler.java | 16 +- .../internal/KeyMgtServiceComponent.java | 16 +- .../extension/service/KeyMgtServiceImpl.java | 31 +-- .../pom.xml | 98 ++++--- .../publisher/APIPublisherServiceImpl.java | 42 +-- .../publisher/APIPublisherStartupHandler.java | 4 +- .../webapp/publisher/APIPublisherUtil.java | 4 +- .../config/WebappPublisherConfig.java | 2 +- .../APIPublisherServiceComponent.java | 41 +-- .../APIPublisherLifecycleListener.java | 12 +- .../lifecycle/util/AnnotationProcessor.java | 19 +- .../ExtendedFileProtocolIteratorFactory.java | 1 - .../publisher/APIPublisherServiceTest.java | 14 +- .../publisher/APIPublisherUtilTest.java | 11 +- .../publisher/BaseAPIPublisherTest.java | 6 +- .../org.wso2.carbon.apimgt.handlers/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 21 +- .../pom.xml | 40 ++- .../mgt/addons/JSONMessageHandler.java | 6 +- .../mgt/addons/MultipartCustomProvider.java | 2 +- .../pom.xml | 1 - .../mgt/api/ArtifactDownloadAPI.java | 16 +- .../mgt/api/impl/ArtifactDownloadAPIImpl.java | 17 +- .../pom.xml | 42 +-- .../common/ApplicationInstallResponse.java | 2 +- .../common/ApplicationSubscriptionInfo.java | 1 - .../application/mgt/common/DeviceList.java | 2 +- .../mgt/common/DeviceSubscriptionData.java | 2 - .../mgt/common/InstallationDetails.java | 2 +- .../mgt/common/LifecycleState.java | 2 +- .../common/dto/ScheduledSubscriptionDTO.java | 2 +- .../common/services/ApplicationManager.java | 18 +- .../mgt/common/services/ReviewManager.java | 4 +- .../common/services/SubscriptionManager.java | 2 +- .../pom.xml | 135 +++++++--- .../mgt/core/config/Configuration.java | 4 +- .../mgt/core/config/ConfigurationManager.java | 6 +- .../mgt/core/config/Extension.java | 2 +- .../mgt/core/dao/ApplicationDAO.java | 2 +- .../mgt/core/dao/ApplicationReleaseDAO.java | 2 +- .../application/mgt/core/dao/ReviewDAO.java | 2 +- .../mgt/core/dao/SPApplicationDAO.java | 2 +- .../ApplicationManagementDAOFactory.java | 42 ++- .../GenericApplicationDAOImpl.java | 20 +- .../application/OracleApplicationDAOImpl.java | 8 +- .../SQLServerApplicationDAOImpl.java | 8 +- .../GenericApplicationReleaseDAOImpl.java | 14 +- .../OracleApplicationReleaseDAOImpl.java | 4 +- .../SQLServerApplicationReleaseDAOImpl.java | 4 +- .../GenericSPApplicationDAOImpl.java | 8 +- .../OracleSPApplicationDAOImpl.java | 9 +- .../PostgreSQLSPApplicationDAOImpl.java | 9 +- .../SQLServerSPApplicationDAOImpl.java | 9 +- .../GenericLifecycleStateDAOImpl.java | 14 +- .../dao/impl/review/GenericReviewDAOImpl.java | 17 +- .../dao/impl/review/OracleReviewDAOImpl.java | 8 +- .../impl/review/SQLServerReviewDAOImpl.java | 6 +- .../GenericSubscriptionDAOImpl.java | 26 +- .../OracleSubscriptionDAOImpl.java | 4 +- .../SQLServerSubscriptionDAOImpl.java | 4 +- .../visibility/GenericVisibilityDAOImpl.java | 4 +- .../mgt/core/impl/ApplicationManagerImpl.java | 86 ++---- .../impl/ApplicationStorageManagerImpl.java | 21 +- .../mgt/core/impl/AppmDataHandlerImpl.java | 10 +- .../mgt/core/impl/ReviewManagerImpl.java | 20 +- .../core/impl/SPApplicationManagerImpl.java | 9 +- .../core/impl/SubscriptionManagerImpl.java | 64 ++--- ...ApplicationManagementServiceComponent.java | 78 +++--- .../mgt/core/internal/DataHolder.java | 7 +- .../core/lifecycle/LifecycleStateManager.java | 8 +- .../impl/WSO2IAMSPApplicationService.java | 3 +- .../ScheduledAppSubscriptionCleanupTask.java | 6 +- .../task/ScheduledAppSubscriptionTask.java | 12 +- .../ScheduledAppSubscriptionTaskManager.java | 20 +- .../application/mgt/core/util/APIUtil.java | 37 ++- .../core/util/ApplicationManagementUtil.java | 35 +-- .../util/ApplicationMgtDatabaseCreator.java | 1 + .../mgt/core/util/ArtifactsParser.java | 12 +- .../mgt/core/util/ConnectionManagerUtil.java | 8 +- .../application/mgt/core/util/DAOUtil.java | 14 +- .../application/mgt/core/util/HelperUtil.java | 4 +- .../application/mgt/core/util/OAuthUtils.java | 6 +- .../mgt/core/ArtifactParserTest.java | 4 +- .../application/mgt/core/BaseTestCase.java | 14 +- .../mgt/core/ConfigurationTest.java | 6 +- .../core/application/mgt/core/InitTest.java | 2 +- .../mgt/core/LifeCycleStateManagerTest.java | 2 +- .../mgt/core/LifecycleManagementTest.java | 8 +- .../mgt/core/StorageManagementUtilTest.java | 6 +- .../dao/ApplicationManagementDAOTest.java | 10 +- .../management/ApplicationManagementTest.java | 14 +- .../conf/datasources/master-datasources.xml | 2 +- .../repository/conf/etc/tasks-config.xml | 2 +- .../pom.xml | 1 - .../ApplicationManagementPublisherAPI.java | 35 +-- .../publisher/api/SPApplicationService.java | 22 +- ...pplicationManagementPublisherAdminAPI.java | 20 +- .../ReviewManagementPublisherAdminAPI.java | 17 +- ...ApplicationManagementPublisherAPIImpl.java | 44 +-- .../api/impl/SPApplicationServiceImpl.java | 12 +- ...cationManagementPublisherAdminAPIImpl.java | 13 +- ...ReviewManagementPublisherAdminAPIImpl.java | 10 +- .../pom.xml | 1 - .../services/ApplicationManagementAPI.java | 22 +- .../api/services/ReviewManagementAPI.java | 23 +- .../services/SubscriptionManagementAPI.java | 19 +- .../admin/ReviewManagementStoreAdminAPI.java | 17 +- .../admin/SubscriptionManagementAdminAPI.java | 21 +- .../impl/ApplicationManagementAPIImpl.java | 13 +- .../impl/ReviewManagementAPIImpl.java | 24 +- .../impl/SubscriptionManagementAPIImpl.java | 31 +-- .../ReviewManagementStoreAdminAPIImpl.java | 12 +- .../SubscriptionManagementAdminAPIImpl.java | 21 +- .../impl/util/RequestValidationUtil.java | 6 +- .../api/services/ReviewManagementAPITest.java | 4 +- components/application-mgt/pom.xml | 19 +- .../pom.xml | 2 +- .../api/impl/CertificateMgtServiceImpl.java | 12 +- .../pom.xml | 3 +- .../cert/admin/api/beans/CertificateList.java | 2 +- ...CertificateManagementAdminServiceImpl.java | 5 +- .../api/util/CertificateMgtAPIUtils.java | 6 +- .../admin/api/util/RequestValidationUtil.java | 2 +- .../pom.xml | 129 ++++----- .../impl/CertificateCacheManagerImpl.java | 2 +- .../dao/CertificateManagementDAOFactory.java | 4 +- .../dao/impl/AbstractCertificateDAOImpl.java | 8 +- .../dao/impl/GenericCertificateDAOImpl.java | 8 +- .../dao/impl/OracleCertificateDAOImpl.java | 8 +- .../impl/PostgreSQLCertificateDAOImpl.java | 8 +- .../dao/impl/SQLServerCertificateDAOImpl.java | 8 +- .../mgt/core/impl/CertificateGenerator.java | 46 +--- .../mgt/core/impl/KeyStoreReader.java | 10 +- ...CertificateManagementServiceComponent.java | 33 +-- .../mgt/core/scep/SCEPManagerImpl.java | 8 +- .../mgt/core/util/CertificateManagerUtil.java | 6 +- .../util/CertificateMgtSchemaInitializer.java | 2 +- .../certificate/mgt/core/util/Serializer.java | 6 +- .../BaseDeviceManagementCertificateTest.java | 8 +- .../CertificateCacheManagerImplTests.java | 4 +- .../CertificateGeneratorNegativeTests.java | 15 +- .../impl/CertificateGeneratorTestSuite.java | 4 +- .../core/impl/CertificateGeneratorTests.java | 2 +- ...ateManagementServiceImplNegativeTests.java | 8 +- ...CertificateManagementServiceImplTests.java | 25 +- .../mgt/core/impl/CertificateTests.java | 2 +- .../mgt/core/util/DummyCertificate.java | 13 +- .../conf/datasources/master-datasources.xml | 2 +- components/certificate-mgt/pom.xml | 21 +- .../pom.xml | 44 ++- .../internal/RoleManagerServiceComponent.java | 37 +-- .../pom.xml | 66 +++-- .../type/deployer/DeviceTypeCAppDeployer.java | 2 +- .../deployer/DeviceTypePluginDeployer.java | 14 +- .../DeviceTypeManagementServiceComponent.java | 45 ++-- .../deployer/util/DeviceTypeConfigUtil.java | 2 +- .../deployer/DeviceTypeCAppDeployerTest.java | 4 +- .../DeviceTypePluginDeployerTest.java | 4 +- .../pom.xml | 7 +- .../pom.xml | 45 ++-- .../PullNotificationSubscriberImpl.java | 6 +- .../PullNotificationServiceComponent.java | 52 ++-- .../pom.xml | 41 +-- .../provider/fcm/FCMNotificationStrategy.java | 4 +- .../FCMPushNotificationServiceComponent.java | 25 +- .../pom.xml | 44 ++- .../provider/http/HTTPMessageExecutor.java | 4 +- .../http/HTTPNotificationStrategy.java | 8 +- .../HTTPPushNotificationServiceComponent.java | 10 +- .../pom.xml | 49 ++-- .../mqtt/MQTTNotificationStrategy.java | 8 +- .../mqtt/internal/MQTTDataHolder.java | 1 - .../MQTTPushNotificationServiceComponent.java | 36 +-- ...MQTTBasedPushNotificationProviderTest.java | 9 +- .../mqtt/MQTTNotificationStrategyTest.java | 20 +- .../pom.xml | 43 ++- .../xmpp/XMPPNotificationStrategy.java | 4 +- .../XMPPPushNotificationServiceComponent.java | 36 +-- .../pom.xml | 28 +- .../stateengine/spi/DeviceStateMachine.java | 4 +- components/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 47 +--- .../mgt/api/jaxrs/NotificationContext.java | 4 +- .../mgt/api/jaxrs/NotificationList.java | 2 +- .../mgt/api/jaxrs/beans/ActivityList.java | 2 +- .../mgt/api/jaxrs/beans/ApplicationList.java | 2 +- .../api/jaxrs/beans/ApplicationWrapper.java | 4 +- .../api/jaxrs/beans/AuthorizationRequest.java | 2 +- .../api/jaxrs/beans/ComplianceDeviceList.java | 2 +- .../mgt/api/jaxrs/beans/Credential.java | 2 +- .../mgt/api/jaxrs/beans/DeviceCompliance.java | 2 +- .../mgt/api/jaxrs/beans/DeviceConfig.java | 4 +- .../mgt/api/jaxrs/beans/DeviceList.java | 2 +- .../jaxrs/beans/DeviceToGroupsAssignment.java | 3 +- .../mgt/api/jaxrs/beans/DeviceTypeList.java | 1 - .../mgt/api/jaxrs/beans/MetadataList.java | 2 +- .../mgt/api/jaxrs/beans/NotificationList.java | 2 +- .../mgt/api/jaxrs/beans/OperationList.java | 2 +- .../mgt/api/jaxrs/beans/OperationRequest.java | 2 +- .../mgt/api/jaxrs/beans/PermissionList.java | 1 + .../mgt/api/jaxrs/beans/PolicyList.java | 2 +- .../mgt/api/jaxrs/beans/PolicyWrapper.java | 4 +- .../mgt/api/jaxrs/beans/ProfileFeature.java | 2 +- .../api/jaxrs/beans/RemoteSessionInfo.java | 4 - .../device/mgt/api/jaxrs/beans/RoleInfo.java | 2 - .../beans/analytics/AdapterConfiguration.java | 2 +- .../beans/analytics/DeviceTypeEvent.java | 2 - .../beans/analytics/EventAttributeList.java | 2 - .../jaxrs/beans/analytics/EventRecords.java | 5 +- .../jaxrs/beans/analytics/EventStream.java | 1 - .../exception/GlobalThrowableMapper.java | 2 +- .../api/ActivityInfoProviderService.java | 24 +- .../AnalyticsArtifactsManagementService.java | 20 +- .../api/ConfigurationManagementService.java | 16 +- .../jaxrs/service/api/DeviceAgentService.java | 26 +- .../api/DeviceEventManagementService.java | 22 +- .../service/api/DeviceManagementService.java | 32 +-- .../api/DeviceTypeManagementService.java | 24 +- .../service/api/GeoLocationBasedService.java | 26 +- .../service/api/GroupManagementService.java | 33 +-- .../jaxrs/service/api/MetadataService.java | 27 +- .../api/NotificationManagementService.java | 23 +- .../service/api/PolicyManagementService.java | 24 +- .../service/api/RemoteSessionService.java | 12 +- .../service/api/ReportManagementService.java | 26 +- .../service/api/RoleManagementService.java | 2 +- .../service/api/UserManagementService.java | 41 +-- .../jaxrs/service/api/WhiteLabelService.java | 27 +- .../ApplicationManagementAdminService.java | 13 +- ...DeviceAccessAuthorizationAdminService.java | 12 +- ...AnalyticsArtifactUploaderAdminService.java | 4 +- .../admin/DeviceManagementAdminService.java | 26 +- .../DeviceTypeManagementAdminService.java | 25 +- .../admin/GroupManagementAdminService.java | 16 +- .../api/admin/UserManagementAdminService.java | 6 +- .../impl/ActivityProviderServiceImpl.java | 25 +- ...alyticsArtifactsManagementServiceImpl.java | 33 +-- .../impl/ConfigurationServiceImpl.java | 13 +- .../service/impl/DeviceAgentServiceImpl.java | 36 ++- .../DeviceEventManagementServiceImpl.java | 18 +- .../impl/DeviceManagementServiceImpl.java | 42 ++- .../impl/DeviceTypeManagementServiceImpl.java | 32 +-- .../impl/GeoLocationBasedServiceImpl.java | 68 ++--- .../impl/GroupManagementServiceImpl.java | 36 +-- .../service/impl/MetadataServiceImpl.java | 43 +-- .../NotificationManagementServiceImpl.java | 23 +- .../impl/PolicyManagementServiceImpl.java | 26 +- .../impl/RemoteSessionServiceImpl.java | 14 +- .../impl/ReportManagementServiceImpl.java | 30 +-- .../impl/RoleManagementServiceImpl.java | 12 +- .../impl/UserManagementServiceImpl.java | 67 ++--- .../service/impl/WhiteLabelServiceImpl.java | 20 +- ...ApplicationManagementAdminServiceImpl.java | 22 +- ...ceAccessAuthorizationAdminServiceImpl.java | 12 +- ...yticsArtifactUploaderAdminServiceImpl.java | 184 +++++++------ .../DeviceManagementAdminServiceImpl.java | 44 +-- .../DeviceTypeManagementAdminServiceImpl.java | 28 +- .../GroupManagementAdminServiceImpl.java | 12 +- .../admin/UserManagementAdminServiceImpl.java | 8 +- .../impl/util/RequestValidationUtil.java | 36 +-- .../SecurityDefinitionConfigurator.java | 3 - .../CredentialManagementResponseBuilder.java | 6 +- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 60 ++--- .../mgt/api/jaxrs/util/DeviceMgtUtil.java | 2 +- .../impl/ActivityProviderServiceImplTest.java | 26 +- .../impl/ConfigurationServiceImplTest.java | 14 +- .../service/impl/DeviceAgentServiceTest.java | 40 ++- .../impl/DeviceManagementServiceImplTest.java | 32 +-- .../DeviceTypeManagementAdminServiceTest.java | 20 +- .../impl/DeviceTypeManagementServiceTest.java | 16 +- .../impl/GeoLocationBasedServiceImplTest.java | 12 +- .../impl/GroupManagementServiceImplTest.java | 28 +- ...NotificationManagementServiceImplTest.java | 11 +- .../impl/UserManagementServiceImplTest.java | 28 +- .../pom.xml | 36 ++- .../mgt/core/device/mgt/common/Billing.java | 1 + .../device/mgt/common/BillingResponse.java | 1 + .../mgt/core/device/mgt/common/Device.java | 6 +- .../core/device/mgt/common/DeviceBilling.java | 4 +- .../core/device/mgt/common/EnrolmentInfo.java | 1 - .../device/mgt/common/PaginationRequest.java | 6 +- .../device/details/DeviceDetailsWrapper.java | 1 - .../common/device/details/DeviceLocation.java | 2 +- .../device/mgt/common/geo/service/Alert.java | 6 +- .../device/mgt/common/geo/service/Event.java | 6 +- .../service/GeoLocationProviderService.java | 2 - .../mgt/common/geo/service/GeofenceData.java | 1 - .../mgt/common/group/mgt/GroupUser.java | 2 - .../mgt/MetadataManagementService.java | 1 + .../common/operation/mgt/ActivityStatus.java | 2 +- .../operation/mgt/OperationManager.java | 7 +- .../device/mgt/common/policy/mgt/Policy.java | 2 +- .../mgt/common/policy/mgt/ui/Modal.java | 1 - .../mgt/common/policy/mgt/ui/SearchInput.java | 2 - .../report/mgt/ReportManagementService.java | 1 - .../type/mgt/DeviceTypeMetaDefinition.java | 1 - .../pom.xml | 5 + .../mgt/config/api/ApiOriginFilter.java | 7 +- .../api/common/GsonMessageBodyHandler.java | 6 +- .../DeviceManagementConfigService.java | 25 +- .../DeviceManagementConfigServiceImpl.java | 23 +- .../config/api/util/DeviceMgtAPIUtils.java | 2 +- .../pom.xml | 254 ++++++++++++++---- .../DeviceManagementPluginRepository.java | 10 +- ...ApplicationManagerProviderServiceImpl.java | 12 +- .../AppManagementConfigurationManager.java | 2 +- .../app/mgt/oauth/ServiceAuthenticator.java | 2 +- .../core/archival/ArchivalServiceImpl.java | 10 +- .../dao/ArchivalDestinationDAOFactory.java | 4 +- .../dao/ArchivalSourceDAOFactory.java | 4 +- .../archival/dao/impl/ArchivalDAOImpl.java | 15 +- .../dao/impl/DataDeletionDAOImpl.java | 4 +- .../DeviceAccessAuthorizationServiceImpl.java | 11 +- .../mgt/core/cache/DeviceCacheManager.java | 2 +- .../cache/impl/BillingCacheManagerImpl.java | 4 +- .../cache/impl/DeviceCacheManagerImpl.java | 4 +- .../device/mgt/core/common/util/FileUtil.java | 2 +- .../device/mgt/core/common/util/HttpUtil.java | 3 +- .../common/util/StorageManagementUtil.java | 12 +- .../config/DeviceConfigurationManager.java | 2 +- .../core/config/DeviceManagementConfig.java | 6 +- .../license/LicenseConfigurationManager.java | 4 +- .../permission/AnnotationProcessor.java | 12 +- .../WebAppDeploymentLifecycleListener.java | 10 +- ...ormConfigurationManagementServiceImpl.java | 6 +- .../config/ui/UIConfigurationManager.java | 6 +- .../config/util/ConfigurationManagerUtil.java | 2 +- .../device/mgt/core/dao/ApplicationDAO.java | 1 - .../core/device/mgt/core/dao/DeviceDAO.java | 4 +- .../core/dao/DeviceManagementDAOFactory.java | 8 +- .../device/mgt/core/dao/DeviceStatusDAO.java | 3 - .../device/mgt/core/dao/EnrollmentDAO.java | 1 - .../device/mgt/core/dao/EventConfigDAO.java | 1 - .../core/dao/EventManagementDAOFactory.java | 5 +- .../core/device/mgt/core/dao/GroupDAO.java | 1 - .../core/dao/GroupManagementDAOFactory.java | 4 +- .../core/dao/TrackerManagementDAOFactory.java | 4 +- .../core/dao/impl/AbstractDeviceDAOImpl.java | 24 +- .../dao/impl/AbstractEnrollmentDAOImpl.java | 9 +- .../core/dao/impl/AbstractEventConfigDAO.java | 8 +- .../dao/impl/AbstractGeofenceDAOImpl.java | 19 +- .../core/dao/impl/AbstractGroupDAOImpl.java | 12 +- .../mgt/core/dao/impl/ApplicationDAOImpl.java | 5 +- .../core/dao/impl/DeviceStatusDAOImpl.java | 1 - .../mgt/core/dao/impl/DeviceTypeDAOImpl.java | 19 +- .../dao/impl/device/GenericDeviceDAOImpl.java | 16 +- .../dao/impl/device/OracleDeviceDAOImpl.java | 14 +- .../impl/device/PostgreSQLDeviceDAOImpl.java | 12 +- .../impl/device/SQLServerDeviceDAOImpl.java | 15 +- .../enrolment/GenericEnrollmentDAOImpl.java | 2 +- .../enrolment/SQLServerEnrollmentDAOImpl.java | 3 +- .../impl/event/GenericEventConfigDAOImpl.java | 11 +- .../dao/impl/event/H2EventConfigDAOImpl.java | 12 +- .../impl/geofence/GenericGeofenceDAOImpl.java | 5 +- .../geofence/SQLServerGeofenceDAOImpl.java | 16 +- .../dao/impl/group/OracleGroupDAOImpl.java | 2 +- .../impl/group/PostgreSQLGroupDAOImpl.java | 2 +- .../dao/impl/group/SQLServerGroupDAOImpl.java | 2 +- .../core/dao/impl/tracker/TrackerDAOImpl.java | 10 +- .../dao/util/DeviceManagementDAOUtil.java | 24 +- .../core/dao/util/GroupManagementDAOUtil.java | 2 +- .../dao/util/TrackerManagementDAOUtil.java | 4 +- .../details/mgt/DeviceInformationManager.java | 2 - .../details/mgt/dao/DeviceDetailsDAO.java | 1 - .../mgt/dao/impl/DeviceDetailsDAOImpl.java | 7 +- .../impl/DeviceInformationManagerImpl.java | 15 +- .../core/device/mgt/core/dto/DeviceType.java | 2 +- ...EventConfigurationProviderServiceImpl.java | 18 +- .../event/config/EventOperationExecutor.java | 18 +- ...GroupAssignmentEventOperationExecutor.java | 6 +- .../GeoLocationProviderServiceImpl.java | 62 ++--- .../task/GeoFenceEventOperationManager.java | 4 +- .../ActivityDataPurgingServiceComponent.java | 39 +-- .../internal/DeviceManagementDataHolder.java | 4 +- .../DeviceManagementServiceComponent.java | 125 +++++---- .../DeviceTaskManagerServiceComponent.java | 31 +-- .../core/internal/TenantCreateObserver.java | 10 +- .../core/internal/UserRoleCreateObserver.java | 2 +- .../mgt/MetadataManagementServiceImpl.java | 9 +- .../mgt/WhiteLabelManagementServiceImpl.java | 23 +- .../mgt/dao/MetadataManagementDAOFactory.java | 6 +- .../mgt/dao/impl/AbstractMetadataDAOImpl.java | 10 +- .../mgt/dao/impl/GenericMetadataDAOImpl.java | 4 +- .../mgt/dao/impl/OracleMetadataDAOImpl.java | 4 +- .../dao/impl/SQLServerMetadataDAOImpl.java | 4 +- .../mgt/dao/util/MetadataDAOUtil.java | 2 +- .../mgt/util/WhiteLabelStorageUtil.java | 7 +- .../NotificationManagementServiceImpl.java | 10 +- .../dao/NotificationManagementDAOFactory.java | 9 +- .../dao/impl/AbstractNotificationDAOImpl.java | 7 +- .../dao/impl/OracleNotificationDAOImpl.java | 6 +- .../mgt/dao/util/NotificationDAOUtil.java | 6 +- .../operation/mgt/OperationManagerImpl.java | 41 +-- .../mgt/OperationManagerRepository.java | 2 +- .../dao/OperationManagementDAOFactory.java | 4 +- .../mgt/dao/impl/CommandOperationDAOImpl.java | 6 +- .../mgt/dao/impl/ConfigOperationDAOImpl.java | 14 +- .../dao/impl/ConfigOperationMSSQLDAOImpl.java | 17 +- .../impl/ConfigOperationPostgresDAOImpl.java | 17 +- .../mgt/dao/impl/GenericOperationDAOImpl.java | 18 +- .../mgt/dao/impl/OperationMappingDAOImpl.java | 8 +- .../mgt/dao/impl/PolicyOperationDAOImpl.java | 4 +- .../mgt/dao/impl/ProfileOperationDAOImpl.java | 5 +- .../impl/operation/MySQLOperationDAOImpl.java | 6 +- .../operation/OracleOperationDAOImpl.java | 12 +- .../operation/PostgreSQLOperationDAOImpl.java | 8 +- .../operation/SQLServerOperationDAOImpl.java | 20 +- .../mgt/dao/util/OperationDAOUtil.java | 19 +- .../task/impl/OperationTimeoutTask.java | 4 +- ...perationTimeoutTaskManagerServiceImpl.java | 6 +- .../otp/mgt/dao/OTPManagementDAOFactory.java | 4 +- .../dao/impl/GenericOTPManagementDAOImpl.java | 11 +- .../mgt/service/OTPManagementServiceImpl.java | 22 +- .../otp/mgt/util/ConnectionManagerUtil.java | 6 +- .../core/permission/mgt/PermissionNode.java | 6 +- .../core/permission/mgt/PermissionTree.java | 2 +- .../core/permission/mgt/PermissionUtils.java | 4 +- .../dao/impl/PrivacyComplianceDAOImpl.java | 4 +- .../impl/PrivacyComplianceProviderImpl.java | 6 +- .../mgt/PushNotificationConfigRepository.java | 2 +- .../PushNotificationProviderRepository.java | 2 +- .../task/PushNotificationSchedulerTask.java | 6 +- .../mgt/ReportManagementServiceImpl.java | 19 +- .../config/ReportMgtConfigurationManager.java | 4 +- .../common/ReportMgtConnectionManager.java | 4 +- .../core/search/mgt/impl/ProcessorImpl.java | 21 +- .../search/mgt/impl/QueryBuilderImpl.java | 8 +- .../mgt/impl/ResultSetAggregatorImpl.java | 6 +- .../DeviceManagementProviderService.java | 18 +- .../DeviceManagementProviderServiceImpl.java | 97 ++----- .../GroupManagementProviderService.java | 9 +- .../GroupManagementProviderServiceImpl.java | 35 +-- .../task/impl/DeviceStatusMonitoringTask.java | 4 +- .../DeviceStatusTaskManagerServiceImpl.java | 4 +- .../mgt/core/task/impl/ArchivalTask.java | 4 +- .../task/impl/ArchivalTaskManagerImpl.java | 6 +- .../task/impl/ArchivedDataDeletionTask.java | 4 +- .../task/impl/DeviceDetailsRetrieverTask.java | 8 +- .../core/task/impl/DeviceTaskManagerImpl.java | 18 +- .../impl/DeviceTaskManagerServiceImpl.java | 6 +- .../impl/DynamicPartitionedScheduleTask.java | 6 +- .../impl/RandomlyAssignedScheduleTask.java | 2 +- .../api/service/TraccarClientFactory.java | 31 +-- .../api/service/addons/TraccarClientImpl.java | 30 +-- .../impl/DeviceAPIClientServiceImpl.java | 8 +- .../core/traccar/common/util/TraccarUtil.java | 2 +- .../config/TraccarConfigurationManager.java | 6 +- .../DeviceManagementSchemaInitializer.java | 2 +- .../mgt/core/util/DeviceManagerUtil.java | 58 ++-- .../mgt/core/util/HttpReportingUtil.java | 5 +- .../core/util/MDMAndroidOperationUtil.java | 4 +- .../mgt/core/util/MDMIOSOperationUtil.java | 2 +- .../core/util/MDMWindowsOperationUtil.java | 4 +- .../mgt/core/DeviceManagementConfigTests.java | 2 +- .../core/DeviceManagementRepositoryTests.java | 6 +- .../device/mgt/core/TestDeviceManager.java | 7 +- .../core/TestHeartBeatManagementService.java | 2 +- .../device/mgt/core/TestTaskServiceImpl.java | 2 - .../mgt/core/device/mgt/core/TestUtils.java | 4 +- ...AppManagementConfigurationManagerTest.java | 2 +- ...licationManagementProviderServiceTest.java | 14 +- .../DeviceAccessAuthorizationServiceTest.java | 33 ++- .../cache/DeviceCacheManagerImplTest.java | 11 +- .../core/common/BaseDeviceManagementTest.java | 22 +- .../mgt/core/common/TestDataHolder.java | 6 +- .../mgt/core/dao/DevicePersistTests.java | 15 +- .../dao/DeviceStatusPersistenceTests.java | 11 +- .../core/dao/EnrolmentPersistenceTests.java | 8 +- .../mgt/core/dao/GroupPersistTests.java | 10 +- .../GeoLocationProviderServiceTest.java | 8 +- .../device/mgt/core/mock/MockConnection.java | 18 +- .../device/mgt/core/mock/MockDataSource.java | 4 +- .../mgt/core/mock/MockDatabaseMetaData.java | 6 +- .../device/mgt/core/mock/MockJDBCDriver.java | 6 +- .../device/mgt/core/mock/MockResultSet.java | 16 +- .../device/mgt/core/mock/MockStatement.java | 19 +- ...otificationManagementServiceImplTests.java | 12 +- ...tionManagementNegativeDBOperationTest.java | 12 +- .../OperationManagementNoDBSchemaTests.java | 12 +- .../operation/OperationManagementTests.java | 36 +-- .../ScheduledTaskOperationTests.java | 10 +- .../mgt/PermissionManagerServiceTest.java | 7 +- .../PushNotificationSchedulerTaskTest.java | 12 +- .../device/mgt/core/search/DeviceDetails.java | 8 +- .../mgt/core/search/ProcessorImplTest.java | 6 +- .../search/SearchManagementServiceTest.java | 12 +- .../mgt/core/search/SearchMgtUtilTest.java | 6 +- .../DeviceManagementProviderServiceTest.java | 31 +-- ...ManagementProviderServiceNegativeTest.java | 4 +- .../GroupManagementProviderServiceTest.java | 16 +- .../task/DeviceTaskManagerServiceTest.java | 10 +- .../mgt/core/task/DeviceTaskManagerTest.java | 22 +- .../conf/datasources/master-datasources.xml | 2 +- .../repository/conf/etc/tasks-config.xml | 2 +- .../pom.xml | 93 ++++--- .../type/template/DeviceTypeManager.java | 23 +- .../template/DeviceTypeManagerService.java | 23 +- .../DeviceTypePluginExtensionServiceImpl.java | 4 +- .../HTTPDeviceTypeManagerService.java | 13 +- .../type/template/config/Attributes.java | 4 +- .../template/config/ConfigProperties.java | 4 +- .../type/template/config/DataPanel.java | 6 +- .../type/template/config/DeviceDetails.java | 6 +- .../config/DeviceTypeConfiguration.java | 7 +- .../device/type/template/config/Feature.java | 7 +- .../config/InitialOperationConfig.java | 4 +- .../type/template/config/Operation.java | 6 +- .../template/config/OperationMetadata.java | 6 +- .../device/type/template/config/Option.java | 1 - .../type/template/config/OptionalData.java | 1 - .../device/type/template/config/Policy.java | 7 +- .../template/config/PolicyMonitoring.java | 6 +- .../type/template/config/Properties.java | 4 +- .../device/type/template/config/Property.java | 6 +- .../PullNotificationSubscriberConfig.java | 6 +- .../config/PushNotificationProvider.java | 6 +- .../device/type/template/config/Table.java | 6 +- .../type/template/config/TableConfig.java | 4 +- .../type/template/config/UIParameter.java | 6 +- .../template/dao/DeviceTypeDAOHandler.java | 4 +- .../template/dao/DeviceTypePluginDAOImpl.java | 12 +- .../dao/DeviceTypePluginDAOManager.java | 2 +- .../dao/PropertyBasedPluginDAOImpl.java | 12 +- .../ConfigurationBasedFeatureManager.java | 4 +- .../mgt/DefaultPolicyMonitoringManager.java | 4 +- .../type/template/util/DeviceTypeUtils.java | 5 +- .../DeviceTypeExtensionDataHolder.java | 2 +- .../DeviceTypeExtensionServiceComponent.java | 38 +-- .../MetaRepositoryBasedLicenseManager.java | 8 +- .../GenericArtifactManagerFactory.java | 2 +- .../registry/RegistryBasedLicenseManager.java | 9 +- .../type/template/BaseExtensionsTest.java | 27 +- .../DeviceTypeManagerNegativeTest.java | 16 +- .../DeviceTypeManagerServiceTest.java | 19 +- .../type/template/DeviceTypeManagerTest.java | 17 +- ...rviceAndDeviceTypeGeneratorServceTest.java | 8 +- .../dao/DeviceDAODefinitionNegativeTest.java | 2 +- .../mock/TypeXDeviceManagementService.java | 10 +- .../extensions/mock/TypeXDeviceManager.java | 6 +- .../device/mgt/extensions/utils/Utils.java | 4 +- .../mgt/extensions/utils/UtilsTest.java | 10 +- .../pom.xml | 28 +- .../url/printer/URLPrinterStartupHandler.java | 2 +- .../internal/UrlPrinterServiceComponent.java | 25 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.device.mgt.ui/pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 85 ++---- .../beacon/HeartBeatBeaconUtils.java | 7 +- .../datasource/JNDILookupDefinition.java | 6 +- .../beacon/dao/HeartBeatBeaconDAOFactory.java | 6 +- .../dao/impl/GenericHeartBeatDAOImpl.java | 7 +- .../internal/HeartBeatBeaconComponent.java | 22 +- .../service/HeartBeatManagementService.java | 2 +- .../HeartBeatManagementServiceImpl.java | 11 +- .../pom.xml | 74 +++-- .../handlers/ScopeValidationHandler.java | 2 +- .../grant/AccessTokenGrantHandler.java | 5 +- .../OAuthAuthenticatorServiceComponent.java | 21 +- .../OAuthExtensionServiceComponent.java | 46 ++-- .../ExtendedJDBCScopeValidator.java | 2 +- .../PermissionBasedScopeValidator.java | 2 +- .../validators/RoleBasedScopeValidator.java | 2 +- .../pom.xml | 81 +++--- .../jwt/client/extension/JWTClient.java | 10 +- .../jwt/client/extension/dto/JWTConfig.java | 2 +- .../JWTClientExtensionServiceComponent.java | 72 ++--- .../service/JWTClientManagerServiceImpl.java | 10 +- .../client/extension/util/JWTClientUtil.java | 23 +- .../service/JWTClientManagerServiceTest.java | 6 +- .../extension/service/JWTClientTest.java | 10 +- .../extension/service/JWTClientUtilTest.java | 6 +- .../common/BaseJWTClientManagerExtTest.java | 2 +- .../conf/datasources/master-datasources.xml | 2 +- .../repository/conf/etc/tasks-config.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../pom.xml | 21 +- components/logger/pom.xml | 2 - .../pom.xml | 77 +++--- .../dao/OperationTemplateDAOFactory.java | 2 +- .../dao/impl/OperationTemplateDAOImpl.java | 11 +- .../config/DeviceConfigurationManager.java | 2 +- .../util/OperationTemplateManagementUtil.java | 2 +- .../impl/OperationTemplateServiceImpl.java | 2 +- .../OperationTemplateMgtDataHolder.java | 2 +- .../OperationTemplateMgtServiceComponent.java | 22 +- .../template/util/ConnectionManagerUtils.java | 11 +- .../template/ServiceNegativeTest.java | 2 +- .../mock/BaseOperationTemplatePluginTest.java | 8 +- .../template/mock/MockConnection.java | 16 +- .../template/mock/MockDatabaseMetaData.java | 6 +- .../template/mock/MockResultSet.java | 16 +- .../template/mock/MockStatement.java | 18 +- .../pom.xml | 35 +-- ...ergedPolicyEvaluationServiceComponent.java | 38 +-- .../PolicyEvaluationServiceComponent.java | 39 +-- .../point/merged/MergedEvaluationPoint.java | 8 +- .../simple/PolicyEvaluationServiceImpl.java | 2 +- .../point/simple/SimpleEvaluationImpl.java | 6 +- .../pom.xml | 27 +- .../point/PolicyInformationServiceImpl.java | 2 +- ...PolicyInformationPointBundleActivator.java | 4 +- .../pom.xml | 30 +-- .../mgt/common/PolicyAdministratorPoint.java | 2 +- .../monitor/ComplianceDecisionPoint.java | 2 +- .../pom.xml | 88 +++--- .../policy/mgt/core/PolicyManagerService.java | 9 +- .../mgt/core/PolicyManagerServiceImpl.java | 13 +- .../mgt/core/cache/PolicyCacheManager.java | 1 - .../cache/impl/PolicyCacheManagerImpl.java | 5 +- .../config/PolicyConfigurationManager.java | 2 +- .../policy/mgt/core/dao/MonitoringDAO.java | 2 +- .../core/policy/mgt/core/dao/PolicyDAO.java | 2 +- .../core/dao/PolicyManagementDAOFactory.java | 4 +- .../mgt/core/dao/impl/MonitoringDAOImpl.java | 8 +- .../mgt/core/dao/impl/ProfileDAOImpl.java | 7 +- .../dao/impl/feature/AbstractFeatureDAO.java | 6 +- .../impl/feature/GenericFeatureDAOImpl.java | 6 +- .../feature/OracleServerFeatureDAOImpl.java | 2 +- .../impl/feature/SQLServerFeatureDAOImpl.java | 6 +- .../impl/policy/AbstractPolicyDAOImpl.java | 19 +- .../dao/impl/policy/GenericPolicyDAOImpl.java | 6 +- .../dao/impl/policy/OraclePolicyDAOImpl.java | 6 +- .../impl/policy/PostgreSQLPolicyDAOImpl.java | 6 +- .../impl/policy/SQLServerPolicyDAOImpl.java | 6 +- .../mgt/core/enforcement/DelegationTask.java | 4 +- .../PolicyEnforcementDelegatorImpl.java | 4 +- .../impl/ComplianceDecisionPointImpl.java | 18 +- .../impl/PolicyAdministratorPointImpl.java | 19 +- .../mgt/core/impl/PolicyFilterImpl.java | 4 +- .../core/impl/PolicyInformationPointImpl.java | 12 +- .../internal/PolicyManagementDataHolder.java | 4 +- .../PolicyManagementServiceComponent.java | 66 ++--- .../mgt/core/mgt/MonitoringManager.java | 2 +- .../policy/mgt/core/mgt/PolicyManager.java | 1 - .../mgt/core/mgt/impl/FeatureManagerImpl.java | 11 +- .../core/mgt/impl/MonitoringManagerImpl.java | 10 +- .../mgt/core/mgt/impl/PolicyManagerImpl.java | 29 +- .../mgt/core/mgt/impl/ProfileManagerImpl.java | 12 +- .../policy/mgt/core/task/MonitoringTask.java | 8 +- .../core/task/TaskScheduleServiceImpl.java | 14 +- .../mgt/core/util/PolicyManagerUtil.java | 15 +- .../mgt/core/BasePolicyManagementDAOTest.java | 36 +-- .../policy/mgt/core/MonitoringTestCase.java | 22 +- .../policy/mgt/core/PolicyDAOTestCase.java | 24 +- .../mgt/core/PolicyEvaluationTestCase.java | 12 +- .../core/PolicyManagerServiceImplTest.java | 40 +-- .../core/mgt/impl/FeatureManagerImplTest.java | 16 +- .../mgt/impl/MonitoringManagerImplTest.java | 30 +-- .../core/mgt/impl/ProfileManagerImplTest.java | 16 +- .../mock/TestHeartBeatManagementService.java | 2 +- .../mock/TestPolicyMonitoringManager.java | 4 +- .../services/PolicyMonitoringManagerTest.java | 4 +- .../services/SimplePolicyEvaluationTest.java | 6 +- .../task/TaskSchedulerServiceImplTest.java | 4 +- .../conf/datasources/master-datasources.xml | 2 +- .../repository/conf/etc/tasks-config.xml | 2 +- .../pom.xml | 2 +- components/policy-mgt/pom.xml | 22 +- .../pom.xml | 81 +++--- .../cache/GetDeviceSubTypeCacheLoader.java | 2 +- .../subtype/mgt/dao/DeviceSubTypeDAO.java | 2 +- .../mgt/dao/DeviceSubTypeDAOFactory.java | 6 +- .../mgt/dao/impl/DeviceSubTypeDAOImpl.java | 6 +- .../mgt/dao/util/ConnectionManagerUtil.java | 6 +- .../mgt/impl/DeviceSubTypeServiceImpl.java | 10 +- .../internal/DeviceSubTypeMgtDataHolder.java | 2 +- .../DeviceSubTypeMgtServiceComponent.java | 61 ++--- .../subtype/mgt/spi/DeviceSubTypeService.java | 2 +- .../mgt/util/DeviceSubTypeMgtUtil.java | 2 +- .../mgt/mock/BaseDeviceSubTypePluginTest.java | 8 +- .../core/subtype/mgt/mock/MockConnection.java | 16 +- .../mgt/mock/MockDatabaseMetaData.java | 6 +- .../core/subtype/mgt/mock/MockResultSet.java | 16 +- .../core/subtype/mgt/mock/MockStatement.java | 18 +- .../pom.xml | 12 + .../mgt/common/spi/TaskManagementService.java | 2 +- .../pom.xml | 62 +++-- .../core/config/TaskConfigurationManager.java | 2 +- .../dao/common/TaskManagementDAOFactory.java | 2 +- .../mgt/core/dao/impl/DynamicTaskDAOImpl.java | 4 +- .../core/dao/impl/DynamicTaskPropDAOImpl.java | 4 +- .../internal/TaskManagerServiceComponent.java | 52 ++-- .../service/TaskManagementServiceImpl.java | 8 +- .../pom.xml | 47 ++-- .../task/mgt/watcher/IoTSStartupHandler.java | 9 +- .../internal/TaskWatcherServiceComponent.java | 61 ++--- .../pom.xml | 12 +- .../pom.xml | 56 ++-- .../mgt/core/impl/TenantManagerImpl.java | 16 +- .../core/impl/TenantManagerServiceImpl.java | 2 +- .../core/internal/TenantMgtDataHolder.java | 2 +- .../internal/TenantMgtServiceComponent.java | 38 +-- .../listener/DeviceMgtTenantListener.java | 2 +- .../pom.xml | 112 +++----- .../mgt/email/sender/core/EmailContext.java | 4 +- .../core/RegistryBasedResourceLoader.java | 63 +++-- .../VelocityBasedEmailContentProvider.java | 20 +- ...EmailSenderAxis2ConfigContextObserver.java | 2 +- .../core/internal/EmailSenderDataHolder.java | 23 +- .../internal/EmailSenderServiceComponent.java | 87 +++--- .../sender/core/internal/EmailUtils.java | 33 +-- components/transport-mgt/email-sender/pom.xml | 2 +- .../pom.xml | 1 - .../api/ConfigurationManagementService.java | 13 +- .../handler/api/addons/ApiOriginFilter.java | 7 +- .../api/addons/GsonMessageBodyHandler.java | 6 +- .../ConfigurationManagementServiceImpl.java | 2 +- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 4 +- .../pom.xml | 13 +- .../pom.xml | 39 ++- .../core/config/SMSConfigurationManager.java | 4 +- .../internal/SMSHandlerServiceComponent.java | 13 +- .../interceptor/DefaultTokenHandler.java | 2 +- .../request/interceptor/GrafanaHandler.java | 2 +- .../request/interceptor/InvokerHandler.java | 9 +- .../ui/request/interceptor/LoginHandler.java | 8 +- .../ui/request/interceptor/LogoutHandler.java | 2 +- .../interceptor/OTPInvokerHandler.java | 9 +- .../interceptor/SsoLoginCallbackHandler.java | 2 +- .../request/interceptor/SsoLoginHandler.java | 8 +- .../request/interceptor/SsoLogoutHandler.java | 8 +- .../ui/request/interceptor/UserHandler.java | 10 +- .../request/interceptor/util/HandlerUtil.java | 15 +- .../websocket/GrafanaLiveSecurityFilter.java | 7 +- .../websocket/GrafanaWebSocketClient.java | 15 +- .../websocket/GrafanaWebSocketHandler.java | 7 +- .../pom.xml | 133 ++++----- .../AuthenticationFrameworkUtil.java | 2 +- .../authenticator/framework/Utils/Utils.java | 14 +- .../framework/WebappAuthenticationValve.java | 6 +- .../framework/WebappAuthenticatorFactory.java | 2 +- .../authenticator/BSTAuthenticator.java | 12 +- .../authenticator/BasicAuthAuthenticator.java | 10 +- .../CertificateAuthenticator.java | 10 +- .../authenticator/JWTAuthenticator.java | 10 +- .../authenticator/OAuthAuthenticator.java | 10 +- .../OneTimeTokenAuthenticator.java | 6 +- .../authenticator/WebappAuthenticator.java | 2 +- .../oauth/impl/LocalOAuthValidator.java | 10 +- .../oauth/impl/RemoteOAuthValidator.java | 8 +- .../authorizer/PermissionAuthorizer.java | 6 +- .../authorizer/WebappTenantAuthorizer.java | 2 +- .../config/WebappAuthenticatorConfig.java | 4 +- .../AuthenticatorFrameworkDataHolder.java | 2 +- ...uthenticatorFrameworkServiceComponent.java | 113 ++++---- .../BaseWebAppAuthenticatorFrameworkTest.java | 10 +- .../WebappAuthenticationValveTest.java | 2 +- .../WebappAuthenticatorConfigTest.java | 9 +- .../WebappAuthenticatorFrameworkUtilTest.java | 2 +- .../WebappAuthenticatorRepositoryTest.java | 5 +- .../authenticator/BSTAuthenticatorTest.java | 8 +- .../BasicAuthAuthenticatorTest.java | 5 +- .../CertificateAuthenticatorTest.java | 34 +-- .../authenticator/JWTAuthenticatorTest.java | 8 +- .../authenticator/OauthAuthenticatorTest.java | 7 +- .../util/MalformedAuthenticator.java | 4 +- .../util/TestCertificateGenerator.java | 19 +- .../util/TestWebappAuthenticator.java | 4 +- .../webapp-authenticator-framework/pom.xml | 21 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 6 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../application-mgt-datasources.xml | 2 +- .../dbscripts/cdm/application-mgt/h2.sql | 3 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 6 +- features/certificate-mgt/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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../conf/datasources/cdm-datasources.xml | 2 +- .../datasources/reporting-mgt-datasources.xml | 2 +- .../src/main/resources/dbscripts/cdm/h2.sql | 75 +++--- .../pom.xml | 2 +- .../pom.xml | 11 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../datasources/heart-beat-datasources.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 1 - .../pom.xml | 2 +- features/oauth-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 1 - .../pom.xml | 9 +- features/transport-mgt/email-sender/pom.xml | 2 +- .../resources/payloads/update-app-request.xml | 3 +- .../pom.xml | 2 +- .../webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 236 ++-------------- 842 files changed, 5008 insertions(+), 7102 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/GrafanaAPIProxyService.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/GrafanaAPIProxyService.java index 3979e472d3..a03e0b3759 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/GrafanaAPIProxyService.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/GrafanaAPIProxyService.java @@ -18,25 +18,12 @@ package io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api; import com.google.gson.JsonObject; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; +import io.swagger.annotations.*; + +import javax.ws.rs.*; +import javax.ws.rs.core.*; @SwaggerDefinition( info = @Info( diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/addons/ApiOriginFilter.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/addons/ApiOriginFilter.java index 206adf4700..cf85c47747 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/addons/ApiOriginFilter.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/addons/ApiOriginFilter.java @@ -18,12 +18,7 @@ package io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.addons; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import javax.servlet.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/addons/ValidationInterceptor.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/addons/ValidationInterceptor.java index 4726adf0b3..1ac97283d8 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/addons/ValidationInterceptor.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/addons/ValidationInterceptor.java @@ -27,11 +27,7 @@ import org.apache.cxf.message.MessageContentsList; import org.apache.cxf.phase.AbstractPhaseInterceptor; import org.apache.cxf.phase.Phase; -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; +import javax.validation.*; import javax.validation.executable.ExecutableValidator; import java.lang.reflect.Method; import java.util.List; diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java index 23a56e2d14..3c5aee3c24 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java @@ -9,20 +9,12 @@ import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception.Gr import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean.GrafanaPanelIdentifier; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.exception.MaliciousQueryAttempt; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.internal.GrafanaMgtDataHolder; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; +import javax.ws.rs.*; +import javax.ws.rs.core.*; import java.io.IOException; import java.sql.SQLException; diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaRequestHandlerUtil.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaRequestHandlerUtil.java index 12d4e9295b..1f94fcdd97 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaRequestHandlerUtil.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaRequestHandlerUtil.java @@ -26,6 +26,8 @@ import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean.GrafanaPa import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.exception.GrafanaEnvVariablesNotDefined; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util.GrafanaConstants; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util.GrafanaUtil; +import io.entgra.device.mgt.core.device.mgt.core.common.util.HttpUtil; +import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; @@ -36,8 +38,6 @@ import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import io.entgra.device.mgt.core.device.mgt.core.common.util.HttpUtil; -import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 68425f07e0..4d01a9520a 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -35,6 +35,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-bundle-plugin @@ -48,12 +56,6 @@ io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.* - - javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}", - com.fasterxml.jackson.annotation;version="${jackson-annotations.version}", - io.swagger.annotations; version="${swagger.annotations.version}"; resolution:=optional, - com.google.gson - diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 0e921289d8..a9728f9704 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -35,10 +35,6 @@ - - org.apache.felix - maven-scr-plugin - org.jacoco jacoco-maven-plugin @@ -65,6 +61,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-bundle-plugin @@ -77,15 +81,47 @@ Grafana API Management Core Bundle io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.internal - io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.*, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - javax.xml.bind.annotation, - javax.xml.bind, - org.apache.commons.lang, - org.wso2.carbon, - io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.core.* - io.entgra.device.mgt.core.application.mgt.core.* + com.google.common.cache;version="[31.0,32)", + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config.xml.bean, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.exception, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.service, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.service.bean, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.service.cache, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.service.impl, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.sql.connection, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.sql.query, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.sql.query.encoder, + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util, + io.entgra.device.mgt.core.application.mgt.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.core.util;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.common.util;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config.datasource;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.dao;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.report.mgt.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.report.mgt.dao.common;version="[5.0,6)", + javax.xml.bind;version="[0.0,1)", + javax.xml.bind.annotation;version="[0.0,1)", + javax.xml.parsers, + org.apache.commons.codec.binary;version="[1.9,2)", + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.lang3;version="[3.1,4)", + org.apache.commons.logging;version="[1.2,2)", + org.apache.http;version="[4.4,5)", + org.apache.http.client, + org.apache.http.client.methods, + org.apache.http.impl.client, + org.apache.juli.logging;version="[9.0,10)", + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.w3c.dom,org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.utils;version="[4.8,5)" !io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.internal, @@ -103,15 +139,12 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services + org.apache.felix + org.apache.felix.scr.ds-annotations + provided - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation @@ -132,7 +165,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon @@ -246,14 +278,6 @@ org.apache.ws.commons.axiom.wso2 axiom - org.apache.axis2.wso2 axis2 diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/internal/GrafanaManagementServiceComponent.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/internal/GrafanaManagementServiceComponent.java index 2b4899bbac..e10a7f2b38 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/internal/GrafanaManagementServiceComponent.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/internal/GrafanaManagementServiceComponent.java @@ -26,16 +26,19 @@ 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.context.PrivilegedCarbonContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; -/** - * @scr.component name="io.entgra.analytics.mgt.grafana.proxy.grafanamanagementservicecomponent" immediate="true" - */ +@Component( + name = "io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.internal.GrafanaManagementServiceComponent", + immediate = true) public class GrafanaManagementServiceComponent { private static Log log = LogFactory.getLog(GrafanaManagementServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -60,6 +63,7 @@ public class GrafanaManagementServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("De-activating Grafana Management Service Component"); 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 438fb28d72..3d9ce4d2d4 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 @@ -27,9 +27,14 @@ io.entgra.device.mgt.core.apimgt.analytics.extension bundle Entgra - API mgt analytics extension - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon org.wso2.carbon.core @@ -40,7 +45,7 @@ org.apache.velocity - velocity + velocity-engine-core @@ -56,8 +61,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -72,10 +81,11 @@ io.entgra.device.mgt.core.apimgt.application.extension.internal io.entgra.device.mgt.core.apimgt.analytics.extension.dto, + io.entgra.device.mgt.core.apimgt.analytics.extension.exception, org.apache.velocity, org.apache.velocity.app, org.apache.velocity.context, - org.wso2.carbon.utils;version="[4.6,5)" + org.wso2.carbon.utils;version="[4.8,5)" io.entgra.device.mgt.core.apimgt.analytics.extension.* diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/AnalyticsArtifactsDeployer.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/AnalyticsArtifactsDeployer.java index fcd197bb0e..66e15be064 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/AnalyticsArtifactsDeployer.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/AnalyticsArtifactsDeployer.java @@ -27,16 +27,11 @@ import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventStrea import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; - import org.apache.velocity.runtime.RuntimeConstants; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; +import java.io.*; public class AnalyticsArtifactsDeployer { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 58e0ac2d1a..4b3dcb1b66 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -31,22 +31,18 @@ bundle WSO2 Carbon - API Management Annotations WSO2 Carbon - API Management Custom Annotation Module - http://wso2.org + https://entgra.io - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.ops4j.pax.logging pax-logging-api provided - javax.ws.rs @@ -56,8 +52,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -72,15 +72,6 @@ io.entgra.device.mgt.core.apimgt.annotations.* - - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - javax.servlet, - javax.xml.*, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - org.apache.commons.lang - scribe;scope=compile|runtime;inline=false; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index a3dcb68c37..83b56581d5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -30,7 +30,7 @@ war WSO2 Carbon - API Application Management API This module provides capability to create api manager application. - http://wso2.org + https://entgra.io @@ -159,10 +159,6 @@ org.wso2.carbon.registry.core provided - - org.wso2.orbit.javax.xml.bind - jaxb-api - diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index 6b328232eb..95a68ac99c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -18,18 +18,18 @@ package io.entgra.device.mgt.core.apimgt.application.extension.api; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; import io.entgra.device.mgt.core.apimgt.application.extension.api.util.APIUtil; import io.entgra.device.mgt.core.apimgt.application.extension.api.util.RegistrationProfile; import io.entgra.device.mgt.core.apimgt.application.extension.constants.ApiApplicationConstants; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.POST; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/filter/ApiPermissionFilter.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/filter/ApiPermissionFilter.java index 0170cc61ec..1d1400032a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/filter/ApiPermissionFilter.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/filter/ApiPermissionFilter.java @@ -17,20 +17,15 @@ */ package io.entgra.device.mgt.core.apimgt.application.extension.api.filter; +import io.entgra.device.mgt.core.apimgt.application.extension.api.util.APIUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.apimgt.application.extension.api.util.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.bind.JAXBContext; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/APIUtil.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/APIUtil.java index 968fcca10e..c6801405a2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/APIUtil.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/APIUtil.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.apimgt.application.extension.api.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.exceptions.RegistryException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 48ad10e3eb..deaca8ffc0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -31,9 +31,14 @@ bundle WSO2 Carbon - API Application Management This module provides capability to create api manager application. - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon org.wso2.carbon.registry.core @@ -88,8 +93,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -103,30 +112,30 @@ API Management Application Bundle io.entgra.device.mgt.core.apimgt.application.extension.internal - org.apache.commons.lang;version="[2.6,3)", - org.apache.commons.logging;version="[1.2,2)", - org.json.simple, - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.wso2.carbon.apimgt.api;version="${carbon.api.mgt.version.range}", - org.wso2.carbon.apimgt.api.dto;version="${carbon.api.mgt.version.range}", - org.wso2.carbon.apimgt.api.model;version="${carbon.api.mgt.version.range}", io.entgra.device.mgt.core.apimgt.application.extension.bean, io.entgra.device.mgt.core.apimgt.application.extension.dto, io.entgra.device.mgt.core.apimgt.application.extension.exception, - 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.context;version="${carbon.kernel.version.range}", - io.entgra.device.mgt.core.identity.jwt.client.extension, - io.entgra.device.mgt.core.identity.jwt.client.extension.dto, - io.entgra.device.mgt.core.identity.jwt.client.extension.exception, - io.entgra.device.mgt.core.identity.jwt.client.extension.service, + io.entgra.device.mgt.core.identity.jwt.client.extension;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="[5.0,6)", + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.logging;version="[1.2,2)", + org.json.simple;version="[1.1,2)", + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.wso2.carbon.apimgt.api;version="[9.28,10)", + org.wso2.carbon.apimgt.api.dto;version="[9.28,10)", + org.wso2.carbon.apimgt.api.model;version="[9.28,10)", + org.wso2.carbon.apimgt.impl;version="[9.28,10)", + org.wso2.carbon.apimgt.impl.utils;version="[9.28,10)", + org.wso2.carbon.context;version="[4.8,5)", org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", org.wso2.carbon.registry.core.service;version="[1.0,2)", - org.wso2.carbon.registry.indexing.service;version="${carbon.registry.imp.pkg.version.range}", + org.wso2.carbon.registry.indexing.service;version="[4.8,5)", org.wso2.carbon.user.api;version="[1.0,2)", - org.wso2.carbon.user.core.service;version="${carbon.kernel.version.range}", - org.wso2.carbon.user.core.tenant;version="${carbon.kernel.version.range}" + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.user.core.tenant;version="[4.8,5)" !io.entgra.device.mgt.core.apimgt.application.extension.internal, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index b73ea49b7e..e78c2dca7e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -18,6 +18,16 @@ package io.entgra.device.mgt.core.apimgt.application.extension; +import io.entgra.device.mgt.core.apimgt.application.extension.bean.APIRegistrationProfile; +import io.entgra.device.mgt.core.apimgt.application.extension.constants.ApiApplicationConstants; +import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; +import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; +import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; +import io.entgra.device.mgt.core.apimgt.application.extension.util.APIManagerUtil; +import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; +import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -25,35 +35,16 @@ import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; -import org.wso2.carbon.apimgt.api.model.API; -import org.wso2.carbon.apimgt.api.model.APIKey; -import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; -import org.wso2.carbon.apimgt.api.model.Application; -import org.wso2.carbon.apimgt.api.model.SubscribedAPI; -import org.wso2.carbon.apimgt.api.model.Subscriber; -import io.entgra.device.mgt.core.apimgt.application.extension.bean.APIRegistrationProfile; -import io.entgra.device.mgt.core.apimgt.application.extension.constants.ApiApplicationConstants; -import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; -import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; -import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; -import io.entgra.device.mgt.core.apimgt.application.extension.util.APIManagerUtil; +import org.wso2.carbon.apimgt.api.model.*; import org.wso2.carbon.apimgt.impl.APIAdminImpl; import org.wso2.carbon.apimgt.impl.APIConstants; import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; -import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * This class represents an implementation of APIManagementProviderService. diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/dto/ApiApplicationKey.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/dto/ApiApplicationKey.java index f0aeb45c79..5e7634c987 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/dto/ApiApplicationKey.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/dto/ApiApplicationKey.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.apimgt.application.extension.dto; -import org.json.simple.JSONObject; import io.entgra.device.mgt.core.apimgt.application.extension.constants.ApiApplicationConstants; +import org.json.simple.JSONObject; /** * This holds api application consumer key and secret. diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 0ee0306775..4e863ba118 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.apimgt.application.extension.internal; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.user.core.service.RealmService; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index b32b591fbc..5335338260 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -17,42 +17,25 @@ */ package io.entgra.device.mgt.core.apimgt.application.extension.internal; +import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext;; -import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; -import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.user.core.service.RealmService; -/** - * @scr.component name="io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionServiceComponent" - * @scr.reference name="tenant.registryloader" - * interface="org.wso2.carbon.registry.core.service.TenantRegistryLoader" - * cardinality="1..1" - * policy="dynamic" - * bind="setTenantRegistryLoader" - * unbind="unsetTenantRegistryLoader" - * @scr.reference name="tenant.indexloader" - * interface="org.wso2.carbon.registry.indexing.service.TenantIndexingLoader" - * cardinality="1..1" - * policy="dynamic" - * bind="setIndexLoader" - * unbind="unsetIndexLoader" - * @scr.reference name="realm.service" - * immediate="true" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - */ +@Component( + name = "io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionServiceComponent", + immediate = true) public class APIApplicationManagerExtensionServiceComponent { private static final Log log = LogFactory.getLog(APIApplicationManagerExtensionServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -67,10 +50,17 @@ public class APIApplicationManagerExtensionServiceComponent { } } + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } + @Reference( + name = "tenant.registry.loader", + service = org.wso2.carbon.registry.core.service.TenantRegistryLoader.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTenantRegistryLoader") protected void setTenantRegistryLoader(TenantRegistryLoader tenantRegistryLoader) { APIApplicationManagerExtensionDataHolder.getInstance().setTenantRegistryLoader(tenantRegistryLoader); } @@ -79,6 +69,12 @@ public class APIApplicationManagerExtensionServiceComponent { APIApplicationManagerExtensionDataHolder.getInstance().setTenantRegistryLoader(null); } + @Reference( + name = "tenant.index.loader", + service = org.wso2.carbon.registry.indexing.service.TenantIndexingLoader.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetIndexLoader") protected void setIndexLoader(TenantIndexingLoader indexLoader) { if (indexLoader != null && log.isDebugEnabled()) { log.debug("IndexLoader service initialized"); @@ -95,6 +91,12 @@ public class APIApplicationManagerExtensionServiceComponent { * * @param realmService An instance of RealmService */ + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { log.debug("Setting Realm Service"); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/util/APIManagerUtil.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/util/APIManagerUtil.java index 37829a2d68..94da658a08 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/util/APIManagerUtil.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/util/APIManagerUtil.java @@ -17,10 +17,10 @@ */ package io.entgra.device.mgt.core.apimgt.application.extension.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; 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 47bdfcc258..2301d92e0e 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,11 @@ https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + commons-httpclient.wso2 commons-httpclient @@ -54,17 +59,6 @@ org.wso2.carbon.core provided - - org.eclipse.osgi - org.eclipse.osgi - provided - - - org.eclipse.osgi - org.eclipse.osgi.services - provided - - org.json.wso2 json @@ -89,8 +83,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -110,17 +108,23 @@ io.entgra.device.mgt.core.apimgt.extension.rest.api.* + com.google.gson;version="[2.9,3)", + 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.dto.APIInfo, + io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions, + io.entgra.device.mgt.core.apimgt.extension.rest.api.util, + javax.net.ssl,okhttp3;version="[4.9,5)", + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.logging;version="[1.2,2)", + org.apache.commons.ssl;version="[3.1,4)", + org.json;version="[3.0,4)", 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", - 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}", - 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 + org.wso2.carbon.apimgt.api.model;version="[9.28,10)", + org.wso2.carbon.apimgt.impl;version="[9.28,10)", + org.wso2.carbon.apimgt.impl.internal;version="[9.28,10)", + org.wso2.carbon.base;version="[1.0,2)" 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 68faf24b80..c6cca34843 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,22 +19,18 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import com.google.gson.Gson; -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.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 okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.RequestBody; -import okhttp3.Credentials; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.HttpsTrustManagerUtils; +import okhttp3.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; import org.wso2.carbon.apimgt.impl.APIManagerConfiguration; import org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder; + import java.io.IOException; 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 6bc3f17318..be134dbb4d 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 @@ -19,18 +19,13 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo.APIInfo; 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.dto.APIInfo.APIInfo; import org.json.JSONObject; -import org.wso2.carbon.apimgt.api.model.APIIdentifier; -import org.wso2.carbon.apimgt.api.model.Scope; -import org.wso2.carbon.apimgt.api.model.Mediation; -import org.wso2.carbon.apimgt.api.model.APIRevision; -import org.wso2.carbon.apimgt.api.model.APIRevisionDeployment; -import org.wso2.carbon.apimgt.api.model.Documentation; +import org.wso2.carbon.apimgt.api.model.*; import java.util.List; 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 3308f13115..455ddb6c5b 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 @@ -21,30 +21,21 @@ 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.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.APIInfo.APIInfo; 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.dto.APIInfo.APIInfo; 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 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.JSONArray; import org.json.JSONObject; -import org.wso2.carbon.apimgt.api.model.APIIdentifier; -import org.wso2.carbon.apimgt.api.model.Scope; -import org.wso2.carbon.apimgt.api.model.Mediation; -import org.wso2.carbon.apimgt.api.model.APIRevision; -import org.wso2.carbon.apimgt.api.model.APIRevisionDeployment; -import org.wso2.carbon.apimgt.api.model.Documentation; +import org.wso2.carbon.apimgt.api.model.*; import java.io.IOException; import java.util.List; 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 30074c7b4a..c2691c4e05 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 @@ -61,10 +61,10 @@ public final class Constants { public static final String SPACE = " "; 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 SCOPE_API_ENDPOINT = "/api/am/publisher/v2/scopes/"; - public static final String API_ENDPOINT = "/api/am/publisher/v2/apis/"; - public static final String GET_ALL_APIS = "/api/am/publisher/v2/apis?limit=1000"; + public static final String GET_ALL_SCOPES = "/api/am/publisher/v4/scopes?limit=1000"; + public static final String SCOPE_API_ENDPOINT = "/api/am/publisher/v4/scopes/"; + public static final String API_ENDPOINT = "/api/am/publisher/v4/apis/"; + public static final String GET_ALL_APIS = "/api/am/publisher/v4/apis?limit=1000"; } 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/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 index 989a547729..5ee6d99b19 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/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 @@ -24,22 +24,17 @@ 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.osgi.service.component.annotations.*; import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; -/** - * @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" - */ +@Component( + name = "io.entgra.device.mgt.core.apimgt.extension.rest.api.internal.PublisherRESTAPIServiceComponent", + immediate = true) public class PublisherRESTAPIServiceComponent { private static Log log = LogFactory.getLog(PublisherRESTAPIServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Initializing publisher API extension bundle"); @@ -58,11 +53,17 @@ public class PublisherRESTAPIServiceComponent { log.error("Error occurred while initializing API Application bundle", e); } } - + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } + @Reference( + name = "apim.configuration.service", + service = org.wso2.carbon.apimgt.impl.APIManagerConfigurationService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetAPIManagerConfigurationService") protected void setAPIManagerConfigurationService(APIManagerConfigurationService apiManagerConfigurationService) { if (log.isDebugEnabled()) { log.debug("Setting API Manager Configuration Service"); 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 745ceee40a..826186d555 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 @@ -25,30 +25,12 @@ 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 javax.net.ssl.*; 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.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; -import java.security.SecureRandom; +import java.net.*; +import java.security.*; import java.security.cert.CertificateException; import java.util.ArrayList; import java.util.List; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 5561082608..1574f824e5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -11,15 +11,16 @@ war WSO2 Carbon - API Key Management API This module extends the API manager's key management apis. - http://wso2.org + https://entgra.io + org.apache.maven.plugins maven-compiler-plugin - + org.apache.maven.plugins maven-war-plugin WEB-INF/lib/*cxf*.jar diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerService.java index 4d7af948e8..b58511f170 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerService.java @@ -18,12 +18,7 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.api; -import javax.ws.rs.Consumes; -import javax.ws.rs.FormParam; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java index 27cfa87573..5179e8f4e2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java @@ -28,12 +28,7 @@ import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtService; import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtServiceImpl; import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnAuthorizedException; -import javax.ws.rs.Consumes; -import javax.ws.rs.FormParam; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.Base64; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/webapp/WEB-INF/cxf-servlet.xml index f93f453965..72fa3b82a2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -19,9 +19,9 @@ + http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index c7d84703db..ef9b856fbe 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -12,9 +12,14 @@ bundle WSO2 Carbon - API Key Management This module extends the API manager's key management. - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + commons-codec.wso2 commons-codec @@ -37,8 +42,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -52,10 +61,40 @@ API Management Application Bundle io.entgra.device.mgt.core.apimgt.keymgt.extension.internal - io.entgra.device.mgt.core.apimgt.application.extension, - io.entgra.device.mgt.core.apimgt.application.extension.*, - io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.core.* + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.apimgt.keymgt.extension, + io.entgra.device.mgt.core.apimgt.keymgt.extension.exception, + io.entgra.device.mgt.core.apimgt.keymgt.extension.service, + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config.keymanager;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", + javax.cache;version="[1.0,2)", + javax.net.ssl,okhttp3;version="[4.9,5)", + org.apache.commons.lang;version="[2.4,3)", + org.apache.commons.logging;version="[1.2,2)", + org.json;version="[3.0,4)", + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.wso2.carbon.apimgt.api;version="[9.28,10)", + org.wso2.carbon.apimgt.api.model;version="[9.28,10)", + org.wso2.carbon.apimgt.api.model.subscription;version="[9.28,10)", + org.wso2.carbon.apimgt.impl;version="[9.28,10)", + org.wso2.carbon.apimgt.impl.caching;version="[9.28,10)", + org.wso2.carbon.apimgt.impl.dto;version="[9.28,10)", + org.wso2.carbon.apimgt.impl.factory;version="[9.28,10)", + org.wso2.carbon.apimgt.impl.jwt;version="[9.28,10)", + org.wso2.carbon.apimgt.impl.utils;version="[9.28,10)", + org.wso2.carbon.apimgt.keymgt;version="[9.28,10)", + org.wso2.carbon.apimgt.keymgt.handlers;version="[9.28,10)", + org.wso2.carbon.apimgt.keymgt.model;version="[9.28,10)", + org.wso2.carbon.apimgt.keymgt.model.entity;version="[9.28,10)", + org.wso2.carbon.apimgt.keymgt.service;version="[9.28,10)", + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.user.core.tenant;version="[4.8,5)", + org.wso2.carbon.utils.multitenancy;version="[4.8,5)" !io.entgra.device.mgt.core.apimgt.keymgt.extension.internal, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/KeyManagerConnectorConfiguration.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/KeyManagerConnectorConfiguration.java index ddc6eed83d..0be25b31a7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/KeyManagerConnectorConfiguration.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/KeyManagerConnectorConfiguration.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension; +import org.osgi.service.component.annotations.Component; import org.wso2.carbon.apimgt.api.model.ConfigurationDto; import org.wso2.carbon.apimgt.impl.APIConstants; import org.wso2.carbon.apimgt.impl.DefaultKeyManagerConnectorConfiguration; @@ -27,9 +28,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -/** - * @scr.component name="io.entgra.device.mgt.core.apimgt.keymgt.extension.customKeyManagerConfigComponent" immediate="true" - */ +@Component( + name = "io.entgra.device.mgt.core.apimgt.keymgt.extension.KeyManagerConnectorConfiguration", + service = DefaultKeyManagerConnectorConfiguration.class, + immediate = true) public class KeyManagerConnectorConfiguration extends DefaultKeyManagerConnectorConfiguration { @Override diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/KeyValidationHandler.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/KeyValidationHandler.java index 0b8bf30bc3..d580b6ea5e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/KeyValidationHandler.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/KeyValidationHandler.java @@ -17,6 +17,10 @@ */ package io.entgra.device.mgt.core.apimgt.keymgt.extension; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagerService; +import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -36,22 +40,12 @@ import org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore; import org.wso2.carbon.apimgt.keymgt.model.entity.API; import org.wso2.carbon.apimgt.keymgt.service.TokenValidationContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagerService; -import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.StringTokenizer; +import java.util.*; public class KeyValidationHandler extends DefaultKeyValidationHandler { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java index d86c3d7ca7..737fa907c3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java @@ -18,21 +18,24 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.internal; +import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtService; +import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtServiceImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtService; -import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtServiceImpl; - -/** - * @scr.component name="io.entgra.device.mgt.core.apimgt.keymgt.extension.keyMgtServiceComponent" immediate="true" - */ +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +@Component( + name = "io.entgra.device.mgt.core.apimgt.keymgt.extension.internal.KeyMgtServiceComponent", + immediate = true) public class KeyMgtServiceComponent { private static final Log log = LogFactory.getLog(KeyMgtServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -54,6 +57,7 @@ public class KeyMgtServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("De-activating Key Management Service Component"); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index c7da98973b..e674c459d2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -19,13 +19,13 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.service; import com.google.gson.Gson; -import okhttp3.Credentials; -import okhttp3.FormBody; -import okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; +import io.entgra.device.mgt.core.apimgt.keymgt.extension.*; +import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.BadRequestException; +import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.KeyMgtException; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; +import io.entgra.device.mgt.core.device.mgt.core.config.keymanager.KeyManagerConfigurations; +import okhttp3.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONObject; @@ -34,18 +34,7 @@ import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.model.Application; import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.impl.utils.APIUtil; -import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; -import io.entgra.device.mgt.core.apimgt.keymgt.extension.KeyManagerPayload; -import io.entgra.device.mgt.core.apimgt.keymgt.extension.KeyMgtConstants; -import io.entgra.device.mgt.core.apimgt.keymgt.extension.OAuthApplication; -import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; -import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; -import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.BadRequestException; -import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.KeyMgtException; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; -import io.entgra.device.mgt.core.device.mgt.core.config.keymanager.KeyManagerConfigurations; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; @@ -59,11 +48,7 @@ import javax.net.ssl.X509TrustManager; import java.io.IOException; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; public class KeyMgtServiceImpl implements KeyMgtService { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 2a45ffeea1..997ac34fad 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -31,22 +31,19 @@ bundle WSO2 Carbon - API Management Webapp Publisher WSO2 Carbon - API Management Webapp Publisher - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.powermock powermock-api-mockito test - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - org.testng testng @@ -67,7 +64,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon @@ -82,7 +78,7 @@ gson - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation @@ -139,8 +135,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -159,47 +159,43 @@ io.entgra.device.mgt.core.apimgt.webapp.publisher.* - com.google.gson;version="[2.3,2.8.6)", - com.google.gson.reflect;version="[2.3,2.8.6)", - io.swagger.annotations, - javax.servlet;version="2.6", - javax.xml, - javax.xml.bind, - javax.xml.bind.annotation, - javax.xml.parsers, - org.apache.catalina;version="9.0", - org.apache.catalina.core;version="9.0", - org.apache.commons.logging;version="1.2", - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.scannotation;version="1.0", - org.scannotation.archiveiterator;version="1.0", - org.w3c.dom, - io.entgra.device.mgt.core.apimgt.extension.rest.api.*, - io.entgra.device.mgt.core.apimgt.annotations, - org.wso2.carbon.apimgt.api, - org.wso2.carbon.apimgt.api.model, - org.wso2.carbon.apimgt.impl, - org.wso2.carbon.apimgt.impl.utils, - io.entgra.device.mgt.core.apimgt.webapp.publisher, + com.google.gson;version="[2.9,3)", + com.google.gson.reflect;version="[2.9,3)", + io.entgra.device.mgt.core.apimgt.annotations;version="[5.0,6)", + io.entgra.device.mgt.core.apimgt.extension.rest.api;version="[5.0,6)", + io.entgra.device.mgt.core.apimgt.extension.rest.api.dto;version="[5.0,6)", + io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;version="[5.0,6)", + io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions;version="[5.0,6)", io.entgra.device.mgt.core.apimgt.webapp.publisher.config, io.entgra.device.mgt.core.apimgt.webapp.publisher.dto, io.entgra.device.mgt.core.apimgt.webapp.publisher.exception, - io.entgra.device.mgt.core.apimgt.webapp.publisher.lifecycle.listener, - io.entgra.device.mgt.core.apimgt.webapp.publisher.lifecycle.util, - org.wso2.carbon.base;version="1.0", - org.wso2.carbon.context;version="4.6", - org.wso2.carbon.core;version="4.6", - org.wso2.carbon.core.util;version="4.6", - org.wso2.carbon.registry.core.service;version="1.0", - org.wso2.carbon.user.api;version="1.0", - org.wso2.carbon.user.core.service;version="4.6", - org.wso2.carbon.user.core.tenant;version="4.6", - 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.json + io.swagger.annotations;version="[1.6,2)", + javax.servlet;version="[2.6,3)", + javax.xml.bind;version="[0.0,1)", + javax.xml.bind.annotation;version="[0.0,1)", + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", + org.apache.catalina;version="${catalina.version.range}", + org.apache.catalina.core;version="${catalina.version.range}", + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.logging;version="[1.2,2)", + org.json;version="[3.0,4)", + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.scannotation;version="[1.0,2)", + org.scannotation.archiveiterator;version="[1.0,2)", + org.w3c.dom, + org.wso2.carbon.apimgt.api;version="[9.28,10)", + org.wso2.carbon.apimgt.api.model;version="[9.28,10)", + org.wso2.carbon.apimgt.impl;version="[9.28,10)", + org.wso2.carbon.apimgt.impl.utils;version="[9.28,10)", + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.core;version="[4.8,5)", + org.wso2.carbon.core.util;version="[4.8,5)", + org.wso2.carbon.registry.core.service, + org.wso2.carbon.user.api, + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.user.core.tenant;version="[4.8,5)", + org.wso2.carbon.utils;version="[4.8,5)" jsr311-api;scope=compile|runtime;inline=false diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index c24e38fdd2..2062f0e01d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -24,33 +24,26 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServi import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServicesImpl; 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.APIInfo.APIInfo; 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.dto.APIInfo.APIInfo; -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.model.APIIdentifier; -import org.wso2.carbon.apimgt.api.model.APIRevision; -import org.wso2.carbon.apimgt.api.model.APIRevisionDeployment; -import org.wso2.carbon.apimgt.api.model.CORSConfiguration; -import org.wso2.carbon.apimgt.api.model.Mediation; -import org.wso2.carbon.apimgt.api.model.Scope; -import org.wso2.carbon.apimgt.impl.APIConstants; -import org.wso2.carbon.apimgt.impl.APIManagerFactory; -import org.wso2.carbon.apimgt.impl.utils.APIUtil; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.WebappPublisherConfig; import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiScope; import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiUriTemplate; import io.entgra.device.mgt.core.apimgt.webapp.publisher.exception.APIManagerPublisherException; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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.model.*; +import org.wso2.carbon.apimgt.impl.APIConstants; +import org.wso2.carbon.apimgt.impl.APIManagerFactory; +import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; @@ -66,16 +59,7 @@ import java.io.IOException; import java.nio.file.DirectoryIteratorException; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Date; +import java.util.*; /** * This class represents the concrete implementation of the APIPublisherService that corresponds to providing all diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java index 56ec060d71..a47c1399d7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -19,10 +19,10 @@ package io.entgra.device.mgt.core.apimgt.webapp.publisher; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.apimgt.webapp.publisher.exception.APIManagerPublisherException; import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.core.ServerStartupObserver; import java.util.Stack; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java index dedd6f9c99..31e1a656ce 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java @@ -23,8 +23,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResource; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResourceConfiguration; @@ -32,6 +30,8 @@ import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.WebappPublisherC import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiScope; import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiUriTemplate; import io.entgra.device.mgt.core.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.Utils; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/config/WebappPublisherConfig.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/config/WebappPublisherConfig.java index 2d7406b4a7..29c6a79a58 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/config/WebappPublisherConfig.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/config/WebappPublisherConfig.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.apimgt.webapp.publisher.config; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.apimgt.webapp.publisher.InvalidConfigurationStateException; import io.entgra.device.mgt.core.apimgt.webapp.publisher.WebappPublisherConfigurationFailedException; import io.entgra.device.mgt.core.apimgt.webapp.publisher.WebappPublisherUtil; +import org.w3c.dom.Document; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java index 7c67f9d0c2..af5da0cb56 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java @@ -18,37 +18,27 @@ */ package io.entgra.device.mgt.core.apimgt.webapp.publisher.internal; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherService; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherServiceImpl; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherStartupHandler; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.WebappPublisherConfig; +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.osgi.service.component.annotations.*; import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; -/** - * @scr.component name="io.entgra.device.mgt.core.apimgt.webapp.publisher" immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="registry.service" - * interface="org.wso2.carbon.registry.core.service.RegistryService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRegistryService" - * unbind="unsetRegistryService" - */ +@Component( + name = "io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherServiceComponent", + immediate = true) public class APIPublisherServiceComponent { private static Log log = LogFactory.getLog(APIPublisherServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -72,6 +62,7 @@ public class APIPublisherServiceComponent { } } + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } @@ -89,6 +80,12 @@ public class APIPublisherServiceComponent { bundleContext.registerService(ServerStartupObserver.class, new APIPublisherStartupHandler(), null); } + @Reference( + name = "user.realmservice.default", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { log.debug("Setting Realm Service"); @@ -103,6 +100,12 @@ public class APIPublisherServiceComponent { APIPublisherDataHolder.getInstance().setRealmService(null); } + @Reference( + name = "registry.service", + service = org.wso2.carbon.registry.core.service.RegistryService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRegistryService") protected void setRegistryService(RegistryService registryService) { if (registryService != null && log.isDebugEnabled()) { log.debug("Registry service initialized"); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java index b486fdf267..a3abe8623e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java @@ -18,12 +18,6 @@ */ package io.entgra.device.mgt.core.apimgt.webapp.publisher.lifecycle.listener; -import org.apache.catalina.Lifecycle; -import org.apache.catalina.LifecycleEvent; -import org.apache.catalina.LifecycleListener; -import org.apache.catalina.core.StandardContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIConfig; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherService; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherUtil; @@ -31,6 +25,12 @@ import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResourceConfi import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.WebappPublisherConfig; import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import io.entgra.device.mgt.core.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor; +import org.apache.catalina.Lifecycle; +import org.apache.catalina.LifecycleEvent; +import org.apache.catalina.LifecycleListener; +import org.apache.catalina.core.StandardContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java index cca49ae996..b51a5a2b8b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java @@ -18,27 +18,18 @@ package io.entgra.device.mgt.core.apimgt.webapp.publisher.lifecycle.util; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherUtil; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResource; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResourceConfiguration; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiScope; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.SwaggerDefinition; import org.apache.catalina.core.StandardContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherUtil; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResource; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResourceConfiguration; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiScope; import javax.servlet.ServletContext; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; -import javax.ws.rs.HttpMethod; -import javax.ws.rs.OPTIONS; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import java.io.File; import java.io.IOException; import java.lang.annotation.Annotation; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/util/ExtendedFileProtocolIteratorFactory.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/util/ExtendedFileProtocolIteratorFactory.java index 68b8878055..f37951ff54 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/util/ExtendedFileProtocolIteratorFactory.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/util/ExtendedFileProtocolIteratorFactory.java @@ -16,7 +16,6 @@ package io.entgra.device.mgt.core.apimgt.webapp.publisher.lifecycle.util; import org.scannotation.archiveiterator.*; - import java.io.File; import java.io.IOException; import java.net.URL; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceTest.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceTest.java index 5f5c8a1ddb..c08c07eb58 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceTest.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceTest.java @@ -17,6 +17,13 @@ */ package io.entgra.device.mgt.core.apimgt.webapp.publisher; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.WebappPublisherConfig; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiScope; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.exception.APIManagerPublisherException; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.utils.MockAPICollectionApi; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.utils.MockAPIIndividualApi; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.utils.TestUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mockito.Mockito; @@ -32,13 +39,6 @@ import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.APIIndi import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.API; import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.APIInfo; import org.wso2.carbon.apimgt.integration.generated.client.publisher.model.APIList; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.WebappPublisherConfig; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiScope; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.exception.APIManagerPublisherException; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.utils.MockAPICollectionApi; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.utils.MockAPIIndividualApi; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.utils.TestUtils; import java.lang.reflect.Field; import java.util.*; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtilTest.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtilTest.java index 70676eb845..71aebd259f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtilTest.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtilTest.java @@ -17,9 +17,6 @@ */ package io.entgra.device.mgt.core.apimgt.webapp.publisher; -import org.testng.Assert; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResource; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResourceConfiguration; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.WebappPublisherConfig; @@ -28,6 +25,9 @@ import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiUriTemplate; import io.entgra.device.mgt.core.apimgt.webapp.publisher.exception.APIManagerPublisherException; import io.entgra.device.mgt.core.apimgt.webapp.publisher.utils.MockServletContext; import io.entgra.device.mgt.core.apimgt.webapp.publisher.utils.TestUtils; +import org.testng.Assert; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService; @@ -36,14 +36,11 @@ import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import javax.servlet.ServletContext; - import java.util.ArrayList; import java.util.List; import java.util.Set; -import static io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherUtil.buildApiConfig; -import static io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherUtil.getApiEndpointUrl; -import static io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherUtil.setResourceAuthTypes; +import static io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherUtil.*; /** * This is the test class for {@link APIPublisherUtil} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/BaseAPIPublisherTest.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/BaseAPIPublisherTest.java index d8da938cff..d5746ee348 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/BaseAPIPublisherTest.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/BaseAPIPublisherTest.java @@ -18,12 +18,13 @@ */ package io.entgra.device.mgt.core.apimgt.webapp.publisher; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.utils.MockAPIIndividualApi; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mockito.Mockito; import org.testng.annotations.BeforeSuite; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.utils.MockAPIIndividualApi; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.internal.OSGiDataHolder; @@ -34,7 +35,6 @@ import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import java.io.File; import java.io.InputStream; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml index bb79290fd6..4386f0c0f3 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml @@ -30,7 +30,7 @@ bundle WSO2 Carbon - API Security Handler Component WSO2 Carbon - API Management Security Handler Module - http://wso2.org + https://entgra.io diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index c91bf08475..a0f940230d 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -22,7 +22,7 @@ bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client - http://wso2.org + https://entgra.io diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml index 98240ce166..b785aa270c 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml @@ -22,7 +22,7 @@ bundle WSO2 Carbon - API Management Integration Generated Client WSO2 Carbon - API Management Integration Client - http://wso2.org + https://entgra.io diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index ae5f8c040c..d74759438b 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -30,7 +30,7 @@ apimgt-extensions pom WSO2 Carbon - API Management Extensions Component - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.apimgt.webapp.publisher @@ -43,23 +43,4 @@ io.entgra.device.mgt.core.apimgt.extension.rest.api - - - - - - - - - - - - - - - - - - - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml index 78dfa71168..784daa0f10 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/pom.xml @@ -29,12 +29,17 @@ Entgra - Application Management Add-Ons Entgra - Application Management Add-Ons https://entgra.io + bundle - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -47,8 +52,21 @@ ${io.entgra.device.mgt.core.version} Application Management Add-Ons Bundle - com.google.gson, - io.swagger.annotations.*;resolution:=optional + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.application.mgt.addons.jaxrs, + javax.servlet;version="[4.0,5)", + javax.servlet.http;version="[4.0,5)", + javax.validation;version="[1.1,2)", + javax.validation.executable;version="[1.1,2)", + javax.ws.rs;version="[2.1,3)", + javax.ws.rs.core;version="[2.1,3)", + javax.ws.rs.ext;version="[2.1,3)", + org.apache.commons.logging;version="[1.2,2)", + org.apache.cxf.interceptor;version="[3.5,4)", + org.apache.cxf.jaxrs.lifecycle;version="[3.5,4)", + org.apache.cxf.jaxrs.model;version="[3.5,4)", + org.apache.cxf.message;version="[3.5,4)", + org.apache.cxf.phase;version="[3.5,4)" io.entgra.device.mgt.core.application.mgt.addons.* @@ -60,6 +78,11 @@ + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.apache.cxf cxf-rt-frontend-jaxws @@ -75,19 +98,10 @@ cxf-rt-transports-http provided - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.equinox - org.eclipse.equinox.common - org.ops4j.pax.logging pax-logging-api provided - commons-codec.wso2 diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/JSONMessageHandler.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/JSONMessageHandler.java index 3834cedd01..8ef8cc7fa2 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/JSONMessageHandler.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/JSONMessageHandler.java @@ -28,11 +28,7 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; +import java.io.*; import java.lang.annotation.Annotation; import java.lang.reflect.Type; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/MultipartCustomProvider.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/MultipartCustomProvider.java index 1ef766a957..3764549e40 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/MultipartCustomProvider.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.addons/src/main/java/io/entgra/device/mgt/core/application/mgt/addons/MultipartCustomProvider.java @@ -20,8 +20,8 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; import io.entgra.device.mgt.core.application.mgt.addons.jaxrs.AnnotationExclusionStrategy; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; import javax.ws.rs.Consumes; import javax.ws.rs.WebApplicationException; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml index 30cc4268e9..9a0724590c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/pom.xml @@ -140,7 +140,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.json.wso2 diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/ArtifactDownloadAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/ArtifactDownloadAPI.java index 6956f57b9c..39dfd51942 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/ArtifactDownloadAPI.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/ArtifactDownloadAPI.java @@ -17,23 +17,11 @@ package io.entgra.device.mgt.core.application.mgt.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; +import io.swagger.annotations.*; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/impl/ArtifactDownloadAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/impl/ArtifactDownloadAPIImpl.java index b6b7938132..d86cfd6e8a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/impl/ArtifactDownloadAPIImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.api/src/main/java/io/entgra/device/mgt/core/application/mgt/api/impl/ArtifactDownloadAPIImpl.java @@ -17,9 +17,6 @@ package io.entgra.device.mgt.core.application.mgt.api.impl; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.api.ArtifactDownloadAPI; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; @@ -28,18 +25,16 @@ import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestExcept import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; import io.entgra.device.mgt.core.application.mgt.core.util.Constants; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; /** * Implementation of ApplicationDTO Management related APIs. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index d1c04250dd..cd9725f50a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -35,8 +35,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -49,13 +53,23 @@ ${io.entgra.device.mgt.core.version} Application Management Common Bundle - io.entgra.device.mgt.core.device.mgt.common.*;version="${io.entgra.device.mgt.core.version}", - io.entgra.device.mgt.core.device.mgt.core.dto;version="${io.entgra.device.mgt.core.version}", - com.google.gson, - io.swagger.annotations.*;resolution:=optional, - com.fasterxml.jackson.annotation, - javax.validation.constraints, - javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}", + com.fasterxml.jackson.annotation;version="[2.9,3)", + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.application.mgt.common, + io.entgra.device.mgt.core.application.mgt.common.config, + io.entgra.device.mgt.core.application.mgt.common.dto, + io.entgra.device.mgt.core.application.mgt.common.exception, + io.entgra.device.mgt.core.application.mgt.common.response, + io.entgra.device.mgt.core.application.mgt.common.wrapper, + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.common.exception;version="[5.0,6)", + io.swagger.annotations;version="[1.6,2)", + javax.validation.constraints;version="[2.0,3)", + javax.xml.bind.annotation;version="[0.0,1)" + + io.entgra.device.mgt.core.application.mgt.common.* @@ -68,18 +82,14 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.equinox - org.eclipse.equinox.common + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.ops4j.pax.logging pax-logging-api provided - commons-codec.wso2 diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationInstallResponse.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationInstallResponse.java index 5d6cb77951..5a7c2b636f 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationInstallResponse.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationInstallResponse.java @@ -17,9 +17,9 @@ package io.entgra.device.mgt.core.application.mgt.common; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; +import io.swagger.annotations.ApiModelProperty; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationSubscriptionInfo.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationSubscriptionInfo.java index 2b3680a41c..895513e3f2 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationSubscriptionInfo.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationSubscriptionInfo.java @@ -20,7 +20,6 @@ package io.entgra.device.mgt.core.application.mgt.common; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import java.util.ArrayList; import java.util.List; public class ApplicationSubscriptionInfo { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceList.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceList.java index cf178048bb..e9a8384b47 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceList.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceList.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.application.mgt.common; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java index 7911cee127..59eb56f9d7 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java @@ -19,8 +19,6 @@ package io.entgra.device.mgt.core.application.mgt.common; import io.entgra.device.mgt.core.device.mgt.common.Device; -import java.sql.Timestamp; - public class DeviceSubscriptionData { private int subId; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/InstallationDetails.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/InstallationDetails.java index 082620261d..48237d02c7 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/InstallationDetails.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/InstallationDetails.java @@ -17,8 +17,8 @@ */ package io.entgra.device.mgt.core.application.mgt.common; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.swagger.annotations.ApiModelProperty; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java index cc6c7c3193..8eb216c4f5 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java @@ -17,10 +17,10 @@ */ package io.entgra.device.mgt.core.application.mgt.common; -import java.sql.Timestamp; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.sql.Timestamp; import java.util.List; @ApiModel(value = "LifecycleState", description = "LifecycleState represents the Lifecycle state for an application release") diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/ScheduledSubscriptionDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/ScheduledSubscriptionDTO.java index 134c434ced..62552129aa 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/ScheduledSubscriptionDTO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/ScheduledSubscriptionDTO.java @@ -20,8 +20,8 @@ package io.entgra.device.mgt.core.application.mgt.common.dto; import com.google.gson.Gson; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; -import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; import io.entgra.device.mgt.core.application.mgt.common.SubAction; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRelease; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java index 1eb7d00395..1b7b1db255 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java @@ -16,7 +16,9 @@ */ package io.entgra.device.mgt.core.application.mgt.common.services; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationType; +import io.entgra.device.mgt.core.application.mgt.common.*; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.RequestValidatingException; import io.entgra.device.mgt.core.application.mgt.common.exception.ResourceManagementException; @@ -24,20 +26,10 @@ import io.entgra.device.mgt.core.application.mgt.common.response.Application; import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRelease; import io.entgra.device.mgt.core.application.mgt.common.response.Category; import io.entgra.device.mgt.core.application.mgt.common.response.Tag; +import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; import io.entgra.device.mgt.core.device.mgt.common.Base64File; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact; -import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; -import io.entgra.device.mgt.core.application.mgt.common.Filter; -import io.entgra.device.mgt.core.application.mgt.common.LifecycleState; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.EntAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationUpdateWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppReleaseWrapper; + import java.util.List; /** diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ReviewManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ReviewManager.java index 2a2f6d29db..6e355a3940 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ReviewManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ReviewManager.java @@ -16,12 +16,12 @@ */ package io.entgra.device.mgt.core.application.mgt.common.services; -import io.entgra.device.mgt.core.application.mgt.common.Rating; -import io.entgra.device.mgt.core.application.mgt.common.response.Review; import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.application.mgt.common.Rating; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.ReviewManagementException; +import io.entgra.device.mgt.core.application.mgt.common.response.Review; import io.entgra.device.mgt.core.application.mgt.common.wrapper.ReviewWrapper; /** diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java index 078d18350e..7f9eb91049 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.application.mgt.common.services; import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; -import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index d7283553df..6fa6d33f45 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -35,8 +35,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -50,40 +54,91 @@ Application Management Core Bundle io.entgra.device.mgt.core.application.mgt.core.internal + com.dd.plist;version="[1.21,2)", + com.google.gson;version="[2.9,3)", + com.google.gson.reflect;version="[2.9,3)", + io.entgra.device.mgt.core.apimgt.application.extension;version="[5.0,6)", + io.entgra.device.mgt.core.apimgt.application.extension.dto;version="[5.0,6)", + io.entgra.device.mgt.core.apimgt.application.extension.exception;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.config;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.dto;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.response;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.services;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.wrapper;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.core.config, + io.entgra.device.mgt.core.application.mgt.core.dao, + io.entgra.device.mgt.core.application.mgt.core.dao.common, + io.entgra.device.mgt.core.application.mgt.core.dao.impl, + io.entgra.device.mgt.core.application.mgt.core.dao.impl.application, + io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release, + io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.spapplication, + io.entgra.device.mgt.core.application.mgt.core.dao.impl.lifecyclestate, + io.entgra.device.mgt.core.application.mgt.core.dao.impl.review, + io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription, + io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility, + io.entgra.device.mgt.core.application.mgt.core.exception, + io.entgra.device.mgt.core.application.mgt.core.serviceprovider, + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.app.mgt.android;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.common.util;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.dto;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.task.impl;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.util;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="[5.0,6)", + javax.annotation;version="[1.0,2)", + javax.naming, + javax.sql, + + javax.xml.bind;version="[0.0,1)", + javax.xml.bind.annotation;version="[0.0,1)", + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", + org.apache.commons.codec.digest;version="[1.4,2)", + org.apache.commons.httpclient;version="[3.1,4)", + org.apache.commons.httpclient.methods;version="[3.1,4)", + org.apache.commons.io;version="[2.4,3)", + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.lang3;version="[3.12,4)", + org.apache.commons.logging;version="[1.2,2)", + org.apache.commons.validator.routines;version="[1.7,2)", + + org.apache.http;version="[4.4,5)", + org.apache.http.client;version="[4.3,5)", + org.apache.http.client.methods;version="[4.3,5)", + org.apache.http.impl.client;version="[4.3,5)", + org.bouncycastle.cert, + org.bouncycastle.cert.jcajce, + org.bouncycastle.cms, + org.bouncycastle.jce.provider;version="[1.70,2)", + org.bouncycastle.util;version="[1.70,2)", + org.json;version="[3.0,4)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - org.wso2.carbon.context.*, - org.wso2.carbon.utils.*, - org.w3c.dom, - org.json, - javax.sql, - com.google.gson.*, - javax.naming, - javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}", - javax.xml.bind; version="${javax.xml.bind.imp.pkg.version}", - io.entgra.device.mgt.core.application.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.core.*, - io.entgra.device.mgt.core.device.mgt.common.*, - org.wso2.carbon.user.core.*, - org.wso2.carbon.user.api.*, - org.wso2.carbon.ntask.*, - org.quartz.*, - org.wso2.carbon.ndatasource.core, - org.wso2.carbon, + org.quartz;version="[2.1,3)", + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.ndatasource.core;version="[4.8,5)", + org.wso2.carbon.ntask.common;version="[4.9,5)", + org.wso2.carbon.ntask.core;version="[4.9,5)", + org.wso2.carbon.ntask.core.service;version="[4.9,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.utils;version="[4.8,5)", + org.wso2.carbon.utils.dbcreator;version="[4.8,5)", org.xml.sax, - org.xml.sax.helpers, - org.apache.commons.io, - org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.apache.commons.codec.digest;version="${commons-codec.wso2.osgi.version.range}", - org.wso2.carbon.base, - com.dd.*, - io.entgra.device.mgt.core.identity.jwt.client.extension.*, - io.entgra.device.mgt.core.apimgt.application.extension.*, - org.apache.commons.httpclient, - org.apache.commons.httpclient.methods, - org.apache.commons.validator.routines + org.xml.sax.helpers apk-parser;scope=compile|runtime;inline=false @@ -112,16 +167,9 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - org.eclipse.equinox - org.eclipse.equinox.common + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.testng @@ -136,7 +184,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/Configuration.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/Configuration.java index c5d2c871dd..cb60147180 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/Configuration.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/Configuration.java @@ -17,14 +17,14 @@ */ package io.entgra.device.mgt.core.application.mgt.core.config; +import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; import io.entgra.device.mgt.core.application.mgt.common.config.MDMConfig; import io.entgra.device.mgt.core.application.mgt.common.config.RatingConfiguration; -import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; -import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; /** * Represents the Application Management Configuration. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/ConfigurationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/ConfigurationManager.java index de441ec9e8..3926ce2590 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/ConfigurationManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/ConfigurationManager.java @@ -17,15 +17,15 @@ */ package io.entgra.device.mgt.core.application.mgt.core.config; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; +import io.entgra.device.mgt.core.application.mgt.common.exception.InvalidConfigurationException; import io.entgra.device.mgt.core.application.mgt.core.util.Constants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.InvalidConfigurationException; -import java.io.File; import javax.xml.bind.JAXBContext; import javax.xml.bind.Unmarshaller; +import java.io.File; /** * ConfigurationManager is responsible for the managing Application Management related configurations. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/Extension.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/Extension.java index 36ba438863..1d4afc4895 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/Extension.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/config/Extension.java @@ -17,11 +17,11 @@ */ package io.entgra.device.mgt.core.application.mgt.core.config; -import java.util.List; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; /** * Represents a extension in the application management configuration. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java index 6378fe0546..497b163394 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java @@ -17,7 +17,7 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao; -import io.entgra.device.mgt.core.application.mgt.common.*; +import io.entgra.device.mgt.core.application.mgt.common.Filter; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.CategoryDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.TagDTO; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationReleaseDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationReleaseDAO.java index 19054f0ae4..6929cf074a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationReleaseDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationReleaseDAO.java @@ -17,8 +17,8 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.device.mgt.core.application.mgt.common.Rating; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ReviewDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ReviewDAO.java index 6d010a0dd7..48aab75a59 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ReviewDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ReviewDAO.java @@ -17,9 +17,9 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao; -import io.entgra.device.mgt.core.application.mgt.common.response.Review; import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.application.mgt.common.dto.ReviewDTO; +import io.entgra.device.mgt.core.application.mgt.common.response.Review; import io.entgra.device.mgt.core.application.mgt.core.exception.ReviewManagementDAOException; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SPApplicationDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SPApplicationDAO.java index 65dc94d98f..3586ceced8 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SPApplicationDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SPApplicationDAO.java @@ -17,8 +17,8 @@ package io.entgra.device.mgt.core.application.mgt.core.dao; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/common/ApplicationManagementDAOFactory.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/common/ApplicationManagementDAOFactory.java index babf2bd07c..5754d66950 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/common/ApplicationManagementDAOFactory.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/common/ApplicationManagementDAOFactory.java @@ -17,38 +17,25 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao.common; -import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO; +import io.entgra.device.mgt.core.application.mgt.common.exception.UnsupportedDatabaseEngineException; +import io.entgra.device.mgt.core.application.mgt.core.dao.*; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.GenericApplicationDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.OracleApplicationDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.PostgreSQLApplicationDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.SQLServerApplicationDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release.GenericApplicationReleaseDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release.OracleApplicationReleaseDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release.PostgreSQLApplicationReleaseDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release.SQLServerApplicationReleaseDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.spapplication.GenericSPApplicationDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.spapplication.OracleSPApplicationDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.spapplication.PostgreSQLSPApplicationDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.spapplication.SQLServerSPApplicationDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility.GenericVisibilityDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility.OracleVisibilityDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility.PostgreSQLVisibilityDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility.SQLServerVisibilityDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.util.Constants; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.exception.UnsupportedDatabaseEngineException; -import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.LifecycleStateDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.ReviewDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.VisibilityDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.PostgreSQLApplicationDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.SQLServerApplicationDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release.OracleApplicationReleaseDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release.PostgreSQLApplicationReleaseDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release.SQLServerApplicationReleaseDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.lifecyclestate.GenericLifecycleStateDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.lifecyclestate.OracleLifecycleStateDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.lifecyclestate.PostgreSQLLifecycleStateDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.lifecyclestate.SQLServerLifecycleStateDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.review.GenericReviewDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.GenericApplicationDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release.GenericApplicationReleaseDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.OracleApplicationDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.lifecyclestate.GenericLifecycleStateDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.review.OracleReviewDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.review.PostgreSQLReviewDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.review.SQLServerReviewDAOImpl; @@ -56,7 +43,14 @@ import io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription.Gene import io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription.OracleSubscriptionDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription.PostgreSQLSubscriptionDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription.SQLServerSubscriptionDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility.GenericVisibilityDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility.OracleVisibilityDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility.PostgreSQLVisibilityDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility.SQLServerVisibilityDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.Constants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.SQLException; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 5480401643..b5f6001118 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -17,27 +17,23 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.application; +import io.entgra.device.mgt.core.application.mgt.common.AppLifecycleState; +import io.entgra.device.mgt.core.application.mgt.common.Filter; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.CategoryDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.TagDTO; +import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; +import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; import io.entgra.device.mgt.core.application.mgt.core.util.Constants; import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.AppLifecycleState; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.CategoryDTO; -import io.entgra.device.mgt.core.application.mgt.common.Filter; -import io.entgra.device.mgt.core.application.mgt.common.dto.TagDTO; -import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; -import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; +import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.StringJoiner; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java index f342dd1c4a..19842cfbed 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java @@ -18,15 +18,15 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.application; +import io.entgra.device.mgt.core.application.mgt.common.Filter; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; +import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.device.mgt.core.application.mgt.core.util.Constants; import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.Filter; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; -import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java index f347080d80..4b934788ee 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java @@ -17,15 +17,15 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.application; +import io.entgra.device.mgt.core.application.mgt.common.Filter; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; +import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.device.mgt.core.application.mgt.core.util.Constants; import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.Filter; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; -import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java index 0506c1d396..7a99cb2c7d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java @@ -18,21 +18,17 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release; -import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.device.mgt.core.application.mgt.common.Rating; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; +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.sql.Statement; +import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.StringJoiner; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/OracleApplicationReleaseDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/OracleApplicationReleaseDAOImpl.java index f3a525b3b3..fdd04cced4 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/OracleApplicationReleaseDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/OracleApplicationReleaseDAOImpl.java @@ -17,10 +17,10 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/SQLServerApplicationReleaseDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/SQLServerApplicationReleaseDAOImpl.java index 905b193bf1..9d99d046a5 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/SQLServerApplicationReleaseDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/SQLServerApplicationReleaseDAOImpl.java @@ -17,10 +17,10 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.release; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/GenericSPApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/GenericSPApplicationDAOImpl.java index df88bc4619..742d15deeb 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/GenericSPApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/GenericSPApplicationDAOImpl.java @@ -17,8 +17,8 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.spapplication; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; @@ -29,11 +29,7 @@ import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; 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.sql.Statement; +import java.sql.*; import java.util.List; public class GenericSPApplicationDAOImpl extends AbstractDAOImpl implements SPApplicationDAO { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/OracleSPApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/OracleSPApplicationDAOImpl.java index f68a68c790..306afff8e3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/OracleSPApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/OracleSPApplicationDAOImpl.java @@ -17,8 +17,8 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.spapplication; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; @@ -27,11 +27,8 @@ import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServer import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; 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.sql.Statement; + +import java.sql.*; import java.util.List; public class OracleSPApplicationDAOImpl extends AbstractDAOImpl implements SPApplicationDAO { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/PostgreSQLSPApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/PostgreSQLSPApplicationDAOImpl.java index 4aeedb4f3e..3794147969 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/PostgreSQLSPApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/PostgreSQLSPApplicationDAOImpl.java @@ -17,8 +17,8 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.spapplication; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; @@ -27,11 +27,8 @@ import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServer import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; 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.sql.Statement; + +import java.sql.*; import java.util.List; public class PostgreSQLSPApplicationDAOImpl extends AbstractDAOImpl implements SPApplicationDAO { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/SQLServerSPApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/SQLServerSPApplicationDAOImpl.java index 33cfa97e0a..8d7cb35f4c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/SQLServerSPApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/SQLServerSPApplicationDAOImpl.java @@ -17,8 +17,8 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.application.spapplication; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; @@ -27,11 +27,8 @@ import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServer import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; 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.sql.Statement; + +import java.sql.*; import java.util.List; public class SQLServerSPApplicationDAOImpl extends AbstractDAOImpl implements SPApplicationDAO { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java index 699f23cf58..4bb8967390 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java @@ -17,21 +17,17 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.lifecyclestate; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.AppLifecycleState; import io.entgra.device.mgt.core.application.mgt.common.LifecycleState; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.dao.LifecycleStateDAO; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.exception.LifeCycleManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; +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.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java index 22bc5a62d2..ffbc654c8b 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java @@ -17,24 +17,19 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.review; -import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; -import io.entgra.device.mgt.core.application.mgt.core.util.Constants; -import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.application.mgt.common.dto.ReviewDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.dao.ReviewDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.exception.ReviewManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; +import io.entgra.device.mgt.core.application.mgt.core.util.Constants; +import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.sql.SQLException; -import java.sql.ResultSet; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.StringJoiner; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java index ad4da703fc..f8620a2562 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java @@ -17,14 +17,14 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.review; -import io.entgra.device.mgt.core.application.mgt.core.util.Constants; -import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.application.mgt.common.dto.ReviewDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.exception.ReviewManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.util.Constants; +import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java index eac947383f..735977063d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java @@ -17,14 +17,14 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.review; -import io.entgra.device.mgt.core.application.mgt.core.util.Constants; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.application.mgt.common.dto.ReviewDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.exception.ReviewManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.util.Constants; import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index a712b397a5..f6573db44f 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -17,32 +17,22 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription; -import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; -import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; -import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; import io.entgra.device.mgt.core.application.mgt.common.SubAction; import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; +import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; +import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; +import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; +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.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; +import java.sql.*; +import java.util.*; public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements SubscriptionDAO { private static final Log log = LogFactory.getLog(GenericSubscriptionDAOImpl.class); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java index 9f304f9af4..7ebeeecfe6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java @@ -17,10 +17,10 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java index e92b2c8cb4..f433802981 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java @@ -17,10 +17,10 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java index 582b76f4a3..e655d65459 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java @@ -17,12 +17,12 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.core.dao.VisibilityDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.exception.VisibilityManagementDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index 81537a3ef1..9d470fb652 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -17,93 +17,49 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.common.Base64File; -import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO; -import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.validator.routines.UrlValidator; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstaller; -import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; -import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger; -import io.entgra.device.mgt.core.application.mgt.common.Pagination; +import io.entgra.device.mgt.core.application.mgt.common.*; import io.entgra.device.mgt.core.application.mgt.common.config.RatingConfiguration; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationSubscriptionType; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationType; -import io.entgra.device.mgt.core.application.mgt.common.dto.CategoryDTO; -import io.entgra.device.mgt.core.application.mgt.common.Filter; -import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; -import io.entgra.device.mgt.core.application.mgt.common.LifecycleState; -import io.entgra.device.mgt.core.application.mgt.common.dto.TagDTO; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationStorageManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; -import io.entgra.device.mgt.core.application.mgt.common.exception.LifecycleManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.RequestValidatingException; -import io.entgra.device.mgt.core.application.mgt.common.exception.ResourceManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.TransactionManagementException; +import io.entgra.device.mgt.core.application.mgt.common.dto.*; +import io.entgra.device.mgt.core.application.mgt.common.exception.*; import io.entgra.device.mgt.core.application.mgt.common.response.Application; import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRelease; import io.entgra.device.mgt.core.application.mgt.common.response.Category; import io.entgra.device.mgt.core.application.mgt.common.response.Tag; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationStorageManager; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.EntAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationUpdateWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppWrapper; +import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; -import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.LifecycleStateDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; -import io.entgra.device.mgt.core.application.mgt.core.dao.VisibilityDAO; +import io.entgra.device.mgt.core.application.mgt.core.dao.*; import io.entgra.device.mgt.core.application.mgt.core.dao.common.ApplicationManagementDAOFactory; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; -import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException; -import io.entgra.device.mgt.core.application.mgt.core.exception.LifeCycleManagementDAOException; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.exception.VisibilityManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.exception.*; import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; +import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil; import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil; import io.entgra.device.mgt.core.application.mgt.core.util.Constants; -import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagementException; +import io.entgra.device.mgt.core.device.mgt.common.Base64File; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; - +import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagementException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.validator.routines.UrlValidator; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java index 8bd02e47c7..a64efee4db 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -18,24 +18,27 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import com.dd.plist.NSDictionary; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstaller; +import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationStorageManagementException; +import io.entgra.device.mgt.core.application.mgt.common.exception.ResourceManagementException; +import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationStorageManager; import io.entgra.device.mgt.core.application.mgt.core.exception.ParsingException; import io.entgra.device.mgt.core.application.mgt.core.util.ArtifactsParser; import io.entgra.device.mgt.core.application.mgt.core.util.Constants; +import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagementException; +import io.entgra.device.mgt.core.device.mgt.core.common.util.StorageManagementUtil; import net.dongliu.apk.parser.bean.ApkMeta; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstaller; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; -import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationStorageManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.ResourceManagementException; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationStorageManager; -import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagementException; -import io.entgra.device.mgt.core.device.mgt.core.common.util.StorageManagementUtil; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.util.List; import static io.entgra.device.mgt.core.device.mgt.core.common.util.StorageManagementUtil.saveFile; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/AppmDataHandlerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/AppmDataHandlerImpl.java index a9e40e9e00..b861e5d0a3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/AppmDataHandlerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/AppmDataHandlerImpl.java @@ -17,22 +17,22 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationStorageManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.LifecycleManagementException; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationStorageManager; import io.entgra.device.mgt.core.application.mgt.common.services.AppmDataHandler; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; +import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; +import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.io.InputStream; import java.util.Map; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ReviewManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ReviewManagerImpl.java index acd483fb6a..370186d647 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ReviewManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ReviewManagerImpl.java @@ -17,34 +17,30 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.application.mgt.common.Rating; -import io.entgra.device.mgt.core.application.mgt.common.ReviewNode; import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.application.mgt.common.Rating; +import io.entgra.device.mgt.core.application.mgt.common.ReviewNode; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ReviewDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.ReviewManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; +import io.entgra.device.mgt.core.application.mgt.common.exception.ReviewManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.TransactionManagementException; import io.entgra.device.mgt.core.application.mgt.common.response.Review; -import io.entgra.device.mgt.core.application.mgt.common.services.*; +import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; import io.entgra.device.mgt.core.application.mgt.common.wrapper.ReviewWrapper; import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.ReviewDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.common.ApplicationManagementDAOFactory; -import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; -import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.exception.ReviewManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.exception.*; import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil; import io.entgra.device.mgt.core.application.mgt.core.util.Constants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.util.ArrayList; import java.util.Comparator; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SPApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SPApplicationManagerImpl.java index f28b46daca..9799c0a6ba 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SPApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SPApplicationManagerImpl.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import io.entgra.device.mgt.core.application.mgt.common.IdentityServerResponse; -import io.entgra.device.mgt.core.application.mgt.common.SPApplicationListResponse; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.SPApplication; +import io.entgra.device.mgt.core.application.mgt.common.SPApplicationListResponse; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServiceProviderDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; @@ -38,18 +38,17 @@ import io.entgra.device.mgt.core.application.mgt.core.dao.common.ApplicationMana import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.core.serviceprovider.ISServiceProviderApplicationService; import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; +import io.entgra.device.mgt.core.application.mgt.core.serviceprovider.ISServiceProviderApplicationService; import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil; import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil; +import io.entgra.device.mgt.core.device.mgt.core.common.util.HttpUtil; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.commons.validator.routines.UrlValidator; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.core.common.util.HttpUtil; import java.util.ArrayList; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index c6b697fd45..55f0abc80c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -18,54 +18,26 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import com.google.gson.Gson; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpMethodBase; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.StringRequestEntity; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONArray; -import org.json.JSONObject; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationSubscriptionInfo; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationType; -import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData; -import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; -import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; -import io.entgra.device.mgt.core.application.mgt.common.SubAction; -import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; -import io.entgra.device.mgt.core.application.mgt.common.SubscribingDeviceIdHolder; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationPolicyDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; -import io.entgra.device.mgt.core.application.mgt.common.exception.LifecycleManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.TransactionManagementException; +import io.entgra.device.mgt.core.application.mgt.common.*; +import io.entgra.device.mgt.core.application.mgt.common.dto.*; +import io.entgra.device.mgt.core.application.mgt.common.exception.*; import io.entgra.device.mgt.core.application.mgt.common.response.Application; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.common.ApplicationManagementDAOFactory; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException; import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; -import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil; -import io.entgra.device.mgt.core.application.mgt.core.util.Constants; -import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; -import io.entgra.device.mgt.core.application.mgt.core.util.OAuthUtils; +import io.entgra.device.mgt.core.application.mgt.core.util.*; +import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.MobileAppTypes; @@ -85,6 +57,17 @@ import io.entgra.device.mgt.core.device.mgt.core.util.MDMAndroidOperationUtil; import io.entgra.device.mgt.core.device.mgt.core.util.MDMIOSOperationUtil; import io.entgra.device.mgt.core.device.mgt.core.util.MDMWindowsOperationUtil; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpMethodBase; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.StringRequestEntity; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; +import org.json.JSONObject; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.core.MediaType; @@ -95,14 +78,7 @@ import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java index ad3c01865b..5f92fe48ac 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java @@ -17,65 +17,38 @@ */ package io.entgra.device.mgt.core.application.mgt.core.internal; -import io.entgra.device.mgt.core.application.mgt.common.services.SPApplicationManager; -import io.entgra.device.mgt.core.application.mgt.core.impl.AppmDataHandlerImpl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationStorageManager; -import io.entgra.device.mgt.core.application.mgt.common.services.AppmDataHandler; -import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; -import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; +import io.entgra.device.mgt.core.application.mgt.common.services.*; import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; import io.entgra.device.mgt.core.application.mgt.core.dao.common.ApplicationManagementDAOFactory; +import io.entgra.device.mgt.core.application.mgt.core.impl.AppmDataHandlerImpl; import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; import io.entgra.device.mgt.core.application.mgt.core.task.ScheduledAppSubscriptionTaskManager; import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +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.osgi.service.component.annotations.*; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.user.core.service.RealmService; import java.util.List; -/** - * @scr.component name="org.wso2.carbon.application.mgt.service" immediate="true" - * @scr.reference name="org.wso2.carbon.device.manager" - * interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceManagementService" - * unbind="unsetDeviceManagementService" - * @scr.reference name="realm.service" - * immediate="true" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="datasource.service" - * interface="org.wso2.carbon.ndatasource.core.DataSourceService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDataSourceService" - * unbind="unsetDataSourceService" - * @scr.reference name="app.mgt.ntask.component" - * interface="org.wso2.carbon.ntask.core.service.TaskService" - * cardinality="1..1" - * policy="dynamic" - * bind="setTaskService" - * unbind="unsetTaskService" - */ + @SuppressWarnings("unused") +@Component( + name = "io.entgra.device.mgt.core.application.mgt.core.internal.ApplicationManagementServiceComponent", + immediate = true) public class ApplicationManagementServiceComponent { private static Log log = LogFactory.getLog(ApplicationManagementServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { BundleContext bundleContext = componentContext.getBundleContext(); try { @@ -117,7 +90,7 @@ public class ApplicationManagementServiceComponent { bundleContext.registerService(AppmDataHandler.class.getName(), configManager, null); ScheduledAppSubscriptionTaskManager taskManager = new ScheduledAppSubscriptionTaskManager(); - taskManager.scheduleCleanupTask(); + // todo: taskManager.scheduleCleanupTask(); log.info("ApplicationManagement core bundle has been successfully initialized"); } catch (Throwable e) { @@ -126,11 +99,18 @@ public class ApplicationManagementServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } @SuppressWarnings("unused") + @Reference( + name = "device.mgt.provider.service", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceManagementService") protected void setDeviceManagementService(DeviceManagementProviderService deviceManagementProviderService) { if (log.isDebugEnabled()) { log.debug("Setting ApplicationDTO Management OSGI Manager"); @@ -147,6 +127,12 @@ public class ApplicationManagementServiceComponent { } @SuppressWarnings("unused") + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { DataHolder.getInstance().setRealmService(realmService); } @@ -157,6 +143,12 @@ public class ApplicationManagementServiceComponent { } @SuppressWarnings("unused") + @Reference( + name = "datasource.service", + service = org.wso2.carbon.ndatasource.core.DataSourceService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDataSourceService") protected void setDataSourceService(DataSourceService dataSourceService) { /*Not implemented. Not needed but to make sure the datasource service are registered, as it is needed create databases. */ @@ -169,6 +161,12 @@ public class ApplicationManagementServiceComponent { } @SuppressWarnings("unused") + @Reference( + name = "task.service", + service = org.wso2.carbon.ntask.core.service.TaskService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTaskService") public void setTaskService(TaskService taskService) { if (log.isDebugEnabled()) { log.debug("Setting the task service to Application Management SC."); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java index 262a73984b..7866f73939 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java @@ -17,12 +17,7 @@ */ package io.entgra.device.mgt.core.application.mgt.core.internal; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationStorageManager; -import io.entgra.device.mgt.core.application.mgt.common.services.AppmDataHandler; -import io.entgra.device.mgt.core.application.mgt.common.services.SPApplicationManager; -import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; -import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; +import io.entgra.device.mgt.core.application.mgt.common.services.*; import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.ntask.core.service.TaskService; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/lifecycle/LifecycleStateManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/lifecycle/LifecycleStateManager.java index 58d11fd24c..e7a399144c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/lifecycle/LifecycleStateManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/lifecycle/LifecycleStateManager.java @@ -17,14 +17,14 @@ package io.entgra.device.mgt.core.application.mgt.core.lifecycle; -import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.exception.LifecycleManagementException; import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; +import io.entgra.device.mgt.core.application.mgt.common.exception.LifecycleManagementException; +import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.Constants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/serviceprovider/impl/WSO2IAMSPApplicationService.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/serviceprovider/impl/WSO2IAMSPApplicationService.java index 2144568173..9cef40ba65 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/serviceprovider/impl/WSO2IAMSPApplicationService.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/serviceprovider/impl/WSO2IAMSPApplicationService.java @@ -25,6 +25,7 @@ import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationMan import io.entgra.device.mgt.core.application.mgt.common.exception.IdentityServerManagementException; import io.entgra.device.mgt.core.application.mgt.core.serviceprovider.ISServiceProviderApplicationService; import io.entgra.device.mgt.core.application.mgt.core.util.Constants; +import io.entgra.device.mgt.core.device.mgt.core.common.util.HttpUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; @@ -34,7 +35,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import io.entgra.device.mgt.core.device.mgt.core.common.util.HttpUtil; + import javax.ws.rs.core.HttpHeaders; import java.io.IOException; import java.util.Collections; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionCleanupTask.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionCleanupTask.java index 612bb1e05b..139e2af2c0 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionCleanupTask.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionCleanupTask.java @@ -18,12 +18,12 @@ package io.entgra.device.mgt.core.application.mgt.core.task; -import io.entgra.device.mgt.core.application.mgt.core.impl.SubscriptionManagerImpl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; +import io.entgra.device.mgt.core.application.mgt.core.impl.SubscriptionManagerImpl; import io.entgra.device.mgt.core.device.mgt.core.task.impl.RandomlyAssignedScheduleTask; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.Map; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTask.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTask.java index 4e295cbe9a..5ddd080549 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTask.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTask.java @@ -20,20 +20,20 @@ package io.entgra.device.mgt.core.application.mgt.core.task; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import io.entgra.device.mgt.core.application.mgt.core.impl.SubscriptionManagerImpl; -import io.entgra.device.mgt.core.application.mgt.core.util.Constants; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; +import io.entgra.device.mgt.core.application.mgt.core.impl.SubscriptionManagerImpl; +import io.entgra.device.mgt.core.application.mgt.core.util.Constants; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.core.task.impl.RandomlyAssignedScheduleTask; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.util.List; import java.util.Map; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java index 70f77259a4..e52357b4e2 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java @@ -19,6 +19,12 @@ package io.entgra.device.mgt.core.application.mgt.core.task; import com.google.gson.Gson; +import io.entgra.device.mgt.core.application.mgt.common.SubAction; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; +import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; +import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; +import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationOperationTaskException; import io.entgra.device.mgt.core.application.mgt.core.impl.SubscriptionManagerImpl; import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.application.mgt.core.util.Constants; @@ -27,24 +33,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.quartz.CronExpression; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.application.mgt.common.SubAction; -import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; -import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; -import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; -import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; -import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationOperationTaskException; import org.wso2.carbon.ntask.common.TaskException; import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskManager; import org.wso2.carbon.ntask.core.service.TaskService; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; +import java.util.*; import java.util.stream.Collectors; public class ScheduledAppSubscriptionTaskManager { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java index a04699796a..bb95599934 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java @@ -18,40 +18,33 @@ package io.entgra.device.mgt.core.application.mgt.core.util; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationType; +import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; import io.entgra.device.mgt.core.application.mgt.common.IdentityServerResponse; +import io.entgra.device.mgt.core.application.mgt.common.config.MDMConfig; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServiceProviderDTO; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.InvalidConfigurationException; +import io.entgra.device.mgt.core.application.mgt.common.response.Application; +import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRelease; +import io.entgra.device.mgt.core.application.mgt.common.services.*; +import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; +import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; import io.entgra.device.mgt.core.application.mgt.core.config.IdentityServiceProvider; -import io.entgra.device.mgt.core.application.mgt.core.serviceprovider.ISServiceProviderApplicationService; import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; +import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; +import io.entgra.device.mgt.core.application.mgt.core.serviceprovider.ISServiceProviderApplicationService; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.validator.routines.UrlValidator; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationType; -import io.entgra.device.mgt.core.application.mgt.common.config.MDMConfig; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.response.Application; -import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRelease; -import io.entgra.device.mgt.core.application.mgt.common.services.*; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.EntAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppWrapper; -import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; -import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import javax.ws.rs.core.Response; import java.util.ArrayList; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java index 891b589c50..cb958904ba 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java @@ -18,40 +18,25 @@ package io.entgra.device.mgt.core.application.mgt.core.util; import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact; -import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; -import io.entgra.device.mgt.core.application.mgt.core.config.Extension; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.common.Base64File; import io.entgra.device.mgt.core.application.mgt.common.FileDataHolder; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; +import io.entgra.device.mgt.core.application.mgt.common.exception.InvalidConfigurationException; import io.entgra.device.mgt.core.application.mgt.common.exception.RequestValidatingException; -import io.entgra.device.mgt.core.application.mgt.common.services.SPApplicationManager; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.EntAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppWrapper; +import io.entgra.device.mgt.core.application.mgt.common.services.*; +import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; +import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; +import io.entgra.device.mgt.core.application.mgt.core.config.Extension; +import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; +import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; +import io.entgra.device.mgt.core.device.mgt.common.Base64File; +import io.entgra.device.mgt.core.device.mgt.core.common.util.FileUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.exception.InvalidConfigurationException; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationStorageManager; -import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; -import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; -import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; -import io.entgra.device.mgt.core.device.mgt.core.common.util.FileUtil; import java.io.InputStream; import java.lang.reflect.Constructor; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; /** * This DAOUtil class is responsible for making sure single instance of each Extension Manager is used throughout for diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationMgtDatabaseCreator.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationMgtDatabaseCreator.java index 9d7f32cf2b..611f75921e 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationMgtDatabaseCreator.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationMgtDatabaseCreator.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.dbcreator.DatabaseCreator; + import java.io.File; /** diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ArtifactsParser.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ArtifactsParser.java index 2832db1f15..d87c09ddec 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ArtifactsParser.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ArtifactsParser.java @@ -22,20 +22,14 @@ import com.dd.plist.BinaryPropertyListParser; import com.dd.plist.NSDictionary; import com.dd.plist.PropertyListFormatException; import com.dd.plist.PropertyListParser; +import io.entgra.device.mgt.core.application.mgt.core.exception.ParsingException; import net.dongliu.apk.parser.ApkFile; import net.dongliu.apk.parser.bean.ApkMeta; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.commons.io.IOUtils; -import io.entgra.device.mgt.core.application.mgt.core.exception.ParsingException; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.nio.file.Files; import java.util.UUID; import java.util.zip.ZipEntry; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ConnectionManagerUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ConnectionManagerUtil.java index 45aaca8725..3ae696038d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ConnectionManagerUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ConnectionManagerUtil.java @@ -17,16 +17,16 @@ */ package io.entgra.device.mgt.core.application.mgt.core.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.common.exception.IllegalTransactionStateException; import io.entgra.device.mgt.core.application.mgt.common.exception.TransactionManagementException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.sql.Connection; -import java.sql.SQLException; import javax.naming.InitialContext; import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.SQLException; /** * ConnectionManagerUtil is responsible for handling all the datasource connections utilities. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java index 7e7b3e28be..a1aea929cb 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java @@ -19,20 +19,14 @@ package io.entgra.device.mgt.core.application.mgt.core.util; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; +import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; +import io.entgra.device.mgt.core.application.mgt.common.dto.*; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONException; -import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; -import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; - -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.ReviewDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/HelperUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/HelperUtil.java index 2a9d29bec0..429fc0bc96 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/HelperUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/HelperUtil.java @@ -17,11 +17,11 @@ */ package io.entgra.device.mgt.core.application.mgt.core.util; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; /** * Utility methods used in the Application Management. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java index c7464bea43..24ba3d4b7f 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java @@ -18,17 +18,17 @@ package io.entgra.device.mgt.core.application.mgt.core.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.application.mgt.common.dto.ApiRegistrationProfile; import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/ArtifactParserTest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/ArtifactParserTest.java index a0527b3c13..4e1d388f2a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/ArtifactParserTest.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/ArtifactParserTest.java @@ -19,11 +19,11 @@ package io.entgra.device.mgt.core.application.mgt.core; import com.dd.plist.NSDictionary; +import io.entgra.device.mgt.core.application.mgt.core.exception.ParsingException; +import io.entgra.device.mgt.core.application.mgt.core.util.ArtifactsParser; import net.dongliu.apk.parser.bean.ApkMeta; import org.testng.Assert; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.application.mgt.core.exception.ParsingException; -import io.entgra.device.mgt.core.application.mgt.core.util.ArtifactsParser; import java.io.FileInputStream; import java.io.FileNotFoundException; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/BaseTestCase.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/BaseTestCase.java index ed2db17930..0e7c99a2c1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/BaseTestCase.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/BaseTestCase.java @@ -17,13 +17,6 @@ */ package io.entgra.device.mgt.core.application.mgt.core; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.tomcat.jdbc.pool.PoolProperties; -import org.testng.annotations.BeforeSuite; -import org.w3c.dom.Document; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.core.common.DataSourceConfig; @@ -37,6 +30,13 @@ import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManag import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tomcat.jdbc.pool.PoolProperties; +import org.testng.annotations.BeforeSuite; +import org.w3c.dom.Document; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/ConfigurationTest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/ConfigurationTest.java index 6462e498b9..bae0481c56 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/ConfigurationTest.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/ConfigurationTest.java @@ -17,11 +17,11 @@ */ package io.entgra.device.mgt.core.application.mgt.core; -import org.junit.Assert; -import org.testng.annotations.Test; +import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; import io.entgra.device.mgt.core.application.mgt.core.config.Configuration; import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; -import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; +import org.junit.Assert; +import org.testng.annotations.Test; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/InitTest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/InitTest.java index 1e3b9005b6..71a01475ba 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/InitTest.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/InitTest.java @@ -17,9 +17,9 @@ */ package io.entgra.device.mgt.core.application.mgt.core; -import org.testng.annotations.BeforeSuite; import io.entgra.device.mgt.core.application.mgt.common.exception.InvalidConfigurationException; import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; +import org.testng.annotations.BeforeSuite; import java.io.File; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/LifeCycleStateManagerTest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/LifeCycleStateManagerTest.java index a16cd9f3fa..8b08a39b82 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/LifeCycleStateManagerTest.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/LifeCycleStateManagerTest.java @@ -17,8 +17,8 @@ */ package io.entgra.device.mgt.core.application.mgt.core; -import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; +import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; import java.util.HashMap; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/LifecycleManagementTest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/LifecycleManagementTest.java index a867c3f3ca..42759a1af5 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/LifecycleManagementTest.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/LifecycleManagementTest.java @@ -17,14 +17,14 @@ */ package io.entgra.device.mgt.core.application.mgt.core; -import org.junit.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; import io.entgra.device.mgt.core.application.mgt.common.exception.LifecycleManagementException; import io.entgra.device.mgt.core.application.mgt.core.config.Configuration; import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; -import io.entgra.device.mgt.core.application.mgt.common.config.LifecycleState; +import org.junit.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/StorageManagementUtilTest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/StorageManagementUtilTest.java index 9d6b084a2e..4c3a6e1e3d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/StorageManagementUtilTest.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/StorageManagementUtilTest.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.application.mgt.core; +import io.entgra.device.mgt.core.application.mgt.common.exception.ResourceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagementException; +import io.entgra.device.mgt.core.device.mgt.core.common.util.StorageManagementUtil; import org.junit.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.application.mgt.common.exception.ResourceManagementException; -import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagementException; -import io.entgra.device.mgt.core.device.mgt.core.common.util.StorageManagementUtil; import java.io.File; import java.io.FileInputStream; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationManagementDAOTest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationManagementDAOTest.java index 49b24f9509..022712963e 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationManagementDAOTest.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationManagementDAOTest.java @@ -17,11 +17,6 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao; -import junit.framework.Assert; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.application.mgt.core.BaseTestCase; import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; import io.entgra.device.mgt.core.application.mgt.core.dao.common.ApplicationManagementDAOFactory; @@ -32,6 +27,11 @@ import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagem import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceTypeDAO; +import junit.framework.Assert; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; public class ApplicationManagementDAOTest extends BaseTestCase { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/management/ApplicationManagementTest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/management/ApplicationManagementTest.java index 34ee305795..39086cc4ee 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/management/ApplicationManagementTest.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/management/ApplicationManagementTest.java @@ -21,11 +21,6 @@ import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact; import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; import io.entgra.device.mgt.core.application.mgt.common.Filter; import io.entgra.device.mgt.core.application.mgt.common.LifecycleState; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.RequestValidatingException; @@ -34,9 +29,9 @@ import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRele import io.entgra.device.mgt.core.application.mgt.common.response.Category; import io.entgra.device.mgt.core.application.mgt.common.response.Tag; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.EntAppReleaseWrapper; import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationUpdateWrapper; import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationWrapper; +import io.entgra.device.mgt.core.application.mgt.common.wrapper.EntAppReleaseWrapper; import io.entgra.device.mgt.core.application.mgt.core.BaseTestCase; import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.common.ApplicationManagementDAOFactory; @@ -44,12 +39,17 @@ import io.entgra.device.mgt.core.application.mgt.core.dto.ApplicationsDTO; import io.entgra.device.mgt.core.application.mgt.core.impl.ApplicationManagerImpl; import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.Base64File; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.common.util.FileUtil; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeVersion; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; import java.io.File; import java.util.ArrayList; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml index 897e33581c..2337c777e2 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml @@ -1,4 +1,4 @@ - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml index 0a9289da70..4f5e043a15 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml @@ -1,4 +1,4 @@ - + org.json.wso2 diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/ApplicationManagementPublisherAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/ApplicationManagementPublisherAPI.java index cbb23f3e48..0f55b5b8a9 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/ApplicationManagementPublisherAPI.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/ApplicationManagementPublisherAPI.java @@ -17,17 +17,6 @@ */ package io.entgra.device.mgt.core.application.mgt.publisher.api; -import io.entgra.device.mgt.core.device.mgt.common.Base64File; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; @@ -37,29 +26,15 @@ import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRelease; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.EntAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationUpdateWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppWrapper; +import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; +import io.entgra.device.mgt.core.device.mgt.common.Base64File; +import io.swagger.annotations.*; -import java.util.List; import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.util.List; /** * APIs to handle application management related tasks. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/SPApplicationService.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/SPApplicationService.java index 23dace1a1a..a68a8ac0d3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/SPApplicationService.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/SPApplicationService.java @@ -17,30 +17,16 @@ package io.entgra.device.mgt.core.application.mgt.publisher.api; +import io.entgra.device.mgt.core.apimgt.annotations.Scope; +import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationWrapper; import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppWrapper; import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppWrapper; import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppWrapper; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; +import io.swagger.annotations.*; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ApplicationManagementPublisherAdminAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ApplicationManagementPublisherAdminAPI.java index 4a79689e70..f48cee20e3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ApplicationManagementPublisherAdminAPI.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ApplicationManagementPublisherAdminAPI.java @@ -17,29 +17,13 @@ */ package io.entgra.device.mgt.core.application.mgt.publisher.api.admin; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; +import io.swagger.annotations.*; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ReviewManagementPublisherAdminAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ReviewManagementPublisherAdminAPI.java index eb2cfc4ba7..fb35ea6893 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ReviewManagementPublisherAdminAPI.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/admin/ReviewManagementPublisherAdminAPI.java @@ -16,26 +16,13 @@ */ package io.entgra.device.mgt.core.application.mgt.publisher.api.admin; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; +import io.swagger.annotations.*; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/ApplicationManagementPublisherAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/ApplicationManagementPublisherAPIImpl.java index adf902a8eb..1e83e29ddb 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/ApplicationManagementPublisherAPIImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/ApplicationManagementPublisherAPIImpl.java @@ -16,54 +16,34 @@ */ package io.entgra.device.mgt.core.application.mgt.publisher.api.impl; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; -import io.entgra.device.mgt.core.device.mgt.common.Base64File; -import io.entgra.device.mgt.core.application.mgt.common.Filter; -import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger; -import io.entgra.device.mgt.core.application.mgt.common.exception.ResourceManagementException; -import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.LifecycleState; +import io.entgra.device.mgt.core.application.mgt.common.*; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.LifecycleManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.RequestValidatingException; +import io.entgra.device.mgt.core.application.mgt.common.exception.ResourceManagementException; import io.entgra.device.mgt.core.application.mgt.common.response.Application; import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRelease; import io.entgra.device.mgt.core.application.mgt.common.response.Category; import io.entgra.device.mgt.core.application.mgt.common.response.Tag; +import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.AppmDataHandler; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.CustomAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.EntAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationUpdateWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.ApplicationWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppReleaseWrapper; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppWrapper; +import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException; +import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil; import io.entgra.device.mgt.core.application.mgt.publisher.api.ApplicationManagementPublisherAPI; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; +import io.entgra.device.mgt.core.device.mgt.common.Base64File; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.util.List; import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.util.List; /** * Implementation of Application Management related APIs. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/SPApplicationServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/SPApplicationServiceImpl.java index f75efac78b..371613fd24 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/SPApplicationServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/SPApplicationServiceImpl.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.application.mgt.publisher.api.impl; import io.entgra.device.mgt.core.application.mgt.common.IdentityServerResponse; -import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.SPApplicationListResponse; +import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServerDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.IdentityServiceProviderDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.RequestValidatingException; @@ -36,15 +36,7 @@ import io.entgra.device.mgt.core.application.mgt.publisher.api.SPApplicationServ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ApplicationManagementPublisherAdminAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ApplicationManagementPublisherAdminAPIImpl.java index dd3b9e7d81..130f85f901 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ApplicationManagementPublisherAdminAPIImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ApplicationManagementPublisherAdminAPIImpl.java @@ -17,8 +17,6 @@ */ package io.entgra.device.mgt.core.application.mgt.publisher.api.impl.admin; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; @@ -26,15 +24,10 @@ import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenExcepti import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; import io.entgra.device.mgt.core.application.mgt.publisher.api.admin.ApplicationManagementPublisherAdminAPI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ReviewManagementPublisherAdminAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ReviewManagementPublisherAdminAPIImpl.java index 8b980ef729..131297cf54 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ReviewManagementPublisherAdminAPIImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.publisher.api/src/main/java/io/entgra/device/mgt/core/application/mgt/publisher/api/impl/admin/ReviewManagementPublisherAdminAPIImpl.java @@ -16,8 +16,6 @@ */ package io.entgra.device.mgt.core.application.mgt.publisher.api.impl.admin; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; import io.entgra.device.mgt.core.application.mgt.common.Rating; @@ -27,12 +25,10 @@ import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; import io.entgra.device.mgt.core.application.mgt.publisher.api.admin.ReviewManagementPublisherAdminAPI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Response; /** diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml index f1ca183fb5..9e9184d2ab 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/pom.xml @@ -140,7 +140,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.json.wso2 diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ApplicationManagementAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ApplicationManagementAPI.java index 9adbb4b252..7e1805cb5a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ApplicationManagementAPI.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ApplicationManagementAPI.java @@ -16,32 +16,16 @@ */ package io.entgra.device.mgt.core.application.mgt.store.api.services; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; import io.entgra.device.mgt.core.application.mgt.common.Filter; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; +import io.swagger.annotations.*; import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPI.java index e59b082ca7..0f6ae56ec9 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPI.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPI.java @@ -17,33 +17,16 @@ */ package io.entgra.device.mgt.core.application.mgt.store.api.services; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.Api; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Tag; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; +import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; import io.entgra.device.mgt.core.application.mgt.common.response.Review; import io.entgra.device.mgt.core.application.mgt.common.wrapper.ReviewWrapper; +import io.swagger.annotations.*; import javax.validation.Valid; -import javax.ws.rs.Path; -import javax.ws.rs.Consumes; -import javax.ws.rs.PUT; -import javax.ws.rs.GET; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.Produces; -import javax.ws.rs.POST; -import javax.ws.rs.DELETE; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/SubscriptionManagementAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/SubscriptionManagementAPI.java index cc61aca38a..099c614446 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/SubscriptionManagementAPI.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/SubscriptionManagementAPI.java @@ -17,30 +17,15 @@ */ package io.entgra.device.mgt.core.application.mgt.store.api.services; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.swagger.annotations.*; import javax.validation.Valid; import javax.validation.constraints.Size; -import javax.ws.rs.Path; -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.PathParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/ReviewManagementStoreAdminAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/ReviewManagementStoreAdminAPI.java index 43e29659b3..a010761fe8 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/ReviewManagementStoreAdminAPI.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/ReviewManagementStoreAdminAPI.java @@ -16,25 +16,12 @@ */ package io.entgra.device.mgt.core.application.mgt.store.api.services.admin; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; +import io.swagger.annotations.*; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java index 8c1fe119e2..cff98b7ef1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/admin/SubscriptionManagementAdminAPI.java @@ -17,29 +17,14 @@ */ package io.entgra.device.mgt.core.application.mgt.store.api.services.admin; -import io.entgra.device.mgt.core.application.mgt.store.api.beans.SubscriptionStatusBean; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; +import io.entgra.device.mgt.core.application.mgt.store.api.beans.SubscriptionStatusBean; +import io.swagger.annotations.*; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java index be7a6db2a0..93883ca22b 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ApplicationManagementAPIImpl.java @@ -16,8 +16,6 @@ */ package io.entgra.device.mgt.core.application.mgt.store.api.services.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.ApplicationList; import io.entgra.device.mgt.core.application.mgt.common.Filter; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; @@ -28,14 +26,11 @@ import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundExceptio import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; import io.entgra.device.mgt.core.application.mgt.store.api.services.ApplicationManagementAPI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java index ffbe19fca7..589a362f3a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java @@ -17,32 +17,24 @@ */ package io.entgra.device.mgt.core.application.mgt.store.api.services.impl; -import io.swagger.annotations.ApiParam; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.application.mgt.common.PaginationResult; import io.entgra.device.mgt.core.application.mgt.common.Rating; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; +import io.entgra.device.mgt.core.application.mgt.common.exception.ReviewManagementException; import io.entgra.device.mgt.core.application.mgt.common.response.Review; import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; import io.entgra.device.mgt.core.application.mgt.common.wrapper.ReviewWrapper; import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException; import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; -import io.entgra.device.mgt.core.application.mgt.store.api.services.ReviewManagementAPI; -import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.common.exception.ReviewManagementException; import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; +import io.entgra.device.mgt.core.application.mgt.store.api.services.ReviewManagementAPI; +import io.swagger.annotations.ApiParam; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.Path; -import javax.ws.rs.Consumes; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.PUT; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.DELETE; +import javax.ws.rs.*; import javax.ws.rs.core.Response; /** diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java index f79c108ef5..7abf085ee6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/SubscriptionManagementAPIImpl.java @@ -18,43 +18,26 @@ package io.entgra.device.mgt.core.application.mgt.store.api.services.impl; -import io.entgra.device.mgt.core.application.mgt.store.api.services.impl.util.RequestValidationUtil; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse; -import io.entgra.device.mgt.core.application.mgt.common.ErrorResponse; -import io.entgra.device.mgt.core.application.mgt.common.SubAction; -import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; +import io.entgra.device.mgt.core.application.mgt.common.*; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationOperationTaskException; -import io.entgra.device.mgt.core.application.mgt.common.DeviceList; -import io.entgra.device.mgt.core.application.mgt.common.BasicUserInfo; -import io.entgra.device.mgt.core.application.mgt.common.BasicUserInfoList; -import io.entgra.device.mgt.core.application.mgt.common.RoleList; -import io.entgra.device.mgt.core.application.mgt.common.DeviceGroupList; import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; import io.entgra.device.mgt.core.application.mgt.core.exception.ForbiddenException; import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; import io.entgra.device.mgt.core.application.mgt.core.task.ScheduledAppSubscriptionTaskManager; import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; import io.entgra.device.mgt.core.application.mgt.store.api.services.SubscriptionManagementAPI; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants; +import io.entgra.device.mgt.core.application.mgt.store.api.services.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.*; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.validation.Valid; -import javax.ws.rs.Path; -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.PathParam; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.util.List; import java.util.Properties; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/ReviewManagementStoreAdminAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/ReviewManagementStoreAdminAPIImpl.java index e2ef8b8252..e5f7a7e827 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/ReviewManagementStoreAdminAPIImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/ReviewManagementStoreAdminAPIImpl.java @@ -16,20 +16,16 @@ */ package io.entgra.device.mgt.core.application.mgt.store.api.services.impl.admin; -import io.entgra.device.mgt.core.application.mgt.store.api.services.admin.ReviewManagementStoreAdminAPI; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.ReviewManagementException; import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; +import io.entgra.device.mgt.core.application.mgt.store.api.services.admin.ReviewManagementStoreAdminAPI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java index d8ded9f3b1..e3c77febd9 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/admin/SubscriptionManagementAdminAPIImpl.java @@ -18,29 +18,22 @@ package io.entgra.device.mgt.core.application.mgt.store.api.services.impl.admin; -import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; -import io.entgra.device.mgt.core.application.mgt.store.api.beans.SubscriptionStatusBean; -import io.entgra.device.mgt.core.application.mgt.store.api.services.admin.SubscriptionManagementAdminAPI; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; +import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; +import io.entgra.device.mgt.core.application.mgt.store.api.beans.SubscriptionStatusBean; +import io.entgra.device.mgt.core.application.mgt.store.api.services.admin.SubscriptionManagementAdminAPI; import io.entgra.device.mgt.core.application.mgt.store.api.services.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/util/RequestValidationUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/util/RequestValidationUtil.java index 1168a1113d..b6453fe42b 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/util/RequestValidationUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/main/java/io/entgra/device/mgt/core/application/mgt/store/api/services/impl/util/RequestValidationUtil.java @@ -18,13 +18,13 @@ */ package io.entgra.device.mgt.core.application.mgt.store.api.services.impl.util; +import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; +import io.entgra.device.mgt.core.application.mgt.store.api.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityStatus; import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.store.api.util.Constants; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityStatus; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPITest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPITest.java index ad640351e9..240288c8b6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPITest.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.store.api/src/test/java/io/entgra/device/mgt/core/application/mgt/store/api/services/ReviewManagementAPITest.java @@ -17,6 +17,8 @@ */ package io.entgra.device.mgt.core.application.mgt.store.api.services; +import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; +import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; import junit.framework.TestCase; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -24,8 +26,6 @@ import org.junit.Ignore; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; -import io.entgra.device.mgt.core.application.mgt.common.services.ReviewManager; -import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil; @PowerMockIgnore("javax.ws.rs.*") @SuppressStaticInitializationFor({ diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 4badfb0349..b4772ca5cc 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -31,7 +31,7 @@ pom WSO2 Carbon - Application Management Component WSO2 Carbon - Application Management Component - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.application.mgt.common @@ -50,22 +50,5 @@ ${maven.checkstyle.vesion} - - - - - - - - - - - - - - - - - diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index e95c4cf732..1113af91c4 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -31,7 +31,7 @@ war WSO2 Carbon - Certificate Management API WSO2 Carbon - Certificate Management API - http://wso2.org + https://entgra.io diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/api/impl/CertificateMgtServiceImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/api/impl/CertificateMgtServiceImpl.java index de82425d71..40e4590072 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/api/impl/CertificateMgtServiceImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/api/impl/CertificateMgtServiceImpl.java @@ -1,14 +1,14 @@ package io.entgra.device.mgt.core.certificate.mgt.api.impl; +import io.entgra.device.mgt.core.certificate.mgt.api.CertificateMgtService; +import io.entgra.device.mgt.core.certificate.mgt.api.beans.ErrorResponse; +import io.entgra.device.mgt.core.certificate.mgt.api.exception.Message; +import io.entgra.device.mgt.core.certificate.mgt.api.exception.UnexpectedServerErrorException; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; +import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; -import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; -import io.entgra.device.mgt.core.certificate.mgt.api.beans.ErrorResponse; -import io.entgra.device.mgt.core.certificate.mgt.api.exception.UnexpectedServerErrorException; -import io.entgra.device.mgt.core.certificate.mgt.api.CertificateMgtService; -import io.entgra.device.mgt.core.certificate.mgt.api.exception.Message; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index d55518babd..2315f7e46b 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -31,7 +31,7 @@ war WSO2 Carbon - Admin Certificate Management API WSO2 Carbon - Admin Certificate Management API - http://wso2.org + https://entgra.io @@ -162,7 +162,6 @@ org.ops4j.pax.logging pax-logging-api provided - io.entgra.device.mgt.core diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/beans/CertificateList.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/beans/CertificateList.java index e05d11315e..03bc08e977 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/beans/CertificateList.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/beans/CertificateList.java @@ -19,8 +19,8 @@ package io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.beans; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/impl/CertificateManagementAdminServiceImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/impl/CertificateManagementAdminServiceImpl.java index 9ef8e10e0d..58352def51 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/impl/CertificateManagementAdminServiceImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/impl/CertificateManagementAdminServiceImpl.java @@ -44,12 +44,15 @@ import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager; import io.entgra.device.mgt.core.certificate.mgt.core.scep.TenantedDeviceWrapper; import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService; import io.entgra.device.mgt.core.certificate.mgt.core.service.PaginationResult; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.security.cert.X509Certificate; import java.util.ArrayList; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/util/CertificateMgtAPIUtils.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/util/CertificateMgtAPIUtils.java index 823e9e992d..d5b2aca77c 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/util/CertificateMgtAPIUtils.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/util/CertificateMgtAPIUtils.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager; import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.SearchManagerService; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.ws.rs.core.MediaType; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/util/RequestValidationUtil.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/util/RequestValidationUtil.java index ac41a7720f..c04009468f 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/util/RequestValidationUtil.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/src/main/java/io/entgra/device/mgt/core/certificate/mgt/cert/admin/api/util/RequestValidationUtil.java @@ -18,8 +18,8 @@ */ package io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.util; -import io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.beans.ErrorResponse; import io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.InputValidationException; +import io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.beans.ErrorResponse; public class RequestValidationUtil { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 668fb6352a..e8946f9a37 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -47,13 +47,17 @@ bundle WSO2 Carbon - Certificate Management Core WSO2 Carbon - Certificate Management Core - http://wso2.org + https://entgra.io - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -70,49 +74,47 @@ io.entgra.device.mgt.core.certificate.mgt.core.util + io.entgra.device.mgt.core.certificate.mgt.core.*, + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config.cache;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.swagger.annotations;version="[1.6,2)", + javax.cache;version="[1.0,2)", + javax.naming, + javax.naming.ldap, + javax.security.auth.x500, + javax.sql, + javax.xml.bind;version="[0.0,1)", + javax.xml.bind.annotation;version="[0.0,1)", + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", + org.apache.commons.codec.binary;version="[1.4,2)", + org.apache.commons.collections.map;version="[3.2,4)", + org.apache.commons.logging;version="[1.2,2)", + org.bouncycastle.asn1;version="[1.70,2)", + org.bouncycastle.asn1.pkcs;version="[1.70,2)", + org.bouncycastle.asn1.x500;version="[1.70,2)", + org.bouncycastle.asn1.x500.style;version="[1.70,2)", + org.bouncycastle.asn1.x509;version="[1.70,2)", + org.bouncycastle.cert;version="[1.70,2)", + org.bouncycastle.cert.jcajce;version="[1.70,2)", + org.bouncycastle.cms;version="[1.70,2)", + org.bouncycastle.jce.provider;version="[1.70,2)", + org.bouncycastle.operator;version="[1.70,2)", + org.bouncycastle.operator.jcajce;version="[1.70,2)", + org.bouncycastle.pkcs;version="[1.70,2)", + org.bouncycastle.util;version="[1.70,2)", + org.jscep.message, + org.jscep.transaction, 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.collections.map, - javax.security.auth.x500, - javax.xml.*, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.bouncycastle.asn1, - org.bouncycastle.asn1.x500, - org.bouncycastle.asn1.x509, - org.bouncycastle.asn1.pkcs, - org.bouncycastle.cert; version="${bcprov.wso2.version.range}", - org.bouncycastle.cert.jcajce; version="${bcprov.wso2.version.range}", - org.bouncycastle.cms, - org.bouncycastle.jce.provider, - org.bouncycastle.operator, - org.bouncycastle.operator.jcajce, - org.bouncycastle.asn1.x500.style, - org.bouncycastle.pkcs, - org.wso2.carbon.user.core.tenant, - org.wso2.carbon.user.api, - org.wso2.carbon.user.core.service, - - org.bouncycastle.util, - org.jscep.message, - org.wso2.carbon.context, - org.jscep.transaction, - org.w3c.dom, - org.xml.sax, - javax.sql, - - javax.naming, - javax.xml.bind.annotation, - javax.xml.bind, - org.wso2.carbon.utils.*, - io.entgra.device.mgt.core.device.mgt.common.*, - io.swagger.annotations.*;resolution:=optional, - io.entgra.device.mgt.core.device.mgt.core.*, - org.wso2.carbon.registry.indexing.*, - javax.cache.*, - javax.naming.ldap - + org.w3c.dom,org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.user.core.tenant;version="[4.8,5)", + org.wso2.carbon.utils;version="[4.8,5)", + org.wso2.carbon.utils.dbcreator;version="[4.8,5)" !io.entgra.device.mgt.core.certificate.mgt.core.internal.*, @@ -140,18 +142,6 @@ jacoco-maven-plugin ${jacoco.maven.plugin.version} - - - - - - - - - - - - jacoco-initialize @@ -169,32 +159,23 @@ ${basedir}/target/coverage-reports/site - - - - - - + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.jacoco org.jacoco.agent ${jacoco.maven.plugin.version} runtime - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.equinox - org.eclipse.equinox.common - org.testng testng @@ -207,7 +188,6 @@ org.wso2.carbon org.wso2.carbon.securevault - test @@ -224,18 +204,19 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.orbit.org.bouncycastle bcprov-jdk15on + provided org.wso2.orbit.org.bouncycastle bcpkix-jdk15on + provided - org.wso2.orbit.com.google.code.jscep + io.entgra.com.google.code.jscep jscep @@ -253,10 +234,12 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.core + provided io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.common + provided io.swagger diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/cache/impl/CertificateCacheManagerImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/cache/impl/CertificateCacheManagerImpl.java index 6e10cd8855..c4b0b3dc7a 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/cache/impl/CertificateCacheManagerImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/cache/impl/CertificateCacheManagerImpl.java @@ -19,8 +19,8 @@ package io.entgra.device.mgt.core.certificate.mgt.core.cache.impl; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; import io.entgra.device.mgt.core.certificate.mgt.core.cache.CertificateCacheManager; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateManagementDAOFactory.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateManagementDAOFactory.java index 828ff45850..8d0b02f39b 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateManagementDAOFactory.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateManagementDAOFactory.java @@ -18,6 +18,8 @@ package io.entgra.device.mgt.core.certificate.mgt.core.dao; +import io.entgra.device.mgt.core.certificate.mgt.core.config.datasource.DataSourceConfig; +import io.entgra.device.mgt.core.certificate.mgt.core.config.datasource.JNDILookupDefinition; import io.entgra.device.mgt.core.certificate.mgt.core.dao.impl.GenericCertificateDAOImpl; import io.entgra.device.mgt.core.certificate.mgt.core.dao.impl.OracleCertificateDAOImpl; import io.entgra.device.mgt.core.certificate.mgt.core.dao.impl.PostgreSQLCertificateDAOImpl; @@ -28,8 +30,6 @@ import io.entgra.device.mgt.core.certificate.mgt.core.exception.UnsupportedDatab import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.certificate.mgt.core.config.datasource.DataSourceConfig; -import io.entgra.device.mgt.core.certificate.mgt.core.config.datasource.JNDILookupDefinition; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java index 2aeb3571f5..1295c4c9ab 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java @@ -19,15 +19,15 @@ package io.entgra.device.mgt.core.certificate.mgt.core.dao.impl; import io.entgra.device.mgt.core.certificate.mgt.core.bean.Certificate; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateDAO; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOException; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOUtil; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; +import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; import io.entgra.device.mgt.core.certificate.mgt.core.util.Serializer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.IOException; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java index 9e5a828df0..5a6008c4fc 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java @@ -18,14 +18,14 @@ package io.entgra.device.mgt.core.certificate.mgt.core.dao.impl; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOException; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOUtil; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; +import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; import io.entgra.device.mgt.core.certificate.mgt.core.service.PaginationResult; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java index a919c98fa8..f06cbfef9e 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java @@ -18,14 +18,14 @@ package io.entgra.device.mgt.core.certificate.mgt.core.dao.impl; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOException; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOUtil; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; +import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; import io.entgra.device.mgt.core.certificate.mgt.core.service.PaginationResult; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java index b2207301e2..aea26b5b22 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java @@ -18,14 +18,14 @@ package io.entgra.device.mgt.core.certificate.mgt.core.dao.impl; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOException; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOUtil; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; +import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; import io.entgra.device.mgt.core.certificate.mgt.core.service.PaginationResult; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java index 7ec250e3c3..54023bde9f 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java @@ -18,14 +18,14 @@ package io.entgra.device.mgt.core.certificate.mgt.core.dao.impl; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOException; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOUtil; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; +import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; import io.entgra.device.mgt.core.certificate.mgt.core.service.PaginationResult; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index d35f89569b..5fb6b44721 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -17,8 +17,17 @@ */ package io.entgra.device.mgt.core.certificate.mgt.core.impl; +import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateDAO; +import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOException; +import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.CAStatus; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.SCEPResponse; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.TransactionManagementException; import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; import io.entgra.device.mgt.core.certificate.mgt.core.util.CommonUtil; +import io.entgra.device.mgt.core.certificate.mgt.core.util.Serializer; import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -46,26 +55,10 @@ import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; import org.bouncycastle.pkcs.PKCS10CertificationRequest; import org.bouncycastle.util.Store; -import org.jscep.message.CertRep; -import org.jscep.message.MessageDecodingException; -import org.jscep.message.MessageEncodingException; -import org.jscep.message.PkcsPkiEnvelopeDecoder; -import org.jscep.message.PkcsPkiEnvelopeEncoder; -import org.jscep.message.PkiMessage; -import org.jscep.message.PkiMessageDecoder; -import org.jscep.message.PkiMessageEncoder; +import org.jscep.message.*; import org.jscep.transaction.FailInfo; import org.jscep.transaction.Nonce; import org.jscep.transaction.TransactionId; -import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateDAO; -import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOException; -import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CAStatus; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.SCEPResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.TransactionManagementException; -import io.entgra.device.mgt.core.certificate.mgt.core.util.Serializer; import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.naming.InvalidNameException; @@ -77,24 +70,9 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; -import java.security.InvalidKeyException; -import java.security.KeyFactory; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.SecureRandom; -import java.security.Security; -import java.security.SignatureException; +import java.security.*; import java.security.cert.Certificate; -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateExpiredException; -import java.security.cert.CertificateFactory; -import java.security.cert.CertificateNotYetValidException; -import java.security.cert.X509Certificate; +import java.security.cert.*; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; import java.util.*; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java index 986f91d78a..f8ea75ed84 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java @@ -17,8 +17,6 @@ */ package io.entgra.device.mgt.core.certificate.mgt.core.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.certificate.mgt.core.cache.CertificateCacheManager; import io.entgra.device.mgt.core.certificate.mgt.core.cache.impl.CertificateCacheManagerImpl; import io.entgra.device.mgt.core.certificate.mgt.core.config.CertificateConfigurationManager; @@ -30,12 +28,10 @@ import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; import io.entgra.device.mgt.core.certificate.mgt.core.exception.CertificateManagementException; import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; import io.entgra.device.mgt.core.certificate.mgt.core.util.Serializer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.security.*; import java.security.cert.Certificate; import java.security.cert.CertificateException; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/internal/CertificateManagementServiceComponent.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/internal/CertificateManagementServiceComponent.java index bec4ce5004..956f618fb1 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/internal/CertificateManagementServiceComponent.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/internal/CertificateManagementServiceComponent.java @@ -18,37 +18,33 @@ package io.entgra.device.mgt.core.certificate.mgt.core.internal; +import io.entgra.device.mgt.core.certificate.mgt.core.config.CertificateConfigurationManager; +import io.entgra.device.mgt.core.certificate.mgt.core.config.CertificateManagementConfig; +import io.entgra.device.mgt.core.certificate.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; import io.entgra.device.mgt.core.certificate.mgt.core.exception.CertificateManagementException; import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager; import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManagerImpl; +import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService; +import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementServiceImpl; import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateMgtSchemaInitializer; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import io.entgra.device.mgt.core.certificate.mgt.core.config.CertificateConfigurationManager; -import io.entgra.device.mgt.core.certificate.mgt.core.config.CertificateManagementConfig; -import io.entgra.device.mgt.core.certificate.mgt.core.config.datasource.DataSourceConfig; -import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService; -import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementServiceImpl; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.osgi.service.component.annotations.*; -/** - * @scr.component name="org.wso2.carbon.certificate.mgt" immediate="true" - * @scr.reference name="org.wso2.carbon.device.manager" - * interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceManagementService" - * unbind="unsetDeviceManagementService" - */ +@Component( + name = "io.entgra.device.mgt.core.certificate.mgt.core.internal.CertificateManagementServiceComponent", + immediate = true) public class CertificateManagementServiceComponent { private static Log log = LogFactory.getLog(CertificateManagementServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -86,10 +82,17 @@ public class CertificateManagementServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } + @Reference( + name = "device.mgt.provider.service", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceManagementService") protected void setDeviceManagementService(DeviceManagementProviderService deviceManagerService) { if (log.isDebugEnabled()) { log.debug("Setting Device Management Service"); diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/scep/SCEPManagerImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/scep/SCEPManagerImpl.java index da51bb05d4..7b3effd558 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/scep/SCEPManagerImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/scep/SCEPManagerImpl.java @@ -35,15 +35,15 @@ package io.entgra.device.mgt.core.certificate.mgt.core.scep; -import org.apache.commons.collections.map.SingletonMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.certificate.mgt.core.internal.CertificateManagementDataHolder; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.collections.map.SingletonMap; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagerUtil.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagerUtil.java index 343e0750d4..07a5646851 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagerUtil.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagerUtil.java @@ -19,15 +19,15 @@ package io.entgra.device.mgt.core.certificate.mgt.core.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.certificate.mgt.core.config.CertificateConfigurationManager; import io.entgra.device.mgt.core.certificate.mgt.core.config.CertificateManagementConfig; import io.entgra.device.mgt.core.certificate.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.certificate.mgt.core.config.datasource.JNDILookupDefinition; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOUtil; import io.entgra.device.mgt.core.certificate.mgt.core.exception.CertificateManagementException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Document; import javax.sql.DataSource; import javax.xml.XMLConstants; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateMgtSchemaInitializer.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateMgtSchemaInitializer.java index 4647c3f2c9..283d6714bb 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateMgtSchemaInitializer.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateMgtSchemaInitializer.java @@ -18,9 +18,9 @@ package io.entgra.device.mgt.core.certificate.mgt.core.util; +import io.entgra.device.mgt.core.certificate.mgt.core.config.datasource.DataSourceConfig; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.certificate.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.dbcreator.DatabaseCreator; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/Serializer.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/Serializer.java index e7d31b2c97..21094417a6 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/Serializer.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/Serializer.java @@ -18,11 +18,7 @@ package io.entgra.device.mgt.core.certificate.mgt.core.util; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; +import java.io.*; /** * Serialize/deserialize a given object to and from a byte array. diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/common/BaseDeviceManagementCertificateTest.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/common/BaseDeviceManagementCertificateTest.java index 2422aaa1a7..b4cffd35df 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/common/BaseDeviceManagementCertificateTest.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/common/BaseDeviceManagementCertificateTest.java @@ -19,6 +19,10 @@ package io.entgra.device.mgt.core.certificate.mgt.core.common; import io.entgra.device.mgt.core.certificate.mgt.core.util.TestUtils; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tomcat.jdbc.pool.PoolProperties; @@ -27,10 +31,6 @@ import org.testng.annotations.BeforeSuite; import org.w3c.dom.Document; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import javax.sql.DataSource; import javax.xml.bind.JAXBContext; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateCacheManagerImplTests.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateCacheManagerImplTests.java index 86ed531b5b..bc9efe9f9a 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateCacheManagerImplTests.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateCacheManagerImplTests.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.certificate.mgt.core.impl; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; import io.entgra.device.mgt.core.certificate.mgt.core.cache.CertificateCacheManager; import io.entgra.device.mgt.core.certificate.mgt.core.common.BaseDeviceManagementCertificateTest; import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; /** * This class tests CertificateCache manager methods diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorNegativeTests.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorNegativeTests.java index 0ff902a8d1..c16e680352 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorNegativeTests.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorNegativeTests.java @@ -17,7 +17,11 @@ */ package io.entgra.device.mgt.core.certificate.mgt.core.impl; + +import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; import io.entgra.device.mgt.core.certificate.mgt.core.util.CSRGenerator; +import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.cert.CertIOException; @@ -36,18 +40,11 @@ import org.powermock.modules.testng.PowerMockTestCase; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.base.MultitenantConstants; -import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; -import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; + import javax.sql.DataSource; import java.io.File; -import java.security.KeyPair; -import java.security.PrivateKey; -import java.security.NoSuchProviderException; -import java.security.NoSuchAlgorithmException; -import java.security.SignatureException; -import java.security.InvalidKeyException; +import java.security.*; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.sql.SQLException; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorTestSuite.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorTestSuite.java index 837df2428f..77f1d33406 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorTestSuite.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorTestSuite.java @@ -1,12 +1,12 @@ package io.entgra.device.mgt.core.certificate.mgt.core.impl; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; +import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.Assert; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; -import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; import java.io.File; import java.io.IOException; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorTests.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorTests.java index de9df7dbf8..2e549a8924 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorTests.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGeneratorTests.java @@ -18,11 +18,11 @@ */ package io.entgra.device.mgt.core.certificate.mgt.core.impl; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; public class CertificateGeneratorTests { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplNegativeTests.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplNegativeTests.java index 24b3a134ac..c5d31221bb 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplNegativeTests.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplNegativeTests.java @@ -18,6 +18,10 @@ package io.entgra.device.mgt.core.certificate.mgt.core.impl; +import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.CertificateManagementException; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.TransactionManagementException; +import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementServiceImpl; import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; @@ -29,10 +33,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.ObjectFactory; import org.testng.annotations.Test; import org.wso2.carbon.base.MultitenantConstants; -import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.CertificateManagementException; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.TransactionManagementException; -import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementServiceImpl; import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.sql.DataSource; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplTests.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplTests.java index 74d761f373..41acfd0cc9 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplTests.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateManagementServiceImplTests.java @@ -18,8 +18,20 @@ package io.entgra.device.mgt.core.certificate.mgt.core.impl; +import io.entgra.device.mgt.core.certificate.mgt.core.common.BaseDeviceManagementCertificateTest; +import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.CAStatus; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; +import io.entgra.device.mgt.core.certificate.mgt.core.dto.SCEPResponse; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.CertificateManagementException; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; +import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementServiceImpl; +import io.entgra.device.mgt.core.certificate.mgt.core.service.PaginationResult; import io.entgra.device.mgt.core.certificate.mgt.core.util.CSRGenerator; +import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; import io.entgra.device.mgt.core.certificate.mgt.core.util.DummyCertificate; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -32,19 +44,8 @@ import org.bouncycastle.pkcs.PKCS10CertificationRequest; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.certificate.mgt.core.common.BaseDeviceManagementCertificateTest; -import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CAStatus; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.SCEPResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.CertificateManagementException; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; -import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementServiceImpl; -import io.entgra.device.mgt.core.certificate.mgt.core.service.PaginationResult; -import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; + import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateTests.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateTests.java index 559cf905c9..cd1a122cd2 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateTests.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateTests.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.certificate.mgt.core.impl; +import io.entgra.device.mgt.core.certificate.mgt.core.bean.Certificate; import io.entgra.device.mgt.core.certificate.mgt.core.util.DummyCertificate; import org.testng.Assert; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.certificate.mgt.core.bean.Certificate; /** * This class tests the DTO for certificates diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/util/DummyCertificate.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/util/DummyCertificate.java index b5b8bb71b4..d6ff3d8d99 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/util/DummyCertificate.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/java/io/entgra/device/mgt/core/certificate/mgt/core/util/DummyCertificate.java @@ -21,17 +21,8 @@ package io.entgra.device.mgt.core.certificate.mgt.core.util; import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; import java.math.BigInteger; -import java.security.Principal; -import java.security.PublicKey; -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateExpiredException; -import java.security.cert.CertificateNotYetValidException; -import java.security.cert.CertificateException; -import java.security.NoSuchAlgorithmException; -import java.security.SignatureException; -import java.security.NoSuchProviderException; -import java.security.cert.X509Certificate; -import java.security.InvalidKeyException; +import java.security.*; +import java.security.cert.*; import java.util.Date; import java.util.Set; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml index 40b7e24343..115062646a 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml @@ -15,7 +15,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 51691757c9..43b4fb7bc9 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -30,7 +30,7 @@ certificate-mgt pom WSO2 Carbon - Certificate Management Component - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.certificate.mgt.core @@ -38,23 +38,4 @@ io.entgra.device.mgt.core.certificate.mgt.cert.admin.api - - - - - - - - - - - - - - - - - - - diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 5bd1ca25cb..a73fd62a4a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -36,13 +36,13 @@ - - org.apache.felix - maven-scr-plugin - org.apache.maven.plugins maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -56,22 +56,19 @@ IoT - User Roles Management Bundle io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.internal + io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.bean;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.exception;version="[5.0,6)", + javax.xml.bind;version="[0.0,1)", + javax.xml.bind.annotation;version="[0.0,1)", + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", + org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - org.apache.axis2.*;version="${axis2.osgi.version.range}", - org.wso2.carbon.core, - org.wso2.carbon.utils.*, - javax.xml.bind;resolution:=optional, - javax.xml.bind.annotation, - javax.xml.parsers, - org.w3c.dom, - org.wso2.carbon, - org.wso2.carbon.context, - org.wso2.carbon.user.api, - org.wso2.carbon.user.core.common, - org.wso2.carbon.user.core.service, - org.wso2.carbon.user.mgt.common + org.w3c.dom,org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.core;version="[4.8,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.utils;version="[4.8,5)" !io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.internal, @@ -124,12 +121,9 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.wso2.carbon @@ -139,7 +133,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon @@ -189,7 +182,6 @@ org.wso2.carbon org.wso2.carbon.securevault - test diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/defaultrole/manager/internal/RoleManagerServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/defaultrole/manager/internal/RoleManagerServiceComponent.java index 3ac6aa7137..5669e545d1 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/defaultrole/manager/internal/RoleManagerServiceComponent.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/defaultrole/manager/internal/RoleManagerServiceComponent.java @@ -20,35 +20,24 @@ package io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.internal; import io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.DefaultRolesConfigManager; +import io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.IoTSStartupHandler; 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.osgi.service.component.annotations.*; import org.wso2.carbon.core.ServerStartupObserver; -import io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.IoTSStartupHandler; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.ConfigurationContextService; -/** - * @scr.component name="io.entgra.device.mgt.role.manager.RoleManagerServiceComponent" - * immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" - * policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.internal.RoleManagerServiceComponent", + immediate = true) public class RoleManagerServiceComponent { private static final Log log = LogFactory.getLog(RoleManagerServiceComponent.class); + @Activate protected void activate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("Activating Role Management Service Component"); @@ -64,13 +53,19 @@ public class RoleManagerServiceComponent { log.error("Error occurred while activating Role Management Service Component", e); } } - + @Deactivate protected void deactivate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("De-activating Role Manager Service Component"); } } + @Reference( + name = "configuration.context.service", + service = org.wso2.carbon.utils.ConfigurationContextService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { if (log.isDebugEnabled()) { log.debug("Setting ConfigurationContextService"); @@ -91,6 +86,12 @@ public class RoleManagerServiceComponent { * * @param realmService An instance of RealmService */ + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { log.debug("Setting Realm Service"); diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index d0b9d6f50a..5756662e73 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -31,9 +31,14 @@ bundle WSO2 Carbon - Device Type Deployer WSO2 Carbon - Device Type Deployer Implementation - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + commons-lang.wso2 commons-lang @@ -46,14 +51,6 @@ org.wso2.carbon org.wso2.carbon.utils - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - commons-logging commons-logging @@ -112,8 +109,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -130,34 +131,29 @@ io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.* - javax.naming, - javax.sql, - javax.xml, - javax.xml.bind, - javax.xml.bind.annotation, - javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}", - org.apache.axis2.context, - org.apache.axis2.deployment.*, - org.apache.commons.lang;version="${commons-lang.wso2.osgi.version.range}", - org.apache.commons.logging, + io.entgra.device.mgt.core.device.mgt.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.util, + io.entgra.device.mgt.core.device.mgt.extensions.device.type.template;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.exception;version="[5.0,6)", + javax.xml.bind;version="[0.0,1)", + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", + org.apache.axis2.context;version="[1.6,2)", + org.apache.axis2.deployment;version="[1.6,2)", + org.apache.axis2.deployment.repository.util;version="[1.6,2)", + org.apache.axis2.engine;version="[1.6,2)", + org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.w3c.dom, - org.wso2.carbon.context, - io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.*, - org.wso2.carbon.registry.api, - org.wso2.carbon.registry.core, - org.wso2.carbon.registry.core.*, - org.wso2.carbon.utils.*, - javax.xml.namespace, - org.apache.commons.io, - org.wso2.carbon.application.deployer.*, - org.apache.axis2.engine, - org.wso2.carbon.ndatasource.core, + org.w3c.dom,org.wso2.carbon.application.deployer;version="[4.8,5)", + org.wso2.carbon.application.deployer.config;version="[4.8,5)", + org.wso2.carbon.application.deployer.handler;version="[4.8,5)", + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.ndatasource.core;version="[4.8,5)", + org.wso2.carbon.registry.core.service;version="[1.0,2)", + org.wso2.carbon.utils;version="[4.8,5)" DeviceTypeDeployer - diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployer.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployer.java index 4ba19f7ba7..c1ff67d7cc 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployer.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployer.java @@ -18,6 +18,7 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer; +import io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.util.DeviceTypePluginConstants; import org.apache.axis2.deployment.Deployer; import org.apache.axis2.deployment.DeploymentException; import org.apache.axis2.deployment.repository.util.DeploymentFileData; @@ -30,7 +31,6 @@ import org.wso2.carbon.application.deployer.CarbonApplication; import org.wso2.carbon.application.deployer.config.Artifact; import org.wso2.carbon.application.deployer.config.CappFile; import org.wso2.carbon.application.deployer.handler.AppDeploymentHandler; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.util.DeviceTypePluginConstants; import java.io.File; import java.util.ArrayList; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployer.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployer.java index 4331159789..94f2f81162 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployer.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployer.java @@ -18,6 +18,13 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer; +import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.internal.DeviceTypeManagementDataHolder; +import io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.util.DeviceTypeConfigUtil; +import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.DeviceTypeConfigIdentifier; +import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.DeviceTypeManagerService; +import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.DeviceTypeConfiguration; +import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.exception.DeviceTypeConfigurationException; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.deployment.AbstractDeployer; import org.apache.axis2.deployment.DeploymentException; @@ -28,13 +35,6 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import org.w3c.dom.Document; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.internal.DeviceTypeManagementDataHolder; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.util.DeviceTypeConfigUtil; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.DeviceTypeConfigIdentifier; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.DeviceTypeManagerService; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.DeviceTypeConfiguration; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.exception.DeviceTypeConfigurationException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/internal/DeviceTypeManagementServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/internal/DeviceTypeManagementServiceComponent.java index 5bfabb7b4c..a5a860effc 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/internal/DeviceTypeManagementServiceComponent.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/internal/DeviceTypeManagementServiceComponent.java @@ -21,34 +21,19 @@ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.int import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.application.deployer.handler.AppDeploymentHandler; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.utils.ConfigurationContextService; -/** - * @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.internal.DeviceTypeManagementServiceComponent" - * immediate="true" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" - * policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - * @scr.reference name="registry.service" - * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="0..1" - * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService" - * @scr.reference name="org.wso2.carbon.ndatasource" - * interface="org.wso2.carbon.ndatasource.core.DataSourceService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDataSourceService" - * unbind="unsetDataSourceService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.internal.DeviceTypeManagementServiceComponent", + immediate = true) public class DeviceTypeManagementServiceComponent { private static final Log log = LogFactory.getLog(DeviceTypeManagementServiceComponent.class); + @Activate protected void activate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("Activating DeviceType Deployer Service Component"); @@ -56,13 +41,19 @@ public class DeviceTypeManagementServiceComponent { // ctx.getBundleContext().registerService(AppDeploymentHandler.class.getName(), new DeviceTypeCAppDeployer(), null); DeviceTypeManagementDataHolder.getInstance().setBundleContext(ctx.getBundleContext()); } - + @Deactivate protected void deactivate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("De-activating DeviceType Deployer Service Component"); } } + @Reference( + name = "configuration.context.service", + service = org.wso2.carbon.utils.ConfigurationContextService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { if (log.isDebugEnabled()) { log.debug("Setting ConfigurationContextService"); @@ -79,6 +70,12 @@ public class DeviceTypeManagementServiceComponent { DeviceTypeManagementDataHolder.getInstance().setConfigurationContextService(null); } + @Reference( + name = "registry.service", + service = org.wso2.carbon.registry.core.service.RegistryService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRegistryService") protected void setRegistryService(RegistryService registryService) { if (log.isDebugEnabled()) { log.debug("RegistryService acquired"); @@ -90,6 +87,12 @@ public class DeviceTypeManagementServiceComponent { DeviceTypeManagementDataHolder.getInstance().setRegistryService(null); } + @Reference( + name = "datasource.service", + service = org.wso2.carbon.ndatasource.core.DataSourceService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDataSourceService") protected void setDataSourceService(DataSourceService dataSourceService) { /* This is to avoid mobile device management component getting initialized before the underlying datasources are registered */ diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java index 68d455309b..c417c6db01 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java @@ -18,8 +18,8 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.util; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.exception.DeviceTypeConfigurationException; +import org.w3c.dom.Document; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployerTest.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployerTest.java index 7dcc4c8510..9fc7aae1d4 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployerTest.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployerTest.java @@ -18,7 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.DeviceTypeCAppDeployer; +import io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.util.DeviceTypePluginConstants; import org.apache.axis2.deployment.DeploymentException; import org.apache.axis2.engine.AxisConfiguration; import org.mockito.Mockito; @@ -29,8 +29,8 @@ import org.wso2.carbon.application.deployer.config.ApplicationConfiguration; import org.wso2.carbon.application.deployer.config.Artifact; import org.wso2.carbon.application.deployer.config.CappFile; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.util.DeviceTypePluginConstants; import org.wso2.carbon.registry.core.exceptions.RegistryException; + import java.io.File; import java.io.IOException; import java.lang.reflect.Field; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployerTest.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployerTest.java index 9c284f63f2..b757aedb28 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployerTest.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployerTest.java @@ -18,7 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.DeviceTypePluginDeployer; +import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.DeviceTypeConfigIdentifier; import org.apache.axis2.deployment.DeploymentException; import org.apache.axis2.deployment.repository.util.DeploymentFileData; import org.junit.Assert; @@ -27,8 +27,8 @@ import org.osgi.framework.ServiceRegistration; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.DeviceTypeConfigIdentifier; import org.wso2.carbon.registry.core.exceptions.RegistryException; + import java.io.File; import java.io.IOException; import java.lang.reflect.Field; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index 70a9a195a3..b3dfb9de7d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -38,6 +38,10 @@ org.apache.maven.plugins maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -51,7 +55,7 @@ Entgra Logger Bundle io.entgra.device.mgt.core.device.mgt.extensions.logger, - org.apache.commons.logging + org.apache.commons.logging;version="[1.2,2)" io.entgra.device.mgt.core.device.mgt.extensions.logger.* @@ -67,7 +71,6 @@ org.ops4j.pax.logging pax-logging-api provided - diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 20a62eb833..3679e7f307 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -31,9 +31,14 @@ bundle WSO2 Carbon - Pull Notification Provider Implementation WSO2 Carbon - Pull Notification Provider Implementation - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.common @@ -42,14 +47,6 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.core - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - io.entgra.device.mgt.core io.entgra.device.mgt.core.policy.mgt.core @@ -64,8 +61,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -82,17 +83,17 @@ io.entgra.device.mgt.core.device.mgt.extensions.pull.notification.* - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.core.service - io.entgra.device.mgt.core.policy.mgt.core.*, - io.entgra.device.mgt.core.policy.mgt.core, - com.google.gson, - io.entgra.device.mgt.core.device.mgt.core.service.*, - io.entgra.device.mgt.core.application.mgt.common.*, - io.entgra.device.mgt.core.application.mgt.common.services.* + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.application.mgt.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.services;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.pull.notification;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.policy.mgt.core;version="[5.0,6)", + org.apache.commons.logging;version="[1.2,2)", + org.osgi.service.*;version="${imp.package.version.osgi.service}" diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java index 8d3d488c71..63f70b8804 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java @@ -22,11 +22,9 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonParser; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; +import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; @@ -34,6 +32,8 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComp import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationExecutionFailedException; import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.extensions.pull.notification.internal.PullNotificationDataHolder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/pull/notification/internal/PullNotificationServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/pull/notification/internal/PullNotificationServiceComponent.java index aa8a4cbd29..9d7515dd37 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/pull/notification/internal/PullNotificationServiceComponent.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/pull/notification/internal/PullNotificationServiceComponent.java @@ -18,39 +18,23 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.pull.notification.internal; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.service.component.ComponentContext; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.*; -/** - * @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.pull.notification.internal.PullNotificationServiceComponent" immediate="true" - * @scr.reference name="carbon.device.mgt.provider" - * interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceManagementProviderService" - * unbind="unsetDeviceManagementProviderService" - * @scr.reference name="io.entgra.device.mgt.core.policy.mgt.core" - * interface="io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService" - * cardinality="1..1" - * policy="dynamic" - * bind="setPolicyManagerService" - * unbind="unsetPolicyManagerService" - * @scr.reference name="org.wso2.carbon.application.mgt.service" - * interface="io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager" - * cardinality="1..1" - * policy="dynamic" - * bind="setApplicationManagerService" - * unbind="unsetApplicationManagerService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.extensions.pull.notification.internal.PullNotificationServiceComponent", + immediate = true) public class PullNotificationServiceComponent { private static final Log log = LogFactory.getLog(PullNotificationServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { //Do nothing @@ -63,11 +47,17 @@ public class PullNotificationServiceComponent { "implementation bundle", e); } } - + @Deactivate protected void deactivate(ComponentContext componentContext) { //Do nothing } + @Reference( + name = "device.mgt.provider.service", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceManagementProviderService") protected void setDeviceManagementProviderService(DeviceManagementProviderService deviceManagementProviderService) { PullNotificationDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); } @@ -76,6 +66,12 @@ public class PullNotificationServiceComponent { PullNotificationDataHolder.getInstance().setDeviceManagementProviderService(null); } + @Reference( + name = "policy.mgr.service", + service = io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetPolicyManagerService") protected void setPolicyManagerService(PolicyManagerService policyManagerService) { PullNotificationDataHolder.getInstance().setPolicyManagerService(policyManagerService); } @@ -84,6 +80,12 @@ public class PullNotificationServiceComponent { PullNotificationDataHolder.getInstance().setPolicyManagerService(null); } + @Reference( + name = "applcation.mgr", + service = io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetApplicationManagerService") protected void setApplicationManagerService(ApplicationManager applicationManagerService){ PullNotificationDataHolder.getInstance().setApplicationManager(applicationManagerService); } diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 073865a700..f33258bc5a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -31,9 +31,14 @@ bundle WSO2 Carbon - FCM Based Push Notification Provider Implementation WSO2 Carbon - FCM Based Push Notification Provider Implementation - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon.governance org.wso2.carbon.governance.api @@ -63,17 +68,9 @@ org.wso2.carbon.utils - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - org.wso2.tomcat tomcat @@ -116,8 +113,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -134,14 +135,14 @@ io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.* - com.google.gson, - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", - io.entgra.device.mgt.core.device.mgt.common.operation.mgt, - io.entgra.device.mgt.core.device.mgt.common.push.notification, - org.apache.commons.logging, - io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.core.service + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + org.apache.commons.logging;version="[1.2,2)", + org.osgi.service.*;version="${imp.package.version.osgi.service}" diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java index 54fdc6c2f3..cda196cff7 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java @@ -21,8 +21,6 @@ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provid import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationContext; @@ -30,6 +28,8 @@ import io.entgra.device.mgt.core.device.mgt.common.push.notification.Notificatio import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationExecutionFailedException; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.internal.FCMDataHolder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.io.IOException; import java.io.OutputStream; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java index cebc3b16d8..7b8aeb7205 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java @@ -18,25 +18,21 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.internal; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.osgi.service.component.annotations.*; -/** - * @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.internal.FCMPushNotificationServiceComponent" immediate="true" - * @scr.reference name="carbon.device.mgt.provider" - * interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceManagementProviderService" - * unbind="unsetDeviceManagementProviderService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.internal.FCMPushNotificationServiceComponent", + immediate = true) public class FCMPushNotificationServiceComponent { private static final Log log = LogFactory.getLog(FCMPushNotificationServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { //Do nothing @@ -49,11 +45,16 @@ public class FCMPushNotificationServiceComponent { "implementation bundle", e); } } - + @Deactivate protected void deactivate(ComponentContext componentContext) { //Do nothing } - + @Reference( + name = "device.mgt.provider.service", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceManagementProviderService") protected void setDeviceManagementProviderService( DeviceManagementProviderService deviceManagementProviderService) { FCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index bdad0b4425..397bb314c4 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -31,9 +31,14 @@ bundle WSO2 Carbon - HTTP Based Push Notification Provider Implementation WSO2 Carbon - HTTP Based Push Notification Provider Implementation - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon.governance org.wso2.carbon.governance.api @@ -63,17 +68,9 @@ org.wso2.carbon.utils - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - org.wso2.tomcat tomcat @@ -107,8 +104,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -125,18 +126,13 @@ io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.* - org.apache.commons.logging, - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.wso2.carbon.context, - io.entgra.device.mgt.core.device.mgt.common.operation.mgt, - io.entgra.device.mgt.core.device.mgt.common.push.notification, - io.entgra.device.mgt.core.device.mgt.common, - io.entgra.device.mgt.core.device.mgt.core.service, - io.entgra.device.mgt.core.device.mgt.core.operation.mgt, - org.wso2.carbon.core, - com.google.gson, - org.apache.commons.httpclient.* + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)", + org.apache.commons.httpclient;version="[3.1,4)", + org.apache.commons.httpclient.methods;version="[3.1,4)", + org.apache.commons.logging;version="[1.2,2)", + org.osgi.service.*;version="${imp.package.version.osgi.service}" diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/HTTPMessageExecutor.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/HTTPMessageExecutor.java index 75e85c901e..290f33f0ac 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/HTTPMessageExecutor.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/HTTPMessageExecutor.java @@ -1,6 +1,8 @@ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http; import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidConfigurationException; +import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationContext; import org.apache.commons.httpclient.HostConfiguration; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.EntityEnclosingMethod; @@ -8,8 +10,6 @@ import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidConfigurationException; -import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationContext; import java.net.UnknownHostException; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/HTTPNotificationStrategy.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/HTTPNotificationStrategy.java index a98a2ba140..f56b71fd26 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/HTTPNotificationStrategy.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/HTTPNotificationStrategy.java @@ -18,15 +18,15 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http; -import org.apache.commons.httpclient.HostConfiguration; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidConfigurationException; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationContext; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationStrategy; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationExecutionFailedException; +import org.apache.commons.httpclient.HostConfiguration; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.net.MalformedURLException; import java.net.URL; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/internal/HTTPPushNotificationServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/internal/HTTPPushNotificationServiceComponent.java index 709680378c..09e8b19321 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/internal/HTTPPushNotificationServiceComponent.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/http/internal/HTTPPushNotificationServiceComponent.java @@ -21,15 +21,17 @@ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provid import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; - -/** - * @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.internal.HTTPPushNotificationServiceComponent" immediate="true" - */ +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +@Component( + name = "io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.internal.HTTPPushNotificationServiceComponent", + immediate = true) public class HTTPPushNotificationServiceComponent { private static final Log log = LogFactory.getLog(HTTPPushNotificationServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 5d72865c31..488019b9c5 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -31,9 +31,14 @@ bundle WSO2 Carbon - MQTT Based Push Notification Provider Implementation WSO2 Carbon - MQTT Based Push Notification Provider Implementation - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon.governance org.wso2.carbon.governance.api @@ -63,17 +68,9 @@ org.wso2.carbon.utils - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - org.wso2.tomcat tomcat @@ -129,8 +126,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -147,21 +148,17 @@ io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.* - org.apache.commons.logging, - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + org.apache.commons.logging;version="[1.2,2)", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.wso2.carbon.context, - io.entgra.device.mgt.core.device.mgt.common.operation.mgt, - io.entgra.device.mgt.core.device.mgt.common.push.notification, - io.entgra.device.mgt.core.device.mgt.common, - io.entgra.device.mgt.core.device.mgt.common.exceptions, - io.entgra.device.mgt.core.device.mgt.core.service, - org.wso2.carbon.event.output.adapter.core, - org.wso2.carbon.event.output.adapter.core.exception, - io.entgra.device.mgt.core.device.mgt.core.operation.mgt, - org.wso2.carbon.core, - io.entgra.device.mgt.core.application.mgt.common.*, - io.entgra.device.mgt.core.application.mgt.common.services.* + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.event.output.adapter.core;version="[5.3,6)", + org.wso2.carbon.event.output.adapter.core.exception;version="[5.3,6)" diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java index 0250e5b739..0ab2001496 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java @@ -18,22 +18,22 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidConfigurationException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationContext; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationStrategy; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationExecutionFailedException; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.PolicyOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.internal.MQTTDataHolder; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.internal.util.MQTTAdapterConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.event.output.adapter.core.MessageType; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.PolicyOperation; import java.util.HashMap; import java.util.List; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/internal/MQTTDataHolder.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/internal/MQTTDataHolder.java index 66ef4a5222..31dfbb54de 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/internal/MQTTDataHolder.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/internal/MQTTDataHolder.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.internal; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; public class MQTTDataHolder { diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/internal/MQTTPushNotificationServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/internal/MQTTPushNotificationServiceComponent.java index e133a420a8..e9a3c75437 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/internal/MQTTPushNotificationServiceComponent.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/internal/MQTTPushNotificationServiceComponent.java @@ -18,32 +18,22 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.internal; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; -/** - * @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.internal.MQTTPushNotificationServiceComponent" immediate="true" - * @scr.reference name="carbon.device.mgt.provider" - * interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceManagementProviderService" - * unbind="unsetDeviceManagementProviderService" - * @scr.reference name="event.output.adapter.service" - * interface="org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService" - * cardinality="1..1" - * policy="dynamic" - * bind="setOutputEventAdapterService" - * unbind="unsetOutputEventAdapterService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.internal.MQTTPushNotificationServiceComponent", + immediate = true) public class MQTTPushNotificationServiceComponent { private static final Log log = LogFactory.getLog(MQTTPushNotificationServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -59,11 +49,17 @@ public class MQTTPushNotificationServiceComponent { "implementation bundle", e); } } - + @Deactivate protected void deactivate(ComponentContext componentContext) { //Do nothing } + @Reference( + name = "device.mgt.provider.service", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceManagementProviderService") protected void setDeviceManagementProviderService( DeviceManagementProviderService deviceManagementProviderService) { MQTTDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); @@ -74,6 +70,12 @@ public class MQTTPushNotificationServiceComponent { MQTTDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); } + @Reference( + name = "output.event.adaptor.service", + service = org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetOutputEventAdapterService") protected void setOutputEventAdapterService(OutputEventAdapterService outputEventAdapterService){ MQTTDataHolder.getInstance().setOutputEventAdapterService(outputEventAdapterService); } diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTBasedPushNotificationProviderTest.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTBasedPushNotificationProviderTest.java index e6e741ebb0..6c70ebdd32 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTBasedPushNotificationProviderTest.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTBasedPushNotificationProviderTest.java @@ -18,15 +18,14 @@ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt; -import org.mockito.Mockito; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationStrategy; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.internal.MQTTDataHolder; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.internal.util.MQTTAdapterConstants; +import org.mockito.Mockito; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException; import org.wso2.carbon.event.output.adapter.core.internal.CarbonOutputEventAdapterService; import org.wso2.carbon.registry.core.exceptions.RegistryException; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategyTest.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategyTest.java index 767c3c04aa..ab2f108577 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategyTest.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategyTest.java @@ -18,12 +18,8 @@ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt; -import org.mockito.Mockito; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationContext; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationExecutionFailedException; @@ -31,19 +27,19 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.PolicyOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.internal.MQTTDataHolder; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.internal.util.MQTTAdapterConstants; +import org.mockito.Mockito; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException; import org.wso2.carbon.event.output.adapter.core.internal.CarbonOutputEventAdapterService; import org.wso2.carbon.registry.core.exceptions.RegistryException; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; -import static io.entgra.device.mgt.core.device.mgt.core.operation.mgt.PolicyOperation.POLICY_OPERATION_CODE; import java.io.IOException; import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; +import java.util.*; + +import static io.entgra.device.mgt.core.device.mgt.core.operation.mgt.PolicyOperation.POLICY_OPERATION_CODE; /* Unit tests for MQTTNotificationStrategy class diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index c9caa1c7d0..831aff4c26 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -31,9 +31,14 @@ bundle WSO2 Carbon - XMPP Based Push Notification Provider Implementation WSO2 Carbon - XMPP Based Push Notification Provider Implementation - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon.governance org.wso2.carbon.governance.api @@ -63,17 +68,9 @@ org.wso2.carbon.utils - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - org.wso2.tomcat tomcat @@ -116,8 +113,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -134,17 +135,15 @@ io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.* - org.apache.commons.logging, - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + org.apache.commons.logging;version="[1.2,2)", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.wso2.carbon.context, - io.entgra.device.mgt.core.device.mgt.common.operation.mgt, - io.entgra.device.mgt.core.device.mgt.common.push.notification, - io.entgra.device.mgt.core.device.mgt.core.*, - org.wso2.carbon.event.output.adapter.core, - org.wso2.carbon.event.output.adapter.core.exception, - org.wso2.carbon.core, - io.entgra.device.mgt.core.device.mgt.common.* + org.wso2.carbon.event.output.adapter.core;version="[5.3,6)", + org.wso2.carbon.event.output.adapter.core.exception;version="[5.3,6)" diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java index 71956c6f4d..485b59f465 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java @@ -18,8 +18,6 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidConfigurationException; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationContext; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationStrategy; @@ -27,6 +25,8 @@ import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotific import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationExecutionFailedException; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.internal.XMPPDataHolder; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.internal.util.XMPPAdapterConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.event.output.adapter.core.MessageType; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException; diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java index f31aa5649e..1441907e58 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java @@ -18,32 +18,22 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.internal; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; -/** - * @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.internal.XMPPPushNotificationServiceComponent" immediate="true" - * @scr.reference name="carbon.device.mgt.provider" - * interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceManagementProviderService" - * unbind="unsetDeviceManagementProviderService" - * @scr.reference name="event.output.adapter.service" - * interface="org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService" - * cardinality="1..1" - * policy="dynamic" - * bind="setOutputEventAdapterService" - * unbind="unsetOutputEventAdapterService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.internal.XMPPPushNotificationServiceComponent", + immediate = true) public class XMPPPushNotificationServiceComponent { private static final Log log = LogFactory.getLog(XMPPPushNotificationServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -59,11 +49,17 @@ public class XMPPPushNotificationServiceComponent { "implementation bundle", e); } } - + @Deactivate protected void deactivate(ComponentContext componentContext) { //Do nothing } + @Reference( + name = "device.mgt.provider.service", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceManagementProviderService") protected void setDeviceManagementProviderService( DeviceManagementProviderService deviceManagementProviderService) { XMPPDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); @@ -74,6 +70,12 @@ public class XMPPPushNotificationServiceComponent { XMPPDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); } + @Reference( + name = "output.event.adaptor.service", + service = org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetOutputEventAdapterService") protected void setOutputEventAdapterService(OutputEventAdapterService outputEventAdapterService){ XMPPDataHolder.getInstance().setOutputEventAdapterService(outputEventAdapterService); } diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index 3b8a1bbd9e..cf9c06d78c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -39,10 +39,10 @@ org.apache.maven.plugins maven-compiler-plugin - - - org.apache.felix - maven-scr-plugin + + 1.8 + 1.8 + org.apache.felix @@ -55,13 +55,13 @@ ${io.entgra.device.mgt.core.version} IoT Device Management State Engine Bundle - org.wso2.carbon.context, - org.wso2.carbon.logging, - org.apache.commons.lang, - org.wso2.carbon.user.api, - org.apache.commons.logging, - org.wso2.carbon.user.core.service, - io.entgra.device.mgt.core.device.mgt.common.* + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.stateengine.dto, + io.entgra.device.mgt.core.device.mgt.extensions.stateengine.exception, + org.apache.commons.logging;version="[1.2,2)", + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)" io.entgra.device.mgt.core.device.mgt.extensions.stateengine.*, @@ -100,11 +100,15 @@ + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.ops4j.pax.logging pax-logging-api provided - com.google.code.gson diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/stateengine/spi/DeviceStateMachine.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/stateengine/spi/DeviceStateMachine.java index ce6430f2e6..b77e461f5c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/stateengine/spi/DeviceStateMachine.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/stateengine/spi/DeviceStateMachine.java @@ -19,10 +19,10 @@ package io.entgra.device.mgt.core.device.mgt.extensions.stateengine.spi; -import io.entgra.device.mgt.core.device.mgt.extensions.stateengine.dto.StateUpdateResult; -import io.entgra.device.mgt.core.device.mgt.extensions.stateengine.exception.StateValidationException; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.extensions.stateengine.dto.StateUpdateResult; +import io.entgra.device.mgt.core.device.mgt.extensions.stateengine.exception.StateValidationException; public interface DeviceStateMachine { diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 6bfd0b58f1..8cb618664d 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -31,7 +31,7 @@ pom WSO2 Carbon - Device Management Extensions WSO2 Carbon - Device Management Extensions - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index dd6554598e..3fda1e9898 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -31,7 +31,7 @@ war WSO2 Carbon - Mobile Device Management API WSO2 Carbon - Mobile Device Management API - http://wso2.org + https://entgra.io @@ -151,18 +151,6 @@ spring-web provided - - org.apache.cxf.wso2 - cxf-bundle - - - - - - - - - org.apache.cxf cxf-bundle-jaxrs @@ -197,7 +185,6 @@ org.ops4j.pax.logging pax-logging-api provided - io.entgra.device.mgt.core @@ -294,10 +281,6 @@ org.slf4j slf4j-api - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-core - @@ -312,10 +295,6 @@ org.slf4j slf4j-api - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-core - @@ -328,29 +307,10 @@ io.entgra.device.mgt.core.apimgt.annotations provided - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-annotations - org.hibernate hibernate-validator - - javax.ws.rs - javax.ws.rs-api - provided - - - javax.ws.rs - jsr311-api - provided - - - org.wso2.carbon.commons - org.wso2.carbon.application.mgt.stub - provided - org.wso2.carbon.analytics org.wso2.carbon.analytics.api @@ -377,11 +337,6 @@ ${carbon.identity.framework.version} provided - - - - - org.wso2.carbon.analytics-common org.wso2.carbon.event.receiver.stub diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/NotificationContext.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/NotificationContext.java index 80aa17f4c2..0ff3d27782 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/NotificationContext.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/NotificationContext.java @@ -19,10 +19,10 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; @ApiModel(value = "NotificationContext") public class NotificationContext { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/NotificationList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/NotificationList.java index e00f91690d..ca28621f72 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/NotificationList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/NotificationList.java @@ -19,9 +19,9 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs; import com.fasterxml.jackson.annotation.JsonProperty; +import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ActivityList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ActivityList.java index b3e37930f0..b125d45aa0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ActivityList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ActivityList.java @@ -20,9 +20,9 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationList.java index 1a898ce6ab..e56d10518d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationList.java @@ -19,8 +19,8 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationWrapper.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationWrapper.java index f3abbc671f..3579837f37 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationWrapper.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationWrapper.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/AuthorizationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/AuthorizationRequest.java index 1681d9493c..c2a335d7fa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/AuthorizationRequest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/AuthorizationRequest.java @@ -13,9 +13,9 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ComplianceDeviceList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ComplianceDeviceList.java index f7cc01bb85..ddb2bc78fe 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ComplianceDeviceList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ComplianceDeviceList.java @@ -19,8 +19,8 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceData; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/Credential.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/Credential.java index fdb107cdfe..22de32c9a8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/Credential.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/Credential.java @@ -17,11 +17,11 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.BadRequestException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpStatus; import org.apache.http.util.TextUtils; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.BadRequestException; public class Credential { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceCompliance.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceCompliance.java index 32beb664bd..366bd4cece 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceCompliance.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceCompliance.java @@ -18,8 +18,8 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; -import io.swagger.annotations.ApiModel; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import io.swagger.annotations.ApiModel; @ApiModel(value = "DeviceCompliance", description = "Device's policy compliance status") public class DeviceCompliance { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceConfig.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceConfig.java index de326c9b02..6dc18831e7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceConfig.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceConfig.java @@ -17,10 +17,8 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; -import io.swagger.annotations.ApiModel; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; - -import java.util.List; +import io.swagger.annotations.ApiModel; @ApiModel(value = "DeviceConfig", description = "Device config") public class DeviceConfig { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceList.java index 7bc34f4520..ef96ad7ac4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceList.java @@ -19,8 +19,8 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceToGroupsAssignment.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceToGroupsAssignment.java index 3f00831880..76b9cf3b2e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceToGroupsAssignment.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceToGroupsAssignment.java @@ -19,9 +19,8 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasePaginatedResult; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceTypeList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceTypeList.java index ba76322923..782b69894c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceTypeList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/DeviceTypeList.java @@ -20,7 +20,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.Device; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/MetadataList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/MetadataList.java index c1b1a4e3d5..e11a83a2fb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/MetadataList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/MetadataList.java @@ -18,9 +18,9 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/NotificationList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/NotificationList.java index d6016bf041..b1f3f2461e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/NotificationList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/NotificationList.java @@ -19,9 +19,9 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; +import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/OperationList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/OperationList.java index 5b239db162..c65f030d96 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/OperationList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/OperationList.java @@ -19,8 +19,8 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; +import io.swagger.annotations.ApiModelProperty; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/OperationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/OperationRequest.java index 91d482dedd..b8d21bc390 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/OperationRequest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/OperationRequest.java @@ -13,9 +13,9 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PermissionList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PermissionList.java index a2b2c3c5c6..f70130ed6c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PermissionList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PermissionList.java @@ -21,6 +21,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PolicyList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PolicyList.java index f00d4ef566..2a914ffa50 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PolicyList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PolicyList.java @@ -19,9 +19,9 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PolicyWrapper.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PolicyWrapper.java index 501fd2c957..091293b215 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PolicyWrapper.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/PolicyWrapper.java @@ -35,11 +35,11 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.CorrectiveAction; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.DeviceGroupWrapper; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ProfileFeature.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ProfileFeature.java index 5f6f829bf8..675e53c201 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ProfileFeature.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ProfileFeature.java @@ -19,9 +19,9 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.CorrectiveAction; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.CorrectiveAction; import java.io.Serializable; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/RemoteSessionInfo.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/RemoteSessionInfo.java index 24a788d8d2..65e0eefbf1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/RemoteSessionInfo.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/RemoteSessionInfo.java @@ -18,12 +18,8 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; -import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; - -import java.util.List; @ApiModel(value = "RemoteSessionInfo", description = "Template of the remote session") public class RemoteSessionInfo { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/RoleInfo.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/RoleInfo.java index b67a80a9e8..c021050363 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/RoleInfo.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/RoleInfo.java @@ -22,8 +22,6 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.user.mgt.common.UIPermissionNode; -import java.util.List; - @ApiModel(value = "RoleInfo", description = "Role details including permission and the users in the roles are " + "wrapped here.") public class RoleInfo { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/AdapterConfiguration.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/AdapterConfiguration.java index ad46b9ef24..4d4b7d547e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/AdapterConfiguration.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/AdapterConfiguration.java @@ -18,7 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics; import io.swagger.annotations.ApiModelProperty; -import java.util.ArrayList; + import java.util.List; /** diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/DeviceTypeEvent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/DeviceTypeEvent.java index 724bd3d9d7..5d05cbbb3d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/DeviceTypeEvent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/DeviceTypeEvent.java @@ -20,8 +20,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModelProperty; -import java.util.List; - /** * This hold stats data record */ diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventAttributeList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventAttributeList.java index 8b27741ce6..f7827bfe7f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventAttributeList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventAttributeList.java @@ -19,8 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasePaginatedResult; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventRecords.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventRecords.java index 670d121bbc..0908fdece6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventRecords.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventRecords.java @@ -18,13 +18,12 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics; import com.fasterxml.jackson.annotation.JsonProperty; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasePaginatedResult; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.Device; +import org.wso2.carbon.analytics.datasource.commons.Record; import java.util.ArrayList; import java.util.List; -import org.wso2.carbon.analytics.datasource.commons.Record; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasePaginatedResult; /** * This hold stats data record diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventStream.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventStream.java index 21062d5ff8..a12fa2c1cb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventStream.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/analytics/EventStream.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics; import io.swagger.annotations.ApiModelProperty; -import java.util.ArrayList; import java.util.List; /** diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/exception/GlobalThrowableMapper.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/exception/GlobalThrowableMapper.java index 67df5e8bea..b465349bf0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/exception/GlobalThrowableMapper.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/exception/GlobalThrowableMapper.java @@ -19,9 +19,9 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception; import com.google.gson.JsonParseException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtUtil; import javax.naming.AuthenticationException; import javax.ws.rs.ClientErrorException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java index 392e25f683..5ffc9c9956 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java @@ -18,35 +18,17 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ActivityList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.common.ActivityIdList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; +import io.swagger.annotations.*; -import javax.validation.Valid; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/AnalyticsArtifactsManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/AnalyticsArtifactsManagementService.java index c95cde1ac2..524df31dda 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/AnalyticsArtifactsManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/AnalyticsArtifactsManagementService.java @@ -17,7 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.ApiParam; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; @@ -25,25 +24,10 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.Adapter; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.EventStream; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.SiddhiExecutionPlan; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; +import io.swagger.annotations.*; import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ConfigurationManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ConfigurationManagementService.java index e0719f7055..71d32c4e7f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ConfigurationManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ConfigurationManagementService.java @@ -18,24 +18,12 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; -import io.swagger.annotations.Api; -import io.swagger.annotations.AuthorizationScope; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.ResponseHeader; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; +import io.swagger.annotations.*; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceAgentService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceAgentService.java index 668a21aa46..66f2fff637 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceAgentService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceAgentService.java @@ -18,35 +18,17 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; +import io.swagger.annotations.*; import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceEventManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceEventManagementService.java index 04bbc205ef..0ec5c44c35 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceEventManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceEventManagementService.java @@ -1,32 +1,14 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.DeviceTypeEvent; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.EventRecords; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.swagger.annotations.*; import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index b049284d6a..31c0d682cb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -36,19 +36,10 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.Feature; @@ -60,28 +51,13 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.search.PropertyMap; import io.entgra.device.mgt.core.device.mgt.common.search.SearchContext; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ApplicationList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationRequest; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationStatusBean; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.swagger.annotations.*; import javax.validation.Valid; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.sql.Timestamp; import java.util.List; /** diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceTypeManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceTypeManagementService.java index 7458a4120e..b3d9ed0c60 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceTypeManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceTypeManagementService.java @@ -36,33 +36,17 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; -import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceTypeList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; +import io.swagger.annotations.*; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GeoLocationBasedService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GeoLocationBasedService.java index 4dc45420d6..09368928b7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GeoLocationBasedService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GeoLocationBasedService.java @@ -18,36 +18,18 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.Alert; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.GeofenceWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.Alert; +import io.swagger.annotations.*; import javax.validation.Valid; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java index 4dbd2ded10..b9b539673d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java @@ -35,40 +35,17 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; -import org.apache.axis2.transport.http.HTTPConstants; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.swagger.annotations.*; +import org.apache.axis2.transport.http.HTTPConstants; import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/MetadataService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/MetadataService.java index 325499fb97..3fed77d445 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/MetadataService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/MetadataService.java @@ -18,35 +18,16 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; -import org.apache.axis2.transport.http.HTTPConstants; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.MetadataList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import io.swagger.annotations.*; +import org.apache.axis2.transport.http.HTTPConstants; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/NotificationManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/NotificationManagementService.java index a065e87521..add01212fd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/NotificationManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/NotificationManagementService.java @@ -18,33 +18,16 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.NotificationList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; +import io.swagger.annotations.*; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/PolicyManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/PolicyManagementService.java index d71d154a14..f34908db6d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/PolicyManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/PolicyManagementService.java @@ -18,37 +18,19 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PolicyWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PriorityUpdatedPolicyWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ProfileFeature; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; +import io.swagger.annotations.*; import javax.validation.Valid; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RemoteSessionService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RemoteSessionService.java index eec267c7c8..753defa7ab 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RemoteSessionService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RemoteSessionService.java @@ -19,20 +19,10 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.swagger.annotations.*; import javax.validation.constraints.Size; import javax.ws.rs.GET; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ReportManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ReportManagementService.java index d4a3582057..c8e7185753 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ReportManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ReportManagementService.java @@ -17,37 +17,17 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import com.google.gson.JsonObject; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.ReportManagementException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.ReportManagementException; +import io.swagger.annotations.*; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; import java.util.List; @SwaggerDefinition( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java index 54d95b1bad..6d92fcbafa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java @@ -18,13 +18,13 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.*; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleInfo; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.swagger.annotations.*; import org.wso2.carbon.user.mgt.common.UIPermissionNode; import javax.ws.rs.*; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/UserManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/UserManagementService.java index 8d460ae15c..96121cd009 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/UserManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/UserManagementService.java @@ -35,45 +35,16 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; import com.google.gson.JsonArray; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.ResponseHeader; -import org.apache.axis2.transport.http.HTTPConstants; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitation; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ActivityList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasicUserInfo; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasicUserInfoList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.Credential; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.EnrollmentInvitation; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OldPasswordResetWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PermissionList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.UserInfo; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.UserStoreList; +import io.entgra.device.mgt.core.apimgt.annotations.Scopes; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitation; +import io.swagger.annotations.*; +import org.apache.axis2.transport.http.HTTPConstants; import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/WhiteLabelService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/WhiteLabelService.java index 17ca3eb0d6..c7de5ad12f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/WhiteLabelService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/WhiteLabelService.java @@ -17,30 +17,17 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; -import io.swagger.annotations.ApiParam; -import org.apache.axis2.transport.http.HTTPConstants; + import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.PathParam; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; +import io.swagger.annotations.*; +import org.apache.axis2.transport.http.HTTPConstants; + +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/ApplicationManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/ApplicationManagementAdminService.java index 5f8ee0de17..1c7eb490cb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/ApplicationManagementAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/ApplicationManagementAdminService.java @@ -18,22 +18,13 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ApplicationWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; +import io.swagger.annotations.*; import javax.ws.rs.Consumes; import javax.ws.rs.POST; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAccessAuthorizationAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAccessAuthorizationAdminService.java index 4ea42d24e0..11f389bf92 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAccessAuthorizationAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAccessAuthorizationAdminService.java @@ -18,21 +18,13 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAuthorizationResult; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.AuthorizationRequest; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAuthorizationResult; +import io.swagger.annotations.*; import javax.ws.rs.Consumes; import javax.ws.rs.POST; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAnalyticsArtifactUploaderAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAnalyticsArtifactUploaderAdminService.java index 44fed757ab..e7d81017c9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAnalyticsArtifactUploaderAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAnalyticsArtifactUploaderAdminService.java @@ -19,17 +19,15 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin; -import io.swagger.annotations.*; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.swagger.annotations.*; -import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; @SwaggerDefinition( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceManagementAdminService.java index 8eaca88ea0..d5baf66089 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceManagementAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceManagementAdminService.java @@ -34,35 +34,17 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; -import org.apache.axis2.transport.http.HTTPConstants; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.swagger.annotations.*; +import org.apache.axis2.transport.http.HTTPConstants; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.sql.Timestamp; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceTypeManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceTypeManagementAdminService.java index 81992cd340..92c2947bbd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceTypeManagementAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceTypeManagementAdminService.java @@ -35,35 +35,18 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; -import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceTypeList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceTypeVersionWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; +import io.swagger.annotations.*; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java index 63699f268e..b6b3759db0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java @@ -35,24 +35,14 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.ResponseHeader; -import org.apache.axis2.transport.http.HTTPConstants; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.swagger.annotations.*; +import org.apache.axis2.transport.http.HTTPConstants; import javax.validation.Valid; import javax.ws.rs.*; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java index c40a4c36b4..97a4d6c550 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java @@ -18,14 +18,14 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin; -import io.swagger.annotations.*; -import org.apache.axis2.transport.http.HTTPConstants; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PasswordResetWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.swagger.annotations.*; +import org.apache.axis2.transport.http.HTTPConstants; import javax.validation.constraints.Size; import javax.ws.rs.*; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java index 6c3b666343..0d1e4e266b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java @@ -19,31 +19,24 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ActivityList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.common.ActivityIdList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.ActivityInfoProviderService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.user.api.UserStoreException; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.text.ParseException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java index a8facadc4d..ab8805ba63 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java @@ -17,23 +17,18 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.Attribute; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.AdapterMappingConfiguration; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.MappingProperty; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.AdapterConfiguration; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.AdapterProperty; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.MessageFormat; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.SiddhiExecutionPlan; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.ArtifactAlreadyExistsException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.*; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.ErrorDTO; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.InvalidExecutionPlanException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.NotFoundException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.*; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.AnalyticsArtifactsManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.Adapter; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.EventStream; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import org.apache.axis2.AxisFault; +import org.apache.axis2.client.Stub; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub; import org.wso2.carbon.event.publisher.stub.EventPublisherAdminServiceStub; import org.wso2.carbon.event.publisher.stub.types.BasicOutputAdapterPropertyDto; @@ -45,20 +40,10 @@ import org.wso2.carbon.event.receiver.stub.types.EventReceiverConfigurationDto; import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub; import org.wso2.carbon.event.stream.stub.types.EventStreamAttributeDto; import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.UserStoreException; -import org.apache.axis2.AxisFault; -import org.apache.axis2.client.Stub; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import javax.validation.Valid; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.rmi.RemoteException; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImpl.java index 518a9912a1..ce976dd4c1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImpl.java @@ -18,22 +18,19 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; -import io.entgra.device.mgt.core.device.mgt.core.config.ui.UIConfiguration; -import io.entgra.device.mgt.core.device.mgt.core.config.ui.UIConfigurationManager; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.ConfigurationManagementService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; import javax.ws.rs.PUT; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceImpl.java index f821641fb4..9ec42bd7e0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceImpl.java @@ -22,10 +22,13 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonParser; -import org.apache.axis2.AxisFault; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.Attribute; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.AttributeType; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.EventAttributeList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceAgentService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; @@ -38,29 +41,20 @@ import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManage import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.Attribute; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.AttributeType; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.EventAttributeList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceAgentService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; -import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub; -import org.wso2.carbon.event.stream.stub.types.EventStreamAttributeDto; -import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto; import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import io.entgra.device.mgt.core.policy.mgt.common.PolicyAdministratorPoint; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; +import org.apache.axis2.AxisFault; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub; +import org.wso2.carbon.event.stream.stub.types.EventStreamAttributeDto; +import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto; import org.wso2.carbon.user.api.UserStoreException; import javax.validation.Valid; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.rmi.RemoteException; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceEventManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceEventManagementServiceImpl.java index 2bb854160b..c2d79f8dc1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceEventManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceEventManagementServiceImpl.java @@ -2,9 +2,15 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import io.entgra.device.mgt.core.apimgt.analytics.extension.AnalyticsArtifactsDeployer; import io.entgra.device.mgt.core.apimgt.analytics.extension.dto.*; -import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventReceiverDeployerException; import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventPublisherDeployerException; +import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventReceiverDeployerException; import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventStreamDeployerException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.*; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceEventManagementService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import org.apache.axis2.AxisFault; import org.apache.axis2.client.Stub; import org.apache.commons.lang.StringUtils; @@ -14,15 +20,6 @@ import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.databridge.commons.StreamDefinition; import org.wso2.carbon.databridge.commons.exception.MalformedStreamDefinitionException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.Attribute; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.AttributeType; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.DeviceTypeEvent; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.EventAttributeList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.TransportType; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceEventManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; import org.wso2.carbon.event.publisher.core.EventPublisherService; @@ -46,7 +43,6 @@ import org.wso2.carbon.event.stream.core.exception.EventStreamConfigurationExcep import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub; import org.wso2.carbon.event.stream.stub.types.EventStreamAttributeDto; import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.UserStoreException; import javax.validation.Valid; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 4e6fb4446e..556f6c494a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -37,25 +37,24 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import com.google.gson.Gson; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse; -import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; -import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; -import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; -import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONObject; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.KeyMgtException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtService; import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtServiceImpl; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; +import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; +import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; +import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; +import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.InputValidationException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; @@ -82,7 +81,6 @@ import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceStatus; import io.entgra.device.mgt.core.device.mgt.core.app.mgt.ApplicationManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; -import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.DeviceInformationManager; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; @@ -93,22 +91,19 @@ import io.entgra.device.mgt.core.device.mgt.core.search.mgt.SearchManagerService import io.entgra.device.mgt.core.device.mgt.core.search.mgt.SearchMgtException; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.DeviceAPIClientService; -import io.entgra.device.mgt.core.device.mgt.core.traccar.common.TraccarHandlerConstants; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; -import io.entgra.device.mgt.core.device.mgt.core.util.HttpReportingUtil; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.InputValidationException; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; @@ -122,7 +117,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Properties; -import java.util.concurrent.ExecutionException; @Path("/devices") public class DeviceManagementServiceImpl implements DeviceManagementService { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java index 696c327dce..5eeb591119 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java @@ -35,31 +35,27 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceTypeNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.Feature; -import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; -import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; -import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; -import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceTypeManagementService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.InputValidationException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.Feature; +import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceTypeNotFoundException; +import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.validation.constraints.Size; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GeoLocationBasedServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GeoLocationBasedServiceImpl.java index 56b30ff0a6..85c4127ab9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GeoLocationBasedServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GeoLocationBasedServiceImpl.java @@ -22,44 +22,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; -import org.wso2.carbon.analytics.api.AnalyticsDataAPI; -import org.wso2.carbon.analytics.api.AnalyticsDataAPIUtil; -//import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse; -//import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry; -//import org.wso2.carbon.analytics.dataservice.commons.SortByField; -//import org.wso2.carbon.analytics.dataservice.commons.SortType; -//import org.wso2.carbon.analytics.datasource.commons.Record; -//import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; -import org.wso2.carbon.context.CarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants.GeoServices; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.Alert; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.AlertAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.Event; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCoordinate; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoFence; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoLocationBasedServiceException; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoLocationProviderService; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoQuery; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeofenceData; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; -import io.entgra.device.mgt.core.device.mgt.core.geo.geoHash.geoHashStrategy.GeoHashLengthStrategy; -import io.entgra.device.mgt.core.device.mgt.core.geo.geoHash.geoHashStrategy.ZoomGeoHashLengthStrategy; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.EventAction; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.GeofenceWrapper; @@ -70,27 +32,31 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestV import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtUtil; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; +import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants.GeoServices; +import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; +import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; +import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.*; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; +import io.entgra.device.mgt.core.device.mgt.core.geo.geoHash.geoHashStrategy.GeoHashLengthStrategy; +import io.entgra.device.mgt.core.device.mgt.core.geo.geoHash.geoHashStrategy.ZoomGeoHashLengthStrategy; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpStatus; +import org.wso2.carbon.analytics.api.AnalyticsDataAPI; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * The api for diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index e6980b9900..f55d69dd94 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -35,26 +35,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; @@ -62,14 +42,20 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.GroupManagementService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.*; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import io.entgra.device.mgt.core.policy.mgt.common.PolicyAdministratorPoint; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.CarbonConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/MetadataServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/MetadataServiceImpl.java index 478e382f19..6ed5e8198c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/MetadataServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/MetadataServiceImpl.java @@ -18,42 +18,27 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.NotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelTheme; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; -import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.MetadataList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.MetadataService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyNotFoundException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; +import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.List; /** * This is the service class for metadata management. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImpl.java index 6cd83dca86..3c4d010f43 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImpl.java @@ -18,28 +18,21 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; -import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.NotificationManagementException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.NotificationList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.NotificationManagementService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; +import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.NotificationManagementException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java index 05e9d39be7..52c50fefea 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java @@ -35,30 +35,26 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; -import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService; -import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PolicyList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PolicyWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PriorityUpdatedPolicyWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ProfileFeature; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.PolicyManagementService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.FilteringUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtUtil; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; +import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; +import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.policy.mgt.common.PolicyAdministratorPoint; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.validation.Valid; import javax.ws.rs.*; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RemoteSessionServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RemoteSessionServiceImpl.java index b6cf1aed39..0fe485a6c8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RemoteSessionServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RemoteSessionServiceImpl.java @@ -18,19 +18,15 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RemoteSessionInfo; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.RemoteSessionService; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; import io.entgra.device.mgt.core.device.mgt.core.config.remote.session.RemoteSessionConfiguration; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RemoteSessionInfo; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.RemoteSessionService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.Response; /** diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ReportManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ReportManagementServiceImpl.java index d51813c93d..5dc0ae62d9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ReportManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ReportManagementServiceImpl.java @@ -19,30 +19,24 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import com.google.gson.JsonObject; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceTypeNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.ReportManagementException; -import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; -import io.entgra.device.mgt.core.device.mgt.common.ReportFiltersList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.ReportManagementService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.ReportFiltersList; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceTypeNotFoundException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.ReportManagementException; +import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index bf457dbd96..046b49c9e6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -34,12 +34,6 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.RegistryType; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleInfo; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; @@ -49,6 +43,12 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestV import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.SetReferenceTransformer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.CarbonConstants; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.RegistryType; import org.wso2.carbon.registry.api.Registry; import org.wso2.carbon.registry.core.session.UserRegistry; import org.wso2.carbon.registry.resource.services.utils.ChangeRolePermissionsUtil; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java index f699e8c022..9a03d154dd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java @@ -35,16 +35,16 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; -import org.eclipse.wst.common.uriresolver.internal.util.URIEncoder; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.UserManagementService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.CredentialManagementResponseBuilder; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.OTPManagementException; import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitation; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; @@ -53,24 +53,13 @@ import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.EmailMetaInfo; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ActivityList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasicUserInfo; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasicUserInfoList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasicUserInfoWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.Credential; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.EnrollmentInvitation; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OldPasswordResetWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PermissionList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.UserInfo; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.UserStoreList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.UserManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.CredentialManagementResponseBuilder; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpStatus; +import org.eclipse.wst.common.uriresolver.internal.util.URIEncoder; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.claim.metadata.mgt.ClaimMetadataManagementAdminService; import org.wso2.carbon.identity.claim.metadata.mgt.dto.AttributeMappingDTO; import org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO; @@ -78,11 +67,7 @@ import org.wso2.carbon.identity.claim.metadata.mgt.dto.LocalClaimDTO; import org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException; import org.wso2.carbon.identity.user.store.count.UserStoreCountRetriever; import org.wso2.carbon.identity.user.store.count.exception.UserStoreCounterException; -import org.wso2.carbon.user.api.Permission; -import org.wso2.carbon.user.api.RealmConfiguration; -import org.wso2.carbon.user.api.UserRealm; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.api.UserStoreManager; +import org.wso2.carbon.user.api.*; import org.wso2.carbon.user.core.UserCoreConstants; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.mgt.UserRealmProxy; @@ -91,16 +76,7 @@ import org.wso2.carbon.user.mgt.common.UserAdminException; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.io.File; @@ -111,15 +87,8 @@ import java.security.SecureRandom; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.Instant; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; import java.util.Properties; -import java.util.Set; +import java.util.*; @Path("/users") @Produces(MediaType.APPLICATION_JSON) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/WhiteLabelServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/WhiteLabelServiceImpl.java index 900176a384..0c40c47fae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/WhiteLabelServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/WhiteLabelServiceImpl.java @@ -18,24 +18,20 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.WhiteLabelService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.common.FileResponse; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.NotFoundException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelTheme; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.WhiteLabelService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.PathParam; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.io.ByteArrayInputStream; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java index f455e4d5d1..0ff55def7a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/ApplicationManagementAdminServiceImpl.java @@ -18,23 +18,23 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.Platform; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManager; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ApplicationWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnknownApplicationTypeException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.ApplicationManagementAdminService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.Platform; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManager; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnknownApplicationTypeException; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.util.MDMAndroidOperationUtil; import io.entgra.device.mgt.core.device.mgt.core.util.MDMIOSOperationUtil; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ApplicationWrapper; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.ws.rs.Consumes; import javax.ws.rs.POST; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAccessAuthorizationAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAccessAuthorizationAdminServiceImpl.java index c2c7aebc04..a79c1a3b7b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAccessAuthorizationAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAccessAuthorizationAdminServiceImpl.java @@ -18,17 +18,17 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.AuthorizationRequest; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceAccessAuthorizationAdminService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; +import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAuthorizationResult; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; -import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAuthorizationResult; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.AuthorizationRequest; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceAccessAuthorizationAdminService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import javax.ws.rs.Consumes; import javax.ws.rs.POST; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAnalyticsArtifactUploaderAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAnalyticsArtifactUploaderAdminServiceImpl.java index 56298ce36a..b66badc40c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAnalyticsArtifactUploaderAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAnalyticsArtifactUploaderAdminServiceImpl.java @@ -18,6 +18,10 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceAnalyticsArtifactUploaderAdminService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import org.apache.axis2.AxisFault; import org.apache.axis2.client.Options; import org.apache.axis2.client.Stub; @@ -32,23 +36,15 @@ import org.apache.commons.logging.LogFactory; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; -import org.wso2.carbon.application.mgt.stub.upload.CarbonAppUploaderStub; -import org.wso2.carbon.application.mgt.stub.upload.types.carbon.UploadedFileItem; import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.Utils; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceAnalyticsArtifactUploaderAdminService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; -import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceStub; import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import javax.activation.DataHandler; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManagerFactory; @@ -59,11 +55,7 @@ import javax.ws.rs.core.Response; import java.io.*; import java.nio.file.Files; import java.rmi.RemoteException; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; +import java.security.*; import java.security.cert.CertificateException; import java.util.ArrayList; import java.util.List; @@ -177,10 +169,11 @@ public class DeviceAnalyticsArtifactUploaderAdminServiceImpl implements DeviceAn if (streamFileList != null) { publishDynamicEventStream(type, tenantDomain, streamFileList); } - if (deployAnalyticsCapp(type, list)){ - return Response.status(Response.Status.BAD_REQUEST) - .entity("\"Error, Artifact does not exist.\"").build(); - } + //todo:analytics +// if (deployAnalyticsCapp(type, list)){ +// return Response.status(Response.Status.BAD_REQUEST) +// .entity("\"Error, Artifact does not exist.\"").build(); +// } if (receiverFileList != null) { publishDynamicEventReceivers(type, tenantDomain, receiverFileList); } @@ -202,62 +195,64 @@ public class DeviceAnalyticsArtifactUploaderAdminServiceImpl implements DeviceAn KeyManagementException | IOException | NoSuchAlgorithmException e) { log.error("Failed to access keystore for, tenantDomain: " + tenantDomain, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (RegistryException e) { - log.error("Failed to load tenant, tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + //todo:analytics +// } catch (RegistryException e) { +// log.error("Failed to load tenant, tenantDomain: " + tenantDomain, e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (ParseException e) { log.error("Invalid stream definition for device type" + type + " for tenant, tenantDomain: " + tenantDomain, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } - private boolean deployAnalyticsCapp(@PathParam("type") String type, List
list) throws IOException, RegistryException { - CarbonAppUploaderStub carbonAppUploaderStub = null; - try { - File directory = new File(CAR_FILE_LOCATION + File.separator + type); - if (directory.isDirectory() && directory.exists()) { - UploadedFileItem[] uploadedFileItems = loadCappFromFileSystem(type); - if (uploadedFileItems.length > 0) { - if (DEVICE_MANAGEMENT_TYPE.equals(type.toLowerCase())) { - carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty( - IOT_MGT_URL)); - Options appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions(); - if (appUploaderOptions == null) { - appUploaderOptions = new Options(); - } - appUploaderOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); - appUploaderOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER - , new Protocol(DEFAULT_HTTP_PROTOCOL, - (ProtocolSocketFactory) new SSLProtocolSocketFactory - (sslContext), Integer.parseInt(Utils.replaceSystemProperty( - IOT_MGT_PORT)))); - - carbonAppUploaderStub._getServiceClient().setOptions(appUploaderOptions); - carbonAppUploaderStub.uploadApp(uploadedFileItems); - } else { - carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty(DAS_URL)); - Options appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions(); - if (appUploaderOptions == null) { - appUploaderOptions = new Options(); - } - appUploaderOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); - appUploaderOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER - , new Protocol(DEFAULT_HTTP_PROTOCOL - , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) - , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); - - carbonAppUploaderStub._getServiceClient().setOptions(appUploaderOptions); - carbonAppUploaderStub.uploadApp(uploadedFileItems); - } - } - } else { - return true; - } - return false; - } finally { - cleanup(carbonAppUploaderStub); - } - } + //todo:analytics +// private boolean deployAnalyticsCapp(@PathParam("type") String type, List
list) throws IOException, RegistryException { +// CarbonAppUploaderStub carbonAppUploaderStub = null; +// try { +// File directory = new File(CAR_FILE_LOCATION + File.separator + type); +// if (directory.isDirectory() && directory.exists()) { +// UploadedFileItem[] uploadedFileItems = loadCappFromFileSystem(type); +// if (uploadedFileItems.length > 0) { +// if (DEVICE_MANAGEMENT_TYPE.equals(type.toLowerCase())) { +// carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty( +// IOT_MGT_URL)); +// Options appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions(); +// if (appUploaderOptions == null) { +// appUploaderOptions = new Options(); +// } +// appUploaderOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); +// appUploaderOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER +// , new Protocol(DEFAULT_HTTP_PROTOCOL, +// (ProtocolSocketFactory) new SSLProtocolSocketFactory +// (sslContext), Integer.parseInt(Utils.replaceSystemProperty( +// IOT_MGT_PORT)))); +// +// carbonAppUploaderStub._getServiceClient().setOptions(appUploaderOptions); +// carbonAppUploaderStub.uploadApp(uploadedFileItems); +// } else { +// carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty(DAS_URL)); +// Options appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions(); +// if (appUploaderOptions == null) { +// appUploaderOptions = new Options(); +// } +// appUploaderOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); +// appUploaderOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER +// , new Protocol(DEFAULT_HTTP_PROTOCOL +// , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) +// , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); +// +// carbonAppUploaderStub._getServiceClient().setOptions(appUploaderOptions); +// carbonAppUploaderStub.uploadApp(uploadedFileItems); +// } +// } +// } else { +// return true; +// } +// return false; +// } finally { +// cleanup(carbonAppUploaderStub); +// } +// } private void publishDynamicEventReceivers(String deviceType, String tenantDomain, List receiversList) throws IOException, UserStoreException, JWTClientException { @@ -407,31 +402,32 @@ public class DeviceAnalyticsArtifactUploaderAdminServiceImpl implements DeviceAn return streamList; } - private UploadedFileItem[] loadCappFromFileSystem(String deviceType) throws IOException { - - File directory = new File(CAR_FILE_LOCATION + File.separator + deviceType); - File[] carFiles = directory.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.toLowerCase().endsWith(".car"); - } - }); - List uploadedFileItemLis = new ArrayList<>(); - if (carFiles != null) { - - for (File carFile : carFiles) { - UploadedFileItem uploadedFileItem = new UploadedFileItem(); - DataHandler param = new DataHandler(carFile.toURI().toURL()); - uploadedFileItem.setDataHandler(param); - uploadedFileItem.setFileName(carFile.getName()); - uploadedFileItem.setFileType("jar"); - uploadedFileItemLis.add(uploadedFileItem); - } - } - UploadedFileItem[] fileItems = new UploadedFileItem[uploadedFileItemLis.size()]; - fileItems = uploadedFileItemLis.toArray(fileItems); - return fileItems; - } + //todo:analytics +// private UploadedFileItem[] loadCappFromFileSystem(String deviceType) throws IOException { +// +// File directory = new File(CAR_FILE_LOCATION + File.separator + deviceType); +// File[] carFiles = directory.listFiles(new FilenameFilter() { +// @Override +// public boolean accept(File dir, String name) { +// return name.toLowerCase().endsWith(".car"); +// } +// }); +// List uploadedFileItemLis = new ArrayList<>(); +// if (carFiles != null) { +// +// for (File carFile : carFiles) { +// UploadedFileItem uploadedFileItem = new UploadedFileItem(); +// DataHandler param = new DataHandler(carFile.toURI().toURL()); +// uploadedFileItem.setDataHandler(param); +// uploadedFileItem.setFileName(carFile.getName()); +// uploadedFileItem.setFileType("jar"); +// uploadedFileItemLis.add(uploadedFileItem); +// } +// } +// UploadedFileItem[] fileItems = new UploadedFileItem[uploadedFileItemLis.size()]; +// fileItems = uploadedFileItemLis.toArray(fileItems); +// return fileItems; +// } /** * Loads the keystore. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java index 3885dab5f6..34fef0d4e5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceManagementAdminServiceImpl.java @@ -34,45 +34,29 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.UserNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceManagementAdminService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.*; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; import javax.validation.constraints.Size; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.sql.Timestamp; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceTypeManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceTypeManagementAdminServiceImpl.java index 5ffea17ab3..01282b6e08 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceTypeManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceTypeManagementAdminServiceImpl.java @@ -36,31 +36,23 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceTypeVersionWrapper; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceTypeManagementAdminService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeVersion; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceTypeVersionWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceTypeManagementAdminService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.util.List; import java.util.regex.Matcher; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 6a70868825..b37fc595bf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -34,18 +34,18 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupManagementAdminService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupManagementAdminService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java index 048321763e..9c7ef9e213 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java @@ -18,14 +18,14 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.PrivacyComplianceException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PasswordResetWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.UserManagementAdminService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.CredentialManagementResponseBuilder; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.PrivacyComplianceException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.validation.constraints.Size; import javax.ws.rs.*; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java index 45dfb6cc31..c4edcba02a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java @@ -20,45 +20,33 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; -import io.entgra.device.mgt.core.device.mgt.common.Base64File; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.Feature; -import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; -import io.entgra.device.mgt.core.device.mgt.common.OperationLogFilters; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceTypeNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelImageRequestPayload; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; import io.entgra.device.mgt.core.device.mgt.core.common.util.HttpUtil; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ApplicationWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.EventConfig; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.GeofenceWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OldPasswordResetWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PolicyWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ProfileFeature; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleInfo; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.Scope; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.policy.mgt.common.PolicyPayloadValidator; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpStatus; import java.lang.reflect.InvocationTargetException; -import java.util.List; import java.util.ArrayList; -import java.util.Calendar; import java.util.Arrays; +import java.util.Calendar; +import java.util.List; public class RequestValidationUtil { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/swagger/extension/SecurityDefinitionConfigurator.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/swagger/extension/SecurityDefinitionConfigurator.java index 4dc40acc2f..550be89158 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/swagger/extension/SecurityDefinitionConfigurator.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/swagger/extension/SecurityDefinitionConfigurator.java @@ -24,11 +24,8 @@ import io.swagger.jaxrs.config.ReaderListener; import io.swagger.models.Swagger; import io.swagger.models.auth.OAuth2Definition; import io.swagger.models.auth.SecuritySchemeDefinition; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.Scope; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; @SwaggerDefinition( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/CredentialManagementResponseBuilder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/CredentialManagementResponseBuilder.java index 7c009c04de..2263da3e55 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/CredentialManagementResponseBuilder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/CredentialManagementResponseBuilder.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OldPasswordResetWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PasswordResetWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index e0c4f96771..2291df9466 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -37,24 +37,12 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; -import org.apache.axis2.AxisFault; -import org.apache.axis2.client.Options; -import org.apache.axis2.java.security.SSLProtocolSocketFactory; -import org.apache.axis2.transport.http.HTTPConstants; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.httpclient.Header; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.analytics.api.AnalyticsDataAPI; -import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; -import org.wso2.carbon.authenticator.stub.AuthenticationAdminStub; -import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.core.util.Utils; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceTypeVersionWrapper; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationStatusBean; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.EventAttributeList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.InputValidationException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService; @@ -77,7 +65,6 @@ import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.report.mgt.ReportManagementService; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceTypeGeneratorService; import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; -import io.entgra.device.mgt.core.device.mgt.common.spi.TraccarManagementService; import io.entgra.device.mgt.core.device.mgt.core.app.mgt.ApplicationManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.DeviceInformationManager; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeVersion; @@ -87,12 +74,29 @@ import io.entgra.device.mgt.core.device.mgt.core.search.mgt.SearchManagerService import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.DeviceAPIClientService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceTypeVersionWrapper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationStatusBean; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.EventAttributeList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.InputValidationException; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; +import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyMonitoringTaskException; +import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; +import io.entgra.device.mgt.core.policy.mgt.core.task.TaskScheduleService; +import org.apache.axis2.AxisFault; +import org.apache.axis2.client.Options; +import org.apache.axis2.java.security.SSLProtocolSocketFactory; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.protocol.Protocol; +import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.CarbonConstants; +import org.wso2.carbon.analytics.api.AnalyticsDataAPI; +import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub; +import org.wso2.carbon.base.ServerConfiguration; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub; import org.wso2.carbon.event.publisher.core.EventPublisherService; import org.wso2.carbon.event.publisher.stub.EventPublisherAdminServiceStub; @@ -101,17 +105,11 @@ import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceStub; import org.wso2.carbon.event.stream.core.EventStreamService; import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub; import org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO; -import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.identity.user.store.count.AbstractCountRetrieverFactory; import org.wso2.carbon.identity.user.store.count.UserStoreCountRetriever; import org.wso2.carbon.identity.user.store.count.exception.UserStoreCounterException; import org.wso2.carbon.identity.user.store.count.jdbc.JDBCCountRetrieverFactory; import org.wso2.carbon.identity.user.store.count.jdbc.internal.InternalCountRetrieverFactory; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyMonitoringTaskException; -import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; -import io.entgra.device.mgt.core.policy.mgt.core.task.TaskScheduleService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.api.*; import org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtUtil.java index 7cd79fa96e..e5b3b7b50f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtUtil.java @@ -18,12 +18,12 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; -import io.entgra.device.mgt.core.device.mgt.core.config.permission.Scope; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorListItem; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ProfileFeature; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.BadRequestException; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; +import io.entgra.device.mgt.core.device.mgt.core.config.permission.Scope; import javax.validation.ConstraintViolation; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImplTest.java index 4909347a20..f28ba9ee1c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImplTest.java @@ -19,6 +19,19 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.common.ActivityIdList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.ActivityInfoProviderService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; +import io.entgra.device.mgt.core.device.mgt.core.authorization.DeviceAccessAuthorizationServiceImpl; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mockito.Mockito; @@ -32,19 +45,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.ObjectFactory; import org.testng.annotations.Test; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; -import io.entgra.device.mgt.core.device.mgt.core.authorization.DeviceAccessAuthorizationServiceImpl; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.common.ActivityIdList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.ActivityInfoProviderService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; -import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; import javax.ws.rs.core.Response; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java index 4bd41a6738..74715f96dd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java @@ -19,6 +19,13 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.ConfigurationManagementService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; +import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; @@ -29,13 +36,6 @@ import org.testng.IObjectFactory; import org.testng.annotations.BeforeClass; import org.testng.annotations.ObjectFactory; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.ConfigurationManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; -import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; import javax.ws.rs.core.Response; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java index ebba226d7d..e718cd6061 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java @@ -17,6 +17,25 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceAgentService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceTypeManagementAdminService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DeviceMgtAPITestHelper; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; +import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; +import io.entgra.device.mgt.core.device.mgt.core.authorization.DeviceAccessAuthorizationServiceImpl; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; +import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerServiceImpl; import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,28 +53,7 @@ import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.caching.impl.CacheImpl; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; -import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; -import io.entgra.device.mgt.core.device.mgt.core.authorization.DeviceAccessAuthorizationServiceImpl; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceAgentService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceTypeManagementAdminService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DeviceMgtAPITestHelper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub; -import org.wso2.carbon.event.stream.stub.types.EventStreamAttributeDto; -import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; -import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerServiceImpl; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.CarbonUtils; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java index e8c03be32a..ddd1f7b76e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java @@ -36,19 +36,9 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; -import org.testng.Assert; -import org.testng.IObjectFactory; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.ObjectFactory; -import org.testng.annotations.Test; -import org.wso2.carbon.context.CarbonContext; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DeviceMgtAPITestHelper; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; @@ -70,11 +60,21 @@ import io.entgra.device.mgt.core.device.mgt.core.search.mgt.SearchMgtException; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DeviceMgtAPITestHelper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.testng.Assert; +import org.testng.IObjectFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.ObjectFactory; +import org.testng.annotations.Test; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java index bb9b80c86f..b9c1cf2f05 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java @@ -35,6 +35,16 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceTypeManagementAdminService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin.DeviceTypeManagementAdminServiceImpl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DeviceMgtAPITestHelper; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceTypeGeneratorService; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.DeviceTypeGeneratorServiceImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mockito.Mockito; @@ -50,16 +60,6 @@ import org.testng.annotations.Test; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceTypeGeneratorService; -import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; -import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.DeviceTypeGeneratorServiceImpl; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceTypeManagementAdminService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin.DeviceTypeManagementAdminServiceImpl; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DeviceMgtAPITestHelper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import javax.ws.rs.core.Response; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java index 33e3088c26..5e2207f275 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java @@ -17,6 +17,14 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceTypeManagementService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DeviceMgtAPITestHelper; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mockito.Mockito; @@ -29,14 +37,6 @@ import org.testng.IObjectFactory; import org.testng.annotations.BeforeClass; import org.testng.annotations.ObjectFactory; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; -import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceTypeManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DeviceMgtAPITestHelper; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import javax.ws.rs.core.Response; import java.lang.reflect.InvocationTargetException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GeoLocationBasedServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GeoLocationBasedServiceImplTest.java index 23c4d3c4c6..9c4862d846 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GeoLocationBasedServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GeoLocationBasedServiceImplTest.java @@ -1,17 +1,17 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.GeoLocationBasedService; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCoordinate; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoQuery; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.mockito.Mockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCoordinate; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoQuery; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.GeoLocationBasedService; import javax.ws.rs.core.Response; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java index e5feaf310f..2a8001cc53 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java @@ -35,6 +35,18 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.GroupManagementService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.*; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; +import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; @@ -48,22 +60,6 @@ import org.testng.annotations.Test; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.GroupManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; -import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; import javax.ws.rs.core.Response; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java index 64575c7496..06b85f2db0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java @@ -19,6 +19,11 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; +import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.NotificationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.NotificationManagementService; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; @@ -30,13 +35,9 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.ObjectFactory; import org.testng.annotations.Test; import org.wso2.carbon.context.CarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; -import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.NotificationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.NotificationManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java index 912ca09034..3ca294ac51 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java @@ -36,6 +36,20 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasicUserInfo; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.EnrollmentInvitation; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.UserInfo; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.UserManagementService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.OTPManagementException; +import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitation; +import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; +import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.service.OTPManagementServiceImpl; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -49,20 +63,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.ObjectFactory; import org.testng.annotations.Test; import org.wso2.carbon.context.CarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.OTPManagementException; -import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitation; -import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; -import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.service.OTPManagementServiceImpl; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.BasicUserInfo; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.EnrollmentInvitation; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.UserInfo; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.UserManagementService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.user.api.RealmConfiguration; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index 253f7c86bb..fe45ed706d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -30,10 +30,18 @@ bundle WSO2 Carbon - Device Management Commons WSO2 Carbon - Device Management Commons - http://wso2.org + https://entgra.io + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-bundle-plugin @@ -48,10 +56,28 @@ io.entgra.device.mgt.core.device.mgt.common.* - javax.xml.bind.annotation; version="${javax.xml.bind.imp.pkg.version}", - com.fasterxml.jackson.annotation;version="${jackson-annotations.version}", - io.swagger.annotations; version="${swagger.annotations.version}"; resolution:=optional, - com.google.gson + com.fasterxml.jackson.annotation;version="[2.9,3)", + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.device.mgt.common, + io.entgra.device.mgt.core.device.mgt.common.app.mgt, + io.entgra.device.mgt.core.device.mgt.common.configuration.mgt, + io.entgra.device.mgt.core.device.mgt.common.device.details, + io.entgra.device.mgt.core.device.mgt.common.event.config, + io.entgra.device.mgt.core.device.mgt.common.exceptions, + io.entgra.device.mgt.core.device.mgt.common.general, + io.entgra.device.mgt.core.device.mgt.common.group.mgt, + io.entgra.device.mgt.core.device.mgt.common.invitation.mgt, + io.entgra.device.mgt.core.device.mgt.common.license.mgt, + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt, + io.entgra.device.mgt.core.device.mgt.common.operation.mgt, + io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto, + io.entgra.device.mgt.core.device.mgt.common.policy.mgt, + io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor, + io.entgra.device.mgt.core.device.mgt.common.pull.notification, + io.entgra.device.mgt.core.device.mgt.common.push.notification, + io.entgra.device.mgt.core.device.mgt.common.type.mgt, + io.swagger.annotations;version="[1.6,2)", + javax.xml.bind.annotation;version="[0.0,1)" diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Billing.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Billing.java index 14a25af7bf..ed77fd3cde 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Billing.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Billing.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.common; import com.google.gson.Gson; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; @ApiModel(value = "Billing", description = "This class carries all information related to a device billing.") diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/BillingResponse.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/BillingResponse.java index 793c922f3f..49fc387cfb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/BillingResponse.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/BillingResponse.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.common; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; + import java.io.Serializable; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java index eeb0ea3a91..c9fd0fbb91 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java @@ -17,14 +17,14 @@ */ package io.entgra.device.mgt.core.device.mgt.common; -import com.google.gson.Gson; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.Gson; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocationHistorySnapshotWrapper; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceStatus; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceBilling.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceBilling.java index 5e735e0a44..1373cae427 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceBilling.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceBilling.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.common; import com.google.gson.Gson; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceStatus; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/EnrolmentInfo.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/EnrolmentInfo.java index c946f3d01b..e17cedd4aa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/EnrolmentInfo.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/EnrolmentInfo.java @@ -22,7 +22,6 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; -import java.math.BigInteger; @ApiModel(value = "EnrolmentInfo", description = "This class carries all information related to a devices enrollment" + " status.") diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java index 0246b9fe95..50d6bf1bed 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java @@ -18,11 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.common; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * This class holds required parameters for a querying a paginated device response. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/device/details/DeviceDetailsWrapper.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/device/details/DeviceDetailsWrapper.java index cacdfb79a1..128bc94e92 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/device/details/DeviceDetailsWrapper.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/device/details/DeviceDetailsWrapper.java @@ -23,7 +23,6 @@ import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import java.util.List; -import java.util.Map; public class DeviceDetailsWrapper { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/device/details/DeviceLocation.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/device/details/DeviceLocation.java index 3abe6fd732..440e89080b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/device/details/DeviceLocation.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/device/details/DeviceLocation.java @@ -19,9 +19,9 @@ package io.entgra.device.mgt.core.device.mgt.common.device.details; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import java.io.Serializable; import java.util.Date; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/Alert.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/Alert.java index 09c7f0ef86..8ecab38b29 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/Alert.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/Alert.java @@ -18,11 +18,7 @@ */ package io.entgra.device.mgt.core.device.mgt.common.geo.service; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.*; /** * The Class Alert Bean. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/Event.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/Event.java index ecba5fca2c..848f46b007 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/Event.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/Event.java @@ -19,11 +19,7 @@ package io.entgra.device.mgt.core.device.mgt.common.geo.service; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.*; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/GeoLocationProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/GeoLocationProviderService.java index 3ec6d96ded..c50d57e866 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/GeoLocationProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/GeoLocationProviderService.java @@ -20,11 +20,9 @@ package io.entgra.device.mgt.core.device.mgt.common.geo.service; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationException; -import java.util.ArrayList; import java.util.List; /** diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/GeofenceData.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/GeofenceData.java index a027bff017..c18aeeeb71 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/GeofenceData.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/geo/service/GeofenceData.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.common.geo.service; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventMetaData; import java.util.List; import java.util.Map; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/GroupUser.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/GroupUser.java index e8619ab1d1..00121f9667 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/GroupUser.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/GroupUser.java @@ -21,8 +21,6 @@ package io.entgra.device.mgt.core.device.mgt.common.group.mgt; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/MetadataManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/MetadataManagementService.java index f11c6f7476..f040cc7db4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/MetadataManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/MetadataManagementService.java @@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; + import java.util.List; /** diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/ActivityStatus.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/ActivityStatus.java index 81439108ef..a392646959 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/ActivityStatus.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/ActivityStatus.java @@ -20,9 +20,9 @@ package io.entgra.device.mgt.core.device.mgt.common.operation.mgt; import com.fasterxml.jackson.annotation.JsonProperty; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/OperationManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/OperationManager.java index be8109bfea..8bcd82e4f8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/OperationManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/OperationManager.java @@ -17,12 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.common.operation.mgt; -import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationStrategy; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/Policy.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/Policy.java index 05d442ca99..6938374570 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/Policy.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/Policy.java @@ -34,9 +34,9 @@ */ package io.entgra.device.mgt.core.device.mgt.common.policy.mgt; +import io.entgra.device.mgt.core.device.mgt.common.Device; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.Device; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/ui/Modal.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/ui/Modal.java index 808375f890..e446e348c3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/ui/Modal.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/ui/Modal.java @@ -17,7 +17,6 @@ package io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ui; -import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/ui/SearchInput.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/ui/SearchInput.java index e632b43747..4a7386ca60 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/ui/SearchInput.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/policy/mgt/ui/SearchInput.java @@ -18,9 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ui; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; @XmlRootElement(name = "SearchInput") public class SearchInput { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/report/mgt/ReportManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/report/mgt/ReportManagementService.java index 67cd7e28a5..854c2be62e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/report/mgt/ReportManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/report/mgt/ReportManagementService.java @@ -20,7 +20,6 @@ package io.entgra.device.mgt.core.device.mgt.common.report.mgt; import com.google.gson.JsonObject; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceTypeNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.ReportManagementException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java index ed5832eab8..0bd4da11e0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java @@ -5,7 +5,6 @@ import io.entgra.device.mgt.core.device.mgt.common.InitialOperationConfig; import io.entgra.device.mgt.core.device.mgt.common.license.mgt.License; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; -import java.util.ArrayList; import java.util.List; public class DeviceTypeMetaDefinition { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index c011c1acaf..cf1b04bf1f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -189,6 +189,11 @@ + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.common + provided + io.swagger swagger-annotations diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/ApiOriginFilter.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/ApiOriginFilter.java index 4674930bfc..1f5cb82bda 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/ApiOriginFilter.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/ApiOriginFilter.java @@ -19,12 +19,7 @@ package io.entgra.device.mgt.core.device.mgt.config.api; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import javax.servlet.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/common/GsonMessageBodyHandler.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/common/GsonMessageBodyHandler.java index 64e31780da..61d0355eee 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/common/GsonMessageBodyHandler.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/common/GsonMessageBodyHandler.java @@ -29,11 +29,7 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; +import java.io.*; import java.lang.annotation.Annotation; import java.lang.reflect.Type; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java index d295300bc3..a1716ffcb6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java @@ -18,32 +18,15 @@ package io.entgra.device.mgt.core.device.mgt.config.api.service; -import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; -import io.entgra.device.mgt.core.device.mgt.config.api.beans.ErrorResponse; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; +import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.DeviceConfiguration; import io.entgra.device.mgt.core.device.mgt.common.general.TenantDetail; +import io.entgra.device.mgt.core.device.mgt.config.api.beans.ErrorResponse; +import io.swagger.annotations.*; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java index dfb94ed0f8..058578bf2f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java @@ -21,13 +21,6 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import io.entgra.device.mgt.core.device.mgt.config.api.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.config.api.service.DeviceManagementConfigService; -import io.entgra.device.mgt.core.device.mgt.config.api.util.DeviceMgtAPIUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.AppRegistrationCredentials; import io.entgra.device.mgt.core.device.mgt.common.ApplicationRegistrationException; import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; @@ -37,6 +30,9 @@ import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementEx import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.general.TenantDetail; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; +import io.entgra.device.mgt.core.device.mgt.config.api.beans.ErrorResponse; +import io.entgra.device.mgt.core.device.mgt.config.api.service.DeviceManagementConfigService; +import io.entgra.device.mgt.core.device.mgt.config.api.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; @@ -48,18 +44,15 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.Tenant; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.io.IOException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java index 1e71c48560..62ad7dc997 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.config.api.util; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.user.core.service.RealmService; /** diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 8d473781ab..6f750346d4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -31,14 +31,10 @@ bundle WSO2 Carbon - Device Management Core WSO2 Carbon - Device Management Core - http://wso2.org + https://entgra.io - - org.apache.felix - maven-scr-plugin - org.jacoco jacoco-maven-plugin @@ -65,6 +61,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-bundle-plugin @@ -77,45 +81,194 @@ Device Management Core Bundle io.entgra.device.mgt.core.device.mgt.core.internal - org.apache.axis2.*;version="${axis2.osgi.version.range}", + com.fasterxml.jackson.databind;version="[2.13,3)", + com.google.common.collect;version="[31.0,32)", + com.google.common.reflect;version="[31.0,32)", + com.google.gson;version="[2.9,3)", + com.google.gson.reflect;version="[2.9,3)", + io.entgra.device.mgt.core.apimgt.annotations;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.app.mgt.android;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.app.mgt.ios;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.authorization;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.configuration.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.cost.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.device.details;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.enrollment.notification;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.event.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.general;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.geo.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.invitation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.license.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.notification.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.otp.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.pull.notification;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.report.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.roles.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.search;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.type.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.app.mgt.config, + io.entgra.device.mgt.core.device.mgt.core.archival, + io.entgra.device.mgt.core.device.mgt.core.archival.dao, + io.entgra.device.mgt.core.device.mgt.core.archival.dao.impl, + io.entgra.device.mgt.core.device.mgt.core.cache, + io.entgra.device.mgt.core.device.mgt.core.cache.impl, + io.entgra.device.mgt.core.device.mgt.core.common.exception, + io.entgra.device.mgt.core.device.mgt.core.common.util, + io.entgra.device.mgt.core.device.mgt.core.config, + io.entgra.device.mgt.core.device.mgt.core.config.analytics, + io.entgra.device.mgt.core.device.mgt.core.config.analytics.operation, + io.entgra.device.mgt.core.device.mgt.core.config.archival, + io.entgra.device.mgt.core.device.mgt.core.config.cache, + io.entgra.device.mgt.core.device.mgt.core.config.datasource, + io.entgra.device.mgt.core.device.mgt.core.config.enrollment.guide, + io.entgra.device.mgt.core.device.mgt.core.config.geo.location, + io.entgra.device.mgt.core.device.mgt.core.config.identity, + io.entgra.device.mgt.core.device.mgt.core.config.keymanager, + io.entgra.device.mgt.core.device.mgt.core.config.license, + io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt, + io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.whitelabel, + io.entgra.device.mgt.core.device.mgt.core.config.operation.timeout, + io.entgra.device.mgt.core.device.mgt.core.config.pagination, + io.entgra.device.mgt.core.device.mgt.core.config.permission, + io.entgra.device.mgt.core.device.mgt.core.config.policy, + io.entgra.device.mgt.core.device.mgt.core.config.pull.notification, + io.entgra.device.mgt.core.device.mgt.core.config.push.notification, + io.entgra.device.mgt.core.device.mgt.core.config.remote.session, + io.entgra.device.mgt.core.device.mgt.core.config.status.task, + io.entgra.device.mgt.core.device.mgt.core.config.task, + io.entgra.device.mgt.core.device.mgt.core.config.tenant, + io.entgra.device.mgt.core.device.mgt.core.config.ui, + io.entgra.device.mgt.core.device.mgt.core.dao, + io.entgra.device.mgt.core.device.mgt.core.dao.impl, + io.entgra.device.mgt.core.device.mgt.core.dao.impl.device, + io.entgra.device.mgt.core.device.mgt.core.dao.impl.enrolment, + io.entgra.device.mgt.core.device.mgt.core.dao.impl.event, + io.entgra.device.mgt.core.device.mgt.core.dao.impl.geofence, + io.entgra.device.mgt.core.device.mgt.core.dao.impl.group, + io.entgra.device.mgt.core.device.mgt.core.dao.impl.tracker, + io.entgra.device.mgt.core.device.mgt.core.device.details.mgt, + io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao, + io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao.impl, + io.entgra.device.mgt.core.device.mgt.core.dto, + io.entgra.device.mgt.core.device.mgt.core.dto.event.config, + io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt, + io.entgra.device.mgt.core.device.mgt.core.geo.geoHash, + io.entgra.device.mgt.core.device.mgt.core.geo.task, + io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao, + io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.impl, + io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util, + io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.util, + io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao, + io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.impl, + io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao, + io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl, + io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.operation, + io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util, + io.entgra.device.mgt.core.device.mgt.core.operation.mgt.util, + io.entgra.device.mgt.core.device.mgt.core.operation.timeout.task, + io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao, + io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl, + io.entgra.device.mgt.core.device.mgt.core.otp.mgt.exception, + io.entgra.device.mgt.core.device.mgt.core.otp.mgt.util, + io.entgra.device.mgt.core.device.mgt.core.privacy, + io.entgra.device.mgt.core.device.mgt.core.privacy.dao, + io.entgra.device.mgt.core.device.mgt.core.privacy.dao.impl, + io.entgra.device.mgt.core.device.mgt.core.report.mgt, + io.entgra.device.mgt.core.device.mgt.core.report.mgt.config, + io.entgra.device.mgt.core.device.mgt.core.search.mgt, + io.entgra.device.mgt.core.device.mgt.core.search.mgt.dao, + io.entgra.device.mgt.core.device.mgt.core.status.task, + io.entgra.device.mgt.core.device.mgt.core.task, + io.entgra.device.mgt.core.device.mgt.core.traccar.api.service, + io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.impl, + io.entgra.device.mgt.core.device.mgt.core.traccar.common.beans, + io.entgra.device.mgt.core.device.mgt.core.traccar.common.config, + io.entgra.device.mgt.core.device.mgt.core.traccar.common.util, + io.entgra.device.mgt.core.device.mgt.core.traccar.core.config, + io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="[5.0,6)", + io.entgra.device.mgt.core.notification.logger;version="[5.0,6)", + io.entgra.device.mgt.core.notification.logger.impl;version="[5.0,6)", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="[5.0,6)", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="[5.0,6)", + io.entgra.device.mgt.core.transport.mgt.email.sender.core;version="[5.0,6)", + io.entgra.device.mgt.core.transport.mgt.email.sender.core.service;version="[5.0,6)", + io.swagger.annotations;version="[1.6,2)",javax.cache;version="[1.0,2)", + javax.naming,javax.net.ssl,javax.servlet;version="[2.6,3)", + javax.sql,javax.ws.rs,javax.xml.bind;version="[0.0,1)", + javax.xml.bind.annotation;version="[0.0,1)", + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", + javax.xml.stream;version="[1.0,2)", + okhttp3, + org.apache.axis2;version="[1.6,2)", + org.apache.axis2.client;version="[1.6,2)", + org.apache.axis2.context;version="[1.6,2)", + org.apache.axis2.java.security;version="[1.6,2)", + org.apache.axis2.transport.http;version="[1.6,2)", + org.apache.catalina;version="${catalina.version.range}", + org.apache.catalina.core;version="${catalina.version.range}", + org.apache.commons.codec.binary;version="[1.4,2)", + org.apache.commons.collections.map;version="[3.2,4)", + org.apache.commons.httpclient;version="[3.1,4)", + org.apache.commons.httpclient.protocol;version="[3.1,4)", + org.apache.commons.io;version="[2.0,3)", + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.lang3;version="[3.1,4)", + org.apache.commons.logging;version="[1.2,2)", + org.apache.commons.validator.routines;version="[1.7,2)", + org.apache.http;version="[4.4,5)", + org.apache.http.client.methods;version="[4.3,5)", + org.apache.http.entity;version="[4.4,5)", + org.apache.http.impl.client;version="[4.3,5)", + org.apache.http.util;version="[4.4,5)", + org.apache.solr.common;version="[8.11,9)", + org.json;version="[3.0,4)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - javax.naming, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - javax.servlet.*, - org.xml.sax, - javax.sql.*, - org.wso2.carbon.context, - org.wso2.carbon.core, - org.wso2.carbon.utils.*, - io.entgra.device.mgt.core.device.mgt.common.*, - org.wso2.carbon.user.api, - org.wso2.carbon.user.core.*, - org.wso2.carbon.registry.core.service, + org.scannotation;version="[1.0,2)", + org.scannotation.archiveiterator;version="[1.0,2)", + org.w3c.dom, + org.wso2.carbon.base, + + + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.core;version="[4.8,5)", + org.wso2.carbon.core.util;version="[4.8,5)", + org.wso2.carbon.event.processor.stub;version="[2.3,3)", + org.wso2.carbon.event.processor.stub.types;version="[2.3,3)", + org.wso2.carbon.ndatasource.core;version="[4.8,5)", + org.wso2.carbon.ntask.common, + org.wso2.carbon.ntask.core, + org.wso2.carbon.ntask.core.service, + org.wso2.carbon.registry.api, org.wso2.carbon.registry.core, org.wso2.carbon.registry.core.exceptions, + org.wso2.carbon.registry.core.service, org.wso2.carbon.registry.core.session, - org.wso2.carbon.registry.api, - org.w3c.dom, - org.wso2.carbon.identity.oauth.stub, - org.wso2.carbon.identity.oauth.stub.dto, - org.wso2.carbon.ndatasource.core, - org.wso2.carbon.ntask.core.*, - org.wso2.carbon.ntask.common, - io.entgra.device.mgt.core.task.mgt.common.*, - org.apache.commons.collections;version="${commons-collections.version.range}", - io.entgra.device.mgt.core.email.sender.*, - io.swagger.annotations.*;resolution:=optional, - org.wso2.carbon, - org.wso2.carbon.base, - org.scannotation.*, - org.wso2.carbon.event.processor.stub, - io.entgra.device.mgt.core.identity.jwt.client.extension.service, - org.apache.commons.codec.binary, - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon, - io.entgra.device.mgt.core.device.mgt.extensions.logger.*, - io.entgra.device.mgt.core.notification.logger.* + org.wso2.carbon.stratos.common.beans;version="[4.7,5)", + org.wso2.carbon.stratos.common.util;version="[4.7,5)", + org.wso2.carbon.tenant.mgt.services, + org.wso2.carbon.user.api, + org.wso2.carbon.user.core.config;version="[4.8,5)", + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.user.core.tenant;version="[4.8,5)", + org.wso2.carbon.utils;version="[4.8,5)", + org.wso2.carbon.utils.dbcreator;version="[4.8,5)" !io.entgra.device.mgt.core.device.mgt.core.internal, @@ -149,15 +302,12 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services + org.apache.felix + org.apache.felix.scr.ds-annotations + provided - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation @@ -212,10 +362,12 @@ org.wso2.carbon org.wso2.carbon.registry.api + provided org.wso2.carbon org.wso2.carbon.registry.core + provided org.apache.tomcat.wso2 @@ -237,14 +389,6 @@ org.apache.ws.commons.axiom.wso2 axiom - org.apache.axis2.wso2 axis2 @@ -325,6 +469,7 @@ org.javassist javassist + provided org.powermock @@ -362,6 +507,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.notification.logger + provided diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java index 3a5fa2d6f7..a6155ccc8c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java @@ -18,14 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.core; import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.DeviceStatusTaskPluginConfig; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidConfigurationException; import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; import io.entgra.device.mgt.core.device.mgt.common.ProvisioningConfig; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidConfigurationException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationStrategy; @@ -49,6 +46,9 @@ import io.entgra.device.mgt.core.device.mgt.core.status.task.impl.DeviceStatusTa import io.entgra.device.mgt.core.device.mgt.core.task.DeviceMgtTaskException; import io.entgra.device.mgt.core.device.mgt.core.task.DeviceTaskManagerService; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.util.Collections; import java.util.HashMap; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java index ebf7dc443e..627aecf659 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java @@ -19,18 +19,14 @@ package io.entgra.device.mgt.core.device.mgt.core.app.mgt; import com.google.gson.Gson; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceDetailsWrapper; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; @@ -41,6 +37,10 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOExceptio import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.util.HttpReportingUtil; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import java.sql.SQLException; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/config/AppManagementConfigurationManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/config/AppManagementConfigurationManager.java index 5c755616ef..130a629789 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/config/AppManagementConfigurationManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/config/AppManagementConfigurationManager.java @@ -18,9 +18,9 @@ package io.entgra.device.mgt.core.device.mgt.core.app.mgt.config; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.w3c.dom.Document; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/oauth/ServiceAuthenticator.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/oauth/ServiceAuthenticator.java index cb3b519158..301d1b1634 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/oauth/ServiceAuthenticator.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/oauth/ServiceAuthenticator.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.core.app.mgt.oauth; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; import org.apache.axis2.client.Options; import org.apache.axis2.client.ServiceClient; import org.apache.axis2.transport.http.HttpTransportProperties; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; /** * Authenticate a given service client. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/ArchivalServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/ArchivalServiceImpl.java index d78e08efb6..db6be2f8f1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/ArchivalServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/ArchivalServiceImpl.java @@ -18,15 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.core.archival; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; +import io.entgra.device.mgt.core.device.mgt.core.archival.dao.*; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDAO; -import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDAOException; -import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDestinationDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalSourceDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.archival.dao.DataDeletionDAO; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import java.sql.SQLException; import java.sql.Timestamp; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/ArchivalDestinationDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/ArchivalDestinationDAOFactory.java index 0cd663e001..f1fb05d2eb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/ArchivalDestinationDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/ArchivalDestinationDAOFactory.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.archival.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.core.archival.dao.impl.DataDeletionDAOImpl; @@ -28,6 +26,8 @@ import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceCon import io.entgra.device.mgt.core.device.mgt.core.config.datasource.JNDILookupDefinition; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/ArchivalSourceDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/ArchivalSourceDAOFactory.java index 4d5c9b96cd..d06ce8a411 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/ArchivalSourceDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/ArchivalSourceDAOFactory.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.archival.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.core.archival.dao.impl.ArchivalDAOImpl; @@ -29,6 +27,8 @@ import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceCon import io.entgra.device.mgt.core.device.mgt.core.config.datasource.JNDILookupDefinition; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/ArchivalDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/ArchivalDAOImpl.java index e4b6aac52c..54a20b8670 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/ArchivalDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/ArchivalDAOImpl.java @@ -18,21 +18,12 @@ package io.entgra.device.mgt.core.device.mgt.core.archival.dao.impl; +import io.entgra.device.mgt.core.device.mgt.core.archival.dao.*; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDAO; -import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDAOException; -import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDAOUtil; -import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDestinationDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalSourceDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/DataDeletionDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/DataDeletionDAOImpl.java index 324d7a316f..ffc7841b5b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/DataDeletionDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/DataDeletionDAOImpl.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.core.archival.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDAOException; import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDestinationDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.archival.dao.DataDeletionDAO; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java index 0bbcab246d..2aec915d1e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java @@ -18,23 +18,24 @@ package io.entgra.device.mgt.core.device.mgt.core.authorization; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAuthorizationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.CarbonConstants; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; + import java.util.Iterator; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheManager.java index b65f4a5221..692ba65f91 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheManager.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.device.mgt.core.cache; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/impl/BillingCacheManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/impl/BillingCacheManagerImpl.java index 068b28c935..8db28e6bd7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/impl/BillingCacheManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/impl/BillingCacheManagerImpl.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.core.cache.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.cache.BillingCacheKey; import io.entgra.device.mgt.core.device.mgt.core.cache.BillingCacheManager; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.cache.Cache; import java.sql.Timestamp; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/impl/DeviceCacheManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/impl/DeviceCacheManagerImpl.java index 6243e617cc..2e37edd95d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/impl/DeviceCacheManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/impl/DeviceCacheManagerImpl.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.core.cache.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.core.cache.DeviceCacheKey; import io.entgra.device.mgt.core.device.mgt.core.cache.DeviceCacheManager; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.cache.Cache; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/FileUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/FileUtil.java index 04ba70443c..d645141d38 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/FileUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/FileUtil.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.device.mgt.core.common.util; -import org.apache.commons.io.FileUtils; import io.entgra.device.mgt.core.device.mgt.common.Base64File; +import org.apache.commons.io.FileUtils; import java.io.ByteArrayInputStream; import java.io.File; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/HttpUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/HttpUtil.java index 919e86a9fd..1a96c9d9d1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/HttpUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/HttpUtil.java @@ -17,13 +17,14 @@ */ package io.entgra.device.mgt.core.device.mgt.core.common.util; +import io.entgra.device.mgt.core.device.mgt.core.common.Constants; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.StringUtils; import org.apache.commons.validator.routines.UrlValidator; import org.apache.http.HttpResponse; import org.apache.http.entity.ContentType; import org.apache.http.util.EntityUtils; -import io.entgra.device.mgt.core.device.mgt.core.common.Constants; + import java.io.IOException; import java.net.URI; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/StorageManagementUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/StorageManagementUtil.java index 09f4600281..16b4e42bad 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/StorageManagementUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/StorageManagementUtil.java @@ -18,18 +18,12 @@ package io.entgra.device.mgt.core.device.mgt.core.common.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Base64File; import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagementException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; +import java.io.*; import java.nio.file.Files; /** diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/DeviceConfigurationManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/DeviceConfigurationManager.java index ee8c992cdc..ffabb2ec4a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/DeviceConfigurationManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/DeviceConfigurationManager.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.core.config; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.w3c.dom.Document; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/DeviceManagementConfig.java index 51c07e05c4..8841ac31ce 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/DeviceManagementConfig.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/DeviceManagementConfig.java @@ -26,12 +26,11 @@ import io.entgra.device.mgt.core.device.mgt.core.config.cache.CertificateCacheCo import io.entgra.device.mgt.core.device.mgt.core.config.cache.DeviceCacheConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.cache.GeoFenceCacheConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.enrollment.guide.EnrollmentGuideConfiguration; -import io.entgra.device.mgt.core.device.mgt.core.config.operation.timeout.OperationTimeoutConfiguration; -import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; -import io.entgra.device.mgt.core.device.mgt.core.event.config.EventOperationTaskConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.geo.location.GeoLocationConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.identity.IdentityConfigurations; import io.entgra.device.mgt.core.device.mgt.core.config.keymanager.KeyManagerConfigurations; +import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; +import io.entgra.device.mgt.core.device.mgt.core.config.operation.timeout.OperationTimeoutConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.pagination.PaginationConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.policy.PolicyConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.pull.notification.PullNotificationConfiguration; @@ -39,6 +38,7 @@ import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.PushNo import io.entgra.device.mgt.core.device.mgt.core.config.remote.session.RemoteSessionConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.status.task.DeviceStatusTaskConfig; import io.entgra.device.mgt.core.device.mgt.core.config.task.TaskConfiguration; +import io.entgra.device.mgt.core.device.mgt.core.event.config.EventOperationTaskConfiguration; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/license/LicenseConfigurationManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/license/LicenseConfigurationManager.java index b7cf1ff6fc..9bbfef6cdd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/license/LicenseConfigurationManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/license/LicenseConfigurationManager.java @@ -20,10 +20,10 @@ package io.entgra.device.mgt.core.device.mgt.core.config.license; -import org.w3c.dom.Document; -import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.license.mgt.LicenseManagementException; +import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.w3c.dom.Document; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/permission/AnnotationProcessor.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/permission/AnnotationProcessor.java index 6fd15af267..a79316c762 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/permission/AnnotationProcessor.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/permission/AnnotationProcessor.java @@ -19,22 +19,14 @@ package io.entgra.device.mgt.core.device.mgt.core.config.permission; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; import io.swagger.annotations.SwaggerDefinition; import org.apache.catalina.core.StandardContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; import javax.servlet.ServletContext; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HttpMethod; -import javax.ws.rs.OPTIONS; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import java.io.File; import java.io.IOException; import java.lang.annotation.Annotation; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/permission/lifecycle/WebAppDeploymentLifecycleListener.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/permission/lifecycle/WebAppDeploymentLifecycleListener.java index 56163440b8..7fb91b1d95 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/permission/lifecycle/WebAppDeploymentLifecycleListener.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/permission/lifecycle/WebAppDeploymentLifecycleListener.java @@ -18,17 +18,17 @@ package io.entgra.device.mgt.core.device.mgt.core.config.permission.lifecycle; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagerService; +import io.entgra.device.mgt.core.device.mgt.core.config.permission.AnnotationProcessor; +import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleEvent; import org.apache.catalina.LifecycleListener; import org.apache.catalina.core.StandardContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagerService; -import io.entgra.device.mgt.core.device.mgt.core.config.permission.AnnotationProcessor; -import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; import javax.servlet.ServletContext; import java.io.IOException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/tenant/PlatformConfigurationManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/tenant/PlatformConfigurationManagementServiceImpl.java index 64e44bfd64..d26974a835 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/tenant/PlatformConfigurationManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/tenant/PlatformConfigurationManagementServiceImpl.java @@ -17,15 +17,15 @@ */ package io.entgra.device.mgt.core.device.mgt.core.config.tenant; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; import io.entgra.device.mgt.core.device.mgt.core.config.ConfigurationManagerConstants; import io.entgra.device.mgt.core.device.mgt.core.config.util.ConfigurationManagerUtil; -import org.wso2.carbon.registry.api.Resource; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.registry.api.RegistryException; +import org.wso2.carbon.registry.api.Resource; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/ui/UIConfigurationManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/ui/UIConfigurationManager.java index e717786b59..a9becf6019 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/ui/UIConfigurationManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/ui/UIConfigurationManager.java @@ -18,12 +18,12 @@ package io.entgra.device.mgt.core.device.mgt.core.config.ui; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Document; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/util/ConfigurationManagerUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/util/ConfigurationManagerUtil.java index b65515fac3..4cd83fa064 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/util/ConfigurationManagerUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/util/ConfigurationManagerUtil.java @@ -17,9 +17,9 @@ */ package io.entgra.device.mgt.core.device.mgt.core.config.util; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Registry; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/ApplicationDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/ApplicationDAO.java index 626b05538a..55a513feca 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/ApplicationDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/ApplicationDAO.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java index 8ba7d64412..a1e2792bea 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java @@ -35,16 +35,16 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; -import org.apache.commons.collections.map.SingletonMap; import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo.Status; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.DevicePropertyInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceData; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocationHistorySnapshot; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceMonitoringData; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoQuery; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; +import org.apache.commons.collections.map.SingletonMap; import java.sql.SQLException; import java.sql.Timestamp; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java index 700b289a4b..0726bd6d18 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java @@ -18,15 +18,15 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnsupportedDatabaseEngineException; import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.device.mgt.core.config.datasource.JNDILookupDefinition; -import io.entgra.device.mgt.core.device.mgt.core.dao.impl.*; +import io.entgra.device.mgt.core.device.mgt.core.dao.impl.ApplicationDAOImpl; +import io.entgra.device.mgt.core.device.mgt.core.dao.impl.DeviceStatusDAOImpl; +import io.entgra.device.mgt.core.device.mgt.core.dao.impl.DeviceTypeDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.device.GenericDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.device.OracleDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.device.PostgreSQLDeviceDAOImpl; @@ -39,6 +39,8 @@ import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao.DeviceDe import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao.impl.DeviceDetailsDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.privacy.dao.PrivacyComplianceDAO; import io.entgra.device.mgt.core.device.mgt.core.privacy.dao.impl.PrivacyComplianceDAOImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusDAO.java index bd278a5c67..58c6b6062e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusDAO.java @@ -18,9 +18,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo.Status; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceStatus; import java.util.Date; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java index 67101585de..fb2f071aaf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java @@ -22,7 +22,6 @@ import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo.Status; -import java.sql.Timestamp; import java.util.List; public interface EnrollmentDAO { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EventConfigDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EventConfigDAO.java index 2776ffe10f..31d09e55b9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EventConfigDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EventConfigDAO.java @@ -21,7 +21,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; import java.util.List; -import java.util.Map; public interface EventConfigDAO { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EventManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EventManagementDAOFactory.java index 8640c3bef8..e71db748e6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EventManagementDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EventManagementDAOFactory.java @@ -18,20 +18,19 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnsupportedDatabaseEngineException; import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.device.mgt.core.config.datasource.JNDILookupDefinition; -import io.entgra.device.mgt.core.device.mgt.core.dao.impl.*; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.event.GenericEventConfigDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.event.H2EventConfigDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.geofence.GenericGeofenceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.geofence.SQLServerGeofenceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 96e056c262..e32f0b96c0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -38,7 +38,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.ReportManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupManagementDAOFactory.java index 3e629e45c1..10817ccfdf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupManagementDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupManagementDAOFactory.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; @@ -31,6 +29,8 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.impl.group.OracleGroupDAOIm import io.entgra.device.mgt.core.device.mgt.core.dao.impl.group.PostgreSQLGroupDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.group.SQLServerGroupDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.GroupManagementDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TrackerManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TrackerManagementDAOFactory.java index ebf658e9b6..152c1ea959 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TrackerManagementDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TrackerManagementDAOFactory.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; @@ -28,6 +26,8 @@ import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceCon import io.entgra.device.mgt.core.device.mgt.core.config.datasource.JNDILookupDefinition; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.tracker.TrackerDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 072cb742b1..b806b2eb69 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -36,9 +36,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; -import org.apache.commons.collections.map.SingletonMap; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; @@ -48,28 +45,21 @@ import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.DevicePrope import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceData; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocationHistorySnapshot; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceMonitoringData; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCoordinate; import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoQuery; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCoordinate; +import org.apache.commons.collections.map.SingletonMap; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.LogFactory; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; +import java.sql.*; import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; +import java.util.*; public abstract class AbstractDeviceDAOImpl implements DeviceDAO { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index dd1241c505..e707113d1f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -18,7 +18,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; @@ -26,13 +25,9 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOExceptio import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.EnrollmentDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import org.wso2.carbon.context.PrivilegedCarbonContext; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEventConfigDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEventConfigDAO.java index f6fb072b2e..1d7655d8d6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEventConfigDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEventConfigDAO.java @@ -18,24 +18,20 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.EventConfigDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOFactory; +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.sql.Timestamp; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; public abstract class AbstractEventConfigDAO implements EventConfigDAO { private static final Log log = LogFactory.getLog(AbstractEventConfigDAO.class); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGeofenceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGeofenceDAOImpl.java index 28a59fd391..630d55a012 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGeofenceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGeofenceDAOImpl.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; @@ -28,21 +26,12 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOExceptio import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.GeofenceDAO; import io.entgra.device.mgt.core.device.mgt.core.dto.event.config.GeoFenceGroupMap; +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.sql.Statement; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Collections; +import java.sql.*; import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; public abstract class AbstractGeofenceDAOImpl implements GeofenceDAO { private static final Log log = LogFactory.getLog(AbstractGeofenceDAOImpl.class); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index f1da6e3269..115ad8a7bb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -35,9 +35,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; @@ -47,16 +44,15 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dao.util.GroupManagementDAOUtil; +import org.apache.commons.lang.StringUtils; +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.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; +import java.util.*; /** * This class represents implementation of GroupDAO diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/ApplicationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/ApplicationDAOImpl.java index c4f1d7a6db..a85dc0fe0a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/ApplicationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/ApplicationDAOImpl.java @@ -18,15 +18,14 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.core.dao.ApplicationDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; - +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/DeviceStatusDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/DeviceStatusDAOImpl.java index d80bc78022..df91913cb6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/DeviceStatusDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/DeviceStatusDAOImpl.java @@ -5,7 +5,6 @@ import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceStatus; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceStatusDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.EnrollmentDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import java.sql.*; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java index 77abcbe484..4c0625f056 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java @@ -35,9 +35,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; import com.google.gson.Gson; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; @@ -46,19 +43,11 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceTypeDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeVersion; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.nio.file.Files; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 400bb8c3f3..6d247250e7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -18,25 +18,17 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.device; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.Count; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; +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.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index 1da26e841c..849babdb8b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -18,12 +18,8 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.device; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Count; import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceBilling; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; @@ -31,13 +27,11 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; +import org.apache.commons.lang.StringUtils; +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.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index 7b72d1edf3..f5ee804bf4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -18,12 +18,8 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.device; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Count; import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceBilling; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; @@ -31,12 +27,10 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; +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.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 3d695e0670..ce8fd9e9db 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -18,27 +18,20 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.device; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Count; import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceBilling; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCoordinate; import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; +import org.apache.commons.lang.StringUtils; +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.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/GenericEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/GenericEnrollmentDAOImpl.java index 09f27ca257..4a1415f2f7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/GenericEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/GenericEnrollmentDAOImpl.java @@ -18,7 +18,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.enrolment; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; @@ -26,6 +25,7 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOExceptio import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractEnrollmentDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.*; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/SQLServerEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/SQLServerEnrollmentDAOImpl.java index 0bc07bfa55..a4b0b3874f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/SQLServerEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/SQLServerEnrollmentDAOImpl.java @@ -18,7 +18,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.enrolment; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; @@ -26,6 +25,8 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOExceptio import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractEnrollmentDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import org.wso2.carbon.context.PrivilegedCarbonContext; + import java.sql.*; import java.util.ArrayList; import java.util.Date; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/event/GenericEventConfigDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/event/GenericEventConfigDAOImpl.java index 3f3b0fad60..04131e40b8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/event/GenericEventConfigDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/event/GenericEventConfigDAOImpl.java @@ -18,19 +18,14 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.event; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractEventConfigDAO; +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.sql.Statement; -import java.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/event/H2EventConfigDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/event/H2EventConfigDAOImpl.java index 3b89c9d0f1..1afce08917 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/event/H2EventConfigDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/event/H2EventConfigDAOImpl.java @@ -18,20 +18,14 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.event; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractEventConfigDAO; +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.sql.Statement; -import java.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java index cc1f6349d6..6b84531dea 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java @@ -18,17 +18,16 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.geofence; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeofenceData; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.GeofenceDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractGeofenceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dto.event.config.GeoFenceGroupMap; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.*; import java.util.Date; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java index 0fdb37441b..7d4d74221f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java @@ -18,21 +18,21 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.geofence; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeofenceData; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.GeofenceDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractGeofenceDAOImpl; -import io.entgra.device.mgt.core.device.mgt.core.dto.event.config.GeoFenceGroupMap; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.sql.*; -import java.util.Date; -import java.util.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public class SQLServerGeofenceDAOImpl extends AbstractGeofenceDAOImpl { private static final Log log = LogFactory.getLog(SQLServerGeofenceDAOImpl.class); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/OracleGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/OracleGroupDAOImpl.java index eec782e874..fcfdacdb51 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/OracleGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/OracleGroupDAOImpl.java @@ -35,7 +35,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.group; -import org.apache.commons.lang.StringUtils; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; @@ -44,6 +43,7 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractGroupDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dao.util.GroupManagementDAOUtil; +import org.apache.commons.lang.StringUtils; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java index 128fcf0fb9..d1df92f20a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java @@ -35,7 +35,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.group; -import org.apache.solr.common.StringUtils; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; @@ -43,6 +42,7 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractGroupDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dao.util.GroupManagementDAOUtil; +import org.apache.solr.common.StringUtils; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/SQLServerGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/SQLServerGroupDAOImpl.java index 22d249103f..37db6d2e21 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/SQLServerGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/SQLServerGroupDAOImpl.java @@ -35,7 +35,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.group; -import org.apache.commons.lang.StringUtils; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; @@ -44,6 +43,7 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractGroupDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dao.util.GroupManagementDAOUtil; +import org.apache.commons.lang.StringUtils; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/tracker/TrackerDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/tracker/TrackerDAOImpl.java index 915ef7073e..fced5f2149 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/tracker/TrackerDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/tracker/TrackerDAOImpl.java @@ -18,18 +18,16 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.tracker; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.TrackerDeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.TrackerGroupInfo; import io.entgra.device.mgt.core.device.mgt.common.TrackerPermissionInfo; -import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.TrackerManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.traccar.common.TraccarHandlerConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java index 0b5281352d..e357af55e1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java @@ -17,34 +17,32 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao.util; -import java.sql.*; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.*; -import java.util.Date; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.el.lang.ELSupport; -import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceBilling; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocationHistorySnapshot; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceMonitoringData; -import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceStatus; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.tenant.TenantManager; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import javax.naming.InitialContext; import javax.sql.DataSource; +import java.sql.*; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Date; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Map; public final class DeviceManagementDAOUtil { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java index 9be9b835a8..82ab942c78 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java @@ -34,9 +34,9 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.util; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import javax.naming.InitialContext; import javax.sql.DataSource; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/TrackerManagementDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/TrackerManagementDAOUtil.java index 62f0c33257..fc2981c0c0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/TrackerManagementDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/TrackerManagementDAOUtil.java @@ -17,12 +17,12 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.TrackerDeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.TrackerGroupInfo; import io.entgra.device.mgt.core.device.mgt.common.TrackerPermissionInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.naming.InitialContext; import javax.sql.DataSource; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/DeviceInformationManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/DeviceInformationManager.java index 177c674bb8..993bdec9dd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/DeviceInformationManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/DeviceInformationManager.java @@ -21,10 +21,8 @@ package io.entgra.device.mgt.core.device.mgt.core.device.details.mgt; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocation; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/dao/DeviceDetailsDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/dao/DeviceDetailsDAO.java index a09936c510..75747a31d8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/dao/DeviceDetailsDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/dao/DeviceDetailsDAO.java @@ -20,7 +20,6 @@ package io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao; import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocation; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/dao/impl/DeviceDetailsDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/dao/impl/DeviceDetailsDAOImpl.java index 60eaf9e3e3..09f23217cb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/dao/impl/DeviceDetailsDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/dao/impl/DeviceDetailsDAOImpl.java @@ -19,18 +19,17 @@ package io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao.impl; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocation; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao.DeviceDetailsDAO; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao.DeviceDetailsMgtDAOException; import io.entgra.device.mgt.core.device.mgt.core.geo.geoHash.GeoHashGenerator; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java index edd656c6f4..12e6609f02 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java @@ -18,10 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.impl; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceDetailsWrapper; @@ -45,15 +41,14 @@ import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import io.entgra.device.mgt.core.device.mgt.core.util.HttpReportingUtil; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.user.api.UserStoreException; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; +import java.util.*; public class DeviceInformationManagerImpl implements DeviceInformationManager { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceType.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceType.java index 1ca01a8bd4..f1c5fc2d17 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceType.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceType.java @@ -18,9 +18,9 @@ package io.entgra.device.mgt.core.device.mgt.core.dto; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import java.io.Serializable; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventConfigurationProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventConfigurationProviderServiceImpl.java index 186dc0bfd7..e4a3a8b21a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventConfigurationProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventConfigurationProviderServiceImpl.java @@ -19,27 +19,23 @@ package io.entgra.device.mgt.core.device.mgt.core.event.config; import com.google.common.collect.Lists; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationException; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationProviderService; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventMetaData; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import io.entgra.device.mgt.core.device.mgt.core.dao.*; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dao.EventConfigDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.geo.task.GeoFenceEventOperationManager; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.*; public class EventConfigurationProviderServiceImpl implements EventConfigurationProviderService { private static final Log log = LogFactory.getLog(EventConfigurationProviderServiceImpl.class); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventOperationExecutor.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventOperationExecutor.java index 5f261e48cb..517399ab95 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventOperationExecutor.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventOperationExecutor.java @@ -19,17 +19,10 @@ package io.entgra.device.mgt.core.device.mgt.core.event.config; import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationException; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventMetaData; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventOperation; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventRevokeOperation; +import io.entgra.device.mgt.core.device.mgt.common.event.config.*; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoFenceEventMeta; import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoLocationBasedServiceException; @@ -43,12 +36,11 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationMgtConst import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; /** * Event create/revoke operation creation task. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/GroupAssignmentEventOperationExecutor.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/GroupAssignmentEventOperationExecutor.java index 2aacb72801..4f207988f8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/GroupAssignmentEventOperationExecutor.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/GroupAssignmentEventOperationExecutor.java @@ -19,9 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.core.event.config; import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationException; @@ -40,6 +37,9 @@ import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHo import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationMgtConstants; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.util.ArrayList; import java.util.Arrays; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java index 88f0bb102c..22ccd060c2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java @@ -20,6 +20,27 @@ package io.entgra.device.mgt.core.device.mgt.core.geo.service; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants.GeoServices; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; +import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationException; +import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationProviderService; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.*; +import io.entgra.device.mgt.core.device.mgt.core.cache.impl.GeoCacheManagerImpl; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.core.dao.GeofenceDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import io.entgra.device.mgt.core.device.mgt.core.dto.event.config.GeoFenceGroupMap; +import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationMgtConstants; +import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.apache.axis2.AxisFault; import org.apache.axis2.client.Options; import org.apache.axis2.client.Stub; @@ -35,35 +56,8 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.Utils; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants.GeoServices; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationException; -import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationProviderService; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.Alert; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.AlertAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoFence; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoFenceEventMeta; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoLocationBasedServiceException; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoLocationProviderService; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeofenceData; -import io.entgra.device.mgt.core.device.mgt.core.cache.impl.GeoCacheManagerImpl; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.GeofenceDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import io.entgra.device.mgt.core.device.mgt.core.dto.event.config.GeoFenceGroupMap; -import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationMgtConstants; import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub; import org.wso2.carbon.event.processor.stub.types.ExecutionPlanConfigurationDto; -import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.registry.api.Registry; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; @@ -78,20 +72,10 @@ import java.io.InputStream; import java.io.StringWriter; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; +import java.security.*; import java.security.cert.CertificateException; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.util.*; import static io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants.GeoServices.DAS_PORT; import static io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants.GeoServices.DEFAULT_HTTP_PROTOCOL; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/task/GeoFenceEventOperationManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/task/GeoFenceEventOperationManager.java index e31bfedb3a..a360c60532 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/task/GeoFenceEventOperationManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/task/GeoFenceEventOperationManager.java @@ -18,14 +18,14 @@ package io.entgra.device.mgt.core.device.mgt.core.geo.task; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventMetaData; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.event.config.EventOperationExecutor; import io.entgra.device.mgt.core.device.mgt.core.event.config.GroupAssignmentEventOperationExecutor; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/ActivityDataPurgingServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/ActivityDataPurgingServiceComponent.java index fa7fcd7da9..edc1890188 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/ActivityDataPurgingServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/ActivityDataPurgingServiceComponent.java @@ -18,9 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.internal; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.service.component.ComponentContext; import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalDestinationDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.archival.dao.ArchivalSourceDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; @@ -29,26 +26,19 @@ import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceCon import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.task.ArchivalTaskManager; import io.entgra.device.mgt.core.device.mgt.core.task.impl.ArchivalTaskManagerImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.ntask.core.service.TaskService; -/** - * @scr.component name="org.wso2.carbon.activity.data.archival" immediate="true" - * @scr.reference name="device.ntask.component" - * interface="org.wso2.carbon.ntask.core.service.TaskService" - * cardinality="1..1" - * policy="dynamic" - * bind="setTaskService" - * unbind="unsetTaskService" - * @scr.reference name="org.wso2.carbon.device.manager" - * interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceManagementService" - * unbind="unsetDeviceManagementService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.core.internal.ActivityDataPurgingServiceComponent", + immediate = true) public class ActivityDataPurgingServiceComponent { private static Log log = LogFactory.getLog(ActivityDataPurgingServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -99,6 +89,12 @@ public class ActivityDataPurgingServiceComponent { } } + @Reference( + name = "task.service", + service = org.wso2.carbon.ntask.core.service.TaskService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTaskService") protected void setTaskService(TaskService taskService) { if (log.isDebugEnabled()) { log.debug("Setting the task service."); @@ -113,6 +109,12 @@ public class ActivityDataPurgingServiceComponent { DeviceManagementDataHolder.getInstance().setTaskService(null); } + @Reference( + name = "device.mgt.provider.service", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceManagementService") protected void setDeviceManagementService(DeviceManagementProviderService deviceManagementService){ } @@ -122,6 +124,7 @@ public class ActivityDataPurgingServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java index f9bed42c54..d3f17865ae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.internal; -import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceStatusTaskPluginConfig; import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManager; @@ -46,7 +44,9 @@ import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProvider import io.entgra.device.mgt.core.device.mgt.core.status.task.DeviceStatusTaskManagerService; import io.entgra.device.mgt.core.device.mgt.core.task.DeviceTaskManagerService; import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.DeviceAPIClientService; +import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; import io.entgra.device.mgt.core.transport.mgt.email.sender.core.service.EmailSenderService; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java index a95d8b2bc0..eca29df3ac 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -17,13 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.internal; -import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; -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.context.PrivilegedCarbonContext; -import org.wso2.carbon.core.ServerStartupObserver; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; @@ -86,7 +79,15 @@ import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.DeviceAPICl import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.impl.DeviceAPIClientServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagementSchemaInitializer; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; import io.entgra.device.mgt.core.transport.mgt.email.sender.core.service.EmailSenderService; +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.osgi.service.component.annotations.*; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; @@ -100,57 +101,9 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -/** - * @scr.component name="org.wso2.carbon.device.manager" immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="device.manager.service" - * interface="io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService" - * cardinality="0..n" - * policy="dynamic" - * bind="setDeviceManagementService" - * unbind="unsetDeviceManagementService" - * @scr.reference name="registry.service" - * interface="org.wso2.carbon.registry.core.service.RegistryService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRegistryService" - * unbind="unsetRegistryService" - * @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="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" - * policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - * @scr.reference name="email.sender.service" - * interface="io.entgra.device.mgt.core.transport.mgt.email.sender.core.service.EmailSenderService" - * cardinality="0..1" - * policy="dynamic" - * bind="setEmailSenderService" - * unbind="unsetEmailSenderService" - * @scr.reference name="device.type.generator.service" - * interface="io.entgra.device.mgt.core.device.mgt.common.spi.DeviceTypeGeneratorService" - * cardinality="0..1" - * policy="dynamic" - * bind="setDeviceTypeGeneratorService" - * unbind="unsetDeviceTypeGeneratorService" - * @scr.reference name="entgra.heart.beat.service" - * interface="io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService" - * cardinality="0..1" - * policy="dynamic" - * bind="setHeartBeatService" - * unbind="unsetHeartBeatService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementServiceComponent", + immediate = true) public class DeviceManagementServiceComponent { private static final Object LOCK = new Object(); @@ -179,6 +132,7 @@ public class DeviceManagementServiceComponent { } @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -278,6 +232,7 @@ public class DeviceManagementServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } @@ -442,6 +397,12 @@ public class DeviceManagementServiceComponent { * * @param deviceManagementService An instance of DeviceManagementService */ + @Reference( + name = "device.mgt.service", + service = io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService.class, + cardinality = ReferenceCardinality.MULTIPLE, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceManagementService") protected void setDeviceManagementService(DeviceManagementService deviceManagementService) { try { if (log.isDebugEnabled()) { @@ -482,6 +443,12 @@ public class DeviceManagementServiceComponent { * * @param realmService An instance of RealmService */ + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { log.debug("Setting Realm Service"); @@ -506,6 +473,12 @@ public class DeviceManagementServiceComponent { * * @param registryService An instance of RegistryService */ + @Reference( + name = "registry.service", + service = org.wso2.carbon.registry.core.service.RegistryService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRegistryService") protected void setRegistryService(RegistryService registryService) { if (log.isDebugEnabled()) { log.debug("Setting Registry Service"); @@ -530,6 +503,12 @@ public class DeviceManagementServiceComponent { * * @param heartBeatService An instance of HeartBeatManagementService */ + @Reference( + name = "heart.beat.service", + service = io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetHeartBeatService") protected void setHeartBeatService(HeartBeatManagementService heartBeatService) { if (log.isDebugEnabled()) { log.debug("Setting Heart Beat Service"); @@ -547,6 +526,12 @@ public class DeviceManagementServiceComponent { DeviceManagementDataHolder.getInstance().setHeartBeatService(null); } + @Reference( + name = "datasource.service", + service = org.wso2.carbon.ndatasource.core.DataSourceService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDataSourceService") protected void setDataSourceService(DataSourceService dataSourceService) { /* This is to avoid mobile device management component getting initialized before the underlying datasources are registered */ @@ -559,6 +544,12 @@ public class DeviceManagementServiceComponent { //do nothing } + @Reference( + name = "configuration.context.service", + service = org.wso2.carbon.utils.ConfigurationContextService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { if (log.isDebugEnabled()) { log.debug("Setting ConfigurationContextService"); @@ -573,6 +564,12 @@ public class DeviceManagementServiceComponent { DeviceManagementDataHolder.getInstance().setConfigurationContextService(null); } + @Reference( + name = "email.sender.service", + service = io.entgra.device.mgt.core.transport.mgt.email.sender.core.service.EmailSenderService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetEmailSenderService") protected void setEmailSenderService(EmailSenderService emailSenderService) { if (log.isDebugEnabled()) { log.debug("Setting Email Sender Service"); @@ -588,6 +585,12 @@ public class DeviceManagementServiceComponent { } + @Reference( + name = "device.task.service", + service = io.entgra.device.mgt.core.device.mgt.core.task.DeviceTaskManagerService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceTaskManagerService") protected void setDeviceTaskManagerService(DeviceTaskManagerService deviceTaskManagerService) { if (log.isDebugEnabled()) { } @@ -605,6 +608,12 @@ public class DeviceManagementServiceComponent { * * @param deviceTypeGeneratorService An Instance of DeviceTypeGeneratorService */ + @Reference( + name = "device.type.generator.service", + service = io.entgra.device.mgt.core.device.mgt.common.spi.DeviceTypeGeneratorService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceTypeGeneratorService") protected void setDeviceTypeGeneratorService(DeviceTypeGeneratorService deviceTypeGeneratorService) { if (log.isDebugEnabled()) { log.debug("Un setting Device DeviceTypeGeneratorService"); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java index 4d5c1e1d62..ea92f06679 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceTaskManagerServiceComponent.java @@ -18,10 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.internal; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceStatusTaskPluginConfig; import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; @@ -38,20 +34,17 @@ import io.entgra.device.mgt.core.device.mgt.core.status.task.impl.DeviceStatusTa import io.entgra.device.mgt.core.device.mgt.core.task.DeviceMgtTaskException; import io.entgra.device.mgt.core.device.mgt.core.task.DeviceTaskManagerService; import io.entgra.device.mgt.core.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl; +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.osgi.service.component.annotations.*; import org.wso2.carbon.ntask.core.service.TaskService; import java.util.Map; - -/** - * @scr.component name="org.wso2.carbon.device.task.manager" immediate="true" - * @scr.reference name="device.ntask.component" - * interface="org.wso2.carbon.ntask.core.service.TaskService" - * cardinality="1..1" - * policy="dynamic" - * bind="setTaskService" - * unbind="unsetTaskService" - */ - +@Component( + name = "io.entgra.device.mgt.core.device.mgt.core.internal.DeviceTaskManagerServiceComponent", + immediate = true) @SuppressWarnings("unused") public class DeviceTaskManagerServiceComponent { @@ -59,6 +52,7 @@ public class DeviceTaskManagerServiceComponent { private DeviceManagementConfig deviceManagementConfig; @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -133,6 +127,7 @@ public class DeviceTaskManagerServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { try { stopOperationMonitoringTask(); @@ -192,6 +187,12 @@ public class DeviceTaskManagerServiceComponent { } } + @Reference( + name = "task.service", + service = org.wso2.carbon.ntask.core.service.TaskService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTaskService") protected void setTaskService(TaskService taskService) { if (log.isDebugEnabled()) { log.debug("Setting the task service."); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/TenantCreateObserver.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/TenantCreateObserver.java index b6dddef4f2..a86cac3b5a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/TenantCreateObserver.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/TenantCreateObserver.java @@ -17,17 +17,13 @@ */ package io.entgra.device.mgt.core.device.mgt.core.internal; +import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; +import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants.User; import org.apache.axis2.context.ConfigurationContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants.User; -import org.wso2.carbon.user.api.AuthorizationManager; -import org.wso2.carbon.user.api.Permission; -import org.wso2.carbon.user.api.UserRealm; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.api.UserStoreManager; +import org.wso2.carbon.user.api.*; import org.wso2.carbon.utils.AbstractAxis2ConfigurationContextObserver; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/UserRoleCreateObserver.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/UserRoleCreateObserver.java index 1ec82618cf..9c309fb518 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/UserRoleCreateObserver.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/UserRoleCreateObserver.java @@ -17,10 +17,10 @@ */ package io.entgra.device.mgt.core.device.mgt.core.internal; +import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.core.ServerStartupObserver; -import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.user.api.AuthorizationManager; import org.wso2.carbon.user.api.Permission; import org.wso2.carbon.user.api.UserStoreException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java index 98e3b07723..1638763620 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java @@ -18,10 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; @@ -34,6 +30,11 @@ import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataDAO; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; + import java.sql.SQLException; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index 30419351e1..7a1fcb470a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -19,26 +19,13 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt; import com.google.gson.Gson; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Base64File; import io.entgra.device.mgt.core.device.mgt.common.FileResponse; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.NotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelImage; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelImageRequestPayload; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelManagementService; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelTheme; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.*; import io.entgra.device.mgt.core.device.mgt.core.common.util.HttpUtil; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; @@ -50,6 +37,14 @@ import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManage import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util.MetadataConstants; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.util.WhiteLabelStorageUtil; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.File; import java.io.IOException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/MetadataManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/MetadataManagementDAOFactory.java index 4fb2a99137..e3d3675b64 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/MetadataManagementDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/MetadataManagementDAOFactory.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; @@ -30,12 +28,14 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUti import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.impl.GenericMetadataDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.impl.OracleMetadataDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.impl.SQLServerMetadataDAOImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import javax.sql.DataSource; import java.sql.Connection; import java.sql.SQLException; import java.util.Hashtable; import java.util.List; -import javax.sql.DataSource; /** * DAO factory class to be used in MetadataManagement related functionalities. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/AbstractMetadataDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/AbstractMetadataDAOImpl.java index 459a9d6478..00e19a6a80 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/AbstractMetadataDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/AbstractMetadataDAOImpl.java @@ -18,19 +18,15 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataDAO; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util.MetadataDAOUtil; +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.sql.Statement; +import java.sql.*; /** * Implementation of MetadataDAO which includes the methods to do CRUD operations on metadata. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/GenericMetadataDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/GenericMetadataDAOImpl.java index c90cdac7bb..a00a770b7e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/GenericMetadataDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/GenericMetadataDAOImpl.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util.MetadataDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/OracleMetadataDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/OracleMetadataDAOImpl.java index 6215d1e5af..6f36d68451 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/OracleMetadataDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/OracleMetadataDAOImpl.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util.MetadataDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/SQLServerMetadataDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/SQLServerMetadataDAOImpl.java index 329748b5d9..57bf4ea481 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/SQLServerMetadataDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/impl/SQLServerMetadataDAOImpl.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util.MetadataDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/util/MetadataDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/util/MetadataDAOUtil.java index 1e966bed5a..385a5d9362 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/util/MetadataDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/dao/util/MetadataDAOUtil.java @@ -18,9 +18,9 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java index 841acae516..8ed691dd69 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java @@ -17,10 +17,6 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.util; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Base64File; import io.entgra.device.mgt.core.device.mgt.common.FileResponse; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; @@ -33,6 +29,9 @@ import io.entgra.device.mgt.core.device.mgt.core.common.util.StorageManagementUt import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.io.File; import java.io.IOException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java index 3e98cf9715..0552d6007c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java @@ -18,15 +18,12 @@ package io.entgra.device.mgt.core.device.mgt.core.notification.mgt; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceLoggerImpl; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.EntityDoesNotExistException; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.EntityDoesNotExistException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.NotificationManagementException; @@ -36,6 +33,9 @@ import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.Notificati import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceLoggerImpl; import java.sql.SQLException; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/NotificationManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/NotificationManagementDAOFactory.java index e95cec27b0..6fd5f53775 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/NotificationManagementDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/NotificationManagementDAOFactory.java @@ -18,16 +18,19 @@ package io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnsupportedDatabaseEngineException; import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.device.mgt.core.config.datasource.JNDILookupDefinition; -import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.impl.*; +import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.impl.GenericNotificationDAOImpl; +import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.impl.OracleNotificationDAOImpl; +import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.impl.PostgreSQLNotificationDAOImpl; +import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.impl.SQLServerNotificationDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/impl/AbstractNotificationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/impl/AbstractNotificationDAOImpl.java index 0b4a156518..e3c64eb6e6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/impl/AbstractNotificationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/impl/AbstractNotificationDAOImpl.java @@ -24,12 +24,7 @@ import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.Notificati import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/impl/OracleNotificationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/impl/OracleNotificationDAOImpl.java index 20c8019642..eaf6b26936 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/impl/OracleNotificationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/impl/OracleNotificationDAOImpl.java @@ -24,11 +24,7 @@ import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/util/NotificationDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/util/NotificationDAOUtil.java index fcd5cbb728..a748ed1683 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/util/NotificationDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/dao/util/NotificationDAOUtil.java @@ -18,12 +18,12 @@ package io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.util; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.NotificationManagementException; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.tenant.TenantManager; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index 1612c4db8f..ae2e0c6526 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -18,36 +18,14 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt; -import com.google.gson.Gson; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; -import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityStatus; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; -import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationContext; -import io.entgra.device.mgt.core.device.mgt.common.push.notification.NotificationStrategy; -import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; -import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationExecutionFailedException; -import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationProvider; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.*; +import io.entgra.device.mgt.core.device.mgt.common.push.notification.*; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.core.cache.impl.DeviceCacheManagerImpl; @@ -69,16 +47,15 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import io.entgra.device.mgt.core.device.mgt.core.task.DeviceTaskManager; import io.entgra.device.mgt.core.device.mgt.core.task.impl.DeviceTaskManagerImpl; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.SQLException; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executors; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerRepository.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerRepository.java index e8139ab7d0..a2993bab4e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerRepository.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerRepository.java @@ -18,8 +18,8 @@ */ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt; -import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeServiceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeServiceIdentifier; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java index 423578e591..fe37df535c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; @@ -32,6 +30,8 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.operatio import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.operation.OracleOperationDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.operation.PostgreSQLOperationDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.operation.SQLServerOperationDAOImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java index a5fdb56b69..c2e1de76c5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java @@ -18,22 +18,20 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; +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.sql.Timestamp; import java.util.ArrayList; -import java.util.Date; import java.util.List; public class CommandOperationDAOImpl extends GenericOperationDAOImpl { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java index f53f3fe8c7..c65a2c4f35 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java @@ -19,21 +19,19 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ConfigOperation; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.io.*; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationMSSQLDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationMSSQLDAOImpl.java index 813d02bbe9..0b274ac0fe 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationMSSQLDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationMSSQLDAOImpl.java @@ -19,25 +19,16 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ConfigOperation; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; +import java.io.*; +import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationPostgresDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationPostgresDAOImpl.java index c2e95bc2c7..af06d9d1c9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationPostgresDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ConfigOperationPostgresDAOImpl.java @@ -19,25 +19,16 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ConfigOperation; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; +import java.io.*; +import java.sql.*; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index 0de459b782..70fd0d707a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -17,9 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; @@ -37,23 +34,18 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationMana import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; +import java.sql.*; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java index f61fa5ccb1..8fe711a464 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/OperationMappingDAOImpl.java @@ -18,10 +18,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationEnrolmentMapping; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationMapping; @@ -29,15 +26,14 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationMana import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationMappingDAO; +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.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class OperationMappingDAOImpl implements OperationMappingDAO { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java index e0693c2f8b..ee2b80f6bd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java @@ -18,14 +18,14 @@ */ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.PolicyOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.io.*; import java.sql.*; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java index d50e068f9f..945f57054d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java @@ -18,19 +18,18 @@ */ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ProfileOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.io.*; import java.sql.*; import java.util.ArrayList; -import java.util.Date; import java.util.List; public class ProfileOperationDAOImpl extends GenericOperationDAOImpl { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java index 9859e468d6..fa606cab3e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/MySQLOperationDAOImpl.java @@ -18,9 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.operation; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityHolder; @@ -31,6 +28,9 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationMana import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.GenericOperationDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/OracleOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/OracleOperationDAOImpl.java index 33d455bbbc..dbde7931fd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/OracleOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/OracleOperationDAOImpl.java @@ -18,9 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.operation; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; @@ -32,6 +29,9 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationMana import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.GenericOperationDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; import java.sql.PreparedStatement; @@ -39,11 +39,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ArrayList; -import java.util.LinkedList; +import java.util.*; /** * This class holds the implementation of OperationDAO which can be used to support Oracle db syntax. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/PostgreSQLOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/PostgreSQLOperationDAOImpl.java index e2debfad6f..b9bf13e8bf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/PostgreSQLOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/PostgreSQLOperationDAOImpl.java @@ -27,16 +27,12 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationMana import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.GenericOperationDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; +import java.sql.*; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.ArrayList; /** * This class holds the implementation of OperationDAO which can be used to support PostgreSQL db syntax. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java index 6de5008fc8..a3edb87305 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/operation/SQLServerOperationDAOImpl.java @@ -35,15 +35,10 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.operation; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityHolder; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityStatus; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationResponse; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationMapping; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; @@ -51,19 +46,14 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationMana import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.GenericOperationDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; +import java.sql.*; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; /** * This class holds the implementation of OperationDAO which can be used to support SQLServer db syntax. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java index 5d6d192d65..09d6007cf2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java @@ -18,21 +18,14 @@ */ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.*; +import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; +import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; +import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.*; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityHolder; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityMapper; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityStatus; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationResponse; -import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation; -import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ConfigOperation; -import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; -import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.PolicyOperation; -import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ProfileOperation; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTask.java index 0351647824..19b21ab68a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTask.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTask.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.timeout.task.impl; import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityStatus; @@ -29,6 +27,8 @@ import io.entgra.device.mgt.core.device.mgt.core.config.operation.timeout.Operat import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.task.impl.DynamicPartitionedScheduleTask; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTaskManagerServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTaskManagerServiceImpl.java index 90e45395d3..8414f44a3b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTaskManagerServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/timeout/task/impl/OperationTimeoutTaskManagerServiceImpl.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.timeout.task.impl; import com.google.gson.Gson; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.config.operation.timeout.OperationTimeout; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.operation.timeout.task.OperationTimeoutTaskException; import io.entgra.device.mgt.core.device.mgt.core.operation.timeout.task.OperationTimeoutTaskManagerService; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.ntask.common.TaskException; import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskManager; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/OTPManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/OTPManagementDAOFactory.java index 9d0e804274..c8314ec97d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/OTPManagementDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/OTPManagementDAOFactory.java @@ -17,8 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnsupportedDatabaseEngineException; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl.GenericOTPManagementDAOImpl; @@ -26,6 +24,8 @@ import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl.OracleOTPManag import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl.PostgreSQLOTPManagementDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl.SQLServerOTPManagementDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.util.ConnectionManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java index 27c85d9fdb..2d22d2a114 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java @@ -17,20 +17,15 @@ package io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto.OneTimePinDTO; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.AbstractDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.OTPManagementDAO; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.exception.OTPManagementDAOException; +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.sql.Statement; -import java.sql.Timestamp; +import java.sql.*; import java.util.Calendar; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java index 5fc3f3de83..2f360e0aff 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java @@ -17,16 +17,8 @@ package io.entgra.device.mgt.core.device.mgt.core.otp.mgt.service; import com.google.gson.Gson; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.OTPManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.*; import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitation; import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitationDetails; import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentType; @@ -42,17 +34,15 @@ import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.util.ConnectionManagerU import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.EmailMetaInfo; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.user.api.Tenant; import org.wso2.carbon.user.api.UserStoreException; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.UUID; +import java.util.*; public class OTPManagementServiceImpl implements OTPManagementService { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/util/ConnectionManagerUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/util/ConnectionManagerUtil.java index 7af805b7ea..3f694e28d9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/util/ConnectionManagerUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/util/ConnectionManagerUtil.java @@ -17,11 +17,11 @@ */ package io.entgra.device.mgt.core.device.mgt.core.otp.mgt.util; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import javax.naming.InitialContext; import javax.sql.DataSource; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionNode.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionNode.java index d2f11b331c..18715f729b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionNode.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionNode.java @@ -20,11 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.core.permission.mgt; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * This class represents the node of a permission tree. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionTree.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionTree.java index 0fe785588b..1633db2ece 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionTree.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionTree.java @@ -18,9 +18,9 @@ package io.entgra.device.mgt.core.device.mgt.core.permission.mgt; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; import java.util.StringTokenizer; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionUtils.java index fc79156fa7..21c1cc3470 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionUtils.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.core.permission.mgt; -import org.w3c.dom.Document; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import org.w3c.dom.Document; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Registry; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/privacy/dao/impl/PrivacyComplianceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/privacy/dao/impl/PrivacyComplianceDAOImpl.java index d60c9a6d0f..a899e8ad3e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/privacy/dao/impl/PrivacyComplianceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/privacy/dao/impl/PrivacyComplianceDAOImpl.java @@ -19,13 +19,13 @@ package io.entgra.device.mgt.core.device.mgt.core.privacy.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.privacy.dao.PrivacyComplianceDAO; import io.entgra.device.mgt.core.device.mgt.core.privacy.dao.PrivacyComplianceDAOException; import io.entgra.device.mgt.core.device.mgt.core.privacy.impl.DeviceEnrollmentMapping; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/privacy/impl/PrivacyComplianceProviderImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/privacy/impl/PrivacyComplianceProviderImpl.java index a622fc074b..a8da47019c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/privacy/impl/PrivacyComplianceProviderImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/privacy/impl/PrivacyComplianceProviderImpl.java @@ -19,9 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.core.privacy.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; @@ -32,6 +29,9 @@ import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHo import io.entgra.device.mgt.core.device.mgt.core.privacy.PrivacyComplianceProvider; import io.entgra.device.mgt.core.device.mgt.core.privacy.dao.PrivacyComplianceDAO; import io.entgra.device.mgt.core.device.mgt.core.privacy.dao.PrivacyComplianceDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.util.ArrayList; import java.util.HashMap; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/PushNotificationConfigRepository.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/PushNotificationConfigRepository.java index ef0946a484..8279fda4ad 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/PushNotificationConfigRepository.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/PushNotificationConfigRepository.java @@ -18,8 +18,8 @@ */ package io.entgra.device.mgt.core.device.mgt.core.push.notification.mgt; -import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; +import org.wso2.carbon.context.CarbonContext; import java.util.HashMap; import java.util.Map; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/PushNotificationProviderRepository.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/PushNotificationProviderRepository.java index 17484496db..13f11237f9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/PushNotificationProviderRepository.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/PushNotificationProviderRepository.java @@ -18,9 +18,9 @@ */ package io.entgra.device.mgt.core.device.mgt.core.push.notification.mgt; +import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationProvider; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationProvider; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/task/PushNotificationSchedulerTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/task/PushNotificationSchedulerTask.java index b0e7ef8d5d..bf4a3afcf5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/task/PushNotificationSchedulerTask.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/task/PushNotificationSchedulerTask.java @@ -17,9 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.push.notification.mgt.task; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; @@ -35,6 +32,9 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationMana import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationMappingDAO; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.util.HashMap; import java.util.LinkedList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/ReportManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/ReportManagementServiceImpl.java index de85e8dc7f..45c073be3e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/ReportManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/ReportManagementServiceImpl.java @@ -18,34 +18,29 @@ package io.entgra.device.mgt.core.device.mgt.core.report.mgt; import com.google.gson.JsonObject; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Count; import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceTypeNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.ReportManagementException; import io.entgra.device.mgt.core.device.mgt.common.report.mgt.ReportManagementService; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.GroupDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.core.dao.*; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.SQLException; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; import java.util.List; -import java.util.Calendar; import java.util.concurrent.TimeUnit; /** diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/config/ReportMgtConfigurationManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/config/ReportMgtConfigurationManager.java index 7da7b7fa81..df867e9e04 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/config/ReportMgtConfigurationManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/config/ReportMgtConfigurationManager.java @@ -17,11 +17,11 @@ */ package io.entgra.device.mgt.core.device.mgt.core.report.mgt.config; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidConfigurationException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.ReportManagementException; import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.xml.bind.JAXBContext; import javax.xml.bind.Unmarshaller; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/dao/common/ReportMgtConnectionManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/dao/common/ReportMgtConnectionManager.java index 8cba2a8b4b..78fb3aa524 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/dao/common/ReportMgtConnectionManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/dao/common/ReportMgtConnectionManager.java @@ -17,11 +17,11 @@ */ package io.entgra.device.mgt.core.device.mgt.core.report.mgt.dao.common; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.core.report.mgt.config.ReportMgtConfigurationManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.naming.InitialContext; import javax.sql.DataSource; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/ProcessorImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/ProcessorImpl.java index 0b86efddbe..09ce7c90b7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/ProcessorImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/ProcessorImpl.java @@ -19,9 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.core.search.mgt.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; @@ -33,21 +30,13 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.ApplicationDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.Constants; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.InvalidOperatorException; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.Processor; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.QueryBuilder; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.QueryHolder; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.ResultSetAggregator; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.SearchMgtException; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.ValueType; +import io.entgra.device.mgt.core.device.mgt.core.search.mgt.*; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.dao.SearchDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; -import java.sql.Array; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java index d07767d546..031866a4b3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java @@ -19,15 +19,11 @@ package io.entgra.device.mgt.core.device.mgt.core.search.mgt.impl; +import io.entgra.device.mgt.core.device.mgt.common.search.Condition; +import io.entgra.device.mgt.core.device.mgt.core.search.mgt.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.search.Condition; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.Constants; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.InvalidOperatorException; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.QueryBuilder; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.QueryHolder; -import io.entgra.device.mgt.core.device.mgt.core.search.mgt.ValueType; import java.util.ArrayList; import java.util.HashMap; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/ResultSetAggregatorImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/ResultSetAggregatorImpl.java index 59a7f5e6b9..bcc10946b6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/ResultSetAggregatorImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/search/mgt/impl/ResultSetAggregatorImpl.java @@ -19,14 +19,14 @@ package io.entgra.device.mgt.core.device.mgt.core.search.mgt.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.Constants; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.ResultSetAggregator; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index ca1dccbd0d..0133f8f5f3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -35,22 +35,13 @@ package io.entgra.device.mgt.core.device.mgt.core.service; -import org.apache.commons.collections.map.SingletonMap; import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.AmbiguousConfigurationException; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.DeviceConfiguration; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.*; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceData; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocationHistorySnapshot; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceTypeNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnauthorizedDeviceAccessException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.UserNotFoundException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.*; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoQuery; import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitationDetails; import io.entgra.device.mgt.core.device.mgt.common.license.mgt.License; @@ -65,11 +56,10 @@ import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceStatus; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeVersion; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; +import org.apache.commons.collections.map.SingletonMap; import java.sql.SQLException; import java.sql.Timestamp; -import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 6370502e81..c7596a03cc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -37,50 +37,10 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import com.google.common.reflect.TypeToken; import com.google.gson.Gson; -import org.apache.commons.collections.map.SingletonMap; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -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.wso2.carbon.CarbonConstants; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.Billing; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceEnrollmentInfoNotification; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManager; -import io.entgra.device.mgt.core.device.mgt.common.DeviceNotification; -import io.entgra.device.mgt.core.device.mgt.common.DevicePropertyNotification; -import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; -import io.entgra.device.mgt.core.device.mgt.common.InitialOperationConfig; -import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; -import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.StartupOperationConfig; -import io.entgra.device.mgt.core.device.mgt.common.BillingResponse; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.MobileAppTypes; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.AmbiguousConfigurationException; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.CorrectiveActionConfig; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.DeviceConfiguration; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.DevicePropertyInfo; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.EnrollmentConfiguration; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.*; import io.entgra.device.mgt.core.device.mgt.common.cost.mgt.Cost; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceData; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; @@ -89,15 +49,8 @@ import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocation import io.entgra.device.mgt.core.device.mgt.common.enrollment.notification.EnrollmentNotificationConfiguration; import io.entgra.device.mgt.core.device.mgt.common.enrollment.notification.EnrollmentNotifier; import io.entgra.device.mgt.core.device.mgt.common.enrollment.notification.EnrollmentNotifierException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceTypeNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnauthorizedDeviceAccessException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.UserNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.*; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoQuery; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; @@ -128,20 +81,13 @@ import io.entgra.device.mgt.core.device.mgt.core.cache.impl.DeviceCacheManagerIm import io.entgra.device.mgt.core.device.mgt.core.common.Constants; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; -import io.entgra.device.mgt.core.device.mgt.core.dao.ApplicationDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceStatusDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceTypeDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.EnrollmentDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.*; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.DeviceInformationManager; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeServiceIdentifier; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeVersion; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementServiceComponent; import io.entgra.device.mgt.core.device.mgt.core.internal.PluginInitializationListener; @@ -152,16 +98,25 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.CommandOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import io.entgra.device.mgt.core.device.mgt.core.util.HttpReportingUtil; -import io.entgra.device.mgt.core.transport.mgt.email.sender.core.ContentProviderInfo; -import io.entgra.device.mgt.core.transport.mgt.email.sender.core.EmailContext; -import io.entgra.device.mgt.core.transport.mgt.email.sender.core.EmailSendingFailedException; -import io.entgra.device.mgt.core.transport.mgt.email.sender.core.EmailTransportNotConfiguredException; -import io.entgra.device.mgt.core.transport.mgt.email.sender.core.TypedValue; +import io.entgra.device.mgt.core.transport.mgt.email.sender.core.*; import io.entgra.device.mgt.core.transport.mgt.email.sender.core.service.EmailSenderService; +import org.apache.commons.collections.map.SingletonMap; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +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.wso2.carbon.CarbonConstants; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.stratos.common.beans.TenantInfoBean; import org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService; import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -172,17 +127,7 @@ import java.lang.reflect.Type; import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index 670c47f830..61a069f1d8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -37,15 +37,10 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.*; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 46e168a4cc..87dc81825d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -35,46 +35,29 @@ package io.entgra.device.mgt.core.device.mgt.core.service; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TrackerAlreadyExistException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.*; import io.entgra.device.mgt.core.device.mgt.core.dao.*; import io.entgra.device.mgt.core.device.mgt.core.event.config.GroupAssignmentEventOperationExecutor; import io.entgra.device.mgt.core.device.mgt.core.geo.task.GeoFenceEventOperationManager; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationMgtConstants; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; -import io.entgra.device.mgt.core.device.mgt.core.util.HttpReportingUtil; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.CarbonConstants; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; +import java.util.*; import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java index 407c0d9327..6494635bc8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java @@ -19,8 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.core.status.task.impl; import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.DeviceStatusTaskPluginConfig; import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; @@ -33,6 +31,8 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOExceptio import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.status.task.DeviceStatusTaskException; import io.entgra.device.mgt.core.device.mgt.core.task.impl.DynamicPartitionedScheduleTask; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.SQLException; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java index 1fcbf8f258..421659da62 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusTaskManagerServiceImpl.java @@ -19,13 +19,13 @@ package io.entgra.device.mgt.core.device.mgt.core.status.task.impl; import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceStatusTaskPluginConfig; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.status.task.DeviceStatusTaskException; import io.entgra.device.mgt.core.device.mgt.core.status.task.DeviceStatusTaskManagerService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.ntask.common.TaskException; import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskManager; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivalTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivalTask.java index 1d2ff568d5..3c2a1ffef7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivalTask.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivalTask.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.core.task.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.archival.ArchivalException; import io.entgra.device.mgt.core.device.mgt.core.archival.ArchivalService; import io.entgra.device.mgt.core.device.mgt.core.archival.ArchivalServiceImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.ntask.core.Task; import java.text.SimpleDateFormat; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivalTaskManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivalTaskManagerImpl.java index 00c5e73f65..3c3326c68c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivalTaskManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivalTaskManagerImpl.java @@ -19,13 +19,13 @@ package io.entgra.device.mgt.core.device.mgt.core.task.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.task.ArchivalTaskException; import io.entgra.device.mgt.core.device.mgt.core.task.ArchivalTaskManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.ntask.common.TaskException; import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskManager; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivedDataDeletionTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivedDataDeletionTask.java index fe03d6251f..28df6536dc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivedDataDeletionTask.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/ArchivedDataDeletionTask.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.core.task.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.core.archival.ArchivalException; import io.entgra.device.mgt.core.device.mgt.core.archival.ArchivalService; import io.entgra.device.mgt.core.device.mgt.core.archival.ArchivalServiceImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.ntask.core.Task; import java.text.SimpleDateFormat; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java index 66a47ebfde..0124124358 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java @@ -35,10 +35,6 @@ package io.entgra.device.mgt.core.device.mgt.core.task.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; import io.entgra.device.mgt.core.device.mgt.common.StartupOperationConfig; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; @@ -46,6 +42,10 @@ import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHo import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.task.DeviceMgtTaskException; import io.entgra.device.mgt.core.device.mgt.core.task.DeviceTaskManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceTaskManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceTaskManagerImpl.java index 082ebbb07a..c1783b0f49 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceTaskManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceTaskManagerImpl.java @@ -34,17 +34,10 @@ package io.entgra.device.mgt.core.device.mgt.core.task.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.ServerConfiguration; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; -import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; -import io.entgra.device.mgt.core.device.mgt.common.StartupOperationConfig; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.CommandOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; @@ -52,12 +45,11 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import io.entgra.device.mgt.core.device.mgt.core.task.DeviceMgtTaskException; import io.entgra.device.mgt.core.device.mgt.core.task.DeviceTaskManager; import io.entgra.device.mgt.core.device.mgt.core.task.Utils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.ServerConfiguration; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class DeviceTaskManagerImpl implements DeviceTaskManager { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceTaskManagerServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceTaskManagerServiceImpl.java index 3737aa389d..c4a72ed6d3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceTaskManagerServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DeviceTaskManagerServiceImpl.java @@ -20,13 +20,13 @@ package io.entgra.device.mgt.core.device.mgt.core.task.impl; import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.task.DeviceMgtTaskException; import io.entgra.device.mgt.core.device.mgt.core.task.DeviceTaskManagerService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.ntask.common.TaskException; import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskManager; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java index 4aeb87289a..53e42edfc3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.core.task.impl; +import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; +import io.entgra.device.mgt.core.device.mgt.common.ServerCtxInfo; +import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception.HeartBeatManagementException; import io.entgra.device.mgt.core.task.mgt.common.constant.TaskMgtConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; -import io.entgra.device.mgt.core.device.mgt.common.ServerCtxInfo; -import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.ntask.core.Task; import java.util.Map; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/RandomlyAssignedScheduleTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/RandomlyAssignedScheduleTask.java index 4a8cf638bd..bd5373862f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/RandomlyAssignedScheduleTask.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/RandomlyAssignedScheduleTask.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.core.task.impl; +import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception.HeartBeatManagementException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.ntask.core.Task; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/TraccarClientFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/TraccarClientFactory.java index 50a8f39359..bcdbedf09d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/TraccarClientFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/TraccarClientFactory.java @@ -18,27 +18,14 @@ package io.entgra.device.mgt.core.device.mgt.core.traccar.api.service; -import okhttp3.ConnectionPool; -import okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONArray; -import org.json.JSONObject; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.TrackerDeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.TrackerGroupInfo; import io.entgra.device.mgt.core.device.mgt.common.TrackerPermissionInfo; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TrackerAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.TraccarClient; import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.impl.DeviceAPIClientServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.traccar.common.TraccarHandlerConstants; import io.entgra.device.mgt.core.device.mgt.core.traccar.common.beans.TraccarDevice; @@ -49,6 +36,13 @@ import io.entgra.device.mgt.core.device.mgt.core.traccar.common.config.TraccarGa import io.entgra.device.mgt.core.device.mgt.core.traccar.common.util.TraccarUtil; import io.entgra.device.mgt.core.device.mgt.core.traccar.core.config.TraccarConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.util.HttpReportingUtil; +import okhttp3.*; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; +import org.json.JSONObject; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.IOException; import java.sql.SQLException; @@ -58,12 +52,7 @@ import java.util.Date; import java.util.List; import java.util.Objects; import java.util.Random; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; import java.util.stream.Collectors; import java.util.stream.IntStream; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/addons/TraccarClientImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/addons/TraccarClientImpl.java index 21eccc0bcc..b988b7dde2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/addons/TraccarClientImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/addons/TraccarClientImpl.java @@ -19,25 +19,13 @@ package io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.addons; -import okhttp3.ConnectionPool; -import okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONArray; -import org.json.JSONObject; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.TrackerDeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.TrackerGroupInfo; import io.entgra.device.mgt.core.device.mgt.common.TrackerPermissionInfo; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TrackerAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.TraccarClient; import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.impl.DeviceAPIClientServiceImpl; @@ -50,6 +38,13 @@ import io.entgra.device.mgt.core.device.mgt.core.traccar.common.config.TraccarGa import io.entgra.device.mgt.core.device.mgt.core.traccar.common.util.TraccarUtil; import io.entgra.device.mgt.core.device.mgt.core.traccar.core.config.TraccarConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.util.HttpReportingUtil; +import okhttp3.*; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; +import org.json.JSONObject; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.SQLException; import java.time.LocalDateTime; @@ -58,12 +53,7 @@ import java.util.Date; import java.util.List; import java.util.Objects; import java.util.Random; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; public class TraccarClientImpl implements TraccarClient { private static final Log log = LogFactory.getLog(TraccarClientImpl.class); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/impl/DeviceAPIClientServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/impl/DeviceAPIClientServiceImpl.java index 5c39b2364c..f6c40e9c60 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/impl/DeviceAPIClientServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/api/service/impl/DeviceAPIClientServiceImpl.java @@ -19,15 +19,12 @@ package io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.JSONObject; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.TrackerDeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.TrackerPermissionInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocation; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TrackerAlreadyExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.core.dao.TrackerManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.DeviceAPIClientService; import io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.TraccarClientFactory; @@ -35,6 +32,9 @@ import io.entgra.device.mgt.core.device.mgt.core.traccar.common.beans.TraccarDev import io.entgra.device.mgt.core.device.mgt.core.traccar.common.beans.TraccarGroups; import io.entgra.device.mgt.core.device.mgt.core.traccar.common.beans.TraccarPosition; import io.entgra.device.mgt.core.device.mgt.core.traccar.common.beans.TraccarUser; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; import java.util.Date; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/common/util/TraccarUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/common/util/TraccarUtil.java index 587612534f..d1f6a21ca9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/common/util/TraccarUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/common/util/TraccarUtil.java @@ -19,9 +19,9 @@ package io.entgra.device.mgt.core.device.mgt.core.traccar.common.util; -import org.json.JSONObject; import io.entgra.device.mgt.core.device.mgt.core.traccar.common.beans.TraccarDevice; import io.entgra.device.mgt.core.device.mgt.core.traccar.common.beans.TraccarUser; +import org.json.JSONObject; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/core/config/TraccarConfigurationManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/core/config/TraccarConfigurationManager.java index ac2e9d855e..72d6a4513e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/core/config/TraccarConfigurationManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/traccar/core/config/TraccarConfigurationManager.java @@ -19,13 +19,13 @@ package io.entgra.device.mgt.core.device.mgt.core.traccar.core.config; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.traccar.common.TraccarHandlerConstants; import io.entgra.device.mgt.core.device.mgt.core.traccar.common.config.TraccarConfiguration; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Document; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagementSchemaInitializer.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagementSchemaInitializer.java index 5f6a07b75f..0a14040908 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagementSchemaInitializer.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagementSchemaInitializer.java @@ -18,9 +18,9 @@ package io.entgra.device.mgt.core.device.mgt.core.util; +import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceConfig; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.dbcreator.DatabaseCreator; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java index 35beda596c..c573b2e69d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java @@ -36,34 +36,8 @@ package io.entgra.device.mgt.core.device.mgt.core.util; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -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.w3c.dom.Document; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.caching.impl.CacheImpl; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.AppRegistrationCredentials; -import io.entgra.device.mgt.core.device.mgt.common.ApplicationRegistration; -import io.entgra.device.mgt.core.device.mgt.common.ApplicationRegistrationException; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.EnrollmentConfiguration; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; -import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; +import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.*; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfigurationProviderService; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; @@ -98,11 +72,21 @@ import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; -import org.wso2.carbon.user.api.RealmConfiguration; -import org.wso2.carbon.user.api.TenantManager; -import org.wso2.carbon.user.api.UserRealm; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.api.UserStoreManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +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.w3c.dom.Document; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.caching.impl.CacheImpl; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.*; import org.wso2.carbon.user.core.config.RealmConfigXMLProcessor; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.ConfigurationContextService; @@ -121,13 +105,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Base64; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/HttpReportingUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/HttpReportingUtil.java index 1cc50225b8..00e91007f3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/HttpReportingUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/HttpReportingUtil.java @@ -17,6 +17,8 @@ package io.entgra.device.mgt.core.device.mgt.core.util; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.EventPublishingException; +import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; @@ -27,8 +29,7 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.protocol.HTTP; import org.json.JSONObject; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.EventPublishingException; -import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; + import java.io.IOException; public class HttpReportingUtil { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java index f433a19f64..de0c32727f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java @@ -19,13 +19,13 @@ package io.entgra.device.mgt.core.device.mgt.core.util; import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.android.AppStoreApplication; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.android.EnterpriseApplication; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.android.WebApplication; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnknownApplicationTypeException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnknownApplicationTypeException; /** * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMIOSOperationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMIOSOperationUtil.java index ee8f73f0b0..8c0996b5d4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMIOSOperationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMIOSOperationUtil.java @@ -19,11 +19,11 @@ package io.entgra.device.mgt.core.device.mgt.core.util; import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ios.AppStoreApplication; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ios.EnterpriseApplication; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ios.RemoveApplication; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ios.WebClip; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java index fb06594765..ea8a8ece87 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java @@ -23,8 +23,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows.EnterpriseApplication; @@ -33,6 +31,8 @@ import io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows.HostedMSIAppl import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnknownApplicationTypeException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConfigTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConfigTests.java index 79516708e4..875c83f851 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConfigTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConfigTests.java @@ -17,12 +17,12 @@ */ package io.entgra.device.mgt.core.device.mgt.core; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; 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 io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementRepositoryTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementRepositoryTests.java index 18c66bbcbc..9ea9fb523f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementRepositoryTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementRepositoryTests.java @@ -17,14 +17,14 @@ */ package io.entgra.device.mgt.core.device.mgt.core; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; public class DeviceManagementRepositoryTests{ diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManager.java index 0b8ca1aece..6c3755345a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManager.java @@ -15,12 +15,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManager; -import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.Feature; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformConfiguration; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.license.mgt.License; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestHeartBeatManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestHeartBeatManagementService.java index 2ba1696726..be8d3574b2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestHeartBeatManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestHeartBeatManagementService.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.core; +import io.entgra.device.mgt.core.device.mgt.common.ServerCtxInfo; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dto.HeartBeatEvent; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dto.ServerContext; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception.HeartBeatManagementException; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; -import io.entgra.device.mgt.core.device.mgt.common.ServerCtxInfo; import java.util.Map; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestTaskServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestTaskServiceImpl.java index 77e215e653..3f3f80fe09 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestTaskServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestTaskServiceImpl.java @@ -19,11 +19,9 @@ package io.entgra.device.mgt.core.device.mgt.core; import io.entgra.device.mgt.core.device.mgt.core.task.TestTaskManagerImpl; import org.wso2.carbon.ntask.common.TaskException; -import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskManager; import org.wso2.carbon.ntask.core.service.TaskService; -import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java index 39188314c2..4827f44256 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java @@ -17,13 +17,13 @@ */ package io.entgra.device.mgt.core.device.mgt.core; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/AppManagementConfigurationManagerTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/AppManagementConfigurationManagerTest.java index 029cdd7744..e72b7848b9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/AppManagementConfigurationManagerTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/AppManagementConfigurationManagerTest.java @@ -18,12 +18,12 @@ package io.entgra.device.mgt.core.device.mgt.core.app.mgt; +import io.entgra.device.mgt.core.device.mgt.core.app.mgt.config.AppManagementConfig; 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 io.entgra.device.mgt.core.device.mgt.core.app.mgt.config.AppManagementConfig; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagementProviderServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagementProviderServiceTest.java index 11df30cfbd..577aacd235 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagementProviderServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagementProviderServiceTest.java @@ -15,18 +15,18 @@ */ package io.entgra.device.mgt.core.device.mgt.core.app.mgt; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementPluginRepository; +import io.entgra.device.mgt.core.device.mgt.core.TestDeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; 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 io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; -import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementPluginRepository; -import io.entgra.device.mgt.core.device.mgt.core.TestDeviceManagementService; -import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import java.util.ArrayList; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceTest.java index bd5c841b6d..7e9831f329 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceTest.java @@ -18,23 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.core.authorization; -import org.apache.commons.dbcp.BasicDataSource; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.mockito.Mockito; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAuthorizationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; @@ -47,23 +37,30 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderServiceImpl; +import org.apache.commons.dbcp.BasicDataSource; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.mockito.Mockito; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.CarbonConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService; import org.wso2.carbon.registry.core.service.RegistryService; +import org.wso2.carbon.user.api.Permission; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; -import org.wso2.carbon.user.api.Permission; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.tenant.JDBCTenantManager; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + import java.io.InputStream; -import java.util.ArrayList; -import java.util.Map; -import java.util.List; -import java.util.HashMap; -import java.util.Arrays; +import java.util.*; /** * Unit tests for DeviceAccessAuthorizationServiceTest diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheManagerImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheManagerImplTest.java index 1b30508cc3..95560b0402 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheManagerImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheManagerImplTest.java @@ -18,11 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.cache; -import org.mockito.Mockito; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; @@ -32,7 +27,13 @@ import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; import io.entgra.device.mgt.core.device.mgt.core.config.cache.DeviceCacheConfiguration; +import org.mockito.Mockito; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + import java.io.File; import java.io.IOException; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/BaseDeviceManagementTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/BaseDeviceManagementTest.java index c00c1b67a7..852780e9ad 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/BaseDeviceManagementTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/BaseDeviceManagementTest.java @@ -18,17 +18,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.common; -import org.apache.axis2.AxisFault; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.axis2.context.ConfigurationContextFactory; -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 io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.TestUtils; import io.entgra.device.mgt.core.device.mgt.core.authorization.DeviceAccessAuthorizationServiceImpl; @@ -45,6 +34,17 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.ConfigurationContextFactory; +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.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java index 8cf7a98a10..9d42501c42 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java @@ -15,11 +15,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core.common; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; -import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java index f15fc880df..677d309297 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java @@ -18,11 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; -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 io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo.Status; @@ -31,8 +26,16 @@ import io.entgra.device.mgt.core.device.mgt.core.TestUtils; import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; +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 java.sql.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; public class DevicePersistTests extends BaseDeviceManagementTest { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusPersistenceTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusPersistenceTests.java index 185c98103b..28d524726c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusPersistenceTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusPersistenceTests.java @@ -18,20 +18,19 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.Assert; -import org.testng.annotations.Test; -import org.testng.annotations.BeforeClass; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceStatus; import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; +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 java.sql.SQLException; import java.util.*; -import java.util.List; import java.util.stream.Stream; import static io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo.Status.*; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrolmentPersistenceTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrolmentPersistenceTests.java index fe400c4264..93725b7693 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrolmentPersistenceTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrolmentPersistenceTests.java @@ -18,15 +18,15 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; +import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; 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 io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; -import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import java.sql.SQLException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupPersistTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupPersistTests.java index 8cccaa4e15..9398305b82 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupPersistTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupPersistTests.java @@ -18,17 +18,17 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; -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 io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; +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 java.sql.SQLException; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceTest.java index 9b6137a26a..ae53028ef2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceTest.java @@ -19,10 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.core.geo.service; -import org.mockito.Mockito; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; @@ -34,6 +30,10 @@ import io.entgra.device.mgt.core.device.mgt.core.TestDeviceManagementService; import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.mockito.Mockito; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub; import org.wso2.carbon.event.processor.stub.types.ExecutionPlanConfigurationDto; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockConnection.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockConnection.java index 4d82236c86..ea05eb59fc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockConnection.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockConnection.java @@ -17,23 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core.mock; -import java.sql.Array; -import java.sql.Blob; -import java.sql.CallableStatement; -import java.sql.Clob; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.NClob; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.RowIdLifetime; -import java.sql.SQLClientInfoException; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Savepoint; -import java.sql.Statement; -import java.sql.Struct; +import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockDataSource.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockDataSource.java index 7f96c0cd14..3b7c52e970 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockDataSource.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockDataSource.java @@ -17,8 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core.mock; -import org.mockito.Mock; - +import javax.sql.DataSource; import java.io.PrintWriter; import java.sql.Connection; import java.sql.SQLException; @@ -26,7 +25,6 @@ import java.sql.SQLFeatureNotSupportedException; import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; -import javax.sql.DataSource; /** * This is the mock data source implementation that will be used in the test cases. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockDatabaseMetaData.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockDatabaseMetaData.java index 3992e86f11..8d0599f3f2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockDatabaseMetaData.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockDatabaseMetaData.java @@ -19,11 +19,7 @@ package io.entgra.device.mgt.core.device.mgt.core.mock; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.sql.RowIdLifetime; -import java.sql.SQLException; +import java.sql.*; public class MockDatabaseMetaData implements DatabaseMetaData { private String url; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockJDBCDriver.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockJDBCDriver.java index 58d21b7daa..3e8990e9d9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockJDBCDriver.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockJDBCDriver.java @@ -17,11 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core.mock; -import java.sql.Connection; -import java.sql.Driver; -import java.sql.DriverPropertyInfo; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; +import java.sql.*; import java.util.Properties; import java.util.logging.Logger; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockResultSet.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockResultSet.java index ddfa16efed..ad2f6ca4d1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockResultSet.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockResultSet.java @@ -21,21 +21,7 @@ import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; import java.net.URL; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Date; -import java.sql.NClob; -import java.sql.Ref; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Statement; -import java.sql.Time; -import java.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Calendar; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockStatement.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockStatement.java index df1f1cfd79..da11002f6d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockStatement.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/mock/MockStatement.java @@ -21,24 +21,7 @@ import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; import java.net.URL; -import java.sql.Array; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Connection; -import java.sql.Date; -import java.sql.NClob; -import java.sql.ParameterMetaData; -import java.sql.PreparedStatement; -import java.sql.Ref; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Statement; -import java.sql.Time; -import java.sql.Timestamp; +import java.sql.*; import java.util.ArrayList; import java.util.Calendar; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java index 6500909e6d..5bcf1961cd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/notification/mgt/NotificationManagementServiceImplTests.java @@ -17,16 +17,11 @@ */ package io.entgra.device.mgt.core.device.mgt.core.notification.mgt; -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 io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.EntityDoesNotExistException; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.EntityDoesNotExistException; import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.NotificationManagementException; import io.entgra.device.mgt.core.device.mgt.core.TestDeviceManagementService; @@ -38,6 +33,11 @@ import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementServic import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderServiceImpl; +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.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementNegativeDBOperationTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementNegativeDBOperationTest.java index e6b0952be5..8d1e13a614 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementNegativeDBOperationTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementNegativeDBOperationTest.java @@ -17,15 +17,10 @@ */ package io.entgra.device.mgt.core.device.mgt.core.operation; -import org.powermock.api.mockito.PowerMockito; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; @@ -38,6 +33,11 @@ import io.entgra.device.mgt.core.device.mgt.core.mock.MockDataSource; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.powermock.api.mockito.PowerMockito; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import javax.sql.DataSource; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementNoDBSchemaTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementNoDBSchemaTests.java index 5ce9fe7e40..b49ab83208 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementNoDBSchemaTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementNoDBSchemaTests.java @@ -18,16 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.core.operation; -import org.powermock.api.mockito.PowerMockito; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; @@ -41,6 +36,11 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.CommandOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.powermock.api.mockito.PowerMockito; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import javax.sql.DataSource; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementTests.java index 8a9efe5979..018bf6efc2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/OperationManagementTests.java @@ -18,6 +18,18 @@ package io.entgra.device.mgt.core.device.mgt.core.operation; +import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.*; +import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; +import io.entgra.device.mgt.core.device.mgt.core.TestDeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; +import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; +import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.*; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.powermock.api.mockito.PowerMockito; @@ -25,30 +37,6 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityStatus; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; -import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; -import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.core.TestDeviceManagementService; -import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; -import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; -import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.CommandOperation; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ConfigOperation; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.PolicyOperation; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.text.ParseException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/ScheduledTaskOperationTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/ScheduledTaskOperationTests.java index 7c4d50b469..af33152652 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/ScheduledTaskOperationTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/operation/ScheduledTaskOperationTests.java @@ -17,11 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.operation; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; @@ -42,6 +37,11 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerI import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.task.DeviceTaskManagerService; import io.entgra.device.mgt.core.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import org.wso2.carbon.ntask.core.internal.TasksDSComponent; import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.ntask.core.service.impl.TaskServiceImpl; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java index 4218aa315a..c7a30d474c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java @@ -17,6 +17,9 @@ */ package io.entgra.device.mgt.core.device.mgt.core.permission.mgt; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagerService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.powermock.api.mockito.PowerMockito; @@ -26,14 +29,10 @@ import org.testng.IObjectFactory; import org.testng.annotations.BeforeClass; import org.testng.annotations.ObjectFactory; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagerService; import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.ArrayList; import java.util.List; -import java.util.Properties; import static org.mockito.MockitoAnnotations.initMocks; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/task/PushNotificationSchedulerTaskTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/task/PushNotificationSchedulerTaskTest.java index 87b78cf6d8..6ea50b6861 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/task/PushNotificationSchedulerTaskTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/push/notification/mgt/task/PushNotificationSchedulerTaskTest.java @@ -17,12 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.push.notification.mgt.task; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.mockito.Mockito; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; @@ -37,6 +31,12 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationMana import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.mockito.Mockito; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.sql.SQLException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/DeviceDetails.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/DeviceDetails.java index 8c97bd7b8f..8b34362bed 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/DeviceDetails.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/DeviceDetails.java @@ -19,16 +19,16 @@ package io.entgra.device.mgt.core.device.mgt.core.search; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.DeviceInformationManager; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.impl.DeviceInformationManagerImpl; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; public class DeviceDetails extends BaseDeviceManagementTest { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java index ef8155b900..700ad7da06 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java @@ -17,9 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.search; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.search.Condition; @@ -36,6 +33,9 @@ import io.entgra.device.mgt.core.device.mgt.core.search.util.ChangeEnumValues; import io.entgra.device.mgt.core.device.mgt.core.search.util.Utils; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/SearchManagementServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/SearchManagementServiceTest.java index 339fd06bf4..0273b0900d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/SearchManagementServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/SearchManagementServiceTest.java @@ -17,15 +17,10 @@ */ package io.entgra.device.mgt.core.device.mgt.core.search; -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 io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.search.Condition; import io.entgra.device.mgt.core.device.mgt.common.search.SearchContext; import io.entgra.device.mgt.core.device.mgt.core.TestDeviceManagementService; @@ -43,6 +38,11 @@ import io.entgra.device.mgt.core.device.mgt.core.search.mgt.impl.SearchManagerSe import io.entgra.device.mgt.core.device.mgt.core.search.util.Utils; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; +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.utils.multitenancy.MultitenantConstants; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/SearchMgtUtilTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/SearchMgtUtilTest.java index 5a93437d5c..e50c121962 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/SearchMgtUtilTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/SearchMgtUtilTest.java @@ -17,13 +17,13 @@ */ package io.entgra.device.mgt.core.device.mgt.core.search; -import org.junit.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.impl.Utils; +import org.junit.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.util.ArrayList; import java.util.HashMap; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceTest.java index c4744bbc0b..290f0e6bee 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceTest.java @@ -53,21 +53,10 @@ package io.entgra.device.mgt.core.device.mgt.core.service; -import org.apache.commons.collections.map.SingletonMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.mockito.Mockito; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.license.mgt.License; import io.entgra.device.mgt.core.device.mgt.core.TestDeviceManagementService; import io.entgra.device.mgt.core.device.mgt.core.authorization.DeviceAccessAuthorizationServiceImpl; @@ -87,6 +76,13 @@ import io.entgra.device.mgt.core.device.mgt.core.mock.MockConnection; import io.entgra.device.mgt.core.device.mgt.core.mock.MockDataSource; import io.entgra.device.mgt.core.device.mgt.core.mock.MockResultSet; import io.entgra.device.mgt.core.device.mgt.core.mock.MockStatement; +import org.apache.commons.collections.map.SingletonMap; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.mockito.Mockito; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; @@ -99,12 +95,7 @@ import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.io.InputStream; import java.lang.reflect.Field; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Properties; +import java.util.*; public class DeviceManagementProviderServiceTest extends BaseDeviceManagementTest { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceNegativeTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceNegativeTest.java index 6915fe5282..79cd951a1e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceNegativeTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceNegativeTest.java @@ -35,8 +35,6 @@ package io.entgra.device.mgt.core.device.mgt.core.service; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; @@ -44,6 +42,8 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistExc import io.entgra.device.mgt.core.device.mgt.core.TestUtils; import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import javax.sql.DataSource; import java.util.ArrayList; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceTest.java index 9089c0f2f5..7561540d6e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceTest.java @@ -35,27 +35,23 @@ package io.entgra.device.mgt.core.device.mgt.core.service; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.*; import io.entgra.device.mgt.core.device.mgt.core.TestUtils; import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.cache.DeviceCacheConfiguration; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService; import org.wso2.carbon.user.api.Permission; import org.wso2.carbon.user.api.UserStoreException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/task/DeviceTaskManagerServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/task/DeviceTaskManagerServiceTest.java index 1825c67533..bda795dfe7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/task/DeviceTaskManagerServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/task/DeviceTaskManagerServiceTest.java @@ -17,17 +17,17 @@ */ package io.entgra.device.mgt.core.device.mgt.core.task; +import io.entgra.device.mgt.core.device.mgt.core.TestTaskServiceImpl; +import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import io.entgra.device.mgt.core.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mockito.Mockito; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.device.mgt.core.TestTaskServiceImpl; -import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; -import io.entgra.device.mgt.core.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl; import org.wso2.carbon.ntask.common.TaskException; import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskManager; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/task/DeviceTaskManagerTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/task/DeviceTaskManagerTest.java index a2e79103a0..743fbb88b2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/task/DeviceTaskManagerTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/task/DeviceTaskManagerTest.java @@ -17,14 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.task; -import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.powermock.api.mockito.PowerMockito; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; @@ -46,14 +38,18 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.task.impl.DeviceDetailsRetrieverTask; import io.entgra.device.mgt.core.device.mgt.core.task.impl.DeviceTaskManagerImpl; +import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.powermock.api.mockito.PowerMockito; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; /** * This is a test class to test the functionality in {@link DeviceTaskManager}. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml index 897e33581c..2337c777e2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml @@ -1,4 +1,4 @@ - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml index 0a9289da70..4f5e043a15 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml @@ -1,4 +1,4 @@ - + org.wso2.carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/src/main/java/io/entgra/device/mgt/core/device/mgt/url/printer/URLPrinterStartupHandler.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/src/main/java/io/entgra/device/mgt/core/device/mgt/url/printer/URLPrinterStartupHandler.java index 827b456425..b991a6bb38 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/src/main/java/io/entgra/device/mgt/core/device/mgt/url/printer/URLPrinterStartupHandler.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/src/main/java/io/entgra/device/mgt/core/device/mgt/url/printer/URLPrinterStartupHandler.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.url.printer; +import io.entgra.device.mgt.core.device.mgt.url.printer.internal.UrlPrinterDataHolder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.core.ServerStartupObserver; -import io.entgra.device.mgt.core.device.mgt.url.printer.internal.UrlPrinterDataHolder; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.ConfigurationContextService; import org.wso2.carbon.utils.NetworkUtils; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/src/main/java/io/entgra/device/mgt/core/device/mgt/url/printer/internal/UrlPrinterServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/src/main/java/io/entgra/device/mgt/core/device/mgt/url/printer/internal/UrlPrinterServiceComponent.java index 96000edbed..06d0d4ac41 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/src/main/java/io/entgra/device/mgt/core/device/mgt/url/printer/internal/UrlPrinterServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/src/main/java/io/entgra/device/mgt/core/device/mgt/url/printer/internal/UrlPrinterServiceComponent.java @@ -18,28 +18,23 @@ package io.entgra.device.mgt.core.device.mgt.url.printer.internal; +import io.entgra.device.mgt.core.device.mgt.url.printer.URLPrinterStartupHandler; 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.osgi.service.component.annotations.*; import org.wso2.carbon.core.ServerStartupObserver; -import io.entgra.device.mgt.core.device.mgt.url.printer.URLPrinterStartupHandler; import org.wso2.carbon.utils.ConfigurationContextService; -/** - * @scr.component name="UrlPrinterServiceComponent" - * immediate="true" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" - * policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.url.printer.internal.UrlPrinterServiceComponent", + immediate = true) public class UrlPrinterServiceComponent { private static final Log log = LogFactory.getLog(UrlPrinterServiceComponent.class); + @Activate protected void activate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("Activating Url printer Service Component"); @@ -54,13 +49,19 @@ public class UrlPrinterServiceComponent { log.error("Error occurred while activating Url printer Service Component", e); } } - + @Deactivate protected void deactivate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("De-activating Url printer Service Component"); } } + @Reference( + name = "configuration.context.service", + service = org.wso2.carbon.utils.ConfigurationContextService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { if (log.isDebugEnabled()) { log.debug("Setting ConfigurationContextService"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index 954c10e8ff..0b238e4d9c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -31,7 +31,7 @@ bundle WSO2 Carbon - Device Analytics WSO2 Carbon - Device Analytics - http://wso2.org + https://entgra.io diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml index b71ee171df..67b0d8d552 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml @@ -27,7 +27,7 @@ org.wso2.carbon.device.mgt.analytics.wsproxy war WSO2 - Webapp for Web Socket Proxy - http://wso2.org + https://entgra.io diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml index e866e84aaf..6cf72dc999 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml @@ -31,7 +31,7 @@ pom WSO2 Carbon - Device Management Base UI WSO2 Carbon - Device Management Base UI - http://wso2.org + https://entgra.io diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 0947987d7f..7611d57df3 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -30,7 +30,7 @@ device-mgt pom WSO2 Carbon - Device Management Component - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.device.mgt.core diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index b04e6492c9..714c887fd4 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -36,8 +36,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -51,20 +55,28 @@ Server Startup Heart Beat Beacon Bundle io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.internal - org.apache.axis2.*;version="${axis2.osgi.version.range}", - org.apache.axiom.*; version="${axiom.osgi.version.range}", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon, + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.config, + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.config.datasource, + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dao, + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dao.exception, + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dao.impl, + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dao.util, + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dto, + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception, + javax.naming, + javax.sql, + javax.xml.bind;version="[0.0,1)", + javax.xml.bind.annotation;version="[0.0,1)", + javax.xml.parsers, + org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - org.wso2.carbon.context, - org.wso2.carbon.utils.*, - org.wso2.carbon.ndatasource.core, org.w3c.dom, - org.apache.commons.io, - org.apache.axis2.transport.mail, - org.apache.commons.collections, - io.entgra.device.mgt.core.device.mgt.common.* + org.wso2.carbon.ndatasource.core;version="[4.8,5)", + org.wso2.carbon.utils;version="[4.8,5)" !io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.internal, @@ -73,55 +85,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.ops4j.pax.logging diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/HeartBeatBeaconUtils.java b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/HeartBeatBeaconUtils.java index 32f7340998..211e4a890a 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/HeartBeatBeaconUtils.java +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/HeartBeatBeaconUtils.java @@ -29,12 +29,7 @@ import javax.sql.DataSource; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.net.InetAddress; import java.net.SocketException; import java.net.UnknownHostException; diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/config/datasource/JNDILookupDefinition.java b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/config/datasource/JNDILookupDefinition.java index 2e6a09f1fe..7f2e4826e8 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/config/datasource/JNDILookupDefinition.java +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/config/datasource/JNDILookupDefinition.java @@ -18,11 +18,7 @@ package io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.config.datasource; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.*; import java.util.List; /** diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/HeartBeatBeaconDAOFactory.java b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/HeartBeatBeaconDAOFactory.java index 57599d4d2f..43f2986405 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/HeartBeatBeaconDAOFactory.java +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/HeartBeatBeaconDAOFactory.java @@ -18,16 +18,14 @@ package io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dao; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.HeartBeatBeaconUtils; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.config.datasource.JNDILookupDefinition; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dao.impl.GenericHeartBeatDAOImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnsupportedDatabaseEngineException; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/impl/GenericHeartBeatDAOImpl.java b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/impl/GenericHeartBeatDAOImpl.java index 18303897b1..06bff0d1c5 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/impl/GenericHeartBeatDAOImpl.java +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/impl/GenericHeartBeatDAOImpl.java @@ -28,12 +28,7 @@ import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dto.ServerContex 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.sql.Statement; -import java.sql.Timestamp; +import java.sql.*; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/internal/HeartBeatBeaconComponent.java b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/internal/HeartBeatBeaconComponent.java index 990ca60b87..0a32c24e0c 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/internal/HeartBeatBeaconComponent.java +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/internal/HeartBeatBeaconComponent.java @@ -27,23 +27,18 @@ import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBea import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.ndatasource.core.DataSourceService; -/** - * @scr.component name="io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.heartbeatBeaconComponent" - * immediate="true" - * @scr.reference name="org.wso2.carbon.ndatasource" - * interface="org.wso2.carbon.ndatasource.core.DataSourceService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDataSourceService" - * unbind="unsetDataSourceService" - */ +@Component( + name = "io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.internal.HeartBeatBeaconComponent", + immediate = true) public class HeartBeatBeaconComponent { private static Log log = LogFactory.getLog(HeartBeatBeaconComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -71,6 +66,7 @@ public class HeartBeatBeaconComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } @@ -84,6 +80,12 @@ public class HeartBeatBeaconComponent { componentContext.getBundleContext().registerService(HeartBeatManagementService.class, heartBeatServiceProvider, null); } + @Reference( + name = "datasource.service", + service = org.wso2.carbon.ndatasource.core.DataSourceService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDataSourceService") protected void setDataSourceService(DataSourceService dataSourceService) { /* This is to avoid mobile device management component getting initialized before the underlying datasources are registered */ diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/service/HeartBeatManagementService.java b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/service/HeartBeatManagementService.java index 2b86a2e0b0..d187e1e8cd 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/service/HeartBeatManagementService.java +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/service/HeartBeatManagementService.java @@ -18,10 +18,10 @@ package io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service; +import io.entgra.device.mgt.core.device.mgt.common.ServerCtxInfo; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dto.HeartBeatEvent; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dto.ServerContext; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception.HeartBeatManagementException; -import io.entgra.device.mgt.core.device.mgt.common.ServerCtxInfo; import java.util.Map; diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/service/HeartBeatManagementServiceImpl.java b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/service/HeartBeatManagementServiceImpl.java index 616d1b5de5..9db98f88fb 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/service/HeartBeatManagementServiceImpl.java +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/service/HeartBeatManagementServiceImpl.java @@ -18,6 +18,8 @@ package io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service; +import io.entgra.device.mgt.core.device.mgt.common.ServerCtxInfo; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.config.HeartBeatBeaconConfig; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dao.HeartBeatBeaconDAOFactory; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dao.HeartBeatDAO; @@ -29,17 +31,10 @@ import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception.HeartB import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.internal.HeartBeatBeaconDataHolder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.ServerCtxInfo; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import java.sql.SQLException; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; +import java.util.*; import java.util.concurrent.TimeUnit; public class HeartBeatManagementServiceImpl implements HeartBeatManagementService { diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 1198fd3b9a..732a2359c7 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -30,9 +30,14 @@ io.entgra.device.mgt.core.device.mgt.oauth.extensions bundle WSO2 Carbon - OAuth Extensions - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + commons-codec.wso2 commons-codec @@ -62,8 +67,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -81,32 +90,41 @@ io.entgra.device.mgt.core.device.mgt.oauth.extensions.* - org.wso2.carbon.identity.oauth2.grant.jwt;version="${carbon.identity.jwt.grant.version.range}", - org.apache.commons.lang, - org.apache.commons.logging, - org.osgi.service.component, - org.wso2.carbon.identity.application.common.model;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.application.common;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.application.mgt.*;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.user.api, - org.wso2.carbon.user.core.service, - org.wso2.carbon.user.core.tenant, - org.wso2.carbon.user.core.util, - org.json.simple, - javax.cache, - org.wso2.carbon.identity.core.util;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.utils, - org.wso2.carbon.context, - org.wso2.carbon.identity.oauth.*;version="${carbon.identity.framework.version.range}", - - org.wso2.carbon.base, - org.wso2.carbon.identity.application.authentication.framework.model;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.base;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.identity.oauth2.*;version="${carbon.identity.framework.version.range}", - org.wso2.carbon.utils.multitenancy, - org.apache.oltu.oauth2.common.validators, - org.apache.commons.lang3.tuple, + io.entgra.device.mgt.core.device.mgt.oauth.extensions.handlers.grant.oauth.validator, + io.entgra.device.mgt.core.device.mgt.oauth.extensions.handlers.grant.oauth.validator.internal, + javax.servlet.http;version="[2.6,3)", + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.lang3.tuple;version="[3.1,4)", + org.apache.commons.logging;version="[1.2,2)", + org.apache.oltu.oauth2.common.validators;version="[1.0,2)", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.identity.application.authentication.framework.model;version="[5.24,6)", + org.wso2.carbon.identity.application.common;version="[5.24,6)", + org.wso2.carbon.identity.application.common.model;version="[5.24,6)", + org.wso2.carbon.identity.application.mgt;version="[5.24,6)", + org.wso2.carbon.identity.core.util;version="[5.24,6)", + org.wso2.carbon.identity.oauth.cache;version="[6.9,7)", + org.wso2.carbon.identity.oauth2;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.dao;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.dto;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.grant.jwt;version="[2.1,3)", + org.wso2.carbon.identity.oauth2.internal;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.model;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.token;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.token.handlers.grant;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.token.handlers.grant.saml;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.util;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.validators;version="[6.9,7)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.user.core.tenant;version="[4.8,5)", + org.wso2.carbon.user.core.util;version="[4.8,5)", + org.wso2.carbon.utils.multitenancy;version="[4.8,5)" + + oltu;scope=compile|runtime;inline=false + diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java index 9799e8d8b8..4901099ce8 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/ScopeValidationHandler.java @@ -17,10 +17,10 @@ */ package io.entgra.device.mgt.core.device.mgt.oauth.extensions.handlers; +import io.entgra.device.mgt.core.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; import org.wso2.carbon.identity.oauth.cache.CacheEntry; import org.wso2.carbon.identity.oauth.cache.OAuthCache; import org.wso2.carbon.identity.oauth.cache.OAuthCacheKey; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java index be84f5d12f..eda3a4a811 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/grant/AccessTokenGrantHandler.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.oauth.extensions.handlers.grant; +import io.entgra.device.mgt.core.device.mgt.oauth.extensions.handlers.grant.oauth.validator.LocalOAuthValidator; +import io.entgra.device.mgt.core.device.mgt.oauth.extensions.handlers.grant.oauth.validator.OAuthValidationResponse; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.oauth.extensions.handlers.grant.oauth.validator.LocalOAuthValidator; -import io.entgra.device.mgt.core.device.mgt.oauth.extensions.handlers.grant.oauth.validator.OAuthValidationResponse; import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException; import org.wso2.carbon.identity.application.common.model.ServiceProvider; @@ -35,6 +35,7 @@ import org.wso2.carbon.identity.oauth2.token.handlers.grant.AbstractAuthorizatio import org.wso2.carbon.identity.oauth2.util.OAuth2Util; import org.wso2.carbon.user.core.util.UserCoreUtil; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + import java.rmi.RemoteException; /** diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/grant/oauth/validator/internal/OAuthAuthenticatorServiceComponent.java b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/grant/oauth/validator/internal/OAuthAuthenticatorServiceComponent.java index 5b61bbd2f8..45a3726a49 100755 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/grant/oauth/validator/internal/OAuthAuthenticatorServiceComponent.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/handlers/grant/oauth/validator/internal/OAuthAuthenticatorServiceComponent.java @@ -21,22 +21,18 @@ package io.entgra.device.mgt.core.device.mgt.oauth.extensions.handlers.grant.oau import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; -/** - * @scr.component name="io.entgra.device.mgt.core.device.mgt.oauth.extensions.authenticator" immediate="true" - * @scr.reference name="identity.oauth2.validation.service" - * interface="org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService" - * cardinality="1..1" - * policy="dynamic" - * bind="setOAuth2ValidationService" - * unbind="unsetOAuth2ValidationService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.oauth.extensions.handlers.grant.oauth.validator.internal.OAuthAuthenticatorServiceComponent", + immediate = true) public class OAuthAuthenticatorServiceComponent { private static final Log log = LogFactory.getLog(OAuthAuthenticatorServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Starting Backend OAuthAuthenticator Framework Bundle"); @@ -44,6 +40,7 @@ public class OAuthAuthenticatorServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } @@ -54,6 +51,12 @@ public class OAuthAuthenticatorServiceComponent { * @param tokenValidationService An instance of OAuth2TokenValidationService. */ @SuppressWarnings("unused") + @Reference( + name = "oauth2.token.validation.service", + service = org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetOAuth2ValidationService") protected void setOAuth2ValidationService(OAuth2TokenValidationService tokenValidationService) { if (log.isDebugEnabled()) { log.debug("Setting OAuth2TokenValidationService Service"); diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java index 4402d6a7cb..cb161906cf 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/internal/OAuthExtensionServiceComponent.java @@ -22,33 +22,15 @@ import io.entgra.device.mgt.core.device.mgt.oauth.extensions.validators.Extended import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; - +import org.osgi.service.component.annotations.*; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; import org.wso2.carbon.identity.oauth2.validators.JDBCScopeValidator; import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator; import org.wso2.carbon.user.core.service.RealmService; -/** - * @scr.component name="io.entgra.device.mgt.core.device.mgt.oauth.extensions" immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="identity.oauth2.validation.service" - * interface="org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService" - * cardinality="1..1" - * policy="dynamic" - * bind="setOAuth2ValidationService" - * unbind="unsetOAuth2ValidationService" - * * @scr.reference name="scope.validator.service" - * interface="org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator" - * cardinality="0..n" - * policy="dynamic" - * bind="addScopeValidator" - * unbind="removeScopeValidator" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.oauth.extensions.internal.OAuthExtensionServiceComponent", + immediate = true) public class OAuthExtensionServiceComponent { private static final Log log = LogFactory.getLog(OAuthExtensionServiceComponent.class); @@ -60,6 +42,7 @@ public class OAuthExtensionServiceComponent { @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Starting OAuthExtensionBundle"); @@ -75,6 +58,7 @@ public class OAuthExtensionServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Stopping OAuthExtensionBundle"); @@ -86,6 +70,12 @@ public class OAuthExtensionServiceComponent { * * @param realmService An instance of RealmService */ + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { log.debug("Setting Realm Service"); @@ -110,6 +100,12 @@ public class OAuthExtensionServiceComponent { * * @param tokenValidationService An instance of OAuth2TokenValidationService */ + @Reference( + name = "oauth2.token.validation.service", + service = org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetOAuth2ValidationService") protected void setOAuth2ValidationService(OAuth2TokenValidationService tokenValidationService) { if (log.isDebugEnabled()) { log.debug("Setting OAuth2TokenValidation Service"); @@ -133,6 +129,12 @@ public class OAuthExtensionServiceComponent { * Add scope validator to the map. * @param scopesValidator */ + @Reference( + name = "oauth2.scope.validator", + service = org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator.class, + cardinality = ReferenceCardinality.MULTIPLE, + policy = ReferencePolicy.DYNAMIC, + unbind = "removeScopeValidator") protected void addScopeValidator(OAuth2ScopeValidator scopesValidator) { OAuthExtensionsDataHolder.getInstance().addScopeValidator(scopesValidator, DEFAULT_PREFIX); } diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java index 1f8dc547ba..40f9327b94 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.oauth.extensions.validators; +import io.entgra.device.mgt.core.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; import org.wso2.carbon.identity.application.common.model.User; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.oauth.cache.CacheEntry; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java index 9ca887beb7..722a8b7c9b 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.oauth.extensions.validators; +import io.entgra.device.mgt.core.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; import org.wso2.carbon.identity.application.common.model.User; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java index 422739ea17..26d098b20f 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.device.mgt.oauth.extensions.validators; +import io.entgra.device.mgt.core.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; import org.wso2.carbon.identity.application.common.model.User; import org.wso2.carbon.identity.base.IdentityConstants; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 249ef62aec..fa65956a71 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -31,9 +31,14 @@ bundle WSO2 Carbon - Device Management JWT Client Extensions WSO2 Carbon - Device Management JWT Client Extensions - http://wso2.org + https://entgra.io + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon.governance org.wso2.carbon.governance.api @@ -55,17 +60,9 @@ org.wso2.carbon.utils - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - org.wso2.tomcat tomcat @@ -124,7 +121,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.testng @@ -171,8 +167,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -190,35 +190,35 @@ io.entgra.device.mgt.core.identity.jwt.client.extension.* + com.nimbusds.jose;version="[7.9,8)", + com.nimbusds.jose.crypto;version="[7.9,8)", + com.nimbusds.jwt;version="[7.9,8)", + io.entgra.device.mgt.core.identity.jwt.client.extension, + io.entgra.device.mgt.core.identity.jwt.client.extension.dto, + io.entgra.device.mgt.core.identity.jwt.client.extension.exception, + io.entgra.device.mgt.core.identity.jwt.client.extension.service, + javax.net.ssl, + org.apache.commons.codec.binary;version="[1.4,2)", + org.apache.commons.logging;version="[1.2,2)", + org.apache.http;version="[4.4,5)", + org.apache.http.client;version="[4.3,5)", + org.apache.http.client.entity;version="[4.3,5)", + org.apache.http.client.methods;version="[4.3,5)", + org.apache.http.conn.socket;version="[4.3,5)", + org.apache.http.conn.ssl;version="[4.3,5)", + org.apache.http.impl.client;version="[4.3,5)", + org.apache.http.message;version="[4.4,5)", + org.apache.http.util;version="[4.4,5)", + org.json.simple;version="[1.1,2)", + org.json.simple.parser;version="[1.1,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.wso2.carbon.context, - org.wso2.carbon.registry.core, - org.wso2.carbon.registry.core.exceptions, - org.wso2.carbon.registry.core.session, - org.wso2.carbon.utils, - org.apache.commons.logging, - org.wso2.carbon.registry.core.*;resolution:=optional, - org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}", - com.nimbusds.jwt.*;version="${nimbus.orbit.version.range}", - com.nimbusds.jose.*;version="${nimbus.orbit.version.range}", - javax.net.ssl, - org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.apache.http;version="${httpclient.version.range}", - org.apache.http.client;version="${httpclient.version.range}", - org.apache.http.message;version="${httpclient.version.range}", - org.apache.http.client;version="${httpclient.version.range}", - org.apache.http.conn.*;version="${httpclient.version.range}", - org.apache.http.util;version="${httpclient.version.range}", - org.apache.http.client.entity;version="${httpclient.version.range}", - org.apache.http.client.methods;version="${httpclient.version.range}", - org.apache.http.impl.client;version="${httpclient.version.range}", - org.json.simple.*, - org.wso2.carbon.core.util, - javax.net.ssl, - org.wso2.carbon.user.core.service, - org.wso2.carbon.user.core.tenant, - org.wso2.carbon.base + org.wso2.carbon.context;version="${carbon.platform.package.import.version.range}", + org.wso2.carbon.core.*; version="${carbon.platform.package.import.version.range}", + org.wso2.carbon.registry.core.*; version="${carbon.registry.imp.pkg.version}", + org.wso2.carbon.registry.indexing.*;version="${carbon.registry.package.import.version.range}", + org.wso2.carbon.user.core.*;version="${carbon.platform.package.import.version.range}", + org.wso2.carbon.utils.*; version="${carbon.platform.package.import.version.range}" @@ -263,5 +263,4 @@ - diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java index ea0ac57dd3..dff879db33 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java @@ -18,6 +18,11 @@ package io.entgra.device.mgt.core.identity.jwt.client.extension; +import io.entgra.device.mgt.core.identity.jwt.client.extension.constant.JWTConstants; +import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.util.JWTClientUtil; import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -30,11 +35,6 @@ import org.apache.http.message.BasicNameValuePair; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.constant.JWTConstants; -import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; -import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.util.JWTClientUtil; import java.io.IOException; import java.net.MalformedURLException; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/dto/JWTConfig.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/dto/JWTConfig.java index 7a1fdc0d6e..f48ac99597 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/dto/JWTConfig.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/dto/JWTConfig.java @@ -1,7 +1,7 @@ package io.entgra.device.mgt.core.identity.jwt.client.extension.dto; -import org.wso2.carbon.core.util.Utils; import io.entgra.device.mgt.core.identity.jwt.client.extension.constant.JWTConstants; +import org.wso2.carbon.core.util.Utils; import java.util.ArrayList; import java.util.List; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionServiceComponent.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionServiceComponent.java index e4ff7849b6..06082de65b 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionServiceComponent.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionServiceComponent.java @@ -18,53 +18,32 @@ */ package io.entgra.device.mgt.core.identity.jwt.client.extension.internal; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientConfigurationException; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerServiceImpl; import io.entgra.device.mgt.core.identity.jwt.client.extension.util.JWTClientUtil; +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.osgi.service.component.annotations.*; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.user.core.service.RealmService; + import java.io.IOException; -/** - * @scr.component name="io.entgra.device.mgt.core.identity.jwt.client.extension.internal.JWTClientExtensionServiceComponent" - * immediate="true" - * @scr.reference name="registry.service" - * interface="org.wso2.carbon.registry.core.service.RegistryService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRegistryService" - * unbind="unsetRegistryService" - * @scr.reference name="tenant.registryloader" - * interface="org.wso2.carbon.registry.core.service.TenantRegistryLoader" - * cardinality="1..1" - * policy="dynamic" - * bind="setTenantRegistryLoader" - * unbind="unsetTenantRegistryLoader" - * @scr.reference name="tenant.indexloader" - * interface="org.wso2.carbon.registry.indexing.service.TenantIndexingLoader" - * cardinality="1..1" - * policy="dynamic" - * bind="setIndexLoader" - * unbind="unsetIndexLoader" - * @scr.reference name="realm.service" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - */ +@Component( + name = "io.entgra.device.mgt.core.identity.jwt.client.extension.internal.JWTClientExtensionServiceComponent", + immediate = true) public class JWTClientExtensionServiceComponent { private static Log log = LogFactory.getLog(JWTClientExtensionServiceComponent.class); + // private ServiceRegistration serviceRegistration = null; + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Initializing jwt extension bundle"); @@ -83,10 +62,19 @@ public class JWTClientExtensionServiceComponent { } } + @Deactivate protected void deactivate(ComponentContext componentContext) { - //do nothing + if (log.isDebugEnabled()) { + log.info("deactivating jwt extension bundle"); + } } + @Reference( + name = "registry.service", + service = org.wso2.carbon.registry.core.service.RegistryService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRegistryService") protected void setRegistryService(RegistryService registryService) { if (registryService != null && log.isDebugEnabled()) { log.debug("Registry service initialized"); @@ -98,6 +86,12 @@ public class JWTClientExtensionServiceComponent { JWTClientExtensionDataHolder.getInstance().setRegistryService(null); } + @Reference( + name = "tenant.registry.loader", + service = org.wso2.carbon.registry.core.service.TenantRegistryLoader.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTenantRegistryLoader") protected void setTenantRegistryLoader(TenantRegistryLoader tenantRegistryLoader) { JWTClientExtensionDataHolder.getInstance().setTenantRegistryLoader(tenantRegistryLoader); } @@ -106,6 +100,12 @@ public class JWTClientExtensionServiceComponent { JWTClientExtensionDataHolder.getInstance().setTenantRegistryLoader(null); } + @Reference( + name = "tenant.index.loader", + service = org.wso2.carbon.registry.indexing.service.TenantIndexingLoader.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetIndexLoader") protected void setIndexLoader(TenantIndexingLoader indexLoader) { if (indexLoader != null && log.isDebugEnabled()) { log.debug("IndexLoader service initialized"); @@ -122,6 +122,12 @@ public class JWTClientExtensionServiceComponent { * * @param realmService An instance of RealmService */ + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { log.debug("Setting Realm Service"); diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientManagerServiceImpl.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientManagerServiceImpl.java index b74abc304a..4c3f132fa8 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientManagerServiceImpl.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientManagerServiceImpl.java @@ -18,11 +18,6 @@ package io.entgra.device.mgt.core.identity.jwt.client.extension.service; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; import io.entgra.device.mgt.core.identity.jwt.client.extension.constant.JWTConstants; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; @@ -30,6 +25,11 @@ import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClie import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientConfigurationException; import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; import io.entgra.device.mgt.core.identity.jwt.client.extension.util.JWTClientUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.Resource; import org.wso2.carbon.registry.core.exceptions.RegistryException; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java index 55be8b3afc..a42603f29c 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java @@ -24,6 +24,11 @@ import com.nimbusds.jose.JWSSigner; import com.nimbusds.jose.crypto.RSASSASigner; import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.SignedJWT; +import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientConfigurationException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.internal.JWTClientExtensionDataHolder; +import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; @@ -36,11 +41,6 @@ import org.apache.http.util.EntityUtils; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.KeyStoreManager; -import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientConfigurationException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.internal.JWTClientExtensionDataHolder; -import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.Resource; import org.wso2.carbon.registry.core.exceptions.RegistryException; @@ -48,19 +48,10 @@ import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.utils.CarbonUtils; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.io.*; import java.net.URI; import java.net.URL; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.UnrecoverableKeyException; +import java.security.*; import java.security.cert.CertificateException; import java.security.interfaces.RSAPrivateKey; import java.util.Date; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientManagerServiceTest.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientManagerServiceTest.java index 28d058b538..7117f29902 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientManagerServiceTest.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientManagerServiceTest.java @@ -17,14 +17,14 @@ */ package io.entgra.device.mgt.core.identity.jwt.client.extension.service; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientConfigurationException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.service.common.BaseJWTClientManagerExtTest; 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 io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientConfigurationException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.service.common.BaseJWTClientManagerExtTest; import java.util.Properties; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java index 15f2476ee2..1b8492fc5d 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java @@ -17,6 +17,11 @@ */ package io.entgra.device.mgt.core.identity.jwt.client.extension.service; +import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; +import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; +import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.util.JWTClientUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; @@ -30,11 +35,6 @@ import org.testng.IObjectFactory; import org.testng.annotations.BeforeClass; import org.testng.annotations.ObjectFactory; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; -import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; -import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.util.JWTClientUtil; import java.io.IOException; import java.security.KeyManagementException; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientUtilTest.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientUtilTest.java index 64e92e6fff..32177e1f93 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientUtilTest.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientUtilTest.java @@ -17,6 +17,9 @@ */ package io.entgra.device.mgt.core.identity.jwt.client.extension.service; +import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.util.JWTClientUtil; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.HttpVersion; @@ -29,9 +32,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.ObjectFactory; import org.testng.annotations.Test; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.util.JWTClientUtil; import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.io.ByteArrayInputStream; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/common/BaseJWTClientManagerExtTest.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/common/BaseJWTClientManagerExtTest.java index 7103ac87dc..e68bd901c3 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/common/BaseJWTClientManagerExtTest.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/common/BaseJWTClientManagerExtTest.java @@ -18,13 +18,13 @@ */ package io.entgra.device.mgt.core.identity.jwt.client.extension.service.common; +import io.entgra.device.mgt.core.identity.jwt.client.extension.internal.JWTClientExtensionDataHolder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeSuite; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.identity.jwt.client.extension.internal.JWTClientExtensionDataHolder; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml index 897e33581c..2337c777e2 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml @@ -1,4 +1,4 @@ - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml index 0a9289da70..4f5e043a15 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml @@ -1,4 +1,4 @@ - + + + @@ -59,6 +59,11 @@ org.apache.maven.plugins maven-compiler-plugin + + + 1.8 + 1.8 + org.apache.felix @@ -71,10 +76,12 @@ ${io.entgra.device.mgt.core.version} Device Notification Logger Bundle - io.entgra.device.mgt.core.device.mgt.extensions.logger.*, - org.apache.commons.logging;version="[1.2,2)", - org.apache.log4j;version="[1.2,2)", - org.wso2.carbon.context;version="[4.4,5) + io.entgra.device.mgt.core.device.mgt.extensions.logger;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="[5.0,6)", + io.entgra.device.mgt.core.notification.logger, + io.entgra.device.mgt.core.notification.logger.util, + org.apache.commons.logging;version="[1.2,2)" + io.entgra.device.mgt.core.notification.logger.* diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 5375683ce9..baabe4d82f 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -36,8 +36,6 @@ - 8 - 8 UTF-8 diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index d92821cfc6..8c70a21b01 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -37,10 +37,10 @@ org.apache.maven.plugins maven-compiler-plugin - - - org.apache.felix - maven-scr-plugin + + 1.8 + 1.8 + org.apache.felix @@ -54,32 +54,33 @@ IOT Operation Template Bundle io.entgra.device.mgt.core.operation.template.internal + com.google.common.cache;version="[31.0,32)", + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.operation.template.cache, + io.entgra.device.mgt.core.operation.template.dao, + io.entgra.device.mgt.core.operation.template.dao.impl, + io.entgra.device.mgt.core.operation.template.dao.impl.config, + io.entgra.device.mgt.core.operation.template.dao.impl.config.datasource, + io.entgra.device.mgt.core.operation.template.dao.impl.util, + io.entgra.device.mgt.core.operation.template.dto, + io.entgra.device.mgt.core.operation.template.exception, + io.entgra.device.mgt.core.operation.template.impl, + io.entgra.device.mgt.core.operation.template.spi, + io.entgra.device.mgt.core.operation.template.util, + javax.naming, + javax.sql, + javax.xml.bind;version="[2.3,3)", + javax.xml.bind.annotation;version="[2.3,3)", + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", + org.apache.commons.lang;version="[2.4,3)", + org.apache.commons.logging;version="[1.2,2)", 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.*;version="${javax.xml.bind.imp.pkg.version}", - javax.sql, - javax.xml.parsers; version=0.0.0, - org.w3c.dom, - com.google.gson.*, - javax.naming, - org.wso2.carbon.context, - org.wso2.carbon.base, - org.wso2.carbon.utils.*, - io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.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, - io.entgra.device.mgt.core.device.mgt.extensions.license.mgt.registry, - javax.net.ssl, - org.wso2.carbon.core.util, - okhttp3 + org.w3c.dom,org.wso2.carbon.ndatasource.core;version="[4.8,5)", + org.wso2.carbon.registry.core.service;version="[1.0,2)", + org.wso2.carbon.utils;version="[4.8,5)" !io.entgra.device.mgt.core.operation.template.internal, @@ -130,6 +131,11 @@ + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.common @@ -159,10 +165,6 @@ org.codehaus.woodstox wstx-asl - - - - org.wso2.carbon.analytics org.wso2.carbon.analytics.api @@ -232,21 +234,11 @@ - - org.eclipse.osgi - org.eclipse.osgi - provided - org.wso2.orbit.com.h2database h2 test - - org.eclipse.osgi - org.eclipse.osgi.services - provided - org.wso2.carbon org.wso2.carbon.core @@ -256,7 +248,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/OperationTemplateDAOFactory.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/OperationTemplateDAOFactory.java index c5a63ef251..e2f7145487 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/OperationTemplateDAOFactory.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/OperationTemplateDAOFactory.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.operation.template.dao; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.operation.template.dao.impl.OperationTemplateDAOImpl; import io.entgra.device.mgt.core.operation.template.dao.impl.OperationTemplateMySQLDAOImpl; import io.entgra.device.mgt.core.operation.template.dao.impl.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.operation.template.util.ConnectionManagerUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; public class OperationTemplateDAOFactory { diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/OperationTemplateDAOImpl.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/OperationTemplateDAOImpl.java index 5111e48292..3fd1a9195d 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/OperationTemplateDAOImpl.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/OperationTemplateDAOImpl.java @@ -19,22 +19,17 @@ package io.entgra.device.mgt.core.operation.template.dao.impl; import com.google.gson.Gson; -import io.entgra.device.mgt.core.operation.template.dto.OperationTemplate; import io.entgra.device.mgt.core.operation.template.dao.OperationTemplateDAO; +import io.entgra.device.mgt.core.operation.template.dto.OperationTemplate; import io.entgra.device.mgt.core.operation.template.exception.DBConnectionException; import io.entgra.device.mgt.core.operation.template.exception.OperationTemplateManagementDAOException; import io.entgra.device.mgt.core.operation.template.util.ConnectionManagerUtils; import io.entgra.device.mgt.core.operation.template.util.DAOUtil; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.sql.*; + /** * Implementation for generic DB engines. */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/config/DeviceConfigurationManager.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/config/DeviceConfigurationManager.java index e28960d1d3..968e1470f3 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/config/DeviceConfigurationManager.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/config/DeviceConfigurationManager.java @@ -18,9 +18,9 @@ package io.entgra.device.mgt.core.operation.template.dao.impl.config; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.operation.template.dao.impl.util.OperationTemplateManagementUtil; import org.w3c.dom.Document; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/util/OperationTemplateManagementUtil.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/util/OperationTemplateManagementUtil.java index e648778170..f340d3014e 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/util/OperationTemplateManagementUtil.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/dao/impl/util/OperationTemplateManagementUtil.java @@ -18,9 +18,9 @@ package io.entgra.device.mgt.core.operation.template.dao.impl.util; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.operation.template.dto.OperationTemplateCacheKey; import org.w3c.dom.Document; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/impl/OperationTemplateServiceImpl.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/impl/OperationTemplateServiceImpl.java index 4ae9d343c1..b25356f8cd 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/impl/OperationTemplateServiceImpl.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/impl/OperationTemplateServiceImpl.java @@ -30,8 +30,8 @@ import io.entgra.device.mgt.core.operation.template.exception.DBConnectionExcept import io.entgra.device.mgt.core.operation.template.exception.OperationTemplateManagementDAOException; import io.entgra.device.mgt.core.operation.template.exception.OperationTemplateMgtPluginException; import io.entgra.device.mgt.core.operation.template.spi.OperationTemplateService; -import io.entgra.device.mgt.core.operation.template.util.ConnectionManagerUtils; import io.entgra.device.mgt.core.operation.template.util.AssertUtils; +import io.entgra.device.mgt.core.operation.template.util.ConnectionManagerUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/internal/OperationTemplateMgtDataHolder.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/internal/OperationTemplateMgtDataHolder.java index bab25b690e..61af773f47 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/internal/OperationTemplateMgtDataHolder.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/internal/OperationTemplateMgtDataHolder.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.operation.template.internal; -import io.entgra.device.mgt.core.operation.template.spi.OperationTemplateService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.operation.template.spi.OperationTemplateService; import org.wso2.carbon.registry.core.service.RegistryService; /** diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/internal/OperationTemplateMgtServiceComponent.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/internal/OperationTemplateMgtServiceComponent.java index 2a35ebb632..90b67e1a09 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/internal/OperationTemplateMgtServiceComponent.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/internal/OperationTemplateMgtServiceComponent.java @@ -28,18 +28,12 @@ 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.osgi.service.component.annotations.*; import org.wso2.carbon.ndatasource.core.DataSourceService; -/** - * @scr.component name="io.entgra.device.mgt.operation.template.internal.OperationTemplateMgtServiceComponent" immediate="true" - * immediate="true" - * @scr.reference name="org.wso2.carbon.ndatasource" - * interface="org.wso2.carbon.ndatasource.core.DataSourceService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDataSourceService" - * unbind="unsetDataSourceService" - */ +@Component( + name = "io.entgra.device.mgt.core.operation.template.internal.OperationTemplateMgtServiceComponent", + immediate = true) public class OperationTemplateMgtServiceComponent { private static final Log log = LogFactory.getLog(OperationTemplateMgtServiceComponent.class); @@ -48,6 +42,7 @@ public class OperationTemplateMgtServiceComponent { * * @param componentContext */ + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { @@ -77,6 +72,7 @@ public class OperationTemplateMgtServiceComponent { * * @param componentContext */ + @Deactivate protected void deactivate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("De-activating Operation Template Management Service Component"); @@ -94,6 +90,12 @@ public class OperationTemplateMgtServiceComponent { * * @param dataSourceService */ + @Reference( + name = "datasource.service", + service = org.wso2.carbon.ndatasource.core.DataSourceService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDataSourceService") protected void setDataSourceService(DataSourceService dataSourceService) { /* This is to avoid mobile device management component getting initialized before the underlying datasources are registered */ diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/util/ConnectionManagerUtils.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/util/ConnectionManagerUtils.java index 1945ddfaa0..f2cad4f3f4 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/util/ConnectionManagerUtils.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/util/ConnectionManagerUtils.java @@ -18,20 +18,19 @@ package io.entgra.device.mgt.core.operation.template.util; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.operation.template.dao.impl.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.operation.template.dao.impl.config.datasource.JNDILookupDefinition; import io.entgra.device.mgt.core.operation.template.exception.DBConnectionException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import javax.naming.InitialContext; +import javax.sql.DataSource; import java.sql.Connection; import java.sql.SQLException; import java.util.Hashtable; import java.util.List; -import javax.naming.InitialContext; -import javax.sql.DataSource; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; /** * Connection Manager Utils class. diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/ServiceNegativeTest.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/ServiceNegativeTest.java index 5b6fa1d445..a5e9ec6275 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/ServiceNegativeTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/ServiceNegativeTest.java @@ -21,8 +21,8 @@ package io.entgra.device.mgt.core.operation.template; import io.entgra.device.mgt.core.operation.template.dto.OperationTemplate; import io.entgra.device.mgt.core.operation.template.exception.OperationTemplateMgtPluginException; import io.entgra.device.mgt.core.operation.template.impl.OperationTemplateServiceImpl; -import io.entgra.device.mgt.core.operation.template.spi.OperationTemplateService; import io.entgra.device.mgt.core.operation.template.mock.BaseOperationTemplatePluginTest; +import io.entgra.device.mgt.core.operation.template.spi.OperationTemplateService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.annotations.BeforeClass; diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java index 131c0de39e..829b79ac65 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java @@ -18,10 +18,13 @@ package io.entgra.device.mgt.core.operation.template.mock; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import io.entgra.device.mgt.core.operation.template.DataSourceConfig; +import io.entgra.device.mgt.core.operation.template.TestUtils; import io.entgra.device.mgt.core.operation.template.dao.OperationTemplateDAOFactory; import io.entgra.device.mgt.core.operation.template.util.ConnectionManagerUtils; -import io.entgra.device.mgt.core.operation.template.TestUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.tomcat.jdbc.pool.PoolProperties; @@ -32,9 +35,6 @@ import org.testng.annotations.Parameters; import org.w3c.dom.Document; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import javax.sql.DataSource; import javax.xml.bind.JAXBContext; diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockConnection.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockConnection.java index 19d5c8f28c..e8489a82a3 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockConnection.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockConnection.java @@ -18,21 +18,7 @@ package io.entgra.device.mgt.core.operation.template.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.sql.*; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockDatabaseMetaData.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockDatabaseMetaData.java index bc610469bc..2c397dd1f1 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockDatabaseMetaData.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockDatabaseMetaData.java @@ -20,11 +20,7 @@ package io.entgra.device.mgt.core.operation.template.mock; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.RowIdLifetime; -import java.sql.DatabaseMetaData; -import java.sql.SQLException; +import java.sql.*; public class MockDatabaseMetaData implements DatabaseMetaData { private final String url; diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockResultSet.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockResultSet.java index 16fb7c09c1..0f0187acc9 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockResultSet.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockResultSet.java @@ -22,21 +22,7 @@ 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.sql.*; import java.util.ArrayList; import java.util.Calendar; import java.util.List; diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockStatement.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockStatement.java index 84adadd585..a35641f2c1 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockStatement.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/MockStatement.java @@ -22,23 +22,7 @@ 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.sql.*; import java.util.ArrayList; import java.util.Calendar; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 62d02c301c..641afa455e 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -12,13 +12,17 @@ bundle WSO2 Carbon - Policy Decision Point WSO2 Carbon - Policy Decision Point - http://wso2.org + https://entgra.io - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -32,14 +36,18 @@ Policy Decision Point Bundle io.entgra.device.mgt.core.policy.decision.point.internal - org.wso2.carbon.context;version="${carbon.kernel.version.range}", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.policy.decision.point.internal, + io.entgra.device.mgt.core.policy.decision.point.merged, + io.entgra.device.mgt.core.policy.decision.point.simple, + io.entgra.device.mgt.core.policy.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.policy.mgt.core;version="[5.0,6)", + org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - io.entgra.device.mgt.core.policy.mgt.common.*, - io.entgra.device.mgt.core.policy.mgt.core.*, - org.wso2.carbon.user.core.*, - io.entgra.device.mgt.core.device.mgt.common.* + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.user.core.service;version="[4.8,5)" io.entgra.device.mgt.core.policy.decision.point.* @@ -77,12 +85,9 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.equinox - org.eclipse.equinox.common + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.ops4j.pax.logging diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/internal/MergedPolicyEvaluationServiceComponent.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/internal/MergedPolicyEvaluationServiceComponent.java index 24692c2c10..85e985c51b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/internal/MergedPolicyEvaluationServiceComponent.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/internal/MergedPolicyEvaluationServiceComponent.java @@ -19,33 +19,22 @@ package io.entgra.device.mgt.core.policy.decision.point.internal; import io.entgra.device.mgt.core.policy.decision.point.merged.MergedEvaluationPoint; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; +import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; -import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.user.core.service.RealmService; -/** - * @scr.component name="org.wso2.carbon.policy.decision.MergedPolicyEvaluationServiceComponent" immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="org.wso2.carbon.devicemgt.policy.manager" - * interface="io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService" - * cardinality="0..1" - * policy="dynamic" - * bind="setPolicyManagerService" - * unbind="unsetPolicyManagerService" - */ - +@Component( + name = "io.entgra.device.mgt.core.policy.decision.point.internal.MergedPolicyEvaluationServiceComponent", + immediate = true) public class MergedPolicyEvaluationServiceComponent { private static Log log = LogFactory.getLog(MergedPolicyEvaluationServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Activating the policy evaluation bundle."); @@ -59,6 +48,7 @@ public class MergedPolicyEvaluationServiceComponent { } } + @Deactivate protected void deactivate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("De-activating the policy evaluation bundle."); @@ -70,6 +60,12 @@ public class MergedPolicyEvaluationServiceComponent { * * @param realmService An instance of RealmService */ + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { @@ -90,6 +86,12 @@ public class MergedPolicyEvaluationServiceComponent { PolicyDecisionPointDataHolder.getInstance().setRealmService(null); } + @Reference( + name = "policy.mgt.service", + service = io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetPolicyManagerService") protected void setPolicyManagerService(PolicyManagerService policyManagerService) { if (log.isDebugEnabled()) { log.debug("Unsetting PolicyManagerService Service"); diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/internal/PolicyEvaluationServiceComponent.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/internal/PolicyEvaluationServiceComponent.java index fe5cf9d206..e42ffbe652 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/internal/PolicyEvaluationServiceComponent.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/internal/PolicyEvaluationServiceComponent.java @@ -19,33 +19,22 @@ package io.entgra.device.mgt.core.policy.decision.point.internal; import io.entgra.device.mgt.core.policy.decision.point.simple.PolicyEvaluationServiceImpl; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; +import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; -import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.user.core.service.RealmService; -/** - * @scr.component name="org.wso2.carbon.simple.policy.decision.PolicyEvaluationServiceComponent" immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="org.wso2.carbon.devicemgt.policy.manager" - * interface="io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService" - * cardinality="0..1" - * policy="dynamic" - * bind="setPolicyManagerService" - * unbind="unsetPolicyManagerService" - */ - +@Component( + name = "io.entgra.device.mgt.core.policy.decision.point.internal.PolicyEvaluationServiceComponent", + immediate = true) public class PolicyEvaluationServiceComponent { private static Log log = LogFactory.getLog(PolicyEvaluationServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Activating the policy evaluation bundle."); @@ -58,7 +47,7 @@ public class PolicyEvaluationServiceComponent { log.error("Error occurred while initializing the policy evaluation bundle"); } } - + @Deactivate protected void deactivate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("De-activating the policy evaluation bundle."); @@ -70,6 +59,12 @@ public class PolicyEvaluationServiceComponent { * * @param realmService An instance of RealmService */ + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { @@ -90,6 +85,12 @@ public class PolicyEvaluationServiceComponent { PolicyDecisionPointDataHolder.getInstance().setRealmService(null); } + @Reference( + name = "policy.mgt.service", + service = io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetPolicyManagerService") protected void setPolicyManagerService(PolicyManagerService policyManagerService) { if (log.isDebugEnabled()) { diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/merged/MergedEvaluationPoint.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/merged/MergedEvaluationPoint.java index e075119881..39b322d6b7 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/merged/MergedEvaluationPoint.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/merged/MergedEvaluationPoint.java @@ -18,16 +18,16 @@ package io.entgra.device.mgt.core.policy.decision.point.merged; -import io.entgra.device.mgt.core.policy.decision.point.internal.PolicyDecisionPointDataHolder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; +import io.entgra.device.mgt.core.policy.decision.point.internal.PolicyDecisionPointDataHolder; import io.entgra.device.mgt.core.policy.mgt.common.*; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Timestamp; import java.util.*; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/simple/PolicyEvaluationServiceImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/simple/PolicyEvaluationServiceImpl.java index 2aafb1159b..746b708173 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/simple/PolicyEvaluationServiceImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/simple/PolicyEvaluationServiceImpl.java @@ -20,9 +20,9 @@ package io.entgra.device.mgt.core.policy.decision.point.simple; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationException; import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/simple/SimpleEvaluationImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/simple/SimpleEvaluationImpl.java index c21cb848c1..696bafdfab 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/simple/SimpleEvaluationImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/src/main/java/io/entgra/device/mgt/core/policy/decision/point/simple/SimpleEvaluationImpl.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.policy.decision.point.simple; -import io.entgra.device.mgt.core.policy.decision.point.internal.PolicyDecisionPointDataHolder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; +import io.entgra.device.mgt.core.policy.decision.point.internal.PolicyDecisionPointDataHolder; import io.entgra.device.mgt.core.policy.mgt.common.*; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.Collections; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index c32695d6b2..6d4835556c 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -13,14 +13,18 @@ bundle WSO2 Carbon - Policy Information Point WSO2 Carbon - Policy Information Point - http://wso2.org + https://entgra.io - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -37,6 +41,14 @@ io.entgra.device.mgt.core.policy.information.point.* + + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.policy.information.point, + io.entgra.device.mgt.core.policy.mgt.common;version="[5.0,6)", + org.apache.commons.logging;version="[1.2,2)", + org.osgi.framework.*;version="${imp.package.version.osgi.framework}" + @@ -70,12 +82,9 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.equinox - org.eclipse.equinox.common + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.ops4j.pax.logging diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/src/main/java/io/entgra/device/mgt/core/policy/information/point/PolicyInformationServiceImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/src/main/java/io/entgra/device/mgt/core/policy/information/point/PolicyInformationServiceImpl.java index 139a7e1c67..223fab9142 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/src/main/java/io/entgra/device/mgt/core/policy/information/point/PolicyInformationServiceImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/src/main/java/io/entgra/device/mgt/core/policy/information/point/PolicyInformationServiceImpl.java @@ -20,8 +20,8 @@ package io.entgra.device.mgt.core.policy.information.point; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.Feature; -import io.entgra.device.mgt.core.policy.mgt.common.PIPDevice; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; +import io.entgra.device.mgt.core.policy.mgt.common.PIPDevice; import io.entgra.device.mgt.core.policy.mgt.common.PolicyInformationPoint; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/src/main/java/io/entgra/device/mgt/core/policy/information/point/internal/PolicyInformationPointBundleActivator.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/src/main/java/io/entgra/device/mgt/core/policy/information/point/internal/PolicyInformationPointBundleActivator.java index b65388c7db..884cbdaaaf 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/src/main/java/io/entgra/device/mgt/core/policy/information/point/internal/PolicyInformationPointBundleActivator.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/src/main/java/io/entgra/device/mgt/core/policy/information/point/internal/PolicyInformationPointBundleActivator.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.policy.information.point.internal; +import io.entgra.device.mgt.core.policy.information.point.PolicyInformationServiceImpl; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyInformationPoint; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import io.entgra.device.mgt.core.policy.information.point.PolicyInformationServiceImpl; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyInformationPoint; public class PolicyInformationPointBundleActivator implements BundleActivator { diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 2ac8356ba7..7c84c52170 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -31,13 +31,17 @@ bundle WSO2 Carbon - Policy Management Common WSO2 Carbon - Policy Management Common - http://wso2.org + https://entgra.io - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -50,11 +54,11 @@ ${io.entgra.device.mgt.core.version} Policy Management Common Bundle - javax.xml.bind.annotation, - io.swagger.annotations.*;resolution:=optional, - io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.core.dto.*, - javax.xml.bind.*, + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.dto;version="[5.0,6)" io.entgra.device.mgt.core.policy.mgt.common.* @@ -93,18 +97,14 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.equinox - org.eclipse.equinox.common + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.ops4j.pax.logging pax-logging-api provided - org.testng diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/src/main/java/io/entgra/device/mgt/core/policy/mgt/common/PolicyAdministratorPoint.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/src/main/java/io/entgra/device/mgt/core/policy/mgt/common/PolicyAdministratorPoint.java index 6934803f8d..a72de49e6f 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/src/main/java/io/entgra/device/mgt/core/policy/mgt/common/PolicyAdministratorPoint.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/src/main/java/io/entgra/device/mgt/core/policy/mgt/common/PolicyAdministratorPoint.java @@ -17,8 +17,8 @@ */ package io.entgra.device.mgt.core.policy.mgt.common; + import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/src/main/java/io/entgra/device/mgt/core/policy/mgt/common/monitor/ComplianceDecisionPoint.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/src/main/java/io/entgra/device/mgt/core/policy/mgt/common/monitor/ComplianceDecisionPoint.java index ef79616ddb..a0463b57bb 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/src/main/java/io/entgra/device/mgt/core/policy/mgt/common/monitor/ComplianceDecisionPoint.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/src/main/java/io/entgra/device/mgt/core/policy/mgt/common/monitor/ComplianceDecisionPoint.java @@ -22,9 +22,9 @@ package io.entgra.device.mgt.core.policy.mgt.common.monitor; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index c31384c31d..b98c1cbf55 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -31,13 +31,17 @@ bundle WSO2 Carbon - Policy Management Core WSO2 Carbon - Policy Management Core - http://wso2.org + https://entgra.io - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -51,24 +55,53 @@ Policy Management Core Bundle io.entgra.device.mgt.core.policy.mgt.core.internal + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.configuration.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config.policy;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config.tenant;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.dto;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.task.impl;version="[5.0,6)", + io.entgra.device.mgt.core.policy.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.policy.mgt.common.monitor;version="[5.0,6)", + io.entgra.device.mgt.core.policy.mgt.core.cache, + io.entgra.device.mgt.core.policy.mgt.core.cache.impl, + io.entgra.device.mgt.core.policy.mgt.core.config, + io.entgra.device.mgt.core.policy.mgt.core.config.datasource, + io.entgra.device.mgt.core.policy.mgt.core.dao, + io.entgra.device.mgt.core.policy.mgt.core.dao.impl, + io.entgra.device.mgt.core.policy.mgt.core.dao.impl.feature, + io.entgra.device.mgt.core.policy.mgt.core.dao.impl.policy, + io.entgra.device.mgt.core.policy.mgt.core.dao.util, + io.entgra.device.mgt.core.policy.mgt.core.mgt, + io.entgra.device.mgt.core.policy.mgt.core.mgt.bean, + io.entgra.device.mgt.core.policy.mgt.core.util, + javax.cache;version="[1.0,2)", + javax.naming, + javax.sql, + javax.xml.bind;version="[0.0,1)", + javax.xml.bind.annotation;version="[0.0,1)", + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - javax.sql, - javax.cache, - javax.naming, - javax.xml.*, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, org.w3c.dom, - io.entgra.device.mgt.core.policy.mgt.common.*, - org.wso2.carbon.user.core.*, - org.wso2.carbon.utils.*, - org.wso2.carbon.context.*, - org.wso2.carbon.user.api.*, - io.entgra.device.mgt.core.device.mgt.core.*, - io.entgra.device.mgt.core.device.mgt.common.*, - org.wso2.carbon.ntask.*, - org.wso2.carbon.caching.* + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.ntask.common;version="[4.9,5)", + org.wso2.carbon.ntask.core;version="[4.9,5)", + org.wso2.carbon.ntask.core.service;version="[4.9,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.utils;version="[4.8,5)" !io.entgra.device.mgt.core.policy.mgt.core.internal, @@ -122,27 +155,19 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.equinox - org.eclipse.equinox.common + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon org.wso2.carbon.utils - - - - org.wso2.carbon org.wso2.carbon.core @@ -212,11 +237,6 @@ h2 test - - - - - diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerService.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerService.java index 42a0ae2e76..49bccc0221 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerService.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerService.java @@ -19,18 +19,15 @@ package io.entgra.device.mgt.core.policy.mgt.core; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.Feature; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; -import io.entgra.device.mgt.core.policy.mgt.common.*; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; +import io.entgra.device.mgt.core.policy.mgt.common.*; import io.entgra.device.mgt.core.policy.mgt.core.task.TaskScheduleService; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerServiceImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerServiceImpl.java index 02de4af98c..60748fb9aa 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerServiceImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerServiceImpl.java @@ -35,22 +35,17 @@ package io.entgra.device.mgt.core.policy.mgt.core; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.Feature; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; -import io.entgra.device.mgt.core.policy.mgt.common.*; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; +import io.entgra.device.mgt.core.policy.mgt.common.*; import io.entgra.device.mgt.core.policy.mgt.core.impl.PolicyAdministratorPointImpl; import io.entgra.device.mgt.core.policy.mgt.core.impl.PolicyInformationPointImpl; import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; @@ -61,6 +56,8 @@ import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.PolicyManagerImpl; import io.entgra.device.mgt.core.policy.mgt.core.task.TaskScheduleService; import io.entgra.device.mgt.core.policy.mgt.core.task.TaskScheduleServiceImpl; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/cache/PolicyCacheManager.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/cache/PolicyCacheManager.java index 1c132cb3fd..8e1dc7fe17 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/cache/PolicyCacheManager.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/cache/PolicyCacheManager.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.cache; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java index 06431891d4..b4e80c68b6 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java @@ -19,9 +19,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.cache.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; import io.entgra.device.mgt.core.policy.mgt.core.cache.PolicyCacheManager; @@ -29,6 +26,8 @@ import io.entgra.device.mgt.core.policy.mgt.core.mgt.PolicyManager; import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.PolicyManagerImpl; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.cache.Cache; import java.util.ArrayList; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/config/PolicyConfigurationManager.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/config/PolicyConfigurationManager.java index 2f61677584..7ca2b294de 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/config/PolicyConfigurationManager.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/config/PolicyConfigurationManager.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.policy.mgt.core.config; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; import io.entgra.device.mgt.core.policy.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.w3c.dom.Document; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/MonitoringDAO.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/MonitoringDAO.java index dd5a218e3a..ec832a7634 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/MonitoringDAO.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/MonitoringDAO.java @@ -21,8 +21,8 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceData; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.policy.mgt.common.monitor.PolicyDeviceWrapper; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/PolicyDAO.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/PolicyDAO.java index dd019d17b5..983174d6cf 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/PolicyDAO.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/PolicyDAO.java @@ -38,10 +38,10 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.CorrectiveAction; -import io.entgra.device.mgt.core.policy.mgt.common.Criterion; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.DeviceGroupWrapper; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyCriterion; +import io.entgra.device.mgt.core.policy.mgt.common.Criterion; import java.util.HashMap; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/PolicyManagementDAOFactory.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/PolicyManagementDAOFactory.java index 71e9af6e4d..7851815d6c 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/PolicyManagementDAOFactory.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/PolicyManagementDAOFactory.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnsupportedDatabaseEngineException; @@ -35,6 +33,8 @@ import io.entgra.device.mgt.core.policy.mgt.core.dao.impl.policy.OraclePolicyDAO import io.entgra.device.mgt.core.policy.mgt.core.dao.impl.policy.PostgreSQLPolicyDAOImpl; import io.entgra.device.mgt.core.policy.mgt.core.dao.impl.policy.SQLServerPolicyDAOImpl; import io.entgra.device.mgt.core.policy.mgt.core.dao.util.PolicyManagementDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/MonitoringDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/MonitoringDAOImpl.java index 851bd87d6c..f1b18ad955 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/MonitoringDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/MonitoringDAOImpl.java @@ -19,19 +19,19 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceData; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.policy.mgt.common.monitor.PolicyDeviceWrapper; import io.entgra.device.mgt.core.policy.mgt.core.dao.MonitoringDAO; import io.entgra.device.mgt.core.policy.mgt.core.dao.MonitoringDAOException; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.dao.util.PolicyManagementDAOUtil; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.*; import java.util.*; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/ProfileDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/ProfileDAOImpl.java index 78678470da..8f61defcbc 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/ProfileDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/ProfileDAOImpl.java @@ -18,15 +18,14 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.dao.ProfileDAO; import io.entgra.device.mgt.core.policy.mgt.core.dao.ProfileManagerDAOException; import io.entgra.device.mgt.core.policy.mgt.core.dao.util.PolicyManagementDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/AbstractFeatureDAO.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/AbstractFeatureDAO.java index df02a5107d..9c2035f635 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/AbstractFeatureDAO.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/AbstractFeatureDAO.java @@ -18,9 +18,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl.feature; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Feature; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; @@ -29,6 +26,9 @@ import io.entgra.device.mgt.core.policy.mgt.core.dao.FeatureManagerDAOException; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.dao.util.PolicyManagementDAOUtil; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.ByteArrayInputStream; import java.io.IOException; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/GenericFeatureDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/GenericFeatureDAOImpl.java index 1c6adecb98..71cff8a38b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/GenericFeatureDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/GenericFeatureDAOImpl.java @@ -18,14 +18,14 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl.feature; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import io.entgra.device.mgt.core.policy.mgt.core.dao.FeatureManagerDAOException; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.dao.util.PolicyManagementDAOUtil; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.IOException; import java.sql.Connection; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/OracleServerFeatureDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/OracleServerFeatureDAOImpl.java index 3abd096d26..58a9e317f9 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/OracleServerFeatureDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/OracleServerFeatureDAOImpl.java @@ -17,12 +17,12 @@ */ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl.feature; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import io.entgra.device.mgt.core.policy.mgt.core.dao.FeatureManagerDAOException; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.dao.util.PolicyManagementDAOUtil; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.IOException; import java.sql.Connection; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/SQLServerFeatureDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/SQLServerFeatureDAOImpl.java index ae3c418c66..a60f6acd83 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/SQLServerFeatureDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/feature/SQLServerFeatureDAOImpl.java @@ -18,14 +18,14 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl.feature; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import io.entgra.device.mgt.core.policy.mgt.core.dao.FeatureManagerDAOException; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.dao.util.PolicyManagementDAOUtil; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.IOException; import java.sql.Connection; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java index 88b090bc1e..bebf93ca33 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java @@ -35,9 +35,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl.policy; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.CorrectiveAction; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.DeviceGroupWrapper; @@ -50,21 +47,15 @@ import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagerDAOException; import io.entgra.device.mgt.core.policy.mgt.core.dao.util.PolicyManagementDAOUtil; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; import io.entgra.device.mgt.core.policy.mgt.core.util.SetReferenceTransformer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.HashMap; -import java.util.List; -import java.util.Properties; +import java.sql.*; +import java.util.*; /** * Abstract implementation of PolicyDAO which holds generic SQL queries. diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/GenericPolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/GenericPolicyDAOImpl.java index 9608e56637..fd1debda36 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/GenericPolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/GenericPolicyDAOImpl.java @@ -19,13 +19,13 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl.policy; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagerDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/OraclePolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/OraclePolicyDAOImpl.java index a0efdc4258..d4f1630559 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/OraclePolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/OraclePolicyDAOImpl.java @@ -19,13 +19,13 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl.policy; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagerDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/PostgreSQLPolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/PostgreSQLPolicyDAOImpl.java index c3025c4d2a..89065d783f 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/PostgreSQLPolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/PostgreSQLPolicyDAOImpl.java @@ -19,13 +19,13 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl.policy; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagerDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/SQLServerPolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/SQLServerPolicyDAOImpl.java index 62eac0338d..0bb44e70f4 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/SQLServerPolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/SQLServerPolicyDAOImpl.java @@ -19,13 +19,13 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl.policy; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagerDAOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/enforcement/DelegationTask.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/enforcement/DelegationTask.java index 71f108d61e..7cf274fdbb 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/enforcement/DelegationTask.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/enforcement/DelegationTask.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.enforcement; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; @@ -33,6 +31,8 @@ import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHo import io.entgra.device.mgt.core.policy.mgt.core.mgt.PolicyManager; import io.entgra.device.mgt.core.policy.mgt.core.mgt.bean.UpdatedPolicyDeviceListBean; import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.PolicyManagerImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java index 0f972c58c6..602d189079 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java @@ -34,8 +34,6 @@ */ package io.entgra.device.mgt.core.policy.mgt.core.enforcement; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; @@ -53,6 +51,8 @@ import io.entgra.device.mgt.core.policy.mgt.common.PolicyTransformException; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/ComplianceDecisionPointImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/ComplianceDecisionPointImpl.java index 74ab005edb..218a78975b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/ComplianceDecisionPointImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/ComplianceDecisionPointImpl.java @@ -36,24 +36,26 @@ package io.entgra.device.mgt.core.policy.mgt.core.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.PolicyOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.policy.mgt.common.monitor.ComplianceDecisionPoint; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java index bf2208f2a4..bcf26e7470 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java @@ -18,21 +18,15 @@ package io.entgra.device.mgt.core.policy.mgt.core.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.policy.PolicyConfiguration; -import org.wso2.carbon.ntask.common.TaskException; -import org.wso2.carbon.ntask.core.TaskInfo; -import org.wso2.carbon.ntask.core.TaskManager; -import org.wso2.carbon.ntask.core.service.TaskService; -import io.entgra.device.mgt.core.policy.mgt.common.*; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyAdministratorPoint; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; +import io.entgra.device.mgt.core.policy.mgt.common.ProfileManagementException; import io.entgra.device.mgt.core.policy.mgt.core.cache.PolicyCacheManager; import io.entgra.device.mgt.core.policy.mgt.core.cache.impl.PolicyCacheManagerImpl; import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; @@ -41,6 +35,13 @@ import io.entgra.device.mgt.core.policy.mgt.core.mgt.ProfileManager; import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.PolicyManagerImpl; import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.ProfileManagerImpl; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.ntask.common.TaskException; +import org.wso2.carbon.ntask.core.TaskInfo; +import org.wso2.carbon.ntask.core.TaskManager; +import org.wso2.carbon.ntask.core.service.TaskService; import java.util.HashMap; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyFilterImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyFilterImpl.java index 1749fd4c44..1a11e86a2f 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyFilterImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyFilterImpl.java @@ -36,13 +36,13 @@ package io.entgra.device.mgt.core.policy.mgt.core.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.DeviceGroupWrapper; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.policy.mgt.common.PolicyFilter; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.HashMap; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyInformationPointImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyInformationPointImpl.java index 4938dea88f..1c03b2bcc0 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyInformationPointImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyInformationPointImpl.java @@ -35,9 +35,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.Feature; @@ -48,16 +45,15 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; -import io.entgra.device.mgt.core.policy.mgt.common.FeatureManagementException; -import io.entgra.device.mgt.core.policy.mgt.common.PIPDevice; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyFilter; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyInformationPoint; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; +import io.entgra.device.mgt.core.policy.mgt.common.*; import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; import io.entgra.device.mgt.core.policy.mgt.core.mgt.FeatureManager; import io.entgra.device.mgt.core.policy.mgt.core.mgt.PolicyManager; import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.FeatureManagerImpl; import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.PolicyManagerImpl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/internal/PolicyManagementDataHolder.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/internal/PolicyManagementDataHolder.java index b7447e9ead..a462244511 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/internal/PolicyManagementDataHolder.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/internal/PolicyManagementDataHolder.java @@ -18,17 +18,17 @@ package io.entgra.device.mgt.core.policy.mgt.core.internal; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.policy.PolicyConfiguration; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; -import org.wso2.carbon.ntask.core.service.TaskService; import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; import io.entgra.device.mgt.core.policy.mgt.common.PolicyInformationPoint; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; import io.entgra.device.mgt.core.policy.mgt.core.mgt.MonitoringManager; import io.entgra.device.mgt.core.policy.mgt.core.mgt.PolicyManager; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.user.core.service.RealmService; import java.util.HashMap; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/internal/PolicyManagementServiceComponent.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/internal/PolicyManagementServiceComponent.java index 0694b361a2..edff9188b2 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/internal/PolicyManagementServiceComponent.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/internal/PolicyManagementServiceComponent.java @@ -18,13 +18,9 @@ package io.entgra.device.mgt.core.policy.mgt.core.internal; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.service.component.ComponentContext; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.policy.PolicyConfiguration; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.ntask.core.service.TaskService; import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerServiceImpl; @@ -35,40 +31,22 @@ import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; import io.entgra.device.mgt.core.policy.mgt.core.task.TaskScheduleService; import io.entgra.device.mgt.core.policy.mgt.core.task.TaskScheduleServiceImpl; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.*; +import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.user.core.service.RealmService; -/** - * @scr.component name="org.wso2.carbon.devicemgt.policy.manager" immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="org.wso2.carbon.devicemgt.policy.evaluation.manager" - * interface="io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint" - * cardinality="1..n" - * policy="dynamic" - * bind="setPEPService" - * unbind="unsetPEPService" - * @scr.reference name="org.wso2.carbon.device.manager" - * interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceManagementService" - * unbind="unsetDeviceManagementService" - * @scr.reference name="ntask.component" - * interface="org.wso2.carbon.ntask.core.service.TaskService" - * cardinality="1..1" - * policy="dynamic" - * bind="setTaskService" - * unbind="unsetTaskService" - */ @SuppressWarnings("unused") +@Component( + name = "io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementServiceComponent", + immediate = true) public class PolicyManagementServiceComponent { private static final Log log = LogFactory.getLog(PolicyManagementServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { try { @@ -95,6 +73,7 @@ public class PolicyManagementServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { try { PolicyConfiguration policyConfiguration = @@ -114,6 +93,12 @@ public class PolicyManagementServiceComponent { * * @param realmService An instance of RealmService */ + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { @@ -149,7 +134,12 @@ public class PolicyManagementServiceComponent { PolicyManagementDataHolder.getInstance().setPolicyInformationPoint(null); }*/ - + @Reference( + name = "pep.service", + service = io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint.class, + cardinality = ReferenceCardinality.MULTIPLE, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetPEPService") protected void setPEPService(PolicyEvaluationPoint pepService) { if (log.isDebugEnabled()) { log.debug("Setting Policy Information Service"); @@ -164,6 +154,12 @@ public class PolicyManagementServiceComponent { PolicyManagementDataHolder.getInstance().removePolicyEvaluationPoint(pepService); } + @Reference( + name = "device.mgt.provider.service", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceManagementService") protected void setDeviceManagementService(DeviceManagementProviderService deviceManagerService) { if (log.isDebugEnabled()) { log.debug("Setting Device Management Service"); @@ -178,6 +174,12 @@ public class PolicyManagementServiceComponent { PolicyManagementDataHolder.getInstance().setDeviceManagementService(null); } + @Reference( + name = "task.service", + service = org.wso2.carbon.ntask.core.service.TaskService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTaskService") protected void setTaskService(TaskService taskService) { if (log.isDebugEnabled()) { log.debug("Setting the task service."); diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/MonitoringManager.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/MonitoringManager.java index 15ecc34037..225e9064ff 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/MonitoringManager.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/MonitoringManager.java @@ -22,8 +22,8 @@ import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/PolicyManager.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/PolicyManager.java index 41b46c518d..d5de610624 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/PolicyManager.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/PolicyManager.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/FeatureManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/FeatureManagerImpl.java index b290fdf59e..8698837b52 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/FeatureManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/FeatureManagerImpl.java @@ -18,19 +18,14 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Feature; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import io.entgra.device.mgt.core.policy.mgt.common.FeatureManagementException; -import io.entgra.device.mgt.core.policy.mgt.core.dao.FeatureDAO; -import io.entgra.device.mgt.core.policy.mgt.core.dao.FeatureManagerDAOException; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagerDAOException; -import io.entgra.device.mgt.core.policy.mgt.core.dao.ProfileDAO; -import io.entgra.device.mgt.core.policy.mgt.core.dao.ProfileManagerDAOException; +import io.entgra.device.mgt.core.policy.mgt.core.dao.*; import io.entgra.device.mgt.core.policy.mgt.core.mgt.FeatureManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.SQLException; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java index a48e0848ef..01404cb8c8 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; @@ -40,15 +38,13 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; import io.entgra.device.mgt.core.policy.mgt.common.monitor.ComplianceDecisionPoint; import io.entgra.device.mgt.core.policy.mgt.common.monitor.PolicyDeviceWrapper; -import io.entgra.device.mgt.core.policy.mgt.core.dao.MonitoringDAO; -import io.entgra.device.mgt.core.policy.mgt.core.dao.MonitoringDAOException; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyDAO; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagerDAOException; +import io.entgra.device.mgt.core.policy.mgt.core.dao.*; import io.entgra.device.mgt.core.policy.mgt.core.impl.ComplianceDecisionPointImpl; import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; import io.entgra.device.mgt.core.policy.mgt.core.mgt.MonitoringManager; import io.entgra.device.mgt.core.policy.mgt.core.mgt.PolicyManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.SQLException; import java.util.ArrayList; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index d588aaec55..e516095592 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -35,12 +35,8 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; @@ -48,12 +44,7 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.CorrectiveAction; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.DeviceGroupWrapper; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyCriterion; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.*; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.policy.PolicyConfiguration; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.CommandOperation; @@ -64,28 +55,20 @@ import io.entgra.device.mgt.core.policy.mgt.common.Criterion; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; import io.entgra.device.mgt.core.policy.mgt.common.ProfileManagementException; import io.entgra.device.mgt.core.policy.mgt.core.cache.impl.PolicyCacheManagerImpl; -import io.entgra.device.mgt.core.policy.mgt.core.dao.FeatureDAO; -import io.entgra.device.mgt.core.policy.mgt.core.dao.FeatureManagerDAOException; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyDAO; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagerDAOException; -import io.entgra.device.mgt.core.policy.mgt.core.dao.ProfileDAO; -import io.entgra.device.mgt.core.policy.mgt.core.dao.ProfileManagerDAOException; +import io.entgra.device.mgt.core.policy.mgt.core.dao.*; import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; import io.entgra.device.mgt.core.policy.mgt.core.mgt.PolicyManager; import io.entgra.device.mgt.core.policy.mgt.core.mgt.ProfileManager; import io.entgra.device.mgt.core.policy.mgt.core.mgt.bean.UpdatedPolicyDeviceListBean; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.SQLException; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class PolicyManagerImpl implements PolicyManager { diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/ProfileManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/ProfileManagerImpl.java index e679c31493..6cb35f4a0a 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/ProfileManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/ProfileManagerImpl.java @@ -18,19 +18,13 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import io.entgra.device.mgt.core.policy.mgt.common.ProfileManagementException; -import io.entgra.device.mgt.core.policy.mgt.core.dao.FeatureDAO; -import io.entgra.device.mgt.core.policy.mgt.core.dao.FeatureManagerDAOException; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagerDAOException; -import io.entgra.device.mgt.core.policy.mgt.core.dao.ProfileDAO; -import io.entgra.device.mgt.core.policy.mgt.core.dao.ProfileManagerDAOException; +import io.entgra.device.mgt.core.policy.mgt.core.dao.*; import io.entgra.device.mgt.core.policy.mgt.core.mgt.ProfileManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.sql.SQLException; import java.sql.Timestamp; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/task/MonitoringTask.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/task/MonitoringTask.java index a30f33a4a9..8d9673db56 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/task/MonitoringTask.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/task/MonitoringTask.java @@ -18,10 +18,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.task; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringManager; @@ -31,6 +27,10 @@ import io.entgra.device.mgt.core.device.mgt.core.task.impl.DynamicPartitionedSch import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; import io.entgra.device.mgt.core.policy.mgt.core.mgt.MonitoringManager; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/task/TaskScheduleServiceImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/task/TaskScheduleServiceImpl.java index 25800dd02c..26b1300034 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/task/TaskScheduleServiceImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/task/TaskScheduleServiceImpl.java @@ -19,19 +19,19 @@ package io.entgra.device.mgt.core.policy.mgt.core.task; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.policy.PolicyConfiguration; -import org.wso2.carbon.ntask.common.TaskException; -import org.wso2.carbon.ntask.core.TaskInfo; -import org.wso2.carbon.ntask.core.TaskManager; -import org.wso2.carbon.ntask.core.service.TaskService; import io.entgra.device.mgt.core.policy.mgt.common.PolicyMonitoringTaskException; import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.ntask.common.TaskException; +import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskInfo.TriggerInfo; +import org.wso2.carbon.ntask.core.TaskManager; +import org.wso2.carbon.ntask.core.service.TaskService; import java.util.HashMap; import java.util.Map; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/util/PolicyManagerUtil.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/util/PolicyManagerUtil.java index 6955c052f8..e0a2990891 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/util/PolicyManagerUtil.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/util/PolicyManagerUtil.java @@ -36,13 +36,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.util; import com.google.gson.Gson; -import org.apache.commons.lang.StringUtils; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; @@ -51,20 +44,24 @@ import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.PlatformCon import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.CorrectiveAction; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.policy.PolicyConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.tenant.PlatformConfigurationManagementServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.PolicyOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.policy.mgt.common.PolicyAdministratorPoint; import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import io.entgra.device.mgt.core.policy.mgt.common.PolicyTransformException; import io.entgra.device.mgt.core.policy.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.policy.mgt.core.config.datasource.JNDILookupDefinition; import io.entgra.device.mgt.core.policy.mgt.core.dao.util.PolicyManagementDAOUtil; import io.entgra.device.mgt.core.policy.mgt.core.impl.PolicyAdministratorPointImpl; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Document; import javax.cache.Cache; import javax.cache.CacheManager; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/BasePolicyManagementDAOTest.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/BasePolicyManagementDAOTest.java index 6e79839d13..51f33a7ed4 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/BasePolicyManagementDAOTest.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/BasePolicyManagementDAOTest.java @@ -18,24 +18,6 @@ */ package io.entgra.device.mgt.core.policy.mgt.core; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; -import io.entgra.device.mgt.core.policy.mgt.core.common.DataSourceConfig; -import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; -import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; -import io.entgra.device.mgt.core.policy.mgt.core.mgt.ProfileManager; -import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.ProfileManagerImpl; -import io.entgra.device.mgt.core.policy.mgt.core.services.SimplePolicyEvaluationTest; -import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.tomcat.jdbc.pool.PoolProperties; -import org.testng.Assert; -import org.testng.annotations.BeforeSuite; -import org.testng.internal.collections.Pair; -import org.w3c.dom.Document; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; @@ -57,6 +39,24 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderServiceImpl; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; +import io.entgra.device.mgt.core.policy.mgt.core.common.DataSourceConfig; +import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; +import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; +import io.entgra.device.mgt.core.policy.mgt.core.mgt.ProfileManager; +import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.ProfileManagerImpl; +import io.entgra.device.mgt.core.policy.mgt.core.services.SimplePolicyEvaluationTest; +import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tomcat.jdbc.pool.PoolProperties; +import org.testng.Assert; +import org.testng.annotations.BeforeSuite; +import org.testng.internal.collections.Pair; +import org.w3c.dom.Document; +import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/MonitoringTestCase.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/MonitoringTestCase.java index 7ece16f38d..35b81cb6b8 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/MonitoringTestCase.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/MonitoringTestCase.java @@ -19,17 +19,6 @@ package io.entgra.device.mgt.core.policy.mgt.core; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; -import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; -import io.entgra.device.mgt.core.policy.mgt.core.mgt.MonitoringManager; -import io.entgra.device.mgt.core.policy.mgt.core.mgt.PolicyManager; -import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.MonitoringManagerImpl; -import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.PolicyManagerImpl; -import io.entgra.device.mgt.core.policy.mgt.core.services.PolicyMonitoringManagerTest; -import junit.framework.Assert; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; @@ -42,6 +31,17 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerI import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderServiceImpl; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; +import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; +import io.entgra.device.mgt.core.policy.mgt.core.mgt.MonitoringManager; +import io.entgra.device.mgt.core.policy.mgt.core.mgt.PolicyManager; +import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.MonitoringManagerImpl; +import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.PolicyManagerImpl; +import io.entgra.device.mgt.core.policy.mgt.core.services.PolicyMonitoringManagerTest; +import junit.framework.Assert; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.Test; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyDAOTestCase.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyDAOTestCase.java index 8d1f1a5b9f..6a3792bdb9 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyDAOTestCase.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyDAOTestCase.java @@ -17,18 +17,6 @@ */ package io.entgra.device.mgt.core.policy.mgt.core; -import io.entgra.device.mgt.core.policy.mgt.common.FeatureManagementException; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyAdministratorPoint; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; -import io.entgra.device.mgt.core.policy.mgt.common.ProfileManagementException; -import io.entgra.device.mgt.core.policy.mgt.core.impl.PolicyAdministratorPointImpl; -import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; -import io.entgra.device.mgt.core.policy.mgt.core.util.*; -import junit.framework.Assert; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.Feature; @@ -42,6 +30,18 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.*; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import io.entgra.device.mgt.core.policy.mgt.common.FeatureManagementException; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyAdministratorPoint; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; +import io.entgra.device.mgt.core.policy.mgt.common.ProfileManagementException; +import io.entgra.device.mgt.core.policy.mgt.core.impl.PolicyAdministratorPointImpl; +import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; +import io.entgra.device.mgt.core.policy.mgt.core.util.*; +import junit.framework.Assert; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyEvaluationTestCase.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyEvaluationTestCase.java index fd8e2e0b32..3427185359 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyEvaluationTestCase.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyEvaluationTestCase.java @@ -19,6 +19,12 @@ package io.entgra.device.mgt.core.policy.mgt.core; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; import io.entgra.device.mgt.core.policy.mgt.common.PolicyAdministratorPoint; import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationException; import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; @@ -31,12 +37,6 @@ import org.apache.commons.logging.LogFactory; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.wso2.carbon.ntask.common.TaskException; import java.util.Collections; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerServiceImplTest.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerServiceImplTest.java index 6cd3da756a..ee27b3c281 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerServiceImplTest.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyManagerServiceImplTest.java @@ -17,26 +17,6 @@ */ package io.entgra.device.mgt.core.policy.mgt.core; -import io.entgra.device.mgt.core.policy.mgt.common.FeatureManagementException; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationException; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; -import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; -import io.entgra.device.mgt.core.policy.mgt.core.enforcement.DelegationTask; -import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; -import io.entgra.device.mgt.core.policy.mgt.core.mgt.MonitoringManager; -import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.MonitoringManagerImpl; -import io.entgra.device.mgt.core.policy.mgt.core.mock.TestHeartBeatManagementService; -import io.entgra.device.mgt.core.policy.mgt.core.mock.TypeXDeviceManagementService; -import io.entgra.device.mgt.core.policy.mgt.core.task.MonitoringTask; -import io.entgra.device.mgt.core.policy.mgt.core.task.TaskScheduleService; -import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; -import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; -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 io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; @@ -59,6 +39,26 @@ import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHo import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.PolicyOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; +import io.entgra.device.mgt.core.policy.mgt.common.FeatureManagementException; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationException; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyEvaluationPoint; +import io.entgra.device.mgt.core.policy.mgt.common.PolicyManagementException; +import io.entgra.device.mgt.core.policy.mgt.core.enforcement.DelegationTask; +import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; +import io.entgra.device.mgt.core.policy.mgt.core.mgt.MonitoringManager; +import io.entgra.device.mgt.core.policy.mgt.core.mgt.impl.MonitoringManagerImpl; +import io.entgra.device.mgt.core.policy.mgt.core.mock.TestHeartBeatManagementService; +import io.entgra.device.mgt.core.policy.mgt.core.mock.TypeXDeviceManagementService; +import io.entgra.device.mgt.core.policy.mgt.core.task.MonitoringTask; +import io.entgra.device.mgt.core.policy.mgt.core.task.TaskScheduleService; +import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; +import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; +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.sql.Timestamp; import java.util.ArrayList; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/FeatureManagerImplTest.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/FeatureManagerImplTest.java index e3e1e51589..431fc5c49d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/FeatureManagerImplTest.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/FeatureManagerImplTest.java @@ -17,6 +17,14 @@ */ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; +import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; import io.entgra.device.mgt.core.policy.mgt.common.FeatureManagementException; import io.entgra.device.mgt.core.policy.mgt.core.BasePolicyManagementDAOTest; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerServiceImpl; @@ -33,14 +41,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.testng.internal.collections.Pair; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; -import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/MonitoringManagerImplTest.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/MonitoringManagerImplTest.java index 62173b4cef..3f3067cf28 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/MonitoringManagerImplTest.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/MonitoringManagerImplTest.java @@ -1,5 +1,20 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.DeviceGroupWrapper; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; +import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.policy.mgt.core.BasePolicyManagementDAOTest; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerServiceImpl; @@ -24,21 +39,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.testng.internal.collections.Pair; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.DeviceGroupWrapper; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; -import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import javax.sql.DataSource; import java.lang.reflect.Field; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/ProfileManagerImplTest.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/ProfileManagerImplTest.java index 2bbb24a8cc..e8c92b29db 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/ProfileManagerImplTest.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/ProfileManagerImplTest.java @@ -17,6 +17,14 @@ */ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; +import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; import io.entgra.device.mgt.core.policy.mgt.common.ProfileManagementException; import io.entgra.device.mgt.core.policy.mgt.core.BasePolicyManagementDAOTest; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerServiceImpl; @@ -32,14 +40,6 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.testng.internal.collections.Pair; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationManager; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; -import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TestHeartBeatManagementService.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TestHeartBeatManagementService.java index 13ec9c934c..5da0e3c402 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TestHeartBeatManagementService.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TestHeartBeatManagementService.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.policy.mgt.core.mock; +import io.entgra.device.mgt.core.device.mgt.common.ServerCtxInfo; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dto.HeartBeatEvent; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dto.ServerContext; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception.HeartBeatManagementException; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; -import io.entgra.device.mgt.core.device.mgt.common.ServerCtxInfo; import java.util.Map; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TestPolicyMonitoringManager.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TestPolicyMonitoringManager.java index c861c3a73f..34c20ecc92 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TestPolicyMonitoringManager.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TestPolicyMonitoringManager.java @@ -17,14 +17,14 @@ */ package io.entgra.device.mgt.core.policy.mgt.core.mock; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringManager; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/services/PolicyMonitoringManagerTest.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/services/PolicyMonitoringManagerTest.java index d15fb90cdf..773dd89b11 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/services/PolicyMonitoringManagerTest.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/services/PolicyMonitoringManagerTest.java @@ -19,8 +19,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.services; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringManager; @@ -28,6 +26,8 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.ComplianceFeature; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.NonComplianceData; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/services/SimplePolicyEvaluationTest.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/services/SimplePolicyEvaluationTest.java index 90c42d698d..5883432a87 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/services/SimplePolicyEvaluationTest.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/services/SimplePolicyEvaluationTest.java @@ -19,14 +19,14 @@ package io.entgra.device.mgt.core.policy.mgt.core.services; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import io.entgra.device.mgt.core.policy.mgt.common.*; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerService; import io.entgra.device.mgt.core.policy.mgt.core.PolicyManagerServiceImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; import java.util.Collections; import java.util.List; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/task/TaskSchedulerServiceImplTest.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/task/TaskSchedulerServiceImplTest.java index a9c65d77ad..ca025479fd 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/task/TaskSchedulerServiceImplTest.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/task/TaskSchedulerServiceImplTest.java @@ -18,6 +18,8 @@ package io.entgra.device.mgt.core.policy.mgt.core.task; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import io.entgra.device.mgt.core.device.mgt.core.config.policy.PolicyConfiguration; import io.entgra.device.mgt.core.policy.mgt.common.PolicyMonitoringTaskException; import io.entgra.device.mgt.core.policy.mgt.core.internal.PolicyManagementDataHolder; import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagementConstants; @@ -27,8 +29,6 @@ import org.mockito.Mockito; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import io.entgra.device.mgt.core.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.ntask.common.TaskException; import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskManager; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml index 897e33581c..2337c777e2 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml @@ -1,4 +1,4 @@ - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml index dec2307f1d..bf7718b969 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/carbon-home/repository/conf/etc/tasks-config.xml @@ -1,4 +1,4 @@ - + - - - - - - - - - - - - - - - - - - - diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 4349157706..e7a7c91ee0 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -33,13 +33,13 @@ - - org.apache.felix - maven-scr-plugin - org.apache.maven.plugins maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -53,37 +53,29 @@ Subtype Management Bundle io.entgra.device.mgt.core.subtype.mgt.internal + com.fasterxml.jackson.core;version="[2.10,3)", + com.google.common.cache;version="[31.0,32)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config.datasource;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.subtype.mgt.cache, + io.entgra.device.mgt.core.subtype.mgt.dao, + io.entgra.device.mgt.core.subtype.mgt.dao.impl, + io.entgra.device.mgt.core.subtype.mgt.dao.util, + io.entgra.device.mgt.core.subtype.mgt.dto, + io.entgra.device.mgt.core.subtype.mgt.exception, + io.entgra.device.mgt.core.subtype.mgt.impl, + io.entgra.device.mgt.core.subtype.mgt.spi, + io.entgra.device.mgt.core.subtype.mgt.util, + javax.naming, + javax.sql, + org.apache.commons.logging;version="[1.2,2)", 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.*, - io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.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, - io.entgra.device.mgt.core.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.*, - com.google.common.cache.*, + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.ndatasource.core;version="[4.8,5)", + org.wso2.carbon.registry.core.service;version="[1.0,2)" !io.entgra.device.mgt.core.subtype.mgt.internal, @@ -135,6 +127,11 @@ + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.common @@ -164,10 +161,6 @@ org.codehaus.woodstox wstx-asl - - - - org.wso2.carbon.analytics org.wso2.carbon.analytics.api @@ -227,16 +220,6 @@ - - org.eclipse.osgi - org.eclipse.osgi - provided - - - org.eclipse.osgi - org.eclipse.osgi.services - provided - org.wso2.carbon org.wso2.carbon.core @@ -246,7 +229,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon @@ -341,19 +323,16 @@ com.google.guava guava - provided org.json.wso2 json - provided org.wso2.orbit.com.fasterxml.jackson.core jackson-databind - provided diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java index 50350deadf..fab5e5f7a5 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java @@ -19,11 +19,11 @@ package io.entgra.device.mgt.core.subtype.mgt.cache; import com.google.common.cache.CacheLoader; -import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubTypeCacheKey; import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAO; import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAOFactory; import io.entgra.device.mgt.core.subtype.mgt.dao.util.ConnectionManagerUtil; import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubTypeCacheKey; import io.entgra.device.mgt.core.subtype.mgt.exception.DBConnectionException; import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtDAOException; import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtPluginException; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAO.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAO.java index 0ab0163d26..9b861e4b20 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAO.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAO.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.subtype.mgt.dao; -import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtDAOException; import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtDAOException; import java.util.List; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAOFactory.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAOFactory.java index 88642b2360..882031d540 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAOFactory.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAOFactory.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.subtype.mgt.dao; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; +import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.subtype.mgt.dao.impl.DeviceSubTypeDAOImpl; import io.entgra.device.mgt.core.subtype.mgt.dao.impl.DeviceSubTypeMySQLDAOImpl; +import io.entgra.device.mgt.core.subtype.mgt.dao.util.ConnectionManagerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import io.entgra.device.mgt.core.subtype.mgt.dao.util.ConnectionManagerUtil; -import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceConfig; public class DeviceSubTypeDAOFactory { private static final Log log = LogFactory.getLog(DeviceSubTypeDAOFactory.class); diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java index a6aa286013..1c294747f4 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java @@ -18,12 +18,12 @@ package io.entgra.device.mgt.core.subtype.mgt.dao.impl; -import io.entgra.device.mgt.core.subtype.mgt.exception.DBConnectionException; -import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtDAOException; import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAO; import io.entgra.device.mgt.core.subtype.mgt.dao.util.ConnectionManagerUtil; -import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; import io.entgra.device.mgt.core.subtype.mgt.dao.util.DAOUtil; +import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.core.subtype.mgt.exception.DBConnectionException; +import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtDAOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/ConnectionManagerUtil.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/ConnectionManagerUtil.java index da4e126730..bf7f3d8da0 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/ConnectionManagerUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/ConnectionManagerUtil.java @@ -18,12 +18,12 @@ package io.entgra.device.mgt.core.subtype.mgt.dao.util; -import io.entgra.device.mgt.core.subtype.mgt.exception.DBConnectionException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.device.mgt.core.config.datasource.JNDILookupDefinition; +import io.entgra.device.mgt.core.subtype.mgt.exception.DBConnectionException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.naming.InitialContext; import javax.sql.DataSource; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java index bc5a4511bb..54c27535e5 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java @@ -22,16 +22,16 @@ import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import io.entgra.device.mgt.core.subtype.mgt.cache.GetDeviceSubTypeCacheLoader; +import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAO; +import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAOFactory; +import io.entgra.device.mgt.core.subtype.mgt.dao.util.ConnectionManagerUtil; +import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; import io.entgra.device.mgt.core.subtype.mgt.exception.BadRequestException; import io.entgra.device.mgt.core.subtype.mgt.exception.DBConnectionException; import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtDAOException; import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtPluginException; -import io.entgra.device.mgt.core.subtype.mgt.util.DeviceSubTypeMgtUtil; -import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; -import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAO; -import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAOFactory; -import io.entgra.device.mgt.core.subtype.mgt.dao.util.ConnectionManagerUtil; import io.entgra.device.mgt.core.subtype.mgt.spi.DeviceSubTypeService; +import io.entgra.device.mgt.core.subtype.mgt.util.DeviceSubTypeMgtUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java index fd091a63c9..b4fc94463a 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/internal/DeviceSubTypeMgtDataHolder.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.subtype.mgt.internal; -import io.entgra.device.mgt.core.subtype.mgt.spi.DeviceSubTypeService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.subtype.mgt.spi.DeviceSubTypeService; import org.wso2.carbon.registry.core.service.RegistryService; public class DeviceSubTypeMgtDataHolder { diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java index c7e6ff632a..07a2474aee 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/internal/DeviceSubTypeMgtServiceComponent.java @@ -18,45 +18,29 @@ package io.entgra.device.mgt.core.subtype.mgt.internal; -import io.entgra.device.mgt.core.subtype.mgt.impl.DeviceSubTypeServiceImpl; -import io.entgra.device.mgt.core.subtype.mgt.spi.DeviceSubTypeService; -import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAOFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAOFactory; +import io.entgra.device.mgt.core.subtype.mgt.impl.DeviceSubTypeServiceImpl; +import io.entgra.device.mgt.core.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.osgi.service.component.annotations.*; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; -/** - * @scr.component name="io.entgra.device.mgt.core.subtype.mgt.internal.DeviceSubTypeMgtServiceComponent" immediate="true" - * @scr.reference name="org.wso2.carbon.device.manager" - * interface="io.entgra.device.mgt.core.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" - */ +@Component( + name = "io.entgra.device.mgt.core.subtype.mgt.internal.DeviceSubTypeMgtServiceComponent", + immediate = true) public class DeviceSubTypeMgtServiceComponent { private static final Log log = LogFactory.getLog(DeviceSubTypeMgtServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { @@ -80,7 +64,7 @@ public class DeviceSubTypeMgtServiceComponent { log.error("Error occurred while activating Device SubType Management Service Component", e); } } - + @Deactivate protected void deactivate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("De-activating Device SubType Management Service Component"); @@ -88,6 +72,12 @@ public class DeviceSubTypeMgtServiceComponent { } @SuppressWarnings("unused") + @Reference( + name = "data.mgt.provider.service", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceManagementService") protected void setDeviceManagementService(DeviceManagementProviderService deviceManagementProviderService) { if (log.isDebugEnabled()) { log.debug("Setting Device Management Service to Device SubType Mgt SC"); @@ -103,6 +93,12 @@ public class DeviceSubTypeMgtServiceComponent { DeviceSubTypeMgtDataHolder.getInstance().setDeviceManagementProviderService(null); } + @Reference( + name = "datasource.service", + service = org.wso2.carbon.ndatasource.core.DataSourceService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDataSourceService") protected void setDataSourceService(DataSourceService dataSourceService) { /* This is to avoid mobile device management component getting initialized before the underlying datasources are registered */ @@ -118,7 +114,12 @@ public class DeviceSubTypeMgtServiceComponent { } } - + @Reference( + name = "registry.service", + service = org.wso2.carbon.registry.core.service.RegistryService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRegistryService") protected void setRegistryService(RegistryService registryService) { if (log.isDebugEnabled()) { log.debug("RegistryService set to Device SubType Mgt component"); diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/spi/DeviceSubTypeService.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/spi/DeviceSubTypeService.java index bcd412c80f..8e4f618edd 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/spi/DeviceSubTypeService.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/spi/DeviceSubTypeService.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.subtype.mgt.spi; -import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtPluginException; import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtPluginException; import java.util.List; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/util/DeviceSubTypeMgtUtil.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/util/DeviceSubTypeMgtUtil.java index ed5216c663..a774d32147 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/util/DeviceSubTypeMgtUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/util/DeviceSubTypeMgtUtil.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.subtype.mgt.util; -import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubTypeCacheKey; import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; +import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubTypeCacheKey; public class DeviceSubTypeMgtUtil { public static String setDeviceSubTypeCacheKey(int tenantId, String subTypeId, DeviceSubType.DeviceType deviceType) { diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java index 3ef88509f4..c3563f76cb 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/BaseDeviceSubTypePluginTest.java @@ -18,9 +18,12 @@ package io.entgra.device.mgt.core.subtype.mgt.mock; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; +import io.entgra.device.mgt.core.subtype.mgt.DataSourceConfig; import io.entgra.device.mgt.core.subtype.mgt.TestUtils; import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAOFactory; -import io.entgra.device.mgt.core.subtype.mgt.DataSourceConfig; import io.entgra.device.mgt.core.subtype.mgt.dao.util.ConnectionManagerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -32,9 +35,6 @@ import org.testng.annotations.Parameters; import org.w3c.dom.Document; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import javax.sql.DataSource; import javax.xml.bind.JAXBContext; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockConnection.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockConnection.java index 0c57ddd085..2e66398c46 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockConnection.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockConnection.java @@ -18,21 +18,7 @@ package io.entgra.device.mgt.core.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.sql.*; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockDatabaseMetaData.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockDatabaseMetaData.java index 2888de59c3..018031fb16 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockDatabaseMetaData.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockDatabaseMetaData.java @@ -20,11 +20,7 @@ package io.entgra.device.mgt.core.subtype.mgt.mock; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.RowIdLifetime; -import java.sql.DatabaseMetaData; -import java.sql.SQLException; +import java.sql.*; public class MockDatabaseMetaData implements DatabaseMetaData { private final String url; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockResultSet.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockResultSet.java index c040106fe8..299c668a2c 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockResultSet.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockResultSet.java @@ -22,21 +22,7 @@ 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.sql.*; import java.util.ArrayList; import java.util.Calendar; import java.util.List; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockStatement.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockStatement.java index 2d87ce2819..c041b37934 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockStatement.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/mock/MockStatement.java @@ -22,23 +22,7 @@ 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.sql.*; import java.util.ArrayList; import java.util.Calendar; import java.util.List; diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 6991abad15..12fbac8d4d 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -33,6 +33,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-bundle-plugin @@ -46,6 +54,10 @@ io.entgra.device.mgt.core.task.mgt.common.* + + io.entgra.device.mgt.core.task.mgt.common.bean, + io.entgra.device.mgt.core.task.mgt.common.exception + diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/src/main/java/io/entgra/device/mgt/core/task/mgt/common/spi/TaskManagementService.java b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/src/main/java/io/entgra/device/mgt/core/task/mgt/common/spi/TaskManagementService.java index 5c0b075477..fe8eff769d 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/src/main/java/io/entgra/device/mgt/core/task/mgt/common/spi/TaskManagementService.java +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/src/main/java/io/entgra/device/mgt/core/task/mgt/common/spi/TaskManagementService.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.task.mgt.common.spi; import io.entgra.device.mgt.core.task.mgt.common.bean.DynamicTask; -import io.entgra.device.mgt.core.task.mgt.common.exception.TaskNotFoundException; import io.entgra.device.mgt.core.task.mgt.common.exception.TaskManagementException; +import io.entgra.device.mgt.core.task.mgt.common.exception.TaskNotFoundException; import java.util.List; diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 8511e83f69..b4120513f3 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -35,8 +35,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -50,26 +54,36 @@ Task Management Core Bundle io.entgra.device.mgt.core.task.mgt.core.internal + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="[5.0,6)", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="[5.0,6)", + io.entgra.device.mgt.core.task.mgt.common.bean;version="[5.0,6)", + io.entgra.device.mgt.core.task.mgt.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.task.mgt.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.task.mgt.core.config, + io.entgra.device.mgt.core.task.mgt.core.config.datasource, + io.entgra.device.mgt.core.task.mgt.core.dao, + io.entgra.device.mgt.core.task.mgt.core.dao.common, + io.entgra.device.mgt.core.task.mgt.core.dao.impl, + io.entgra.device.mgt.core.task.mgt.core.dao.util, + javax.naming, + javax.sql, + javax.xml.bind;version="[0.0,1)", + javax.xml.bind.annotation;version="[0.0,1)", + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", + org.apache.commons.codec.digest;version="[1.4,2)", + org.apache.commons.lang;version="[2.4,3)", + org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - org.wso2.carbon.ndatasource.core, org.w3c.dom, - javax.xml.bind.annotation, - javax.xml.bind, - javax.sql, - javax.naming, - io.entgra.device.mgt.core.task.mgt.common.*, - org.wso2.carbon.utils.*, - org.wso2.carbon.ntask.core.*, - org.wso2.carbon.ntask.common, - io.entgra.device.mgt.core.device.mgt.common.*, - org.wso2.carbon.context, - org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.apache.commons.codec.digest;version="${commons-codec.wso2.osgi.version.range}", - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dto, - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception, - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service, + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.ndatasource.core;version="[4.8,5)", + org.wso2.carbon.ntask.common;version="[4.9,5)", + org.wso2.carbon.ntask.core;version="[4.9,5)", + org.wso2.carbon.ntask.core.service;version="[4.9,5)", + org.wso2.carbon.utils;version="[4.8,5)" !io.entgra.device.mgt.core.task.mgt.core.internal, @@ -83,13 +97,8 @@ - org.eclipse.osgi - org.eclipse.osgi - provided - - - org.eclipse.osgi - org.eclipse.osgi.services + org.apache.felix + org.apache.felix.scr.ds-annotations provided @@ -106,7 +115,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/config/TaskConfigurationManager.java b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/config/TaskConfigurationManager.java index d245cf4cd2..55d2487e5f 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/config/TaskConfigurationManager.java +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/config/TaskConfigurationManager.java @@ -17,9 +17,9 @@ */ package io.entgra.device.mgt.core.task.mgt.core.config; -import io.entgra.device.mgt.core.task.mgt.core.util.TaskManagementUtil; import io.entgra.device.mgt.core.task.mgt.common.constant.TaskMgtConstants; import io.entgra.device.mgt.core.task.mgt.common.exception.TaskManagementException; +import io.entgra.device.mgt.core.task.mgt.core.util.TaskManagementUtil; import org.w3c.dom.Document; import org.wso2.carbon.utils.CarbonUtils; diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/common/TaskManagementDAOFactory.java b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/common/TaskManagementDAOFactory.java index cf3bff0dc9..77dea7194f 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/common/TaskManagementDAOFactory.java +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/common/TaskManagementDAOFactory.java @@ -17,7 +17,6 @@ */ package io.entgra.device.mgt.core.task.mgt.core.dao.common; -import io.entgra.device.mgt.core.task.mgt.core.dao.DynamicTaskPropDAO; import io.entgra.device.mgt.core.task.mgt.common.constant.TaskMgtConstants; import io.entgra.device.mgt.core.task.mgt.common.exception.IllegalTransactionStateException; import io.entgra.device.mgt.core.task.mgt.common.exception.TransactionManagementException; @@ -25,6 +24,7 @@ import io.entgra.device.mgt.core.task.mgt.common.exception.UnsupportedDatabaseEn import io.entgra.device.mgt.core.task.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.task.mgt.core.config.datasource.JNDILookupDefinition; import io.entgra.device.mgt.core.task.mgt.core.dao.DynamicTaskDAO; +import io.entgra.device.mgt.core.task.mgt.core.dao.DynamicTaskPropDAO; import io.entgra.device.mgt.core.task.mgt.core.dao.impl.DynamicTaskDAOImpl; import io.entgra.device.mgt.core.task.mgt.core.dao.impl.DynamicTaskPropDAOImpl; import io.entgra.device.mgt.core.task.mgt.core.dao.util.TaskManagementDAOUtil; diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/impl/DynamicTaskDAOImpl.java b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/impl/DynamicTaskDAOImpl.java index 90d73ca21b..067a76c380 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/impl/DynamicTaskDAOImpl.java +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/impl/DynamicTaskDAOImpl.java @@ -17,11 +17,11 @@ */ package io.entgra.device.mgt.core.task.mgt.core.dao.impl; -import io.entgra.device.mgt.core.task.mgt.core.dao.common.TaskManagementDAOFactory; -import io.entgra.device.mgt.core.task.mgt.core.dao.util.TaskManagementDAOUtil; import io.entgra.device.mgt.core.task.mgt.common.bean.DynamicTask; import io.entgra.device.mgt.core.task.mgt.common.exception.TaskManagementDAOException; import io.entgra.device.mgt.core.task.mgt.core.dao.DynamicTaskDAO; +import io.entgra.device.mgt.core.task.mgt.core.dao.common.TaskManagementDAOFactory; +import io.entgra.device.mgt.core.task.mgt.core.dao.util.TaskManagementDAOUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/impl/DynamicTaskPropDAOImpl.java b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/impl/DynamicTaskPropDAOImpl.java index fb613e683e..293934ed9b 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/impl/DynamicTaskPropDAOImpl.java +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/dao/impl/DynamicTaskPropDAOImpl.java @@ -17,11 +17,11 @@ */ package io.entgra.device.mgt.core.task.mgt.core.dao.impl; +import io.entgra.device.mgt.core.task.mgt.common.constant.TaskMgtConstants; +import io.entgra.device.mgt.core.task.mgt.common.exception.TaskManagementDAOException; import io.entgra.device.mgt.core.task.mgt.core.dao.DynamicTaskPropDAO; import io.entgra.device.mgt.core.task.mgt.core.dao.common.TaskManagementDAOFactory; import io.entgra.device.mgt.core.task.mgt.core.dao.util.TaskManagementDAOUtil; -import io.entgra.device.mgt.core.task.mgt.common.constant.TaskMgtConstants; -import io.entgra.device.mgt.core.task.mgt.common.exception.TaskManagementDAOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/internal/TaskManagerServiceComponent.java b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/internal/TaskManagerServiceComponent.java index 386aef3346..b7d6de0e2a 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/internal/TaskManagerServiceComponent.java +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/internal/TaskManagerServiceComponent.java @@ -17,12 +17,12 @@ */ package io.entgra.device.mgt.core.task.mgt.core.internal; -import io.entgra.device.mgt.core.task.mgt.core.dao.common.TaskManagementDAOFactory; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; -import io.entgra.device.mgt.core.task.mgt.core.config.TaskManagementConfig; -import io.entgra.device.mgt.core.task.mgt.core.config.datasource.DataSourceConfig; import io.entgra.device.mgt.core.task.mgt.common.spi.TaskManagementService; import io.entgra.device.mgt.core.task.mgt.core.config.TaskConfigurationManager; +import io.entgra.device.mgt.core.task.mgt.core.config.TaskManagementConfig; +import io.entgra.device.mgt.core.task.mgt.core.config.datasource.DataSourceConfig; +import io.entgra.device.mgt.core.task.mgt.core.dao.common.TaskManagementDAOFactory; import io.entgra.device.mgt.core.task.mgt.core.service.TaskManagementServiceImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -30,32 +30,16 @@ import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.ntask.core.service.TaskService; +import org.osgi.service.component.annotations.*; -/** - * @scr.component name="io.entgra.task.mgt.service" immediate="true" - * @scr.reference name="datasource.service" - * interface="org.wso2.carbon.ndatasource.core.DataSourceService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDataSourceService" - * unbind="unsetDataSourceService" - * @scr.reference name="app.mgt.ntask.component" - * interface="org.wso2.carbon.ntask.core.service.TaskService" - * cardinality="1..1" - * policy="dynamic" - * bind="setTaskService" - * unbind="unsetTaskService" - * @scr.reference name="entgra.heart.beat.service" - * interface="io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService" - * cardinality="0..1" - * policy="dynamic" - * bind="setHeartBeatService" - * unbind="unsetHeartBeatService" - */ +@Component( + name = "io.entgra.device.mgt.core.task.mgt.core.internal.TaskManagerServiceComponent", + immediate = true) public class TaskManagerServiceComponent { private static final Log log = LogFactory.getLog(TaskManagerServiceComponent.class); + @Activate protected void activate(ComponentContext ctx) { if (log.isDebugEnabled()) { @@ -80,13 +64,19 @@ public class TaskManagerServiceComponent { log.error("Error occurred while activating Task Manager Service Component", e); } } - + @Deactivate protected void deactivate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("De-activating Task Manager Service Component"); } } + @Reference( + name = "datasource.service", + service = org.wso2.carbon.ndatasource.core.DataSourceService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDataSourceService") protected void setDataSourceService(DataSourceService dataSourceService) { /* This is to avoid Task Manager Service Component getting initialized before the underlying datasources are registered */ @@ -99,6 +89,12 @@ public class TaskManagerServiceComponent { //do nothing } + @Reference( + name = "task.service", + service = org.wso2.carbon.ntask.core.service.TaskService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTaskService") @SuppressWarnings("unused") public void setTaskService(TaskService taskService) { if (log.isDebugEnabled()) { @@ -115,6 +111,12 @@ public class TaskManagerServiceComponent { TaskManagerDataHolder.getInstance().setnTaskService(null); } + @Reference( + name = "heartbeat.service", + service = io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetHeartBeatService") @SuppressWarnings("unused") protected void setHeartBeatService(HeartBeatManagementService heartBeatService) { if (log.isDebugEnabled()) { diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/service/TaskManagementServiceImpl.java b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/service/TaskManagementServiceImpl.java index 80b757514f..b4858f3ba2 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/service/TaskManagementServiceImpl.java +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/src/main/java/io/entgra/device/mgt/core/task/mgt/core/service/TaskManagementServiceImpl.java @@ -17,10 +17,6 @@ */ package io.entgra.device.mgt.core.task.mgt.core.service; -import io.entgra.device.mgt.core.task.mgt.core.dao.DynamicTaskPropDAO; -import io.entgra.device.mgt.core.task.mgt.core.dao.common.TaskManagementDAOFactory; -import io.entgra.device.mgt.core.task.mgt.core.internal.TaskManagerDataHolder; -import io.entgra.device.mgt.core.task.mgt.core.util.TaskManagementUtil; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception.HeartBeatManagementException; import io.entgra.device.mgt.core.task.mgt.common.bean.DynamicTask; import io.entgra.device.mgt.core.task.mgt.common.constant.TaskMgtConstants; @@ -30,6 +26,10 @@ import io.entgra.device.mgt.core.task.mgt.common.exception.TaskNotFoundException import io.entgra.device.mgt.core.task.mgt.common.exception.TransactionManagementException; import io.entgra.device.mgt.core.task.mgt.common.spi.TaskManagementService; import io.entgra.device.mgt.core.task.mgt.core.dao.DynamicTaskDAO; +import io.entgra.device.mgt.core.task.mgt.core.dao.DynamicTaskPropDAO; +import io.entgra.device.mgt.core.task.mgt.core.dao.common.TaskManagementDAOFactory; +import io.entgra.device.mgt.core.task.mgt.core.internal.TaskManagerDataHolder; +import io.entgra.device.mgt.core.task.mgt.core.util.TaskManagementUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 1011141e50..628dcad436 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -35,8 +35,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -50,18 +54,27 @@ Task Watcher Bundle io.entgra.device.mgt.core.task.mgt.watcher.internal - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.*, - io.entgra.device.mgt.core.task.mgt.common.*, - io.entgra.device.mgt.core.task.mgt.core.*, - org.apache.commons.logging, + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="[5.0,6)", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="[5.0,6)", + io.entgra.device.mgt.core.task.mgt.common.bean;version="[5.0,6)", + io.entgra.device.mgt.core.task.mgt.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.task.mgt.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.task.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.task.mgt.core.util;version="[5.0,6)", + io.entgra.device.mgt.core.task.mgt.watcher, + io.entgra.device.mgt.core.task.mgt.watcher.internal, + org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.wso2.carbon.context, - org.wso2.carbon.core, - io.entgra.device.mgt.core.device.mgt.common.*, - org.wso2.carbon.ntask.*, - org.wso2.carbon.user.api, - org.wso2.carbon.user.core.*, + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.core;version="[4.8,5)", + org.wso2.carbon.ntask.common;version="[4.9,5)", + org.wso2.carbon.ntask.core;version="[4.9,5)", + org.wso2.carbon.ntask.core.service;version="[4.9,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.user.core.tenant;version="[4.8,5)" io.entgra.device.mgt.core.task.mgt.watcher.* @@ -74,20 +87,14 @@ - org.eclipse.osgi - org.eclipse.osgi - provided - - - org.eclipse.osgi - org.eclipse.osgi.services + org.apache.felix + org.apache.felix.scr.ds-annotations provided org.ops4j.pax.logging pax-logging-api provided - io.entgra.device.mgt.core diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/IoTSStartupHandler.java b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/IoTSStartupHandler.java index c7ac374b80..eb23f5b824 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/IoTSStartupHandler.java +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/IoTSStartupHandler.java @@ -36,14 +36,7 @@ import org.wso2.carbon.user.api.Tenant; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; +import java.util.*; public class IoTSStartupHandler implements ServerStartupObserver { private static final Log log = LogFactory.getLog(IoTSStartupHandler.class); diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/internal/TaskWatcherServiceComponent.java b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/internal/TaskWatcherServiceComponent.java index 876edb5b25..899d0f0338 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/internal/TaskWatcherServiceComponent.java +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/internal/TaskWatcherServiceComponent.java @@ -17,11 +17,11 @@ */ package io.entgra.device.mgt.core.task.mgt.watcher.internal; +import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; import io.entgra.device.mgt.core.task.mgt.common.spi.TaskManagementService; import io.entgra.device.mgt.core.task.mgt.core.config.TaskConfigurationManager; import io.entgra.device.mgt.core.task.mgt.core.config.TaskManagementConfig; import io.entgra.device.mgt.core.task.mgt.watcher.IoTSStartupHandler; -import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -29,39 +29,16 @@ import org.osgi.service.component.ComponentContext; import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.user.core.service.RealmService; +import org.osgi.service.component.annotations.*; -/** - * @scr.component - * name="io.entgra.device.mgt.core.task.mgt.watcher" immediate="true" - * @scr.reference name="app.mgt.ntask.component" - * interface="org.wso2.carbon.ntask.core.service.TaskService" - * cardinality="1..1" - * policy="dynamic" - * bind="setTaskService" - * unbind="unsetTaskService" - * @scr.reference name="io.entgra.task.mgt.service" - * interface="io.entgra.device.mgt.core.task.mgt.common.spi.TaskManagementService" - * cardinality="1..1" - * policy="dynamic" - * bind="setTaskMgtService" - * unbind="unsetTaskMgtService" - * @scr.reference name="entgra.heart.beat.service" - * interface="io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService" - * cardinality="0..1" - * policy="dynamic" - * bind="setHeartBeatService" - * unbind="unsetHeartBeatService" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - */ +@Component( + name = "io.entgra.device.mgt.core.task.mgt.watcher.internal.TaskWatcherServiceComponent", + immediate = true) public class TaskWatcherServiceComponent { private static final Log log = LogFactory.getLog(TaskWatcherServiceComponent.class); + @Activate protected void activate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("Activating Task Watcher Service Component"); @@ -83,7 +60,7 @@ public class TaskWatcherServiceComponent { log.error("Error occurred while activating Task Watcher Service Component", e); } } - + @Deactivate protected void deactivate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("De-activating Task Watcher Service Component"); @@ -91,6 +68,12 @@ public class TaskWatcherServiceComponent { } @SuppressWarnings("unused") + @Reference( + name = "task.service", + service = org.wso2.carbon.ntask.core.service.TaskService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTaskService") public void setTaskService(TaskService taskService) { if (log.isDebugEnabled()) { log.debug("Setting the task service to Task Watcher Service Component "); @@ -107,6 +90,12 @@ public class TaskWatcherServiceComponent { } @SuppressWarnings("unused") + @Reference( + name = "task.mgt.service", + service = io.entgra.device.mgt.core.task.mgt.common.spi.TaskManagementService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTaskMgtService") protected void setTaskMgtService(TaskManagementService taskManagementService) { if (log.isDebugEnabled()) { log.debug("Setting the task service to Task Watcher Service Component "); @@ -121,6 +110,12 @@ public class TaskWatcherServiceComponent { } TaskWatcherDataHolder.getInstance().setTaskManagementService(null); } + @Reference( + name = "heartbeat.service", + service = io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetHeartBeatService") @SuppressWarnings("unused") protected void setHeartBeatService(HeartBeatManagementService heartBeatService) { @@ -144,6 +139,12 @@ public class TaskWatcherServiceComponent { * @param realmService An instance of RealmService */ @SuppressWarnings("unused") + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { log.debug("Setting Realm Service"); diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 6b1aec0fc7..fdd9fab4cc 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -32,6 +32,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-bundle-plugin @@ -43,8 +51,8 @@ ${io.entgra.device.mgt.core.version} Tenant Management Common Bundle - org.apache.commons.logging, - org.wso2.carbon.stratos.common.beans + io.entgra.device.mgt.core.tenant.mgt.common.exception, + org.wso2.carbon.stratos.common.beans;version="[4.9,5)" io.entgra.device.mgt.core.tenant.mgt.common.* diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index e8f306be23..a03cbc362b 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -33,8 +33,12 @@ - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -48,26 +52,29 @@ Tenant Management Core Bundle io.entgra.device.mgt.core.tenant.mgt.core.internal + io.entgra.device.mgt.core.application.mgt.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.services;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.roles.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.metadata.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.tenant.mgt.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.tenant.mgt.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.tenant.mgt.core, + org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - io.entgra.device.mgt.core.application.mgt.common.*, - io.entgra.device.mgt.core.application.mgt.core.config, - io.entgra.device.mgt.core.device.mgt.core, - org.wso2.carbon.user.api, - org.wso2.carbon.registry.core.exceptions, - io.entgra.device.mgt.core.tenant.mgt.common.*, - org.wso2.carbon.stratos.common.beans, - org.wso2.carbon.stratos.common.exception, - org.wso2.carbon.stratos.common.listeners, - io.entgra.device.mgt.core.device.mgt.common.metadata.mgt, - io.entgra.device.mgt.core.device.mgt.common.exceptions, - io.entgra.device.mgt.core.device.mgt.common.permission.mgt, - io.entgra.device.mgt.core.device.mgt.common.roles.config, - io.entgra.device.mgt.core.device.mgt.core.metadata.mgt, - io.entgra.device.mgt.core.device.mgt.core.config, - org.wso2.carbon.user.core.service, - org.wso2.carbon.context + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", + org.wso2.carbon.stratos.common.beans;version="[4.9,5)", + org.wso2.carbon.stratos.common.exception;version="[4.9,5)", + org.wso2.carbon.stratos.common.listeners;version="[4.9,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)" !io.entgra.device.mgt.core.tenant.mgt.core.internal, @@ -81,12 +88,9 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.wso2.carbon.commons diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java index 4296031c88..e759e33e1d 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java @@ -18,23 +18,23 @@ package io.entgra.device.mgt.core.tenant.mgt.core.impl; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; -import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; +import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; +import io.entgra.device.mgt.core.device.mgt.common.roles.config.Role; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; +import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException; +import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; import io.entgra.device.mgt.core.tenant.mgt.core.internal.TenantMgtDataHolder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; -import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.stratos.common.beans.TenantInfoBean; import org.wso2.carbon.user.api.Permission; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; -import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.roles.config.Role; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerServiceImpl.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerServiceImpl.java index 9013d534d9..8d130b6400 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerServiceImpl.java +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerServiceImpl.java @@ -17,8 +17,8 @@ */ package io.entgra.device.mgt.core.tenant.mgt.core.impl; -import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerService; import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException; +import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerService; import io.entgra.device.mgt.core.tenant.mgt.core.internal.TenantMgtDataHolder; import org.wso2.carbon.stratos.common.beans.TenantInfoBean; diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtDataHolder.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtDataHolder.java index 0e301d6f8c..1b91bb57a0 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtDataHolder.java +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtDataHolder.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.tenant.mgt.core.internal; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelManagementService; +import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; import org.wso2.carbon.user.core.service.RealmService; public class TenantMgtDataHolder { diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java index 2fc6590ecd..bde5506a22 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java @@ -18,6 +18,8 @@ package io.entgra.device.mgt.core.tenant.mgt.core.internal; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelManagementService; +import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.WhiteLabelManagementServiceImpl; import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerService; import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; import io.entgra.device.mgt.core.tenant.mgt.core.impl.TenantManagerImpl; @@ -26,33 +28,20 @@ import io.entgra.device.mgt.core.tenant.mgt.core.listener.DeviceMgtTenantListene import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelManagementService; -import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.WhiteLabelManagementServiceImpl; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.stratos.common.listeners.TenantMgtListener; import org.wso2.carbon.user.core.service.RealmService; -/** - * @scr.component name="io.entgra.device.mgt.core.tenant.manager" immediate="true" - * @scr.reference name="org.wso2.carbon.application.mgt.service" - * interface="io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager" - * cardinality="1..1" - * policy="dynamic" - * bind="setApplicationManager" - * unbind="unsetApplicationManager" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - */ - +@Component( + name = "io.entgra.device.mgt.core.tenant.mgt.core.internal.TenantMgtServiceComponent", + immediate = true) @SuppressWarnings("unused") public class TenantMgtServiceComponent { private static final Log log = LogFactory.getLog(TenantManagerService.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { TenantManagerService tenantManagerService = new TenantManagerServiceImpl(); @@ -80,10 +69,17 @@ public class TenantMgtServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { // nothing to do } + @Reference( + name = "application.mgr", + service = io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetApplicationManager") protected void setApplicationManager(ApplicationManager applicationManager) { if(log.isDebugEnabled()) { log.info("Application manager service is binding"); @@ -98,6 +94,12 @@ public class TenantMgtServiceComponent { TenantMgtDataHolder.getInstance().setApplicationManager(null); } + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if(log.isDebugEnabled()) { log.info("Realm Service service is binding"); diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java index baaef87785..e121f21a4d 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java @@ -17,8 +17,8 @@ */ package io.entgra.device.mgt.core.tenant.mgt.core.listener; -import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException; +import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; import io.entgra.device.mgt.core.tenant.mgt.core.internal.TenantMgtDataHolder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index b25f17413a..5fa628f088 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -31,13 +31,17 @@ bundle WSO2 Carbon - Email Sender Core WSO2 Carbon - Email Sender Core - http://wso2.org + https://entgra.io - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -51,27 +55,33 @@ Email Management Core Bundle io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal - org.apache.axis2.*;version="${axis2.osgi.version.range}", - org.apache.axiom.*; version="${axiom.osgi.version.range}", + io.entgra.device.mgt.core.transport.mgt.email.sender.core, + javax.xml.bind;version="[0.0,1)", + javax.xml.bind.annotation;version="[0.0,1)", + javax.xml.parsers, + javax.xml.stream;version="[1.0,2)", + org.apache.axiom.om;version="[1.2,2)", + org.apache.axiom.om.impl.llom.util;version="[1.2,2)", + org.apache.axis2;version="[1.6,2)", + org.apache.axis2.addressing;version="[1.6,2)", + org.apache.axis2.client;version="[1.6,2)", + org.apache.axis2.context;version="[1.6,2)", + org.apache.axis2.description;version="[1.6,2)", + org.apache.axis2.engine;version="[1.6,2)", + org.apache.commons.io;version="[2.4,3)", + org.apache.commons.logging;version="[1.2,2)", + org.apache.velocity;version="[2.3,3)", + org.apache.velocity.app;version="[2.3,3)", + org.apache.velocity.context;version="[2.3,3)", + org.apache.velocity.exception;version="[2.3,3)", + org.apache.velocity.runtime.resource;version="[2.3,3)", + org.apache.velocity.runtime.resource.loader;version="[2.3,3)", + org.apache.velocity.util;version="[2.3,3)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - org.wso2.carbon.context, - org.wso2.carbon.utils.*, - org.wso2.carbon.registry.api, org.w3c.dom, - org.apache.velocity;version="${velocity.version}", - org.apache.velocity.app;version="${velocity.version}", - org.apache.velocity.context;version="${velocity.version}", - org.apache.velocity.exception;version="${velocity.version}", - org.apache.velocity.runtime.resource;version="${velocity.version}", - org.apache.velocity.runtime.resource.loader;version="${velocity.version}", - org.apache.commons.io, - org.apache.axis2.transport.mail, - org.wso2.carbon.registry.core.service, - org.wso2.carbon.registry.core.session, - org.apache.commons.collections + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.utils;version="[4.8,5)" !io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal, @@ -80,61 +90,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon @@ -144,10 +112,6 @@ org.testng testng - - org.wso2.carbon - org.wso2.carbon.registry.api - org.wso2.carbon org.wso2.carbon.base @@ -157,8 +121,8 @@ axis2 - org.wso2.orbit.org.apache.velocity - velocity + org.apache.velocity + velocity-engine-core commons-io.wso2 @@ -168,10 +132,6 @@ org.apache.axis2.transport axis2-transport-mail - - org.wso2.carbon - org.wso2.carbon.registry.core - commons-collections.wso2 commons-collections diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/EmailContext.java b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/EmailContext.java index e9a8eb54e7..c8e2c3efc4 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/EmailContext.java +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/EmailContext.java @@ -18,7 +18,9 @@ */ package io.entgra.device.mgt.core.transport.mgt.email.sender.core; -import java.util.*; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; public class EmailContext { diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/RegistryBasedResourceLoader.java b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/RegistryBasedResourceLoader.java index 24ba401944..72302647ae 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/RegistryBasedResourceLoader.java +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/RegistryBasedResourceLoader.java @@ -18,44 +18,63 @@ */ package io.entgra.device.mgt.core.transport.mgt.email.sender.core; -import org.apache.commons.collections.ExtendedProperties; import org.apache.velocity.exception.ResourceNotFoundException; import org.apache.velocity.runtime.resource.Resource; import org.apache.velocity.runtime.resource.loader.ResourceLoader; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.RegistryType; -import org.wso2.carbon.registry.api.Registry; -import org.wso2.carbon.registry.api.RegistryException; +import org.apache.velocity.util.ExtProperties; import java.io.InputStream; +import java.io.Reader; public class RegistryBasedResourceLoader extends ResourceLoader { private static final String EMAIL_CONFIG_BASE_LOCATION = "email-templates"; @Override - public void init(ExtendedProperties extendedProperties) { + public void init(ExtProperties extProperties) { } @Override + public Reader getResourceReader(String name, String encoding) throws ResourceNotFoundException { +// try { +// Registry registry = +// CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_CONFIGURATION); +// if (registry == null) { +// throw new IllegalStateException("No valid registry instance is attached to the current carbon context"); +// } +// if (!registry.resourceExists(EMAIL_CONFIG_BASE_LOCATION + "/" + name)) { +// throw new ResourceNotFoundException("Resource '" + name + "' does not exist"); +// } +// org.wso2.carbon.registry.api.Resource resource = +// registry.get(EMAIL_CONFIG_BASE_LOCATION + "/" + name); +// resource.setMediaType("text/plain"); +// +// return new InputStreamReader(resource.getContentStream()); +// } catch (RegistryException e) { +// throw new ResourceNotFoundException("Error occurred while retrieving resource", e); +// } + return null; + } + public InputStream getResourceStream(String name) throws ResourceNotFoundException { - try { - Registry registry = - CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_CONFIGURATION); - if (registry == null) { - throw new IllegalStateException("No valid registry instance is attached to the current carbon context"); - } - if (!registry.resourceExists(EMAIL_CONFIG_BASE_LOCATION + "/" + name)) { - throw new ResourceNotFoundException("Resource '" + name + "' does not exist"); - } - org.wso2.carbon.registry.api.Resource resource = - registry.get(EMAIL_CONFIG_BASE_LOCATION + "/" + name); - resource.setMediaType("text/plain"); - return resource.getContentStream(); - } catch (RegistryException e) { - throw new ResourceNotFoundException("Error occurred while retrieving resource", e); - } +// try { +// Registry registry = +// CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_CONFIGURATION); +// if (registry == null) { +// throw new IllegalStateException("No valid registry instance is attached to the current carbon context"); +// } +// if (!registry.resourceExists(EMAIL_CONFIG_BASE_LOCATION + "/" + name)) { +// throw new ResourceNotFoundException("Resource '" + name + "' does not exist"); +// } +// org.wso2.carbon.registry.api.Resource resource = +// registry.get(EMAIL_CONFIG_BASE_LOCATION + "/" + name); +// resource.setMediaType("text/plain"); +// return resource.getContentStream(); +// } catch (RegistryException e) { +// throw new ResourceNotFoundException("Error occurred while retrieving resource", e); +// } + return null; } @Override diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/VelocityBasedEmailContentProvider.java b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/VelocityBasedEmailContentProvider.java index 06d8ece984..b4ac3fa1a4 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/VelocityBasedEmailContentProvider.java +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/VelocityBasedEmailContentProvider.java @@ -23,18 +23,13 @@ import org.apache.commons.logging.LogFactory; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; -import org.apache.velocity.runtime.resource.loader.ResourceLoader; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.RegistryType; -import org.wso2.carbon.registry.api.Registry; +import org.apache.velocity.runtime.RuntimeConstants; +import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; +import java.io.*; import java.util.Map; public class VelocityBasedEmailContentProvider implements EmailContentProvider { @@ -42,12 +37,11 @@ public class VelocityBasedEmailContentProvider implements EmailContentProvider { private VelocityEngine engine; private static final Log log = LogFactory.getLog(VelocityBasedEmailContentProvider.class); + private static final String EMAIL_TEMPLATE_PATH = "repository" + File.separator + + "resources" + File.separator + "email-templates"; public VelocityBasedEmailContentProvider() { engine = new VelocityEngine(); - engine.setProperty("resource.loader", "registry"); - engine.setProperty("velocimacro.library", ""); - engine.setProperty("registry.resource.loader.class", - "io.entgra.device.mgt.core.transport.mgt.email.sender.core.RegistryBasedResourceLoader"); + engine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, CarbonUtils.getCarbonHome()); engine.init(); } @@ -58,7 +52,7 @@ public class VelocityBasedEmailContentProvider implements EmailContentProvider { for (Map.Entry, Object>> param : params.entrySet()) { ctx.put(param.getKey(), param.getValue().getValue()); } - Template template = engine.getTemplate(name); + Template template = engine.getTemplate(EMAIL_TEMPLATE_PATH + File.separator + name + ".vm"); StringWriter content = new StringWriter(); template.merge(ctx, content); diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderAxis2ConfigContextObserver.java b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderAxis2ConfigContextObserver.java index 87e8c3a426..214c18b1b2 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderAxis2ConfigContextObserver.java +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderAxis2ConfigContextObserver.java @@ -18,10 +18,10 @@ */ package io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal; +import io.entgra.device.mgt.core.transport.mgt.email.sender.core.EmailSenderConfigurationFailedException; import org.apache.axis2.context.ConfigurationContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.transport.mgt.email.sender.core.EmailSenderConfigurationFailedException; import org.wso2.carbon.utils.Axis2ConfigurationContextObserver; class EmailSenderAxis2ConfigContextObserver implements Axis2ConfigurationContextObserver { diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderDataHolder.java b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderDataHolder.java index 9db2d4c3a4..5633b2374b 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderDataHolder.java +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderDataHolder.java @@ -19,12 +19,11 @@ package io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal; import io.entgra.device.mgt.core.transport.mgt.email.sender.core.service.EmailSenderService; -import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.utils.ConfigurationContextService; public class EmailSenderDataHolder { - private RegistryService registryService; +// private RegistryService registryService; private ConfigurationContextService configurationContextService; private EmailSenderService emailServiceProvider; @@ -36,16 +35,16 @@ public class EmailSenderDataHolder { return thisInstance; } - public RegistryService getRegistryService() { - if (registryService == null) { - throw new IllegalStateException("Registry service is not initialized properly"); - } - return registryService; - } - - public void setRegistryService(RegistryService registryService) { - this.registryService = registryService; - } +// public RegistryService getRegistryService() { +// if (registryService == null) { +// throw new IllegalStateException("Registry service is not initialized properly"); +// } +// return registryService; +// } +// +// public void setRegistryService(RegistryService registryService) { +// this.registryService = registryService; +// } public ConfigurationContextService getConfigurationContextService() { if (configurationContextService == null) { diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderServiceComponent.java b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderServiceComponent.java index 182a962e15..8a0ac57a72 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderServiceComponent.java +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailSenderServiceComponent.java @@ -17,37 +17,25 @@ */ package io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.service.component.ComponentContext; import io.entgra.device.mgt.core.transport.mgt.email.sender.core.EmailSenderConfig; import io.entgra.device.mgt.core.transport.mgt.email.sender.core.service.EmailSenderService; import io.entgra.device.mgt.core.transport.mgt.email.sender.core.service.EmailSenderServiceImpl; -import org.wso2.carbon.registry.core.service.RegistryService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.utils.Axis2ConfigurationContextObserver; import org.wso2.carbon.utils.ConfigurationContextService; -/** - * @scr.component name="io.entgra.device.mgt.core.email.sender.emailsendereervicecomponent" - * immediate="true" - * @scr.reference name="registry.service" - * interface="org.wso2.carbon.registry.core.service.RegistryService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRegistryService" - * unbind="unsetRegistryService" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" - * policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - */ +@Component( + name = "io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal.EmailSenderServiceComponent", + immediate = true) public class EmailSenderServiceComponent { private static Log log = LogFactory.getLog(EmailSenderServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -73,6 +61,7 @@ public class EmailSenderServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } @@ -86,30 +75,42 @@ public class EmailSenderServiceComponent { componentContext.getBundleContext().registerService(EmailSenderService.class, emailServiceProvider, null); } - /** - * Sets Registry Service. - * - * @param registryService An instance of RegistryService - */ - protected void setRegistryService(RegistryService registryService) { - if (log.isDebugEnabled()) { - log.debug("Setting Registry Service"); - } - EmailSenderDataHolder.getInstance().setRegistryService(registryService); - } - - /** - * Unsets Registry Service. - * - * @param registryService An instance of RegistryService - */ - protected void unsetRegistryService(RegistryService registryService) { - if (log.isDebugEnabled()) { - log.debug("Un setting Registry Service"); - } - EmailSenderDataHolder.getInstance().setRegistryService(null); - } +// /** +// * Sets Registry Service. +// * +// * @param registryService An instance of RegistryService +// */ +// @Reference( +// name = "registry.service", +// service = org.wso2.carbon.registry.core.service.RegistryService.class, +// cardinality = ReferenceCardinality.MANDATORY, +// policy = ReferencePolicy.DYNAMIC, +// unbind = "unsetRegistryService") +// protected void setRegistryService(RegistryService registryService) { +// if (log.isDebugEnabled()) { +// log.debug("Setting Registry Service"); +// } +// EmailSenderDataHolder.getInstance().setRegistryService(registryService); +// } +// +// /** +// * Unsets Registry Service. +// * +// * @param registryService An instance of RegistryService +// */ +// protected void unsetRegistryService(RegistryService registryService) { +// if (log.isDebugEnabled()) { +// log.debug("Un setting Registry Service"); +// } +// EmailSenderDataHolder.getInstance().setRegistryService(null); +// } + @Reference( + name = "configuration.context.service", + service = org.wso2.carbon.utils.ConfigurationContextService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { if (log.isDebugEnabled()) { log.debug("Setting ConfigurationContextService"); diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailUtils.java b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailUtils.java index 7eb06e83f0..72c549a452 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailUtils.java +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/email/sender/core/internal/EmailUtils.java @@ -17,20 +17,15 @@ */ package io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal; +import io.entgra.device.mgt.core.transport.mgt.email.sender.core.EmailSenderConfigurationFailedException; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; -import io.entgra.device.mgt.core.transport.mgt.email.sender.core.EmailSenderConfigurationFailedException; -import org.wso2.carbon.registry.api.Collection; -import org.wso2.carbon.registry.api.Registry; -import org.wso2.carbon.registry.api.RegistryException; -import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.utils.CarbonUtils; import java.io.File; import java.io.FileNotFoundException; -import java.io.FilenameFilter; import java.io.IOException; class EmailUtils { @@ -49,31 +44,11 @@ class EmailUtils { } } if (templateDir.canRead()) { - File[] templates = templateDir.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - name = name.toLowerCase(); - return name.endsWith(".vm"); - } - }); try { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - Registry registry = - EmailSenderDataHolder.getInstance().getRegistryService().getConfigSystemRegistry(tenantId); - if (!registry.resourceExists(EMAIL_TEMPLATE_DIR_RELATIVE_REGISTRY_PATH)) { - Collection collection = registry.newCollection(); - registry.put(EMAIL_TEMPLATE_DIR_RELATIVE_REGISTRY_PATH, collection); - for (File template : templates) { - Resource resource = registry.newResource(); - resource.setMediaType("text/plain"); - String contents = FileUtils.readFileToString(template); - resource.setContent(contents); - registry.put(EMAIL_TEMPLATE_DIR_RELATIVE_REGISTRY_PATH + "/" - + template.getName().replace(".vm", ""), resource); - } - } - } catch (RegistryException e) { - throw new EmailSenderConfigurationFailedException("Error occurred while setting up email templates", e); + String tenantTemplateDirectory = CarbonUtils.getCarbonTenantsDirPath() + File.separator + tenantId + File.separator; + File destinationDirectory = new File(tenantTemplateDirectory); + FileUtils.copyDirectoryToDirectory(templateDir, destinationDirectory); } catch (FileNotFoundException e) { throw new EmailSenderConfigurationFailedException("Error occurred while writing template file " + "contents as an input stream of a resource", e); diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 0cad77b1c5..612cc94052 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -30,7 +30,7 @@ email-sender pom WSO2 Carbon - Email Sender Component - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.transport.mgt.email.sender.core diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index e04ee7b273..4d1bb36291 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -133,7 +133,6 @@ org.ops4j.pax.logging pax-logging-api provided - io.entgra.device.mgt.core diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/ConfigurationManagementService.java b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/ConfigurationManagementService.java index 656509e448..022920f3e7 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/ConfigurationManagementService.java +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/ConfigurationManagementService.java @@ -18,19 +18,10 @@ package io.entgra.device.mgt.core.transport.mgt.sms.handler.api; -import io.entgra.device.mgt.core.transport.mgt.sms.handler.common.SMSHandlerConstants; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; +import io.entgra.device.mgt.core.transport.mgt.sms.handler.common.SMSHandlerConstants; +import io.swagger.annotations.*; import javax.ws.rs.Consumes; import javax.ws.rs.GET; diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/addons/ApiOriginFilter.java b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/addons/ApiOriginFilter.java index 905deefcf6..b8b026d7a2 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/addons/ApiOriginFilter.java +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/addons/ApiOriginFilter.java @@ -18,12 +18,7 @@ package io.entgra.device.mgt.core.transport.mgt.sms.handler.api.addons; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import javax.servlet.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/addons/GsonMessageBodyHandler.java b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/addons/GsonMessageBodyHandler.java index 929799870c..09ef6238c8 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/addons/GsonMessageBodyHandler.java +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/addons/GsonMessageBodyHandler.java @@ -24,11 +24,7 @@ import com.google.gson.GsonBuilder; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; +import java.io.*; import java.lang.annotation.Annotation; import java.lang.reflect.Type; diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/impl/ConfigurationManagementServiceImpl.java b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/impl/ConfigurationManagementServiceImpl.java index c4c37d0b72..5e64bf5bc4 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/impl/ConfigurationManagementServiceImpl.java +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/api/impl/ConfigurationManagementServiceImpl.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.transport.mgt.sms.handler.api.impl; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.transport.mgt.sms.handler.api.ConfigurationManagementService; import io.entgra.device.mgt.core.transport.mgt.sms.handler.core.config.SMSConfigurationManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import javax.ws.rs.GET; import javax.ws.rs.Path; diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 742790b542..f390f1b656 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -19,9 +19,9 @@ + http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 6b59870558..5a7a59906c 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -35,6 +35,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-bundle-plugin @@ -49,7 +57,10 @@ io.entgra.device.mgt.core.transport.mgt.sms.handler.common.* - io.swagger.annotations; version="${swagger.annotations.version}"; resolution:=optional, + io.entgra.device.mgt.core.transport.mgt.sms.handler.common.bean, + io.entgra.device.mgt.core.transport.mgt.sms.handler.common.exception, + io.swagger.annotations;version="[1.6,2)", + javax.xml.bind.annotation;version="[0.0,1)" diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 8b6bc1f41a..00fe2d2a6f 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -35,10 +35,6 @@ - - org.apache.felix - maven-scr-plugin - org.jacoco jacoco-maven-plugin @@ -65,6 +61,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-bundle-plugin @@ -77,14 +81,19 @@ SMS Management Core Bundle io.entgra.device.mgt.core.transport.mgt.sms.handler.core.internal - io.entgra.device.mgt.core.transport.mgt.sms.handler.common.*, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - javax.xml.bind.annotation, - javax.xml.bind, - org.apache.commons.lang, - org.wso2.carbon, - io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.core.* + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.util;version="[5.0,6)", + io.entgra.device.mgt.core.transport.mgt.sms.handler.common.bean;version="[5.0,6)", + io.entgra.device.mgt.core.transport.mgt.sms.handler.common.config;version="[5.0,6)", + io.entgra.device.mgt.core.transport.mgt.sms.handler.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.transport.mgt.sms.handler.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.transport.mgt.sms.handler.core.config, + javax.xml.bind;version="[0.0,1)", + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.logging;version="[1.2,2)", + org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.w3c.dom, + org.wso2.carbon.utils;version="[4.8,5)" !io.entgra.device.mgt.core.transport.mgt.sms.handler.core.internal, @@ -98,11 +107,15 @@ + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/core/config/SMSConfigurationManager.java b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/core/config/SMSConfigurationManager.java index ab21c30ea3..515c12b19f 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/core/config/SMSConfigurationManager.java +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/core/config/SMSConfigurationManager.java @@ -18,13 +18,13 @@ package io.entgra.device.mgt.core.transport.mgt.sms.handler.core.config; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import io.entgra.device.mgt.core.transport.mgt.sms.handler.common.SMSHandlerConstants; import io.entgra.device.mgt.core.transport.mgt.sms.handler.common.config.SMSConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/core/internal/SMSHandlerServiceComponent.java b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/core/internal/SMSHandlerServiceComponent.java index 67b8c50b5b..96ed85756d 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/core/internal/SMSHandlerServiceComponent.java +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/src/main/java/io/entgra/device/mgt/core/transport/mgt/sms/handler/core/internal/SMSHandlerServiceComponent.java @@ -22,15 +22,18 @@ import io.entgra.device.mgt.core.transport.mgt.sms.handler.core.config.SMSConfig import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; -/** - * @scr.component - * name="io.entgra.device.mgt.core.transport.mgt.sms.handler.core.internal.SMSHandlerServiceComponent" immediate="true" - */ +@Component( + name = "io.entgra.device.mgt.core.transport.mgt.sms.handler.core.internal.SMSHandlerServiceComponent", + immediate = true) public class SMSHandlerServiceComponent { private static final Log log = LogFactory.getLog(SMSHandlerServiceComponent.class); + @Activate protected void activate(ComponentContext ctx) { if (log.isDebugEnabled()) { @@ -46,7 +49,7 @@ public class SMSHandlerServiceComponent { log.error("Error occurred while activating SMS Handler Service Component", e); } } - + @Deactivate protected void deactivate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("De-activating SMS Handler Service Component"); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java index f763118dde..9250675972 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java @@ -22,6 +22,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.StringUtils; @@ -32,7 +33,6 @@ import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; import org.apache.http.entity.ContentType; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java index efc9f04f4d..ac74b60014 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java @@ -21,6 +21,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception.GrafanaManagementException; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.exception.GrafanaEnvVariablesNotDefined; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util.GrafanaUtil; +import io.entgra.device.mgt.core.device.mgt.core.common.util.HttpUtil; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.GrafanaHandlerUtil; @@ -35,7 +36,6 @@ import org.apache.http.HttpStatus; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.*; import org.apache.http.impl.client.CloseableHttpClient; -import io.entgra.device.mgt.core.device.mgt.core.common.util.HttpUtil; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java index 660b2e55bc..c8861b286f 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.fileupload.FileUploadException; @@ -27,12 +28,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; +import org.apache.http.client.methods.*; + import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index 7368d2935d..5c014ae0fb 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -18,12 +18,9 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; +import com.google.gson.*; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.cache.LoginCache; import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthApp; import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthAppCacheKey; @@ -38,7 +35,6 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HTTP; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LogoutHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LogoutHandler.java index dce8b5feab..d023cdbdbe 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LogoutHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LogoutHandler.java @@ -18,11 +18,11 @@ package io.entgra.device.mgt.core.ui.request.interceptor; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpStatus; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java index 8b03ab6049..c1f1fd4170 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.fileupload.FileUploadException; @@ -25,12 +26,8 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpHead; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; +import org.apache.http.client.methods.*; + import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java index 988c3aa330..19d124f3ac 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java @@ -22,6 +22,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; @@ -30,7 +31,6 @@ import org.apache.http.HttpHeaders; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index 522258d9bc..121ea5b926 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -18,11 +18,8 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; +import com.google.gson.*; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.cache.LoginCache; import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthApp; import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthAppCacheKey; @@ -43,7 +40,6 @@ import org.json.JSONArray; import org.json.JSONObject; import org.w3c.dom.Document; import org.w3c.dom.NodeList; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import org.xml.sax.InputSource; import org.xml.sax.SAXException; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLogoutHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLogoutHandler.java index 0567220ce5..b0b94d566a 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLogoutHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLogoutHandler.java @@ -18,20 +18,16 @@ package io.entgra.device.mgt.core.ui.request.interceptor; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpStatus; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import javax.servlet.http.Cookie; +import javax.servlet.http.*; import java.io.IOException; @MultipartConfig diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index 7451e92f6d..7d7c465eb7 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -22,20 +22,20 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.UserLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraUserLoggerImpl; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.UserLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraUserLoggerImpl; import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 374fcc1931..4ebfffa5f1 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -18,12 +18,9 @@ package io.entgra.device.mgt.core.ui.request.interceptor.util; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import com.google.gson.*; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.cache.LoginCache; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; @@ -54,7 +51,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.Document; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import org.xml.sax.SAXException; import javax.servlet.http.HttpServletRequest; @@ -63,12 +59,7 @@ import javax.servlet.http.HttpSession; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.io.StringWriter; +import java.io.*; import java.util.Enumeration; import java.util.List; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaLiveSecurityFilter.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaLiveSecurityFilter.java index 97e57394c5..98a9ce7db9 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaLiveSecurityFilter.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaLiveSecurityFilter.java @@ -23,12 +23,7 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import java.io.IOException; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketClient.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketClient.java index efa63fd2d1..73fd04e49f 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketClient.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketClient.java @@ -23,20 +23,9 @@ import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util.GrafanaUt import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.websocket.ClientEndpoint; -import javax.websocket.ContainerProvider; -import javax.websocket.Session; -import javax.websocket.OnOpen; -import javax.websocket.OnClose; -import javax.websocket.OnError; -import javax.websocket.CloseReason; -import javax.websocket.WebSocketContainer; -import java.net.URI; - -import javax.websocket.ClientEndpointConfig; -import javax.websocket.Endpoint; -import javax.websocket.EndpointConfig; +import javax.websocket.*; import javax.ws.rs.core.HttpHeaders; +import java.net.URI; import java.util.Collections; import java.util.List; import java.util.Map; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketHandler.java index 66a7df6aa4..df055b17eb 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketHandler.java @@ -24,13 +24,8 @@ import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util.GrafanaUt import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.websocket.CloseReason; +import javax.websocket.*; import javax.websocket.server.ServerEndpoint; -import javax.websocket.Session; -import javax.websocket.OnOpen; -import javax.websocket.OnMessage; -import javax.websocket.OnClose; -import javax.websocket.OnError; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 3083d062f7..2bd2192b1d 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -26,18 +26,21 @@ 4.0.0 - io.entgra.device.mgt.core io.entgra.device.mgt.core.webapp.authenticator.framework bundle WSO2 Carbon - Web Application Authenticator Framework Bundle WSO2 Carbon - Web Application Authenticator Framework Bundle - http://wso2.org + https://entgra.io - org.apache.felix - maven-scr-plugin + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -55,65 +58,70 @@ io.entgra.device.mgt.core.webapp.authenticator.framework.* - com.nimbusds.jose;version="${nimbus.orbit.version.range}", - com.nimbusds.jose.crypto;version="${nimbus.orbit.version.range}", - com.nimbusds.jwt;version="${nimbus.orbit.version.range}", - javax.xml.bind, - javax.xml.bind.annotation, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - javax.xml.validation, - org.apache.catalina;version="9.0", - org.apache.catalina.connector;version="9.0", - org.apache.catalina.util;version="9.0", - org.apache.commons.logging, - org.apache.coyote;version="9.0", - org.apache.tomcat.util.buf;version="9.0", - org.apache.tomcat.util.http;version="9.0", + com.google.gson;version="[2.9,3)", + com.nimbusds.jose;version="[7.9,8)", + com.nimbusds.jose.crypto;version="[7.9,8)", + com.nimbusds.jwt;version="[7.9,8)", + io.entgra.device.mgt.core.certificate.mgt.core.dto;version="[5.0,6)", + io.entgra.device.mgt.core.certificate.mgt.core.exception;version="[5.0,6)", + io.entgra.device.mgt.core.certificate.mgt.core.scep;version="[5.0,6)", + io.entgra.device.mgt.core.certificate.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.util;version="[5.0,6)", + io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth, + io.entgra.device.mgt.core.webapp.authenticator.framework.authorizer, + io.entgra.device.mgt.core.webapp.authenticator.framework.config, + io.entgra.device.mgt.core.webapp.authenticator.framework.config.impl, + javax.servlet;version="[2.6,3)", + + + javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", + + javax.xml.stream.*;version="[1.0.1,1.1.0)", + org.apache.axiom.om;version="[1.2,2)", + org.apache.axiom.om.impl.builder;version="[1.2,2)", + org.apache.axiom.om.util;version="[1.2,2)", + org.apache.axiom.soap;version="[1.2,2)", + org.apache.axiom.soap.impl.builder;version="[1.2,2)", + org.apache.axis2;version="[1.6,2)", + org.apache.axis2.client;version="[1.6,2)", + org.apache.axis2.context;version="[1.6,2)", + org.apache.catalina;version="${catalina.version.range}", + org.apache.catalina.connector;version="${catalina.version.range}", + org.apache.commons.codec.binary;version="[1.14,2)", + org.apache.commons.httpclient;version="[3.1,4)", + org.apache.commons.httpclient.params;version="[3.1,4)", + org.apache.commons.lang;version="[2.6,3)", + org.apache.commons.logging;version="[1.2,2)", + org.apache.commons.pool;version="[1.5,2)", + org.apache.commons.pool.impl;version="[1.5,2)", + org.apache.coyote;version="[9.0,10)", + org.apache.tomcat.util.buf;version="[9.0,10)", + org.apache.tomcat.util.http;version="[9.0,10)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.owasp.encoder;version="[1.2,2)", org.w3c.dom, - org.wso2.carbon.context, - org.wso2.carbon.core.util, - org.wso2.carbon.identity.base; version="${carbon.identity.imp.pkg.version}", - org.wso2.carbon.identity.core.util; version="${carbon.identity.imp.pkg.version}", - org.wso2.carbon.identity.oauth2.*; - version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}", - org.wso2.carbon.tomcat.ext.valves, - org.wso2.carbon.user.api, - org.wso2.carbon.user.core.service, - org.wso2.carbon.user.core.tenant, - org.wso2.carbon.utils, - org.wso2.carbon.utils.multitenancy, - org.xml.sax, - - javax.servlet, - javax.servlet.http, - javax.xml, - org.apache.axis2.transport.http, - io.entgra.device.mgt.core.certificate.mgt.core.*, - io.entgra.device.mgt.core.device.mgt.core.permission.mgt.*, - io.entgra.device.mgt.core.device.mgt.core.util.*, - io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.common.permission.mgt.*, - org.apache.axis2, - org.apache.axis2.client, - org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.apache.commons.httpclient, - org.wso2.carbon.core.security, - org.apache.axis2.context, - org.apache.commons.httpclient.params, - org.apache.commons.pool, - org.apache.commons.pool.impl, - org.apache.http.conn, - org.apache.http.impl.conn, - - javax.xml.stream, - org.apache.axiom.*; version="${axiom.osgi.version.range}", - org.wso2.carbon.registry.core.*, - org.wso2.carbon.registry.common.*;version="${carbon.registry.imp.pkg.version.range}", - org.wso2.carbon.registry.indexing.*; version="${carbon.registry.imp.pkg.version.range}", - org.wso2.carbon.base, - org.owasp.encoder + org.wso2.carbon.base;version="[1.0,2)", + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.core.util;version="[4.8,5)", + org.wso2.carbon.identity.oauth2;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.dto;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.stub;version="[6.9,7)", + org.wso2.carbon.identity.oauth2.stub.dto;version="[6.9,7)", + org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", + org.wso2.carbon.registry.core.service;version="[1.0,2)", + org.wso2.carbon.registry.indexing.service;version="[4.8,5)", + org.wso2.carbon.tomcat.ext.valves;version="[4.8,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)", + org.wso2.carbon.user.core.tenant;version="[4.8,5)", + org.wso2.carbon.utils;version="[4.8,5)", + org.wso2.carbon.utils.multitenancy;version="[4.8,5)" @@ -160,6 +168,11 @@ + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.tomcat tomcat diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/AuthenticationFrameworkUtil.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/AuthenticationFrameworkUtil.java index baf336baf4..b8d81e96e3 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/AuthenticationFrameworkUtil.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/AuthenticationFrameworkUtil.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework; +import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Response; import org.apache.commons.logging.Log; @@ -28,7 +29,6 @@ import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Utils/Utils.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Utils/Utils.java index 148607606c..131a1c8479 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Utils/Utils.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Utils/Utils.java @@ -18,14 +18,7 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.Utils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; -import org.wso2.carbon.user.api.TenantManager; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationException; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.WebappAuthenticator; @@ -33,6 +26,13 @@ import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oa import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthValidationResponse; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthValidatorFactory; import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.TenantManager; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.util.Properties; import java.util.regex.Matcher; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValve.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValve.java index 6d0152df5e..24776e3d86 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValve.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValve.java @@ -19,6 +19,9 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework; import com.google.gson.Gson; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.WebappAuthenticator; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authorizer.PermissionAuthorizer; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authorizer.WebappTenantAuthorizer; import org.apache.catalina.Context; import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Response; @@ -32,9 +35,6 @@ import org.wso2.carbon.tomcat.ext.valves.CompositeValve; import org.wso2.carbon.user.api.Tenant; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.WebappAuthenticator; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authorizer.PermissionAuthorizer; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authorizer.WebappTenantAuthorizer; import javax.servlet.http.HttpServletResponse; import java.net.InetAddress; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorFactory.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorFactory.java index 542f67d9a3..7864e0a8ea 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorFactory.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorFactory.java @@ -18,9 +18,9 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework; -import org.apache.catalina.connector.Request; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.WebappAuthenticator; import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; +import org.apache.catalina.connector.Request; import java.util.Map; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticator.java index 7b6432ae6a..1a6d2f3803 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticator.java @@ -18,6 +18,12 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationException; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; +import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.Utils; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuth2TokenValidator; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthTokenValidationException; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthValidationResponse; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.impl.builder.StAXBuilder; import org.apache.axiom.om.util.StAXUtils; @@ -30,12 +36,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.coyote.InputBuffer; import org.apache.tomcat.util.buf.ByteChunk; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationException; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; -import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.Utils; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuth2TokenValidator; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthTokenValidationException; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthValidationResponse; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java index ffc9565914..c80f3aaa89 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java @@ -18,6 +18,11 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationException; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; +import io.entgra.device.mgt.core.webapp.authenticator.framework.Constants; +import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.Utils; +import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Response; import org.apache.commons.logging.Log; @@ -27,11 +32,6 @@ import org.apache.tomcat.util.buf.MessageBytes; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationException; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; -import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; -import io.entgra.device.mgt.core.webapp.authenticator.framework.Constants; -import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.Utils; import java.nio.charset.Charset; import java.util.Base64; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java index 4545b46033..c2ae19793d 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java @@ -19,10 +19,6 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; -import org.apache.catalina.connector.Request; -import org.apache.catalina.connector.Response; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPException; @@ -33,8 +29,12 @@ import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationException; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; -import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.Utils; +import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.security.cert.X509Certificate; import java.util.Properties; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/JWTAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/JWTAuthenticator.java index a1636159c7..4ae83e3f77 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/JWTAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/JWTAuthenticator.java @@ -21,6 +21,8 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; import com.nimbusds.jose.JWSVerifier; import com.nimbusds.jose.crypto.RSASSAVerifier; import com.nimbusds.jwt.SignedJWT; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; +import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Response; import org.apache.commons.logging.Log; @@ -35,19 +37,13 @@ import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; -import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; import java.io.FileInputStream; import java.security.KeyStore; import java.security.PublicKey; import java.security.interfaces.RSAPublicKey; import java.text.ParseException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Properties; -import java.util.StringTokenizer; +import java.util.*; /** * This authenticator authenticates HTTP requests using JWT header. diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java index c239032a6e..69c51e8342 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java @@ -18,11 +18,6 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; -import org.apache.catalina.connector.Response; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.tomcat.util.buf.ByteChunk; -import org.apache.tomcat.util.buf.MessageBytes; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationException; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import io.entgra.device.mgt.core.webapp.authenticator.framework.Constants; @@ -30,6 +25,11 @@ import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.Utils; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuth2TokenValidator; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthTokenValidationException; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthValidationResponse; +import org.apache.catalina.connector.Response; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tomcat.util.buf.ByteChunk; +import org.apache.tomcat.util.buf.MessageBytes; import java.util.Properties; import java.util.StringTokenizer; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java index 7d439fbd01..c4c6c03ccc 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java @@ -17,15 +17,15 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; -import org.apache.catalina.connector.Response; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto.OneTimePinDTO; import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import io.entgra.device.mgt.core.webapp.authenticator.framework.Constants; import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.Utils; import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; +import org.apache.catalina.connector.Response; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.Properties; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/WebappAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/WebappAuthenticator.java index bb92594a9b..f9b55a4dac 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/WebappAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/WebappAuthenticator.java @@ -18,9 +18,9 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Response; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import java.util.Properties; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/oauth/impl/LocalOAuthValidator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/oauth/impl/LocalOAuthValidator.java index 41e6721f10..18bfc3a233 100755 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/oauth/impl/LocalOAuthValidator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/oauth/impl/LocalOAuthValidator.java @@ -17,15 +17,15 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.impl; -import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO; -import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuth2TokenValidator; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthConstants; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthTokenValidationException; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthValidationResponse; +import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; +import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO; +import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; /** * Handles the OAuth2 token validation from the same server using OSGi services. diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/oauth/impl/RemoteOAuthValidator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/oauth/impl/RemoteOAuthValidator.java index 1db832febf..4db78bb8d2 100755 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/oauth/impl/RemoteOAuthValidator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/oauth/impl/RemoteOAuthValidator.java @@ -17,6 +17,10 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.impl; +import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.OAuthTokenValidationStubFactory; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuth2TokenValidator; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthTokenValidationException; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthValidationResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.pool.impl.GenericObjectPool; @@ -26,10 +30,6 @@ import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_ import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_TokenValidationContextParam; import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.OAuthTokenValidationStubFactory; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuth2TokenValidator; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthTokenValidationException; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthValidationResponse; import java.rmi.RemoteException; import java.util.Properties; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java index 20965b5fb7..bae38d3871 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java @@ -17,9 +17,6 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.authorizer; -import org.apache.catalina.connector.Request; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagerService; @@ -28,6 +25,9 @@ import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationEx import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationFrameworkUtil; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.WebappAuthenticator; +import org.apache.catalina.connector.Request; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/WebappTenantAuthorizer.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/WebappTenantAuthorizer.java index 84622a3b1c..34054cd311 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/WebappTenantAuthorizer.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/WebappTenantAuthorizer.java @@ -18,9 +18,9 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.authorizer; -import org.apache.catalina.connector.Request; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.WebappAuthenticator; +import org.apache.catalina.connector.Request; /** * This class represents the methods that are used to authorize requests based on the tenant subscription. diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/config/WebappAuthenticatorConfig.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/config/WebappAuthenticatorConfig.java index cd7ce74a1a..2e5783fcb9 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/config/WebappAuthenticatorConfig.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/config/WebappAuthenticatorConfig.java @@ -18,12 +18,12 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.config; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationFrameworkUtil; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticatorFrameworkException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; import org.wso2.carbon.utils.CarbonUtils; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationFrameworkUtil; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticatorFrameworkException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/internal/AuthenticatorFrameworkDataHolder.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/internal/AuthenticatorFrameworkDataHolder.java index f241bf166c..e467723ccf 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/internal/AuthenticatorFrameworkDataHolder.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/internal/AuthenticatorFrameworkDataHolder.java @@ -21,11 +21,11 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.internal; import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager; import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService; import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; +import io.entgra.device.mgt.core.webapp.authenticator.framework.WebappAuthenticatorRepository; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.user.core.service.RealmService; -import io.entgra.device.mgt.core.webapp.authenticator.framework.WebappAuthenticatorRepository; public class AuthenticatorFrameworkDataHolder { diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkServiceComponent.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkServiceComponent.java index 7625e6f13f..5fa88feb2c 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkServiceComponent.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/internal/WebappAuthenticatorFrameworkServiceComponent.java @@ -19,19 +19,9 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.internal; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager; import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService; import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; -import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; -import org.wso2.carbon.registry.core.service.TenantRegistryLoader; -import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; -import org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve; -import org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer; -import org.wso2.carbon.user.core.service.RealmService; import io.entgra.device.mgt.core.webapp.authenticator.framework.WebappAuthenticationValve; import io.entgra.device.mgt.core.webapp.authenticator.framework.WebappAuthenticatorRepository; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.WebappAuthenticator; @@ -39,60 +29,30 @@ import io.entgra.device.mgt.core.webapp.authenticator.framework.config.Authentic import io.entgra.device.mgt.core.webapp.authenticator.framework.config.AuthenticatorConfigService; import io.entgra.device.mgt.core.webapp.authenticator.framework.config.WebappAuthenticatorConfig; import io.entgra.device.mgt.core.webapp.authenticator.framework.config.impl.AuthenticatorConfigServiceImpl; +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.osgi.service.component.annotations.*; +import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; +import org.wso2.carbon.registry.core.service.TenantRegistryLoader; +import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; +import org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve; +import org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer; +import org.wso2.carbon.user.core.service.RealmService; import java.util.ArrayList; import java.util.List; import java.util.Properties; -/** - * @scr.component name="org.wso2.carbon.webapp.authenticator" immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="org.wso2.carbon.certificate.mgt" - * interface="io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService" - * policy="dynamic" - * cardinality="1..n" - * bind="setCertificateManagementService" - * unbind="unsetCertificateManagementService" - * @scr.reference name="io.entgra.device.mgt.core.certificate.mgt.core.scep" - * interface="io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager" - * policy="dynamic" - * cardinality="1..n" - * bind="setSCEPManagementService" - * unbind="unsetSCEPManagementService" - * @scr.reference name="identity.oauth2.validation.service" - * interface="org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService" - * cardinality="1..1" - * policy="dynamic" - * bind="setOAuth2ValidationService" - * unbind="unsetOAuth2ValidationService" - * @scr.reference name="tenant.indexloader" - * interface="org.wso2.carbon.registry.indexing.service.TenantIndexingLoader" - * cardinality="1..1" - * policy="dynamic" - * bind="setTenantIndexLoader" - * unbind="unsetTenantIndexLoader" - * @scr.reference name="tenant.registryloader" - * interface="org.wso2.carbon.registry.core.service.TenantRegistryLoader" - * cardinality="1..1" policy="dynamic" - * bind="setTenantRegistryLoader" - * unbind="unsetTenantRegistryLoader" - * @scr.reference name="org.wso2.carbon.device.manager" - * interface="io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService" - * cardinality="1..1" - * policy="dynamic" - * bind="setOTPManagementService" - * unbind="unsetOTPManagementService" - */ - +@Component( + name = "io.entgra.device.mgt.core.webapp.authenticator.framework.internal.WebappAuthenticatorFrameworkServiceComponent", + immediate = true) public class WebappAuthenticatorFrameworkServiceComponent { private static final Log log = LogFactory.getLog(WebappAuthenticatorFrameworkServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Starting Web Application Authenticator Framework Bundle"); @@ -135,10 +95,17 @@ public class WebappAuthenticatorFrameworkServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } + @Reference( + name = "realm.service", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { if (log.isDebugEnabled()) { log.debug("RealmService acquired"); @@ -150,6 +117,12 @@ public class WebappAuthenticatorFrameworkServiceComponent { AuthenticatorFrameworkDataHolder.getInstance().setRealmService(null); } + @Reference( + name = "certificate.mgt.service", + service = io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService.class, + cardinality = ReferenceCardinality.MULTIPLE, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetCertificateManagementService") protected void setCertificateManagementService(CertificateManagementService certificateManagementService) { if (log.isDebugEnabled()) { log.debug("Setting certificate management service"); @@ -165,6 +138,12 @@ public class WebappAuthenticatorFrameworkServiceComponent { AuthenticatorFrameworkDataHolder.getInstance().setCertificateManagementService(null); } + @Reference( + name = "scep.mgr", + service = io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager.class, + cardinality = ReferenceCardinality.MULTIPLE, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetSCEPManagementService") protected void setSCEPManagementService(SCEPManager scepManager) { if (log.isDebugEnabled()) { log.debug("Setting SCEP management service"); @@ -185,6 +164,12 @@ public class WebappAuthenticatorFrameworkServiceComponent { * * @param tokenValidationService An instance of OAuth2TokenValidationService */ + @Reference( + name = "oauth2.token.validation.service", + service = org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetOAuth2ValidationService") protected void setOAuth2ValidationService(OAuth2TokenValidationService tokenValidationService) { if (log.isDebugEnabled()) { log.debug("Setting OAuth2TokenValidationService Service"); @@ -204,6 +189,12 @@ public class WebappAuthenticatorFrameworkServiceComponent { AuthenticatorFrameworkDataHolder.getInstance().setOAuth2TokenValidationService(null); } + @Reference( + name = "tenant.index.loader", + service = org.wso2.carbon.registry.indexing.service.TenantIndexingLoader.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTenantIndexLoader") protected void setTenantIndexLoader(TenantIndexingLoader tenantIndexLoader) { AuthenticatorFrameworkDataHolder.getInstance().setTenantIndexingLoader(tenantIndexLoader); } @@ -212,6 +203,12 @@ public class WebappAuthenticatorFrameworkServiceComponent { AuthenticatorFrameworkDataHolder.getInstance().setTenantIndexingLoader(null); } + @Reference( + name = "tenant.registry.loader", + service = org.wso2.carbon.registry.core.service.TenantRegistryLoader.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetTenantRegistryLoader") protected void setTenantRegistryLoader(TenantRegistryLoader tenantRegistryLoader) { AuthenticatorFrameworkDataHolder.getInstance().setTenantRegistryLoader(tenantRegistryLoader); } @@ -220,6 +217,12 @@ public class WebappAuthenticatorFrameworkServiceComponent { AuthenticatorFrameworkDataHolder.getInstance().setTenantRegistryLoader(null); } + @Reference( + name = "otp.mgt.service", + service = io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetOTPManagementService") protected void setOTPManagementService(OTPManagementService otpManagementService) { if (log.isDebugEnabled()) { log.debug("Setting OTP Management OSGI Service"); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/BaseWebAppAuthenticatorFrameworkTest.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/BaseWebAppAuthenticatorFrameworkTest.java index 13b274663f..08ae619986 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/BaseWebAppAuthenticatorFrameworkTest.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/BaseWebAppAuthenticatorFrameworkTest.java @@ -19,12 +19,15 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework; +import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; +import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; +import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestTenantIndexingLoader; +import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestTenantRegistryLoader; import org.testng.annotations.BeforeSuite; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.internal.CarbonCoreDataHolder; -import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; -import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; @@ -35,9 +38,6 @@ import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; -import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestTenantIndexingLoader; -import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestTenantRegistryLoader; import java.io.File; import java.io.InputStream; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValveTest.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValveTest.java index 54ed7447d7..32dc4cc825 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValveTest.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValveTest.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework; +import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestRequest; import org.apache.catalina.Context; import org.apache.catalina.connector.Connector; import org.apache.catalina.connector.Request; @@ -31,7 +32,6 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.tomcat.ext.valves.CompositeValve; -import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestRequest; import javax.servlet.http.HttpServletResponse; import java.lang.reflect.Field; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorConfigTest.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorConfigTest.java index 1a2e3054e7..cd59086a01 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorConfigTest.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorConfigTest.java @@ -18,16 +18,15 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticatorFrameworkException; +import io.entgra.device.mgt.core.webapp.authenticator.framework.config.AuthenticatorConfig; +import io.entgra.device.mgt.core.webapp.authenticator.framework.config.AuthenticatorConfigService; +import io.entgra.device.mgt.core.webapp.authenticator.framework.config.WebappAuthenticatorConfig; +import io.entgra.device.mgt.core.webapp.authenticator.framework.config.impl.AuthenticatorConfigServiceImpl; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.utils.ServerConstants; -import io.entgra.device.mgt.core.webapp.authenticator.framework.config.AuthenticatorConfig; -import io.entgra.device.mgt.core.webapp.authenticator.framework.config.AuthenticatorConfigService; -import io.entgra.device.mgt.core.webapp.authenticator.framework.config.WebappAuthenticatorConfig; -import io.entgra.device.mgt.core.webapp.authenticator.framework.config.impl.AuthenticatorConfigServiceImpl; import java.util.List; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorFrameworkUtilTest.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorFrameworkUtilTest.java index fa69b1a472..4fc7a1e799 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorFrameworkUtilTest.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorFrameworkUtilTest.java @@ -18,6 +18,7 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework; +import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.OAuthTokenValidationStubFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.pool.ObjectPool; @@ -25,7 +26,6 @@ import org.apache.commons.pool.impl.GenericObjectPool; import org.testng.Assert; import org.testng.annotations.Test; import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; -import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.OAuthTokenValidationStubFactory; import java.util.Properties; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorRepositoryTest.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorRepositoryTest.java index c4603294c3..2a4c2b4a12 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorRepositoryTest.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticatorRepositoryTest.java @@ -18,12 +18,11 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework; -import io.entgra.device.mgt.core.webapp.authenticator.framework.WebappAuthenticatorRepository; -import org.testng.Assert; -import org.testng.annotations.Test; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.WebappAuthenticator; import io.entgra.device.mgt.core.webapp.authenticator.framework.util.MalformedAuthenticator; import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestWebappAuthenticator; +import org.testng.Assert; +import org.testng.annotations.Test; public class WebappAuthenticatorRepositoryTest { diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticatorTest.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticatorTest.java index d853b6d70d..208fba85d5 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticatorTest.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticatorTest.java @@ -19,6 +19,10 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuth2TokenValidator; +import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; +import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestInputBuffer; import org.apache.catalina.Context; import org.apache.catalina.connector.Request; import org.apache.catalina.core.StandardContext; @@ -33,10 +37,6 @@ import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; import org.wso2.carbon.identity.oauth2.dto.OAuth2ClientApplicationDTO; import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuth2TokenValidator; -import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; -import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestInputBuffer; import java.io.File; import java.io.IOException; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticatorTest.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticatorTest.java index dff4a120da..1e00539738 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticatorTest.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticatorTest.java @@ -19,6 +19,8 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; +import io.entgra.device.mgt.core.webapp.authenticator.framework.BaseWebAppAuthenticatorFrameworkTest; import org.apache.catalina.Context; import org.apache.catalina.connector.Request; import org.apache.catalina.core.StandardContext; @@ -27,11 +29,8 @@ import org.apache.tomcat.util.buf.MessageBytes; import org.apache.tomcat.util.http.MimeHeaders; import org.testng.Assert; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; -import io.entgra.device.mgt.core.webapp.authenticator.framework.BaseWebAppAuthenticatorFrameworkTest; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticatorTest.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticatorTest.java index 70d24be3ba..0011f87256 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticatorTest.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticatorTest.java @@ -19,6 +19,23 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; +import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; +import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; +import io.entgra.device.mgt.core.certificate.mgt.core.impl.KeyStoreReader; +import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPException; +import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager; +import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManagerImpl; +import io.entgra.device.mgt.core.certificate.mgt.core.scep.TenantedDeviceWrapper; +import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService; +import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementServiceImpl; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; +import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; +import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestCertificateGenerator; import org.apache.catalina.Context; import org.apache.catalina.connector.Request; import org.apache.catalina.core.StandardContext; @@ -35,23 +52,6 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.base.MultitenantConstants; -import io.entgra.device.mgt.core.certificate.mgt.core.dao.CertificateManagementDAOFactory; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; -import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; -import io.entgra.device.mgt.core.certificate.mgt.core.impl.KeyStoreReader; -import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPException; -import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager; -import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManagerImpl; -import io.entgra.device.mgt.core.certificate.mgt.core.scep.TenantedDeviceWrapper; -import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService; -import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementServiceImpl; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; -import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; -import io.entgra.device.mgt.core.webapp.authenticator.framework.util.TestCertificateGenerator; import javax.sql.DataSource; import java.io.File; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/JWTAuthenticatorTest.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/JWTAuthenticatorTest.java index e4bee2f65d..cee5aa1a62 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/JWTAuthenticatorTest.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/JWTAuthenticatorTest.java @@ -18,6 +18,10 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; +import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; +import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; +import io.entgra.device.mgt.core.identity.jwt.client.extension.util.JWTClientUtil; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import org.apache.catalina.connector.Request; import org.apache.tomcat.util.buf.MessageBytes; import org.apache.tomcat.util.http.MimeHeaders; @@ -25,10 +29,6 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.base.MultitenantConstants; -import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.JWTConfig; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import io.entgra.device.mgt.core.identity.jwt.client.extension.util.JWTClientUtil; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import java.io.File; import java.io.FileInputStream; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OauthAuthenticatorTest.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OauthAuthenticatorTest.java index 06523cee48..c3551da26a 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OauthAuthenticatorTest.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OauthAuthenticatorTest.java @@ -19,6 +19,9 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; +import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; +import io.entgra.device.mgt.core.webapp.authenticator.framework.BaseWebAppAuthenticatorFrameworkTest; +import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.impl.RemoteOAuthValidator; import org.apache.catalina.connector.Request; import org.apache.commons.pool.impl.GenericObjectPool; import org.apache.tomcat.util.buf.MessageBytes; @@ -27,13 +30,9 @@ import org.mockito.Mockito; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import org.wso2.carbon.core.security.AuthenticatorsConfiguration; import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2ClientApplicationDTO; import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; -import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; -import io.entgra.device.mgt.core.webapp.authenticator.framework.BaseWebAppAuthenticatorFrameworkTest; -import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.impl.RemoteOAuthValidator; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/MalformedAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/MalformedAuthenticator.java index 7843cd0747..096b6dbe3c 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/MalformedAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/MalformedAuthenticator.java @@ -18,10 +18,10 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.util; -import org.apache.catalina.connector.Request; -import org.apache.catalina.connector.Response; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.WebappAuthenticator; +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; import java.util.Properties; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/TestCertificateGenerator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/TestCertificateGenerator.java index 935a4a3e22..b9cf031421 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/TestCertificateGenerator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/TestCertificateGenerator.java @@ -19,6 +19,11 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.util; +import io.entgra.device.mgt.core.certificate.mgt.core.bean.Certificate; +import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; +import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; +import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; +import io.entgra.device.mgt.core.certificate.mgt.core.util.CommonUtil; import org.bouncycastle.cert.X509v3CertificateBuilder; import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder; @@ -26,23 +31,11 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.operator.ContentSigner; import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; -import io.entgra.device.mgt.core.certificate.mgt.core.bean.Certificate; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; -import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; -import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagementConstants; -import io.entgra.device.mgt.core.certificate.mgt.core.util.CommonUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.security.auth.x500.X500Principal; import java.math.BigInteger; -import java.security.InvalidKeyException; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.SecureRandom; -import java.security.Security; -import java.security.SignatureException; +import java.security.*; import java.security.cert.CertificateException; import java.security.cert.CertificateExpiredException; import java.security.cert.CertificateNotYetValidException; diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/TestWebappAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/TestWebappAuthenticator.java index 460a3ae824..caf8ad4390 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/TestWebappAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/java/io/entgra/device/mgt/core/webapp/authenticator/framework/util/TestWebappAuthenticator.java @@ -18,10 +18,10 @@ */ package io.entgra.device.mgt.core.webapp.authenticator.framework.util; -import org.apache.catalina.connector.Request; -import org.apache.catalina.connector.Response; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.WebappAuthenticator; +import org.apache.catalina.connector.Request; +import org.apache.catalina.connector.Response; import java.util.Properties; diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 316f49a919..ba421a7957 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -31,29 +31,10 @@ webapp-authenticator-framework pom WSO2 Carbon - Webapp Authenticator Framework - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.webapp.authenticator.framework - - - - - - - - - - - - - - - - - - - diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index 9bf539951e..86dcd4cc7e 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -29,7 +29,7 @@ io.entgra.device.mgt.core.apimgt.application.extension.feature pom WSO2 Carbon - API Management Application Extension Feature - http://wso2.org + https://entgra.io This feature contains an implementation of a api application registration, which takes care of subscription and generating keys. diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 9cdd5f9e48..4f5e779833 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -29,7 +29,7 @@ io.entgra.device.mgt.core.apimgt.keymgt.extension.feature pom WSO2 Carbon - Api Key Mgt Extensions Feature - http://wso2.org + https://entgra.io This feature contains apimgt related key management extensions diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 3b7e131862..88622fa4fb 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -29,7 +29,7 @@ io.entgra.device.mgt.core.apimgt.webapp.publisher.feature pom WSO2 Carbon - API Management Webapp Publisher Feature - http://wso2.org + https://entgra.io This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing JAX-RS web applications as 'Managed APIs' @@ -44,7 +44,7 @@ io.entgra.device.mgt.core.apimgt.annotations - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation @@ -141,7 +141,7 @@ io.entgra.device.mgt.core:io.entgra.device.mgt.core.apimgt.annotations:${io.entgra.device.mgt.core.version} - org.wso2.orbit.org.scannotation:scannotation:${scannotation.version} + io.entgra.org.scannotation:scannotation:${scannotation.version} io.swagger:swagger-annotations:${swagger.version} diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml index 6f2ae848bd..59bd3de0b2 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml @@ -30,7 +30,7 @@ org.wso2.carbon.apimgt.handler.server.feature pom WSO2 Carbon - Device Management - APIM handler Server Feature - http://wso2.org + https://entgra.io This feature contains the handler for the api authentications diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml index 9f8f8b4940..880622d16f 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml @@ -29,7 +29,7 @@ org.wso2.carbon.apimgt.integration.client.feature pom WSO2 Carbon - APIM Integration Client Feature - http://wso2.org + https://entgra.io This feature contains a http client implementation to communicate with WSO2-APIM server diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index bf4e7eb9b0..a50278538c 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -31,7 +31,7 @@ apimgt-extensions-feature pom WSO2 Carbon - API Management Extensions Feature - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.apimgt.webapp.publisher.feature diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/src/main/resources/conf/datasources/application-mgt-datasources.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/src/main/resources/conf/datasources/application-mgt-datasources.xml index 49f02f9318..234785a932 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/src/main/resources/conf/datasources/application-mgt-datasources.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/src/main/resources/conf/datasources/application-mgt-datasources.xml @@ -16,7 +16,7 @@ ~ under the License. --> - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql index f9c5861831..961e855337 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/h2.sql @@ -42,6 +42,7 @@ CREATE TABLE IF NOT EXISTS AP_APP_RELEASE( RATED_USERS INTEGER NULL, AP_APP_ID INTEGER NOT NULL, PRIMARY KEY (ID), + CONSTRAINT UUID_CONSTRAINT UNIQUE (UUID), CONSTRAINT fk_AP_APP_RELEASE_AP_APP1 FOREIGN KEY (AP_APP_ID) REFERENCES AP_APP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION @@ -267,7 +268,7 @@ CREATE INDEX fk_AP_APP_SUB_OP_MAPPING_AP_DEVICE_SUBSCRIPTION1_idx ON AP_APP_SUB_ CREATE TABLE IF NOT EXISTS AP_SCHEDULED_SUBSCRIPTION( ID INTEGER NOT NULL AUTO_INCREMENT, TASK_NAME VARCHAR(100) NOT NULL, - APPLICATION_UUID VARCHAR(36) NOT NULL, + APPLICATION_UUID VARCHAR(200) NOT NULL, SUBSCRIBER_LIST LONGVARCHAR NOT NULL, STATUS VARCHAR(15) NOT NULL, SCHEDULED_AT BIGINT NOT NULL, diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index 0a6662b1f1..ce9838e76a 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.certificate.mgt.api.feature pom WSO2 Carbon - Certificate Management API Feature - http://wso2.org + https://entgra.io This feature contains the APIs required for Certificate Management. diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 736b0bd3d3..4e6b59d9b8 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature pom WSO2 Carbon - Admin Certificate Management API Feature - http://wso2.org + https://entgra.io This feature contains the APIs required for Admin Certificate Management. diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index d2b9cc6553..dfe299370c 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.certificate.mgt.server.feature pom WSO2 Carbon - Certificate Management Server Feature - http://wso2.org + https://entgra.io This feature contains the core bundles required for back-end Certificate Management functionality @@ -48,7 +48,7 @@ bcpkix-jdk15on - org.wso2.orbit.com.google.code.jscep + io.entgra.com.google.code.jscep jscep @@ -123,7 +123,7 @@ org.wso2.orbit.org.bouncycastle:bcpkix-jdk15on:${bcpkix.wso2.version} - org.wso2.orbit.com.google.code.jscep:jscep:${jscep.version} + io.entgra.com.google.code.jscep:jscep:${jscep.version} commons-io.wso2:commons-io:${version.commons.io} diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 8999232efa..0109ad3b2c 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -30,7 +30,7 @@ certificate-mgt-feature pom WSO2 Carbon - Certificate Management Feature - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.certificate.mgt.server.feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 60734677e6..e28b7d84c6 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature pom WSO2 Carbon - Device Type Deployer Feature - http://wso2.org + https://entgra.io WSO2 Carbon - Device Type Deployer Feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 2779d21ec7..107de3a233 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature pom WSO2 Carbon - FCM Based Push Notification Provider Feature - http://wso2.org + https://entgra.io WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 9b660889a8..9c42d63459 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature pom WSO2 Carbon - MQTT Based Push Notification Provider Feature - http://wso2.org + https://entgra.io WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 43b3dde6fb..9c23966075 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature pom WSO2 Carbon - MQTT Based Push Notification Provider Feature - http://wso2.org + https://entgra.io WSO2 Carbon - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 8014092801..c2c9259331 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature pom WSO2 Carbon - XMPP Based Push Notification Provider Feature - http://wso2.org + https://entgra.io WSO2 Carbon - XMPP Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 0f0c542f6c..a691ca886a 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -30,7 +30,7 @@ device-mgt-extensions-feature pom WSO2 Carbon - Device Management Extensions Feature - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 5ed82c80ef..2340bb89c7 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.device.mgt.api.feature pom WSO2 Carbon - Device Management API Feature - http://wso2.org + https://entgra.io This feature contains the APIs required for Device Management console UI diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index f813b763a3..db92ee8599 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.device.mgt.basics.feature pom WSO2 Carbon - Device Management Basics Feature - http://wso2.org + https://entgra.io This feature contains the core bundles required for Basic Device Management functionality diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml index 3c83ee5d99..6ad6ddd274 100755 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml @@ -16,7 +16,7 @@ ~ under the License. --> - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/datasources/reporting-mgt-datasources.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/datasources/reporting-mgt-datasources.xml index 4a518e77ac..24fb4508a3 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/datasources/reporting-mgt-datasources.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/datasources/reporting-mgt-datasources.xml @@ -16,7 +16,7 @@ ~ under the License. --> - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index f675cfb0f3..87842e9da6 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -42,7 +42,7 @@ 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_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -188,17 +188,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT 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 , + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -209,11 +209,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); 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, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,9 +228,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -240,11 +240,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -255,11 +255,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT(11) NOT NULL AUTO_INCREMENT, + ID INT 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, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT DEFAULT NULL, IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID), CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION @@ -270,9 +270,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -296,11 +296,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -353,7 +353,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -368,7 +368,7 @@ 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, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -397,7 +397,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -466,7 +466,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -503,8 +503,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( 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, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -531,7 +531,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT(15) NOT NULL, + TIMESTAMP BIGINT NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -812,16 +812,17 @@ CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( -- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- -- SUB_OPERATION_TEMPLATE TABLE-- -CREATE TABLE SUB_OPERATION_TEMPLATE ( - SUB_OPERATION_TEMPLATE_ID int NOT NULL AUTO_INCREMENT, +CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, OPERATION_DEFINITION TEXT NOT NULL, - OPERATION_CODE varchar(100) NOT NULL, - SUB_TYPE_ID int NOT NULL, + OPERATION_CODE VARCHAR(100) NOT NULL, + SUB_TYPE_ID INT NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, - CREATE_TIMESTAMP timestamp NULL DEFAULT NULL, - UPDATE_TIMESTAMP timestamp NULL DEFAULT NULL, + CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), - UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID,OPERATION_CODE, DEVICE_TYPE), + CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), +-- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index a0263bae1e..1d47540e6c 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -12,7 +12,7 @@ io.entgra.device.mgt.core.device.mgt.extensions.feature pom WSO2 Carbon - Device Management Extensions Feature - http://wso2.org + https://entgra.io This feature contains common extensions used by key device management functionalities diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index ee9b93241a..c50b47db31 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.device.mgt.feature pom WSO2 Carbon - Device Management Aggregate Feature - http://wso2.org + https://entgra.io This feature contains all the bundles required for device management related functionalities @@ -44,11 +44,7 @@ javax.servlet.jsp-api - org.wso2.carbon.store - org.wso2.store.sso.common - - - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation @@ -78,8 +74,7 @@ javax.servlet.jsp:javax.servlet.jsp-api - org.wso2.carbon.store:org.wso2.store.sso.common:${carbon.store.sso.common.version} - org.wso2.orbit.org.scannotation:scannotation:${scannotation.version} + io.entgra.org.scannotation:scannotation:${scannotation.version} diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 4ca9d1a8af..d4e8f99684 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.device.mgt.server.feature pom WSO2 Carbon - Device Management Server Feature - http://wso2.org + https://entgra.io This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml index 154ccae674..577d9274b5 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml @@ -30,7 +30,7 @@ org.wso2.carbon.device.mgt.analytics.feature pom WSO2 Carbon - Device Management Server Feature - http://wso2.org + https://entgra.io This feature contains bundles related to device analytics data publisher and ws proxy diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml index 173f3e4bd6..f487bfedb9 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.ui.feature/pom.xml @@ -30,7 +30,7 @@ org.wso2.carbon.device.mgt.ui.feature pom WSO2 Carbon - Device Management Base UI Feature - http://wso2.org + https://entgra.io This feature contains the base UI required for Device Management diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index bc43a95417..59ec1b2abe 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -30,7 +30,7 @@ device-mgt-feature pom WSO2 Carbon - Device Management Feature - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.device.mgt.basics.feature diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/src/main/resources/datasources/heart-beat-datasources.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/src/main/resources/datasources/heart-beat-datasources.xml index ebbe5087f2..fe9328d7ad 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/src/main/resources/datasources/heart-beat-datasources.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/src/main/resources/datasources/heart-beat-datasources.xml @@ -16,7 +16,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index f6e5d38608..a71e3d93ff 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -31,7 +31,7 @@ io.entgra.device.mgt.core.identity.jwt.client.extension.feature pom WSO2 Carbon - JWT Client Feature - http://wso2.org + https://entgra.io This feature contains jwt client implementation from which we can get a access token using the jwt grant type handler diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 59a5fcd0bf..51d5fe9e41 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -31,7 +31,7 @@ jwt-client-feature pom WSO2 Carbon - JWT Client Extension Feature - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.identity.jwt.client.extension.feature diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index b0962c8ec5..0a4532de48 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -41,7 +41,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.testng diff --git a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml index e932de7ba3..65c85253f4 100644 --- a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml +++ b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml @@ -31,7 +31,7 @@ io.entgra.device.mgt.core.device.mgt.oauth.extensions.feature pom WSO2 Carbon - Device Mgt OAuth Extensions Feature - http://wso2.org + https://entgra.io This feature contains devicemgt related OAuth extensions diff --git a/features/oauth-extensions/pom.xml b/features/oauth-extensions/pom.xml index 73b18607e7..74a3f53631 100644 --- a/features/oauth-extensions/pom.xml +++ b/features/oauth-extensions/pom.xml @@ -30,7 +30,7 @@ oauth-extensions-feature pom WSO2 Carbon - Device Management OAuth Extensions Feature - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.device.mgt.oauth.extensions.feature diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 925f43997a..5c773834cf 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -31,7 +31,7 @@ io.entgra.device.mgt.core.policy.mgt.server.feature pom WSO2 Carbon - Policy Management Server Feature - http://wso2.org + https://entgra.io This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 0b9372a42e..282d237923 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -32,7 +32,7 @@ policy-mgt-feature pom WSO2 Carbon - Policy Management Feature - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.policy.mgt.server.feature diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 4993d7a081..40a949721b 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -29,7 +29,7 @@ io.entgra.device.mgt.core.task.mgt.feature pom Entgra IoT - Task Manager Feature - http://wso2.org + https://entgra.io diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 3478f76af9..f735af22bb 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -90,7 +90,6 @@ - io.entgra.device.mgt.core:io.entgra.device.mgt.core.tenant.mgt.core:${io.entgra.device.mgt.core.version} diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index a38d042939..78a9a261c8 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.email.sender.feature pom WSO2 Carbon - Email Sender Feature - http://wso2.org + https://entgra.io This feature contains the core bundles required for email sender related functionality @@ -39,10 +39,6 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.transport.mgt.email.sender.core - - org.wso2.orbit.org.apache.velocity - velocity - @@ -96,9 +92,6 @@ io.entgra.device.mgt.core:io.entgra.device.mgt.core.transport.mgt.email.sender.core:${io.entgra.device.mgt.core.version} - - org.wso2.orbit.org.apache.velocity:velocity:${velocity.version} - org.wso2.carbon.core.server:${carbon.kernel.version} diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index aa3b05ee62..fb3d7a0c1f 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -31,7 +31,7 @@ email-sender-feature pom WSO2 Carbon - Email Sender Feature - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.email.sender.feature diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml index 50e82b986c..192e1dd103 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/src/main/resources/payloads/update-app-request.xml @@ -1,5 +1,6 @@ - + diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index b35902a323..f16f479d35 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature pom WSO2 Carbon - Webapp Authenticator Framework Server Feature - http://wso2.org + https://entgra.io This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index baa7ba13e1..b51534e648 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -31,7 +31,7 @@ webapp-authenticator-framework-feature pom WSO2 Carbon - Webapp Authenticator Framework Feature - http://wso2.org + https://entgra.io io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature diff --git a/pom.xml b/pom.xml index 5504751710..71bf206021 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ pom 5.0.26-SNAPSHOT WSO2 Carbon - Device Management - Parent - http://wso2.org + https://entgra.io WSO2 Connected Device Manager Components org.wso2 @@ -609,28 +609,6 @@ - - - org.eclipse.osgi - org.eclipse.osgi - ${eclipse.osgi.version} - - - org.eclipse.equinox - org.eclipse.equinox.common - ${eclipse.equinox.common.version} - - - org.eclipse.osgi - org.eclipse.osgi.services - ${eclipse.equinox.services.version} - - - - - - - org.testng @@ -732,10 +710,6 @@ org.eclipse.equinox org.eclipse.equinox.http.helper - org.wso2.carbon org.wso2.carbon.registry.core @@ -838,12 +812,6 @@ - - - - - - org.wso2.orbit.com.h2database h2 @@ -933,12 +901,6 @@ axiom ${axiom.wso2.version} - - - - - - org.wso2.carbon.apimgt org.wso2.carbon.apimgt.api @@ -1180,42 +1142,6 @@ cxf-rt-transports-http ${cxf.version} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.wso2.carbon.identity.framework @@ -1284,11 +1210,6 @@ - - - - - com.googlecode.json-simple.wso2 json-simple @@ -1339,7 +1260,7 @@ ${bcpkix.wso2.version} - org.wso2.orbit.com.google.code.jscep + io.entgra.com.google.code.jscep jscep ${jscep.version} @@ -1389,11 +1310,6 @@ okhttp ${squareup.okhttp3.version} - - - - - io.github.openfeign feign-okhttp @@ -1433,12 +1349,7 @@ org.apache.velocity - velocity - 1.7 - - - org.wso2.orbit.org.apache.velocity - velocity + velocity-engine-core ${velocity.version} @@ -1451,12 +1362,6 @@ commons-collections ${commons-collections.version} - - - - - - @@ -1467,11 +1372,6 @@ - - - - - org.wso2.carbon.analytics-common org.wso2.carbon.event.stream.core @@ -1497,16 +1397,6 @@ org.wso2.carbon.event.output.adapter.rdbms ${carbon.analytics.common.version} - - - - - - - - - - org.wso2.carbon.analytics-common org.wso2.carbon.databridge.commons @@ -1556,7 +1446,7 @@ - org.wso2.orbit.org.scannotation + io.entgra.org.scannotation scannotation ${scannotation.version} @@ -1595,11 +1485,6 @@ ${eclipse.paho.version} - - - - - io.swagger swagger-annotations @@ -1625,16 +1510,6 @@ org.wso2.carbon.event.output.adapter.core ${carbon.analytics.common.version} - - - - - - - - - - org.wso2.carbon.analytics-common org.wso2.carbon.event.publisher.stub @@ -1747,11 +1622,6 @@ wss4j ${org.apache.ws.security.wso2.version} - - org.wso2.carbon.store - org.wso2.store.sso.common - ${carbon.store.sso.common.version} - io.github.openfeign feign-core @@ -1777,16 +1647,6 @@ feign-slf4j ${io.github.openfeign.version} - - org.apache.oltu.oauth2 - org.apache.oltu.oauth2.client - ${oltu.client.version} - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - ${jackson.datatype.joda.version} - org.javassist javassist @@ -1922,6 +1782,11 @@ javax.cache.wso2 4.6.3-m5 + + org.apache.felix + org.apache.felix.scr.ds-annotations + ${apache.felix.scr.ds.annotations.version} + @@ -1960,8 +1825,8 @@ 3.8.1 UTF-8 - 17 - 17 + 11 + 11 @@ -1994,23 +1859,10 @@ 17 - - - - - - - - - - - - - org.apache.felix maven-bundle-plugin - 5.1.1 + 3.2.0 true NONE @@ -2104,28 +1956,13 @@ 4.8.1 [4.5.0, 5.0.0) 5.1.2 - - - [1.6.1, 1.7.0) 1.6.1-wso2v85 1.1.0-wso2v10 - - - - - - - - - - - - 4.13.1 @@ -2133,27 +1970,20 @@ 3.3.100.v20120522-1822 3.8.1.v20120830-144521 - - 7.0.93.wso2v1 7.0.93.wso2v1 7.0.34.wso2v2 - - - 5.24.8 [5.14.0, 6.0.0) 6.9.6 - 2.1.1 [2.1.1, 3.0.0) [5.14.0, 6.0.0) [6.0.0, 7.0.0) - 4.9.20 @@ -2185,7 +2015,6 @@ 5.3.5 [5.3.0,6.0.0) 1.3.25 - 2.3.5 @@ -2195,22 +2024,16 @@ 3.5.5 - 1.1.wso2v1 1.9.13 - - - - - - 1.60.0.wso2v1 - 1.60.0.wso2v1 - [1.52.0,1.70.0) + 1.70.0.wso2v1 + 1.70.0.wso2v1 + [1.52.0,1.80.0) - 2.3.0.wso2v2 + 2.3.0.entgrav2 3.0.0.wso2v1 1.3 @@ -2231,11 +2054,8 @@ 3.1.1 2.0.4.wso2v4 - - - - 1.0.3.wso2v1 + 1.0.3.entgrav1 [1.0.3, 2.0.0) 1.5.6.wso2v1 @@ -2245,12 +2065,11 @@ 3.1.0.wso2v2 4.2.5.wso2v1 - 1.7.0.wso2v1 + 2.3 2.4.0.wso2v1 3.2.0.wso2v1 (3.2.0, 3.3.0] - 5.1.34 @@ -2267,7 +2086,7 @@ 2.0.1 1.6.9 - + 1.6.9 4.0.1 @@ -2283,8 +2102,6 @@ 1.8.10.wso2v2 - - 1.7.0 @@ -2299,18 +2116,12 @@ 2.1.7-wso2v227 1.5.11-wso2v18 - - 1.5.1 - 11.0 [9.3.1,10.0.0) - - 1.0.1 - 2.1.5 1.9 (1.9,2.0] - 3.26.0-GA + 3.18.1-GA true @@ -2332,7 +2143,6 @@ 9.0.24 1.1 - 5.3.23 2.7.18 @@ -2342,7 +2152,6 @@ [1.2.0,1.3.0) 4.2.0 - 2.8.1.wso2v2 4.3.1.wso2v1 2.1.210.wso2v1 @@ -2352,6 +2161,11 @@ 2.3.1.wso2v1 2.4 1.2.2.wso2v1 + [9.0,10) + 1.2.4 + [4.7.0, 4.9.0) + [1.0.1, 2.0.0) + [4.7.0, 5.0.0) From c46a459e6d0d71b96e69cb1fc04721a09ba1f38b Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 6 Jun 2023 17:03:33 +0530 Subject: [PATCH 007/343] Add Application key generating logic --- .../APIManagementProviderServiceImpl.java | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 872d374c90..52a1925df6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.apimgt.application.extension; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.RegistrationProfile; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; @@ -54,11 +55,7 @@ import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClient import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * This class represents an implementation of APIManagementProviderService. @@ -107,17 +104,36 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isAllowedAllDomains, String validityTime, String password) throws APIManagerException { + APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance().getApiApplicationServices(); ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - - /* - - */ - try { - consumerRESTAPIServices.getAllApplications(null, null, null); + consumerRESTAPIServices.getAllApplications(null, null, applicationName); + + List uniqueApiList = new ArrayList(); + + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); + + for (String tag: tags) { + Map queryParams = new HashMap<>(); + queryParams.put("tag", tag); + if ("carbon.super".equals(tenantDomain)) { + consumerRESTAPIServices.getAllApis(null, null, queryParams); + } else { + //call All API getting call with carbon super header param + } + + uniqueApiList.add("Test"); + Set taggedAPISet = new HashSet<>(uniqueApiList); + uniqueApiList.clear(); + uniqueApiList.addAll(taggedAPISet); + } + + consumerRESTAPIServices.getAllSubscriptions(null, null, "1"); + + } catch (APIServicesException e) { e.printStackTrace(); } catch (BadRequestException e) { From a513c13037ec1120bff89959fe987790fba6ba20 Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 5 Jun 2023 15:17:01 +0530 Subject: [PATCH 008/343] Improvements in consumer rest apis --- .../rest/api/ConsumerRESTAPIServices.java | 21 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 40 ++- .../rest/api/bean/APIMConsumer/APIInfo.java | 312 ++++++++++++++++++ .../rest/api/bean/APIMConsumer/APIKey.java | 4 + .../api/bean/APIMConsumer/Application.java | 4 + .../ApplicationConfigurations.java | 110 ++++++ .../api/bean/APIMConsumer/KeyManager.java | 184 +++++++++++ .../api/bean/APIMConsumer/Subscription.java | 12 +- 8 files changed, 653 insertions(+), 34 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/bean/APIMConsumer/APIInfo.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/bean/APIMConsumer/ApplicationConfigurations.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/bean/APIMConsumer/KeyManager.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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index 0dd8783663..bbdc6cf0fe 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -18,47 +18,48 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; 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.json.JSONObject; import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - JSONObject getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - JSONObject getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + Subscription[] getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - JSONObject getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParam) + APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Map queryParam) throws APIServicesException, BadRequestException, UnexpectedResponseException; Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Subscription subscriptions) + Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - List subscriptions) + Subscription[] createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - JSONObject getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + KeyManager[] getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index 383098dd3d..4f406b16bb 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -19,9 +19,11 @@ 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.bean.APIMConsumer.APIInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; 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; @@ -33,6 +35,7 @@ import okhttp3.*; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; import org.json.JSONObject; import java.io.IOException; @@ -51,7 +54,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public JSONObject getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + public Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; @@ -65,8 +68,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray applicationList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(applicationList.toString(), Application[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -141,8 +144,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public JSONObject getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + public Subscription[] getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; @@ -156,8 +159,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray subscriptionList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(subscriptionList.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -181,8 +184,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public JSONObject getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParams) + public APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + Map queryParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; @@ -201,8 +204,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray apiList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(apiList.toString(), APIInfo[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -227,7 +230,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { @Override public Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Subscription subscriptions) + Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API; @@ -274,8 +277,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - List subscriptions) + public Subscription[] createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; @@ -293,7 +296,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - return gson.fromJson(response.body().string(), Subscription.class); + JSONArray subscriptionsArray = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(subscriptionsArray.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. @@ -364,7 +368,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public JSONObject getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + public KeyManager[] getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; @@ -378,8 +382,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONObject jsonObject = new JSONObject(response.body().string()); - return jsonObject; + JSONArray keyManagerList = (JSONArray) new JSONObject(response.body().string()).get("list"); + return gson.fromJson(keyManagerList.toString(), KeyManager[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = 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/bean/APIMConsumer/APIInfo.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/APIMConsumer/APIInfo.java new file mode 100644 index 0000000000..f18647899f --- /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/bean/APIMConsumer/APIInfo.java @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2018 - 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.bean.APIMConsumer; + +import io.entgra.device.mgt.core.apimgt.extension.rest.api.util.ScopeUtils; +import org.json.JSONObject; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * This class represents the Consumer API Information. + */ + +public class APIInfo { + + private String id; + private String name; + private String description; + private String context; + private String version; + private String provider; + private JSONObject apiDefinition; + private String wsdlUri; + private String lifeCycleStatus; + private boolean isDefaultVersion; + private String type; + private Set transport; + private List operations; + private String authorizationHeader; + private String securityScheme; + private Set tags; + private List tiers; + private boolean hasThumbnail; + private String additionalProperties; + private JSONObject monetization; + private List endpointURLs; + private JSONObject businessInformation; + private List environmentList; + private List scopes; + private String avgRating; + private JSONObject advertiseInfo; + private boolean isSubscriptionAvailable; + private List categories; + private List keyManagers = new ArrayList(); + private String createdTime; + private String lastUpdatedTime; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public JSONObject getApiDefinition() { + return apiDefinition; + } + + public void setApiDefinition(JSONObject apiDefinition) { + this.apiDefinition = apiDefinition; + } + + public String getWsdlUri() { + return wsdlUri; + } + + public void setWsdlUri(String wsdlUri) { + this.wsdlUri = wsdlUri; + } + + public String getLifeCycleStatus() { + return lifeCycleStatus; + } + + public void setLifeCycleStatus(String lifeCycleStatus) { + this.lifeCycleStatus = lifeCycleStatus; + } + + public boolean isDefaultVersion() { + return isDefaultVersion; + } + + public void setDefaultVersion(boolean defaultVersion) { + isDefaultVersion = defaultVersion; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Set getTransport() { + return transport; + } + + public void setTransport(Set transport) { + this.transport = transport; + } + + public List getOperations() { + return operations; + } + + public void setOperations(List operations) { + this.operations = operations; + } + + public String getAuthorizationHeader() { + return authorizationHeader; + } + + public void setAuthorizationHeader(String authorizationHeader) { + this.authorizationHeader = authorizationHeader; + } + + public String getSecurityScheme() { + return securityScheme; + } + + public void setSecurityScheme(String securityScheme) { + this.securityScheme = securityScheme; + } + + public Set getTags() { + return tags; + } + + public void setTags(Set tags) { + this.tags = tags; + } + + public List getTiers() { + return tiers; + } + + public void setTiers(List tiers) { + this.tiers = tiers; + } + + public boolean isHasThumbnail() { + return hasThumbnail; + } + + public void setHasThumbnail(boolean hasThumbnail) { + this.hasThumbnail = hasThumbnail; + } + + public String getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(String additionalProperties) { + this.additionalProperties = additionalProperties; + } + + public JSONObject getMonetization() { + return monetization; + } + + public void setMonetization(JSONObject monetization) { + this.monetization = monetization; + } + + public List getEndpointURLs() { + return endpointURLs; + } + + public void setEndpointURLs(List endpointURLs) { + this.endpointURLs = endpointURLs; + } + + public JSONObject getBusinessInformation() { + return businessInformation; + } + + public void setBusinessInformation(JSONObject businessInformation) { + this.businessInformation = businessInformation; + } + + public List getEnvironmentList() { + return environmentList; + } + + public void setEnvironmentList(List environmentList) { + this.environmentList = environmentList; + } + + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes; + } + + public String getAvgRating() { + return avgRating; + } + + public void setAvgRating(String avgRating) { + this.avgRating = avgRating; + } + + public JSONObject getAdvertiseInfo() { + return advertiseInfo; + } + + public void setAdvertiseInfo(JSONObject advertiseInfo) { + this.advertiseInfo = advertiseInfo; + } + + public boolean isSubscriptionAvailable() { + return isSubscriptionAvailable; + } + + public void setSubscriptionAvailable(boolean subscriptionAvailable) { + isSubscriptionAvailable = subscriptionAvailable; + } + + public List getCategories() { + return categories; + } + + public void setCategories(List categories) { + this.categories = categories; + } + + public List getKeyManagers() { + return keyManagers; + } + + public void setKeyManagers(List keyManagers) { + this.keyManagers = keyManagers; + } + + public String getCreatedTime() { + return createdTime; + } + + public void setCreatedTime(String createdTime) { + this.createdTime = createdTime; + } + + public String getLastUpdatedTime() { + return lastUpdatedTime; + } + + public void setLastUpdatedTime(String lastUpdatedTime) { + this.lastUpdatedTime = lastUpdatedTime; + } +} 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/bean/APIMConsumer/APIKey.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/APIMConsumer/APIKey.java index 022f1831b4..5cdaa83577 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/bean/APIMConsumer/APIKey.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/APIMConsumer/APIKey.java @@ -18,6 +18,10 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; +/** + * This class represents the Consumer API Key Information. + */ + public class APIKey { private String apikey; 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/bean/APIMConsumer/Application.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/APIMConsumer/Application.java index 4764f001b9..e137109098 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/bean/APIMConsumer/Application.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/APIMConsumer/Application.java @@ -22,6 +22,10 @@ import org.json.JSONObject; import java.util.List; +/** + * This class represents the Consumer Application Information. + */ + public class Application { private String applicationId; private String name; 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/bean/APIMConsumer/ApplicationConfigurations.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/APIMConsumer/ApplicationConfigurations.java new file mode 100644 index 0000000000..9634b77528 --- /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/bean/APIMConsumer/ApplicationConfigurations.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2018 - 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.bean.APIMConsumer; + +import io.apicurio.datamodels.asyncapi.v2.visitors.Aai20Traverser; + +import java.util.List; + +/** + * This class represents the Consumer Application configuration Information. + */ +public class ApplicationConfigurations { + + private String name; + private String label; + private String type; + private boolean required; + private boolean mask; + private boolean multiple; + private String tooltip; + private List values; + private String defaults; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public boolean isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } + + public boolean isMask() { + return mask; + } + + public void setMask(boolean mask) { + this.mask = mask; + } + + public boolean isMultiple() { + return multiple; + } + + public void setMultiple(boolean multiple) { + this.multiple = multiple; + } + + public String getTooltip() { + return tooltip; + } + + public void setTooltip(String tooltip) { + this.tooltip = tooltip; + } + + public List getValues() { + return values; + } + + public void setValues(List values) { + this.values = values; + } + + public String getDefaults() { + return defaults; + } + + public void setDefaults(String defaults) { + this.defaults = defaults; + } +} 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/bean/APIMConsumer/KeyManager.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/APIMConsumer/KeyManager.java new file mode 100644 index 0000000000..ac34e006dd --- /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/bean/APIMConsumer/KeyManager.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2018 - 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.bean.APIMConsumer; + +import org.json.JSONObject; + +import java.util.List; + +/** + * This class represents the Consumer Key manager Information. + */ + +public class KeyManager { + + private String id; + private String name; + private String type; + private String displayName; + private String description; + private boolean enabled; + private List availableGrantTypes; + private String tokenEndpoint; + private String revokeEndpoint; + private String userInfoEndpoint; + private String enableTokenGeneration; + private String enableTokenEncryption; + private String enableTokenHashing; + private String enableOAuthAppCreation; + private String enableMapOAuthConsumerApps; + private List applicationConfiguration; + private JSONObject additionalProperties; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public List getAvailableGrantTypes() { + return availableGrantTypes; + } + + public void setAvailableGrantTypes(List availableGrantTypes) { + this.availableGrantTypes = availableGrantTypes; + } + + public String getTokenEndpoint() { + return tokenEndpoint; + } + + public void setTokenEndpoint(String tokenEndpoint) { + this.tokenEndpoint = tokenEndpoint; + } + + public String getRevokeEndpoint() { + return revokeEndpoint; + } + + public void setRevokeEndpoint(String revokeEndpoint) { + this.revokeEndpoint = revokeEndpoint; + } + + public String getUserInfoEndpoint() { + return userInfoEndpoint; + } + + public void setUserInfoEndpoint(String userInfoEndpoint) { + this.userInfoEndpoint = userInfoEndpoint; + } + + public String getEnableTokenGeneration() { + return enableTokenGeneration; + } + + public void setEnableTokenGeneration(String enableTokenGeneration) { + this.enableTokenGeneration = enableTokenGeneration; + } + + public String getEnableTokenEncryption() { + return enableTokenEncryption; + } + + public void setEnableTokenEncryption(String enableTokenEncryption) { + this.enableTokenEncryption = enableTokenEncryption; + } + + public String getEnableTokenHashing() { + return enableTokenHashing; + } + + public void setEnableTokenHashing(String enableTokenHashing) { + this.enableTokenHashing = enableTokenHashing; + } + + public String getEnableOAuthAppCreation() { + return enableOAuthAppCreation; + } + + public void setEnableOAuthAppCreation(String enableOAuthAppCreation) { + this.enableOAuthAppCreation = enableOAuthAppCreation; + } + + public String getEnableMapOAuthConsumerApps() { + return enableMapOAuthConsumerApps; + } + + public void setEnableMapOAuthConsumerApps(String enableMapOAuthConsumerApps) { + this.enableMapOAuthConsumerApps = enableMapOAuthConsumerApps; + } + + public List getApplicationConfiguration() { + return applicationConfiguration; + } + + public void setApplicationConfiguration(List applicationConfiguration) { + this.applicationConfiguration = applicationConfiguration; + } + + public JSONObject getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(JSONObject additionalProperties) { + this.additionalProperties = additionalProperties; + } +} 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java index edfbce6b6a..dca36b9669 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java @@ -25,8 +25,8 @@ public class Subscription { private String subscriptionId; private String applicationId; private String apiId; - private JSONObject apiInfo; - private JSONObject applicationInfo; + private APIInfo apiInfo; + private Application applicationInfo; private String throttlingPolicy; private String requestedThrottlingPolicy; private String status; @@ -56,19 +56,19 @@ public class Subscription { this.apiId = apiId; } - public JSONObject getApiInfo() { + public APIInfo getApiInfo() { return apiInfo; } - public void setApiInfo(JSONObject apiInfo) { + public void setApiInfo(APIInfo apiInfo) { this.apiInfo = apiInfo; } - public JSONObject getApplicationInfo() { + public Application getApplicationInfo() { return applicationInfo; } - public void setApplicationInfo(JSONObject applicationInfo) { + public void setApplicationInfo(Application applicationInfo) { this.applicationInfo = applicationInfo; } From a8d45ee41a347db7e0ed616195c40c3c2d02b641 Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 6 Jun 2023 13:38:28 +0530 Subject: [PATCH 009/343] Create methods for consumer api app creation and get details of app --- .../rest/api/APIApplicationServices.java | 6 ++ .../rest/api/APIApplicationServicesImpl.java | 33 ++++++++++ .../rest/api/ConsumerRESTAPIServices.java | 4 ++ .../rest/api/ConsumerRESTAPIServicesImpl.java | 39 +++++++++++ .../api/bean/APIMConsumer/Application.java | 6 +- .../rest/api/bean/APIMConsumer/Scopes.java | 65 +++++++++++++++++++ 6 files changed, 150 insertions(+), 3 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/bean/APIMConsumer/Scopes.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/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 index d628c4ce25..5b19bf9e3c 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/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 @@ -26,6 +26,12 @@ public interface APIApplicationServices { APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; + APIApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) + throws APIServicesException; + AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRefreshToken(String refreshToken, String clientId, String clientSecret) throws APIServicesException; 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 05ecf1fd9e..7209041ad6 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 @@ -35,6 +35,7 @@ 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 java.io.IOException; public class APIApplicationServicesImpl implements APIApplicationServices { @@ -78,6 +79,38 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } } + @Override + public APIApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) + throws APIServicesException { + + String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("callbackUrl", Constants.EMPTY_STRING); + jsonObject.put("clientName", username); + jsonObject.put("grantType", Constants.GRANT_TYPE); + jsonObject.put("owner", username); + 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(username, password)) + .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"; + log.error(msg, e); + throw new APIServicesException(e); + } + } + @Override public AccessTokenInfo generateAccessTokenFromRegisteredApplication(String consumerKey, String consumerSecret) throws APIServicesException { 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index bbdc6cf0fe..3f62abce55 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -36,6 +36,10 @@ public interface ConsumerRESTAPIServices { Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; + Application getDetailsOfAnApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Application application) 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index 4f406b16bb..ec28fe6e9b 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -92,6 +92,45 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public Application getDetailsOfAnApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, + String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; + Request request = new Request.Builder() + .url(getAllApplicationsUrl) + .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()) { + return gson.fromJson(response.body().string(), Application.class); + } 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 getDetailsOfAnApplication(apiApplicationKey, refreshedAccessToken, applicationId); + } 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(msg, e); + } + } + @Override public Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, Application application) 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/bean/APIMConsumer/Application.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/APIMConsumer/Application.java index e137109098..50fb64147d 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/bean/APIMConsumer/Application.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/APIMConsumer/Application.java @@ -37,7 +37,7 @@ public class Application { private int subscriptionCount; private List keys; private JSONObject attributes; - private List subscriptionScopes; + private List subscriptionScopes; private String owner; private boolean hashEnabled; @@ -121,11 +121,11 @@ public class Application { this.attributes = attributes; } - public List getSubscriptionScopes() { + public List getSubscriptionScopes() { return subscriptionScopes; } - public void setSubscriptionScopes(List subscriptionScopes) { + public void setSubscriptionScopes(List subscriptionScopes) { this.subscriptionScopes = subscriptionScopes; } 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/bean/APIMConsumer/Scopes.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/APIMConsumer/Scopes.java new file mode 100644 index 0000000000..a2b55005b6 --- /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/bean/APIMConsumer/Scopes.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 - 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.bean.APIMConsumer; + +import java.util.List; + +/** + * This class represents the scope data. + */ + +public class Scopes { + + private String key; + private String name; + private List 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 List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} From 45d98d5e49157e4df76f4d8bff7a455a18a6524c Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 6 Jun 2023 16:01:32 +0530 Subject: [PATCH 010/343] Improve get all api method to accept header params --- .../rest/api/ConsumerRESTAPIServices.java | 2 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index 3f62abce55..e908e60ffd 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -49,7 +49,7 @@ public interface ConsumerRESTAPIServices { throws APIServicesException, BadRequestException, UnexpectedResponseException; APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParam) + Map queryParam, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index ec28fe6e9b..cec4a927fe 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -224,7 +224,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { @Override public APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParams) + Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; @@ -233,12 +233,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { getAPIsURL = getAPIsURL + Constants.AMPERSAND + query.getKey() + Constants.EQUAL + query.getValue(); } - Request request = new Request.Builder() - .url(getAPIsURL) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) - .get() - .build(); + Request.Builder builder = new Request.Builder(); + builder.url(getAPIsURL); + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessTokenInfo.getAccess_token()); + for (Map.Entry header : headerParams.entrySet()) { + builder.addHeader(header.getKey(), header.getValue()); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); @@ -251,7 +254,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); //TODO: max attempt count - return getAllApis(apiApplicationKey, refreshedAccessToken, queryParams); + return getAllApis(apiApplicationKey, refreshedAccessToken, queryParams, headerParams); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); From c53c8f3d63512d5253d826be2f3b344fd449dab4 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 7 Jun 2023 10:43:34 +0530 Subject: [PATCH 011/343] minor fix --- .../extension/APIManagementProviderServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 52a1925df6..50bd278fe6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -118,9 +118,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe for (String tag: tags) { Map queryParams = new HashMap<>(); + Map headerParams = new HashMap<>(); queryParams.put("tag", tag); if ("carbon.super".equals(tenantDomain)) { - consumerRESTAPIServices.getAllApis(null, null, queryParams); + consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); } else { //call All API getting call with carbon super header param } From 6bf6adf2b5b1561f09f6a23a5a5946159fb544b2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 7 Jun 2023 20:58:48 +0530 Subject: [PATCH 012/343] Add API integration --- .../APIManagementProviderServiceImpl.java | 68 ++++++++++++++++--- .../api/bean/APIMConsumer/Subscription.java | 2 - 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 50bd278fe6..40037475ec 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -20,7 +20,8 @@ package io.entgra.device.mgt.core.apimgt.application.extension; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.RegistrationProfile; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; 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; @@ -110,29 +111,74 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); try { - consumerRESTAPIServices.getAllApplications(null, null, applicationName); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = + consumerRESTAPIServices.getAllApplications(null, null, applicationName); - List uniqueApiList = new ArrayList(); + List uniqueApiList = new ArrayList<>(); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); - for (String tag: tags) { + for (String tag : tags) { Map queryParams = new HashMap<>(); Map headerParams = new HashMap<>(); queryParams.put("tag", tag); - if ("carbon.super".equals(tenantDomain)) { - consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); - } else { - //call All API getting call with carbon super header param + APIInfo[] apiInfos; + if (!"carbon.super".equals(tenantDomain)) { + headerParams.put("X-WSO2-Tenant", "carbon.super"); } + apiInfos = consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); - uniqueApiList.add("Test"); - Set taggedAPISet = new HashSet<>(uniqueApiList); + uniqueApiList.addAll(List.of(apiInfos)); + Set taggedAPISet = new HashSet<>(uniqueApiList); uniqueApiList.clear(); uniqueApiList.addAll(taggedAPISet); } - consumerRESTAPIServices.getAllSubscriptions(null, null, "1"); + if (applications.length == 0) { + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = + new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); + + application.setName(applicationName); + application = consumerRESTAPIServices.createApplication(null, null, application); + List subscriptions = new ArrayList<>(); + for (APIInfo apiInfo : uniqueApiList) { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.getApplicationId()); + subscriptions.add(subscription); + } + consumerRESTAPIServices.createSubscriptions(null, null, subscriptions); + } else { + if (applications.length == 1) { + Optional application = + Arrays.stream(applications).findFirst(); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, null, + application.get().getApplicationId()); + for (Subscription subscription : subscriptions) { + if (uniqueApiList.contains(subscription.getApiInfo())) { + uniqueApiList.remove(subscription.getApiInfo()); + } else { + uniqueApiList.add(subscription.getApiInfo()); + } + } + + + //duplicate code block + List subscriptionList = new ArrayList<>(); + for (APIInfo apiInfo : uniqueApiList) { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.get().getApplicationId()); + subscriptionList.add(subscription); + } + consumerRESTAPIServices.createSubscriptions(null, null, subscriptionList); + } else { + String msg = "Found more than one application for application name: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + + } } catch (APIServicesException e) { 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java index dca36b9669..085b87785f 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; -import org.json.JSONObject; - public class Subscription { private String subscriptionId; From 0e622450648044a678c3a3ee7e7d118e3407c239 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 7 Jun 2023 23:19:57 +0530 Subject: [PATCH 013/343] modify generateAndRetrieveApplicationKeys method --- .../APIManagementProviderServiceImpl.java | 25 ++++++++++++++----- .../rest/api/APIApplicationServices.java | 5 +--- .../rest/api/APIApplicationServicesImpl.java | 5 +--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 40037475ec..1e8fc44518 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -22,6 +22,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationService import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; 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; @@ -110,9 +111,21 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + APIApplicationKey apiApplicationKey; + io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; + try { + apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); + accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + } catch (APIServicesException e) { + String errorMsg = "Error occurred while generating the API application"; + log.error(errorMsg, e); + throw new APIManagerException(e); + } + try { io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(null, null, applicationName); + consumerRESTAPIServices.getAllApplications(apiApplicationKey, accessTokenInfo, applicationName); List uniqueApiList = new ArrayList<>(); @@ -126,7 +139,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (!"carbon.super".equals(tenantDomain)) { headerParams.put("X-WSO2-Tenant", "carbon.super"); } - apiInfos = consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); + apiInfos = consumerRESTAPIServices.getAllApis(apiApplicationKey, accessTokenInfo, queryParams, headerParams); uniqueApiList.addAll(List.of(apiInfos)); Set taggedAPISet = new HashSet<>(uniqueApiList); @@ -139,7 +152,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); - application = consumerRESTAPIServices.createApplication(null, null, application); + application = consumerRESTAPIServices.createApplication(apiApplicationKey, accessTokenInfo, application); List subscriptions = new ArrayList<>(); for (APIInfo apiInfo : uniqueApiList) { Subscription subscription = new Subscription(); @@ -147,12 +160,12 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.getApplicationId()); subscriptions.add(subscription); } - consumerRESTAPIServices.createSubscriptions(null, null, subscriptions); + consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptions); } else { if (applications.length == 1) { Optional application = Arrays.stream(applications).findFirst(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, null, + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(apiApplicationKey, accessTokenInfo, application.get().getApplicationId()); for (Subscription subscription : subscriptions) { if (uniqueApiList.contains(subscription.getApiInfo())) { @@ -171,7 +184,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.get().getApplicationId()); subscriptionList.add(subscription); } - consumerRESTAPIServices.createSubscriptions(null, null, subscriptionList); + consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptionList); } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); 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/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 index 5b19bf9e3c..1cdceff56a 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/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 @@ -26,10 +26,7 @@ public interface APIApplicationServices { APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; - APIApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime, String password) + APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; 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 7209041ad6..8e80e1f5f5 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 @@ -80,10 +80,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime, String password) + public APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); From d251253948ec211e2683ce94fa35acf001240fec Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 8 Jun 2023 06:02:23 +0530 Subject: [PATCH 014/343] Improve application key generating functionality --- .../APIManagementProviderServiceImpl.java | 53 ++++++++++++------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 1e8fc44518..ba57bb3045 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -120,12 +120,13 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } catch (APIServicesException e) { String errorMsg = "Error occurred while generating the API application"; log.error(errorMsg, e); - throw new APIManagerException(e); + throw new APIManagerException(errorMsg, e); } try { io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(apiApplicationKey, accessTokenInfo, applicationName); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = null; List uniqueApiList = new ArrayList<>(); @@ -148,11 +149,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } if (applications.length == 0) { - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = - new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); - + application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); application = consumerRESTAPIServices.createApplication(apiApplicationKey, accessTokenInfo, application); + List subscriptions = new ArrayList<>(); for (APIInfo apiInfo : uniqueApiList) { Subscription subscription = new Subscription(); @@ -163,10 +163,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptions); } else { if (applications.length == 1) { - Optional application = + Optional applicationOpt = Arrays.stream(applications).findFirst(); + application = applicationOpt.get(); Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(apiApplicationKey, accessTokenInfo, - application.get().getApplicationId()); + application.getApplicationId()); for (Subscription subscription : subscriptions) { if (uniqueApiList.contains(subscription.getApiInfo())) { uniqueApiList.remove(subscription.getApiInfo()); @@ -175,13 +176,12 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } - - //duplicate code block + //todo duplicate code block -> move to a private method List subscriptionList = new ArrayList<>(); for (APIInfo apiInfo : uniqueApiList) { Subscription subscription = new Subscription(); subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.get().getApplicationId()); + subscription.setApplicationId(application.getApplicationId()); subscriptionList.add(subscription); } consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptionList); @@ -190,21 +190,38 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe log.error(msg); throw new APIManagerException(msg); } - } - + if (application != null) { + if (!application.getKeys().isEmpty()) { + //todo return Application Keys + return null; + } else{ + //todo this method has to br modified and return different object, this is not mapped with the + // response. + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey apiKey = + consumerRESTAPIServices.generateApplicationKeys(apiApplicationKey, accessTokenInfo, + application.getApplicationId()); + return null; + } + } else{ + String msg = "Application retrieval process failed."; + log.error(msg); + throw new APIManagerException(msg); + } } catch (APIServicesException e) { - e.printStackTrace(); + String msg = "Error occurred wile processing the response of APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); } catch (BadRequestException e) { - e.printStackTrace(); + String msg = "Provided incorrect payload when invoking APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); } catch (UnexpectedResponseException e) { - e.printStackTrace(); + String msg = "Error occurred while invoking APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); } - - return null; - - } From 94e1df617ad52b07ef2e58d6d5804edc53fe0883 Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 9 Jun 2023 02:55:20 +0530 Subject: [PATCH 015/343] Get apiApplication registration to single method and fix generateApplicationKeys --- .../APIManagementProviderServiceImpl.java | 60 +++++--- .../rest/api/ConsumerRESTAPIServices.java | 34 ++-- .../rest/api/ConsumerRESTAPIServicesImpl.java | 145 ++++++++++-------- .../api/bean/APIMConsumer/ApplicationKey.java | 138 +++++++++++++++++ .../rest/api/dto/ApiApplicationInfo.java | 61 ++++++++ 5 files changed, 331 insertions(+), 107 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/bean/APIMConsumer/ApplicationKey.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/dto/ApiApplicationInfo.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index ba57bb3045..18e706f8fc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -21,8 +21,10 @@ package io.entgra.device.mgt.core.apimgt.application.extension; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; 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; @@ -111,21 +113,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - APIApplicationKey apiApplicationKey; - io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; - try { - apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); - accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); - } catch (APIServicesException e) { - String errorMsg = "Error occurred while generating the API application"; - log.error(errorMsg, e); - throw new APIManagerException(errorMsg, e); - } - + ApiApplicationInfo applicationInfo = applicationInfo(apiApplicationServices, username, password); try { io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(apiApplicationKey, accessTokenInfo, applicationName); + consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = null; List uniqueApiList = new ArrayList<>(); @@ -140,7 +131,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (!"carbon.super".equals(tenantDomain)) { headerParams.put("X-WSO2-Tenant", "carbon.super"); } - apiInfos = consumerRESTAPIServices.getAllApis(apiApplicationKey, accessTokenInfo, queryParams, headerParams); + apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, queryParams, headerParams); uniqueApiList.addAll(List.of(apiInfos)); Set taggedAPISet = new HashSet<>(uniqueApiList); @@ -151,7 +142,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (applications.length == 0) { application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); - application = consumerRESTAPIServices.createApplication(apiApplicationKey, accessTokenInfo, application); + application = consumerRESTAPIServices.createApplication(applicationInfo, application); List subscriptions = new ArrayList<>(); for (APIInfo apiInfo : uniqueApiList) { @@ -160,14 +151,13 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.getApplicationId()); subscriptions.add(subscription); } - consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptions); + consumerRESTAPIServices.createSubscriptions(applicationInfo, subscriptions); } else { if (applications.length == 1) { Optional applicationOpt = Arrays.stream(applications).findFirst(); application = applicationOpt.get(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(apiApplicationKey, accessTokenInfo, - application.getApplicationId()); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, application.getApplicationId()); for (Subscription subscription : subscriptions) { if (uniqueApiList.contains(subscription.getApiInfo())) { uniqueApiList.remove(subscription.getApiInfo()); @@ -184,7 +174,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.getApplicationId()); subscriptionList.add(subscription); } - consumerRESTAPIServices.createSubscriptions(apiApplicationKey, accessTokenInfo, subscriptionList); + consumerRESTAPIServices.createSubscriptions(applicationInfo, subscriptionList); } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); @@ -199,9 +189,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } else{ //todo this method has to br modified and return different object, this is not mapped with the // response. - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey apiKey = - consumerRESTAPIServices.generateApplicationKeys(apiApplicationKey, accessTokenInfo, - application.getApplicationId()); + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); return null; } } else{ @@ -560,4 +548,32 @@ Otherwise, Generate Application Keys and return them } return info; } + + private ApiApplicationInfo applicationInfo(APIApplicationServices apiApplicationServices, String username, String password) + throws APIManagerException { + + APIApplicationKey apiApplicationKey; + io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; + try { + if (username == null && password == null) { + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + } else { + apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); + } + accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( + apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + } catch (APIServicesException e) { + String errorMsg = "Error occurred while generating the API application"; + log.error(errorMsg, e); + throw new APIManagerException(errorMsg, e); + } + + ApiApplicationInfo applicationInfo = null; + applicationInfo.setClientId(apiApplicationKey.getClientId()); + applicationInfo.setClientSecret(apiApplicationKey.getClientSecret()); + applicationInfo.setAccess_token(accessTokenInfo.getAccess_token()); + applicationInfo.setRefresh_token(accessTokenInfo.getRefresh_token()); + + return applicationInfo; + } } 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index e908e60ffd..fc90c14463 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -18,13 +18,8 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; -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.bean.APIMConsumer.*; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; 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; @@ -33,37 +28,30 @@ import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + Application[] getAllApplications(ApiApplicationInfo applicationInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application getDetailsOfAnApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + Application getDetailsOfAnApplication(ApiApplicationInfo applicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Application application) + Application createApplication(ApiApplicationInfo applicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParam, Map headerParams) + APIInfo[] getAllApis(ApiApplicationInfo applicationInfo, Map queryParam, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Subscription subscriptions) + Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - List subscriptions) + Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + ApplicationKey generateApplicationKeys(ApiApplicationInfo applicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - KeyManager[] getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index cec4a927fe..fe341bc416 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -19,14 +19,10 @@ 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.bean.APIMConsumer.APIInfo; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; 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.dto.ApiApplicationInfo; 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; @@ -54,14 +50,14 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public Application[] getAllApplications(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, String appName) + public Application[] getAllApplications(ApiApplicationInfo applicationInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; Request request = new Request.Builder() .url(getAllApplicationsUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + applicationInfo.getAccess_token()) .get() .build(); @@ -73,10 +69,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), + applicationInfo.getClientId(), applicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllApplications(apiApplicationKey, refreshedAccessToken, appName); + return getAllApplications(refreshedApiApplicationInfo, appName); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -93,15 +90,14 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application getDetailsOfAnApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request request = new Request.Builder() .url(getAllApplicationsUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .get() .build(); @@ -112,10 +108,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getDetailsOfAnApplication(apiApplicationKey, refreshedAccessToken, applicationId); + return getDetailsOfAnApplication(refreshedApiApplicationInfo, applicationId); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -132,8 +129,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application createApplication(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Application application) + public Application createApplication(ApiApplicationInfo apiApplicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; @@ -152,7 +148,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .post(requestBody) .build(); @@ -163,10 +159,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return createApplication(apiApplicationKey, refreshedAccessToken, application); + return createApplication(refreshedApiApplicationInfo, application); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -183,15 +180,14 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] getAllSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .get() .build(); @@ -203,10 +199,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllSubscriptions(apiApplicationKey, refreshedAccessToken, applicationId); + return getAllSubscriptions(rehreshedApiApplicationInfo, applicationId); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -223,8 +220,8 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public APIInfo[] getAllApis(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Map queryParams, Map headerParams) + public APIInfo[] getAllApis(ApiApplicationInfo applicationInfo, Map queryParams, + Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; @@ -236,7 +233,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(getAPIsURL); builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()); + + applicationInfo.getAccess_token()); for (Map.Entry header : headerParams.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); } @@ -251,10 +248,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), + applicationInfo.getClientId(), applicationInfo.getClientSecret()); + ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllApis(apiApplicationKey, refreshedAccessToken, queryParams, headerParams); + return getAllApis(rehreshedApiApplicationInfo, queryParams, headerParams); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -271,8 +269,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscription(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - Subscription subscriptions) + public Subscription createSubscription(ApiApplicationInfo applicationInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API; @@ -288,7 +285,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + applicationInfo.getAccess_token()) .post(requestBody) .build(); @@ -299,10 +296,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), + applicationInfo.getClientId(), applicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); //TODO: max attempt count - return createSubscription(apiApplicationKey, refreshedAccessToken, subscriptions); + return createSubscription(refreshedApiApplicationInfo, subscriptions); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -319,8 +317,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] createSubscriptions(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - List subscriptions) + public Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; @@ -331,7 +328,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .post(requestBody) .build(); @@ -343,10 +340,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return createSubscriptions(apiApplicationKey, refreshedAccessToken, subscriptions); + return createSubscriptions(refreshedApiApplicationInfo, subscriptions); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -363,15 +361,25 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public APIKey generateApplicationKeys(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo, - String applicationId) + public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + Constants.SLASH + applicationId + - "/generate-keys"; + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + Constants.SLASH + + application.getApplicationId() + "/generate-keys"; String keyInfo = "{\n" + - " \"validityPeriod\": 3600,\n" + + " \"keyType\": \"PRODUCTION\",\n" + + " \"keyManager\": \"Resident Key Manager\",\n" + + " \"grantTypesToBeSupported\": [\n" + + " \"password\",\n" + + " \"client_credentials\"\n" + + " ],\n" + + " \"callbackUrl\": \"http://sample.com/callback/url\",\n" + + " \"scopes\": [\n" + + " \"am_application_scope\",\n" + + " \"default\"\n" + + " ],\n" + + " \"validityTime\": 3600,\n" + " \"additionalProperties\": {}\n" + "}"; @@ -379,21 +387,22 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request request = new Request.Builder() .url(getAllScopesUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .post(requestBody) .build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - return gson.fromJson(response.body().string(), APIKey.class); + return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return generateApplicationKeys(apiApplicationKey, refreshedAccessToken, applicationId); + return generateApplicationKeys(refreshedApiApplicationKey, application); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -410,14 +419,14 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public KeyManager[] getAllKeyManagers(APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) + public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; Request request = new Request.Builder() .url(getAllKeyManagersUrl) .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessTokenInfo.getAccess_token()) + + apiApplicationInfo.getAccess_token()) .get() .build(); @@ -429,10 +438,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(accessTokenInfo.getRefresh_token(), - apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllKeyManagers(apiApplicationKey, refreshedAccessToken); + return getAllKeyManagers(refreshedApiApplicationInfo); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -447,4 +457,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { throw new APIServicesException(msg, e); } } + + private ApiApplicationInfo returnApplicationInfo(ApiApplicationInfo refreshedApplicationInfo, AccessTokenInfo refreshedToken) { + + ApiApplicationInfo applicationInfo = null; + applicationInfo.setClientId(refreshedApplicationInfo.getClientId()); + applicationInfo.setClientSecret(refreshedApplicationInfo.getClientSecret()); + applicationInfo.setAccess_token(refreshedToken.getAccess_token()); + applicationInfo.setRefresh_token(refreshedToken.getRefresh_token()); + + return applicationInfo; + } } 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/bean/APIMConsumer/ApplicationKey.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/APIMConsumer/ApplicationKey.java new file mode 100644 index 0000000000..c51564af2c --- /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/bean/APIMConsumer/ApplicationKey.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2018 - 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.bean.APIMConsumer; + +import org.json.JSONObject; + +import java.util.List; + +/** + * This class represents the Consumer Application key Information. + */ +public class ApplicationKey { + + private String keyMappingId; + private String keyManager; + private String consumerKey; + private String consumerSecret; + private List supportedGrantTypes; + private String callbackUrl; + private String keyState; + private String keyType; + private String mode; + private String groupId; + private JSONObject token; + private JSONObject additionalProperties; + + public String getKeyMappingId() { + return keyMappingId; + } + + public void setKeyMappingId(String keyMappingId) { + this.keyMappingId = keyMappingId; + } + + public String getKeyManager() { + return keyManager; + } + + public void setKeyManager(String keyManager) { + this.keyManager = keyManager; + } + + public String getConsumerKey() { + return consumerKey; + } + + public void setConsumerKey(String consumerKey) { + this.consumerKey = consumerKey; + } + + public String getConsumerSecret() { + return consumerSecret; + } + + public void setConsumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + } + + public List getSupportedGrantTypes() { + return supportedGrantTypes; + } + + public void setSupportedGrantTypes(List supportedGrantTypes) { + this.supportedGrantTypes = supportedGrantTypes; + } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public String getKeyState() { + return keyState; + } + + public void setKeyState(String keyState) { + this.keyState = keyState; + } + + public String getKeyType() { + return keyType; + } + + public void setKeyType(String keyType) { + this.keyType = keyType; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public JSONObject getToken() { + return token; + } + + public void setToken(JSONObject token) { + this.token = token; + } + + public JSONObject getAdditionalProperties() { + return additionalProperties; + } + + public void setAdditionalProperties(JSONObject additionalProperties) { + this.additionalProperties = additionalProperties; + } +} 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/dto/ApiApplicationInfo.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/ApiApplicationInfo.java new file mode 100644 index 0000000000..169ce76442 --- /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/dto/ApiApplicationInfo.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018 - 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.dto; + +/** + * This holds the API application client information and token information. + */ +public class ApiApplicationInfo { + private String clientId; + private String clientSecret; + private String refresh_token; + private String access_token; + + 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; + } + + 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; + } +} From 189a572d310a6841f7ab18301b7dfac08c3f98da Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Fri, 9 Jun 2023 04:51:05 +0530 Subject: [PATCH 016/343] Improve functionality --- .../APIManagementProviderServiceImpl.java | 84 +++++++++++-------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 18e706f8fc..7fa6c440c6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -106,10 +106,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], String keyType, String username, boolean isAllowedAllDomains, - String validityTime, String password) throws APIManagerException { - - APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance().getApiApplicationServices(); + String validityTime, String password) + throws APIManagerException { + APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance() + .getApiApplicationServices(); ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -117,21 +118,21 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe try { io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName); - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = null; + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; List uniqueApiList = new ArrayList<>(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); + Map headerParams = new HashMap<>(); + if (!"carbon.super".equals(tenantDomain)) { + headerParams.put("X-WSO2-Tenant", "carbon.super"); + } + for (String tag : tags) { Map queryParams = new HashMap<>(); - Map headerParams = new HashMap<>(); queryParams.put("tag", tag); - APIInfo[] apiInfos; - if (!"carbon.super".equals(tenantDomain)) { - headerParams.put("X-WSO2-Tenant", "carbon.super"); - } - apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, queryParams, headerParams); + + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, queryParams, headerParams); uniqueApiList.addAll(List.of(apiInfos)); Set taggedAPISet = new HashSet<>(uniqueApiList); @@ -143,15 +144,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); application = consumerRESTAPIServices.createApplication(applicationInfo, application); - - List subscriptions = new ArrayList<>(); - for (APIInfo apiInfo : uniqueApiList) { - Subscription subscription = new Subscription(); - subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.getApplicationId()); - subscriptions.add(subscription); - } - consumerRESTAPIServices.createSubscriptions(applicationInfo, subscriptions); + addSubscriptions(application, uniqueApiList, applicationInfo); } else { if (applications.length == 1) { Optional applicationOpt = @@ -165,16 +158,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe uniqueApiList.add(subscription.getApiInfo()); } } - - //todo duplicate code block -> move to a private method - List subscriptionList = new ArrayList<>(); - for (APIInfo apiInfo : uniqueApiList) { - Subscription subscription = new Subscription(); - subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.getApplicationId()); - subscriptionList.add(subscription); - } - consumerRESTAPIServices.createSubscriptions(applicationInfo, subscriptionList); + addSubscriptions(application, uniqueApiList, applicationInfo); } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); @@ -187,18 +171,20 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe //todo return Application Keys return null; } else{ - //todo this method has to br modified and return different object, this is not mapped with the - // response. + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); - return null; + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; } } else{ String msg = "Application retrieval process failed."; log.error(msg); - throw new APIManagerException(msg); + throw new APIManagerException(msg); } } catch (APIServicesException e) { - String msg = "Error occurred wile processing the response of APIM REST endpoints."; + String msg = "Error occurred while processing the response of APIM REST endpoints."; log.error(msg, e); throw new APIManagerException(msg, e); } catch (BadRequestException e) { @@ -212,6 +198,34 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } + /** + * + * This method can be used to add a new subscriptions providing the ids of the APIs and the applications. + * + * @param application {@link io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application} + * @param apiInfos {@link List} + * @param apiApplicationInfo {@link ApiApplicationInfo} + * + * @throws BadRequestException if incorrect data provided to call subscribing REST API. + * @throws UnexpectedResponseException if error occurred while processing the subscribing REST API. + * @throws APIServicesException if error occurred while invoking the subscribing REST API. + */ + private void addSubscriptions( + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, + List apiInfos, ApiApplicationInfo apiApplicationInfo) + throws BadRequestException, UnexpectedResponseException, APIServicesException { + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + List subscriptionList = new ArrayList<>(); + apiInfos.forEach(apiInfo -> { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.getApplicationId()); + subscriptionList.add(subscription); + }); + consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, subscriptionList); + } /** * {@inheritDoc} From c227969a61a91558831efc2f73ea4bb5b763c0ac Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Fri, 9 Jun 2023 05:06:01 +0530 Subject: [PATCH 017/343] Improve the functionality --- .../APIManagementProviderService.java | 2 +- .../APIManagementProviderServiceImpl.java | 20 ++++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index d2d2fe4674..51ac50cf08 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -50,7 +50,7 @@ public interface APIManagementProviderService { String keyType, String username, boolean isAllowedAllDomains, String validityTime) throws APIManagerException; - ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, String validityTime, String password) throws APIManagerException; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 7fa6c440c6..1bf3d1ded1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -103,7 +103,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, String validityTime, String password) @@ -116,15 +116,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe ApiApplicationInfo applicationInfo = applicationInfo(apiApplicationServices, username, password); try { - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName); - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; - List uniqueApiList = new ArrayList<>(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); Map headerParams = new HashMap<>(); - if (!"carbon.super".equals(tenantDomain)) { + if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) { headerParams.put("X-WSO2-Tenant", "carbon.super"); } @@ -140,6 +135,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe uniqueApiList.addAll(taggedAPISet); } + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = + consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; if (applications.length == 0) { application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); @@ -151,13 +149,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Arrays.stream(applications).findFirst(); application = applicationOpt.get(); Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, application.getApplicationId()); - for (Subscription subscription : subscriptions) { - if (uniqueApiList.contains(subscription.getApiInfo())) { - uniqueApiList.remove(subscription.getApiInfo()); - } else { - uniqueApiList.add(subscription.getApiInfo()); - } - } + Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); addSubscriptions(application, uniqueApiList, applicationInfo); } else { String msg = "Found more than one application for application name: " + applicationName; From f741df7c4baba3d8e0f31430766f019d44be6cb2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Fri, 9 Jun 2023 14:12:30 +0530 Subject: [PATCH 018/343] Add ToDos --- .../api/ApiApplicationRegistrationServiceImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index 687fe5be5e..5dc89a80c4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -59,6 +59,9 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi } String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() .getRealmConfiguration().getAdminUserName(); + //todo + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username); APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( @@ -107,6 +110,8 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { + //todo + registrationProfile.getPassword(); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, @@ -118,6 +123,8 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(PrivilegedCarbonContext. getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName()); + //todo + registrationProfile.getPassword(); synchronized (ApiApplicationRegistrationServiceImpl.class) { ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), From a09d72c33ccecee5757dd29eafd959311ba14e3e Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Sat, 10 Jun 2023 11:43:27 +0530 Subject: [PATCH 019/343] Add todo Comments --- .../pom.xml | 13 ------- .../APIManagementProviderServiceImpl.java | 36 +++++++++---------- .../extension/api/KeyManagerServiceImpl.java | 1 + .../extension/service/KeyMgtServiceImpl.java | 4 +++ .../impl/DeviceManagementServiceImpl.java | 1 + 5 files changed, 22 insertions(+), 33 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index ed7542738a..6ad08c770a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -129,19 +129,6 @@ org.json.simple;version="[1.1,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.wso2.carbon.apimgt.api;version="${carbon.api.mgt.version.range}", - org.wso2.carbon.apimgt.api.dto;version="${carbon.api.mgt.version.range}", - org.wso2.carbon.apimgt.api.model;version="${carbon.api.mgt.version.range}", - io.entgra.device.mgt.core.apimgt.application.extension.bean, - io.entgra.device.mgt.core.apimgt.application.extension.dto, - io.entgra.device.mgt.core.apimgt.application.extension.exception, - 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.context;version="${carbon.kernel.version.range}", - io.entgra.device.mgt.core.identity.jwt.client.extension, - io.entgra.device.mgt.core.identity.jwt.client.extension.dto, - io.entgra.device.mgt.core.identity.jwt.client.extension.exception, - io.entgra.device.mgt.core.identity.jwt.client.extension.service, io.entgra.device.mgt.core.apimgt.extension.rest.api, org.wso2.carbon.apimgt.api;version="[9.28,10)", org.wso2.carbon.apimgt.api.dto;version="[9.28,10)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 67bf9ef56b..ad58ab4f33 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -109,12 +109,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe String validityTime, String password) throws APIManagerException { - APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance() - .getApiApplicationServices(); + ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - ApiApplicationInfo applicationInfo = applicationInfo(apiApplicationServices, username, password); + ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); try { List uniqueApiList = new ArrayList<>(); @@ -138,7 +137,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; + boolean isNewApplication = false; if (applications.length == 0) { + isNewApplication = true; application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); application = consumerRESTAPIServices.createApplication(applicationInfo, application); @@ -158,22 +159,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } - if (application != null) { - if (!application.getKeys().isEmpty()) { - //todo return Application Keys - return null; - } else{ - - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; - } - } else{ - String msg = "Application retrieval process failed."; - log.error(msg); - throw new APIManagerException(msg); + if (isNewApplication) { + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; + } else { + return null; } } catch (APIServicesException e) { String msg = "Error occurred while processing the response of APIM REST endpoints."; @@ -555,9 +548,12 @@ Otherwise, Generate Application Keys and return them return info; } - private ApiApplicationInfo applicationInfo(APIApplicationServices apiApplicationServices, String username, String password) + private ApiApplicationInfo getApplicationInfo(String username, String password) throws APIManagerException { + APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance() + .getApiApplicationServices(); + APIApplicationKey apiApplicationKey; io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; try { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java index 96f506d99e..dbfee32906 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java @@ -45,6 +45,7 @@ public class KeyManagerServiceImpl implements KeyManagerService { public Response dynamicClientRegistration(DCRRequest dcrRequest) { try { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); + //todo lasantha - can pass password from here - modify DCRRequest object DCRResponse resp = keyMgtService.dynamicClientRegistration(dcrRequest.getApplicationName(), dcrRequest.getUsername(), dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod()); return Response.status(Response.Status.CREATED).entity(gson.toJson(resp)).build(); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index aee387abc4..936011e90f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -118,10 +118,13 @@ public class KeyMgtServiceImpl implements KeyMgtService { createUserIfNotExists(subTenantUserUsername, subTenantUserPassword); // DCR for the requesting user + //todo lasantha -> need to pass password of user OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod); String requestingUserAccessToken = createAccessToken(dcrApplication); // get application id + //todo --> can use requestingUserAccessToken token here to get application data - modify getApplication + // method signature Application application = getApplication(clientName, owner); String applicationUUID = application.getUUID(); @@ -420,6 +423,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { try { APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance(); APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner); + //todo modify the method signature and use access token and call REST API to get application data return null; // todo:apim - apiConsumer.getApplicationsByName(owner, applicationName, ""); // // curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index d1ddfaa44f..579f09c606 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -797,6 +797,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); try { + //todo - lasantha - can't get password from here DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username, "client_credentials", null, new String[] {"device_management"}, false, validityTime); deviceConfig.setClientId(dcrResponse.getClientId()); From 3b8405e72ea9b6a1fcf8bc78aafbce82b6c4a170 Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 12 Jun 2023 14:37:00 +0530 Subject: [PATCH 020/343] Fix version issues in REST APIs --- .../apimgt/extension/rest/api/constants/Constants.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 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/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 5ce6c023c9..6c3cf21c89 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 @@ -66,14 +66,14 @@ public final class Constants { public static final String SPACE = " "; 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 SCOPE_API_ENDPOINT = "/api/am/publisher/v2/scopes/"; - public static final String API_ENDPOINT = "/api/am/publisher/v2/apis/"; - public static final String GET_ALL_APIS = "/api/am/publisher/v2/apis?limit=1000"; + public static final String GET_ALL_SCOPES = "/api/am/publisher/v4/scopes?limit=1000"; + public static final String SCOPE_API_ENDPOINT = "/api/am/publisher/v4/scopes/"; + public static final String API_ENDPOINT = "/api/am/publisher/v4/apis/"; + public static final String GET_ALL_APIS = "/api/am/publisher/v4/apis?limit=1000"; public static final String APPLICATIONS_API = "/api/am/devportal/v3/applications"; public static final String SUBSCRIPTION_API = "/api/am/devportal/v3/subscriptions"; public static final String DEV_PORTAL_API = "/api/am/devportal/v3/apis?limit=1000"; - public static final String KEY_MANAGERS_API = "/api/am/devportal/v2/key-managers"; + public static final String KEY_MANAGERS_API = "/api/am/devportal/v3/key-managers"; } From af17e4fa8e971334c2c67446b2cd86c2a6ea0dc3 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Mon, 12 Jun 2023 16:27:38 +0530 Subject: [PATCH 021/343] Improve APIM application key generate method --- .../pom.xml | 7 ++ .../APIManagementProviderServiceImpl.java | 41 +++++++++++- ...ApplicationManagerExtensionDataHolder.java | 10 +++ ...ationManagerExtensionServiceComponent.java | 31 +++++++++ .../keymgt/extension/api/DCRRequest.java | 6 ++ .../pom.xml | 6 ++ .../extension/internal/KeyMgtDataHolder.java | 20 ++++++ .../internal/KeyMgtServiceComponent.java | 67 ++++++++++++++++++- 8 files changed, 184 insertions(+), 4 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 6ad08c770a..7434c58e54 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -84,6 +84,12 @@ io.entgra.device.mgt.core.apimgt.extension.rest.api + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.common + + + @@ -124,6 +130,7 @@ io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)", io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="[5.0,6)", io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", org.apache.commons.lang;version="[2.6,3)", org.apache.commons.logging;version="[1.2,2)", org.json.simple;version="[1.1,2)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index ad58ab4f33..6ab71de887 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -24,6 +24,10 @@ import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplication import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; import io.entgra.device.mgt.core.apimgt.application.extension.util.APIManagerUtil; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; @@ -41,6 +45,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.Unexpected import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.eclipse.jetty.http.MetaData; import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; @@ -159,13 +164,47 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; + + Metadata metaData = new Metadata(); + metaData.setMetaKey(applicationName); + String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); + metaData.setMetaValue(metaValue); + try { + metadataManagementService.createMetadata(metaData); + return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (MetadataKeyAlreadyExistsException e) { + String msg = "Found duplicate meta value entry for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } } else { + try { + Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); + if (metaData == null) { + String msg = + "Couldn't find application key data from meta data mgt service. Meta key: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + String[] metaValues = metaData.getMetaValue().split(":"); + String applicationId = metaValues[0]; + String keyMappingId = metaValues[1]; + //todo call the API key retrieving call, return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while getting meta data for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } return null; } } catch (APIServicesException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 1074edd9d7..d6a3bb2fc5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.apimgt.application.extension.internal; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import org.wso2.carbon.registry.core.service.TenantRegistryLoader; @@ -39,6 +40,7 @@ public class APIApplicationManagerExtensionDataHolder { private JWTClientManagerService jwtClientManagerService; private ConsumerRESTAPIServices consumerRESTAPIServices; private APIApplicationServices apiApplicationServices; + private MetadataManagementService metadataManagementService; private APIApplicationManagerExtensionDataHolder() { } @@ -123,4 +125,12 @@ public class APIApplicationManagerExtensionDataHolder { public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { this.apiApplicationServices = apiApplicationServices; } + + public MetadataManagementService getMetadataManagementService() { + return metadataManagementService; + } + + public void setMetadataManagementService(MetadataManagementService metadataManagementService) { + this.metadataManagementService = metadataManagementService; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index f761bfbf38..b3dc6dbd9d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -21,6 +21,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationService import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -178,4 +179,34 @@ public class APIApplicationManagerExtensionServiceComponent { } APIApplicationManagerExtensionDataHolder.getInstance().setApiApplicationServices(null); } + + /** + * Sets Meta Data Mgt service. + * + * @param metadataManagementService An instance of MetadataManagementService + */ + @Reference( + name = "meta.data.mgt.service", + service = io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetAMetaMgtServices") + protected void setMetaMgtServices(MetadataManagementService metadataManagementService) { + if (log.isDebugEnabled()) { + log.debug("Setting Meta data mgt Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setMetadataManagementService(metadataManagementService); + } + + /** + * Unset Meta Data Mgt service + * + * @param metadataManagementService An instance of MetadataManagementService + */ + protected void unsetAMetaMgtServices(MetadataManagementService metadataManagementService) { + if (log.isDebugEnabled()) { + log.debug("Unsetting Meta Data mgt Service"); + } + APIApplicationManagerExtensionDataHolder.getInstance().setMetadataManagementService(null); + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java index c8171451f6..8f492c2234 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java @@ -32,6 +32,8 @@ public class DCRRequest { @XmlElement(required = true) private String username; @XmlElement(required = true) + private String password; + @XmlElement(required = true) private String grantTypes; @XmlElement private String callBackUrl; @@ -98,4 +100,8 @@ public class DCRRequest { public void setValidityPeriod(int validityPeriod) { this.validityPeriod = validityPeriod; } + + public String getPassword() { return password; } + + public void setPassword(String password) { this.password = password; } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 5d2d371df5..53374f48c6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -55,6 +55,11 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.common + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.apimgt.extension.rest.api + + @@ -108,6 +113,7 @@ org.wso2.carbon.apimgt.keymgt.model;version="[9.28,10)", org.wso2.carbon.apimgt.keymgt.model.entity;version="[9.28,10)", org.wso2.carbon.apimgt.keymgt.service;version="[9.28,10)", + io.entgra.device.mgt.core.apimgt.extension.rest.api, org.wso2.carbon.context;version="[4.8,5)", org.wso2.carbon.user.api;version="[1.0,2)", org.wso2.carbon.user.core.service;version="[4.8,5)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtDataHolder.java index fd711781a1..96e96000be 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtDataHolder.java @@ -18,12 +18,16 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.internal; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtService; public class KeyMgtDataHolder { private static final KeyMgtDataHolder thisInstance = new KeyMgtDataHolder(); private KeyMgtService keyMgtService; + private ConsumerRESTAPIServices consumerRESTAPIServices; + private APIApplicationServices apiApplicationServices; public static KeyMgtDataHolder getInstance() { return thisInstance; @@ -37,4 +41,20 @@ public class KeyMgtDataHolder { this.keyMgtService = keyMgtService; } + + public ConsumerRESTAPIServices getConsumerRESTAPIServices() { + return consumerRESTAPIServices; + } + + public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + this.consumerRESTAPIServices = consumerRESTAPIServices; + } + + public APIApplicationServices getApiApplicationServices() { + return apiApplicationServices; + } + + public void setApiApplicationServices(APIApplicationServices apiApplicationServices) { + this.apiApplicationServices = apiApplicationServices; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java index 395bdc0107..96a05f15f5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/internal/KeyMgtServiceComponent.java @@ -18,15 +18,16 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.internal; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtService; import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtServiceImpl; 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.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.*; + @Component( name = "io.entgra.device.mgt.core.apimgt.keymgt.extension.internal.KeyMgtServiceComponent", immediate = true) @@ -63,4 +64,64 @@ public class KeyMgtServiceComponent { log.debug("De-activating Key Management Service Component"); } } + + /** + * Sets APIM Consumer REST API service. + * + * @param consumerRESTAPIServices An instance of ConsumerRESTAPIServices + */ + @Reference( + name = "APIM.consumer.service", + service = io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetConsumerRESTAPIServices") + protected void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + if (log.isDebugEnabled()) { + log.debug("Setting APIM Consumer REST API Service"); + } + KeyMgtDataHolder.getInstance().setConsumerRESTAPIServices(consumerRESTAPIServices); + } + + /** + * Unset APIM Consumer REST API service + * + * @param consumerRESTAPIServices An instance of ConsumerRESTAPIServices + */ + protected void unsetConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { + if (log.isDebugEnabled()) { + log.debug("Unsetting APIM Consumer REST API Service"); + } + KeyMgtDataHolder.getInstance().setConsumerRESTAPIServices(null); + } + + /** + * Sets DCR REST API service. + * + * @param apiApplicationServices An instance of APIApplicationServices + */ + @Reference( + name = "APIM.application.service", + service = io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetAPIApplicationServices") + protected void setAPIApplicationServices(APIApplicationServices apiApplicationServices) { + if (log.isDebugEnabled()) { + log.debug("Setting DCR REST API Service"); + } + KeyMgtDataHolder.getInstance().setApiApplicationServices(apiApplicationServices); + } + + /** + * Unset DCR REST API service + * + * @param apiApplicationServices An instance of APIApplicationServices + */ + protected void unsetAPIApplicationServices(APIApplicationServices apiApplicationServices) { + if (log.isDebugEnabled()) { + log.debug("Unsetting DCR REST API Service"); + } + KeyMgtDataHolder.getInstance().setApiApplicationServices(null); + } } From 730f3aaa0793ee34adc0ae3f88cee8e0ea5fc92a Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 13 Jun 2023 04:06:04 +0530 Subject: [PATCH 022/343] Improve API publishing functionality --- ...ApiApplicationRegistrationServiceImpl.java | 14 +-- .../APIManagementProviderServiceImpl.java | 84 ++++++++--------- .../publisher/APIPublisherServiceImpl.java | 91 ++++++++----------- .../application/mgt/core/util/OAuthUtils.java | 10 +- 4 files changed, 85 insertions(+), 114 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index f3fb909372..133a5d1a9c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -59,15 +59,13 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi } String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() .getRealmConfiguration().getAdminUserName(); - //todo - PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username); APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService(); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, APIUtil.getDefaultTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false, - ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD); + ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword()); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } catch (APIManagerException e) { String msg = "Error occurred while registering an application '" + applicationName + "'"; @@ -110,12 +108,10 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { - //todo - registrationProfile.getPassword(); ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, - registrationProfile.isAllowedToAllDomains(), validityPeriod); + registrationProfile.isAllowedToAllDomains(), validityPeriod, registrationProfile.getPassword()); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } @@ -123,13 +119,11 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(PrivilegedCarbonContext. getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName()); - //todo - registrationProfile.getPassword(); synchronized (ApiApplicationRegistrationServiceImpl.class) { ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, registrationProfile.getUsername(), - registrationProfile.isAllowedToAllDomains(), validityPeriod); + registrationProfile.isAllowedToAllDomains(), validityPeriod, registrationProfile.getPassword()); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } catch (APIManagerException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 6ab71de887..66ba639ea0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -45,7 +45,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.Unexpected import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.eclipse.jetty.http.MetaData; import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; @@ -64,7 +63,14 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; /** * This class represents an implementation of APIManagementProviderService. @@ -197,6 +203,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } String[] metaValues = metaData.getMetaValue().split(":"); + if (metaValues.length != 2) { + String msg = "Found invalid Meta value for meta key: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; //todo call the API key retrieving call, return apiApplicationKey; @@ -296,41 +307,29 @@ Otherwise, Generate Application Keys and return them } try { APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); - Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -// cnt rm -// // curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" - + Application application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); int applicationId = 0; Subscriber subscriber = null; if (application == null) { - subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); -// cnt rm + subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); if (subscriber == null) { // create subscriber - // todo:apim - apiConsumer.addSubscriber(username, ""); -// cnt rm - subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); -// cnt rm + // todo:resolve:apim - apiConsumer.addSubscriber(username, ""); + subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); } //create application application = new Application(applicationName, subscriber); application.setTier(ApiApplicationConstants.DEFAULT_TIER); application.setGroupId(""); application.setTokenType("OAUTH"); - // todo:apim - apiConsumer.addApplication(application, username); -// cnt rm - application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -// cnt rm + // todo:resolve:apim - apiConsumer.addApplication(application, username); + application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); } else { - subscriber = null; // todo:apim - apiConsumer.getSubscriber(username); -// cnt rm + subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); } Set subscribedAPIs = - null; // todo:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); - - //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/subscriptions?apiId=02e658e7-71c7-4b1d-a623-be145b789340" -// cnt rm + null; // todo:resolve:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); log.info("Already subscribed API count: " + subscribedAPIs.size()); @@ -339,9 +338,7 @@ Otherwise, Generate Application Keys and return them if (tags != null && tags.length > 0) { for (String tag : tags) { boolean startedTenantFlow = false; - Set apisWithTag = null; // todo:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); -// curl -k "https://localhost:9443/api/am/devportal/v3/apis" -// cnt rm + Set apisWithTag = null; // todo:resolve:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); /** * From APIM 4.0.0, APIs published in the super tenant can only be listed by @@ -364,8 +361,7 @@ Otherwise, Generate Application Keys and return them ". Caused by to inability to get super tenant username", e); } - apisWithTag = null; // todo:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); -// cnt rm + apisWithTag = null; // todo:resolve:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); startedTenantFlow = true; } @@ -378,8 +374,7 @@ Otherwise, Generate Application Keys and return them boolean subscriptionExist = false; if (subscribedAPIs.size() > 0) { for (SubscribedAPI subscribedAPI : subscribedAPIs) { - // todo:apim -// cnt rm + // todo:resolve:apim // if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { // subscriptionExist = true; // break; @@ -422,8 +417,7 @@ Otherwise, Generate Application Keys and return them * Oauth app for a child tenant. */ for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { - // todo:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); -// cnt rm + // todo:resolve:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); } } } @@ -454,7 +448,7 @@ Otherwise, Generate Application Keys and return them APIAdmin apiAdmin = new APIAdminImpl(); String keyManagerId = null; try { - List keyManagerConfigurations = null; // todo:apim - + List keyManagerConfigurations = null; // todo:resolve:apim - // apiAdmin.getKeyManagerConfigurationsByTenant(tenantDomain); if (keyManagerConfigurations != null) { for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { @@ -474,7 +468,7 @@ Otherwise, Generate Application Keys and return them "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + "\"username\":\"" + username + "\"}"; - Map keyDetails = null; // todo:apim - apiConsumer + Map keyDetails = null; // todo:resolve:apim - apiConsumer // .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", // allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", // jsonString, keyManagerId, tenantDomain); @@ -486,7 +480,7 @@ Otherwise, Generate Application Keys and return them return apiApplicationKey; } throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); -// todo:apim - commected as it says never throw since we commented apim calls above +// todo:resolve:apim - commected as it says never throw since we commented apim calls above // cnt rm // } catch (APIManagementException e) { } catch (Exception e) { @@ -525,11 +519,10 @@ Otherwise, Generate Application Keys and return them JWTClientManagerService jwtClientManagerService = APIApplicationManagerExtensionDataHolder.getInstance() .getJwtClientManagerService(); JWTClient jwtClient = jwtClientManagerService.getJWTClient(); - AccessTokenInfo accessTokenForAdmin = jwtClient + + return jwtClient .getAccessToken(clientCredentials.getConsumerKey(), clientCredentials.getConsumerSecret(), username, scopes); - - return accessTokenForAdmin; } catch (JWTClientException e) { String msg = "JWT Error occurred while registering Application to get access token."; log.error(msg, e); @@ -546,7 +539,8 @@ Otherwise, Generate Application Keys and return them } /** - * Get Client credentials + * Get Client credentials of application belongs to tenant admin + * * @param tenantDomain Tenant Domain * @param tags Tags * @param applicationName Application Name @@ -554,7 +548,7 @@ Otherwise, Generate Application Keys and return them * @param validityPeriod Validity Period * @return {@link ApiApplicationKey} * @throws APIManagerException if error occurred while generating access token - * @throws UserStoreException if error ocurred while getting admin username. + * @throws UserStoreException if error occurred while getting admin username. */ private ApiApplicationKey getClientCredentials(String tenantDomain, String[] tags, String applicationName, String tokenType, String validityPeriod) throws APIManagerException, UserStoreException { @@ -565,7 +559,6 @@ Otherwise, Generate Application Keys and return them registrationProfile.setTags(tags); registrationProfile.setApplicationName(applicationName); - ApiApplicationKey info = null; if (tenantDomain == null || tenantDomain.isEmpty()) { tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; } @@ -576,15 +569,14 @@ Otherwise, Generate Application Keys and return them PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration() .getAdminUserName()); - if (registrationProfile.getUsername() == null || registrationProfile.getUsername().isEmpty()) { - info = generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), - registrationProfile.getTags(), tokenType, null, - registrationProfile.isAllowedToAllDomains(), validityPeriod); - } + return generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), + registrationProfile.getTags(), tokenType, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminUserName(), + registrationProfile.isAllowedToAllDomains(), validityPeriod, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword()); } finally { PrivilegedCarbonContext.endTenantFlow(); } - return info; } private ApiApplicationInfo getApplicationInfo(String username, String password) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index 8d30d3daf2..fe98a8cef8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -153,17 +153,8 @@ public class APIPublisherServiceImpl implements APIPublisherService { } if (!apiFound) { // add new scopes as shared scopes - for (ApiScope apiScope : apiConfig.getScopes()) { - if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, - apiScope.getKey())) { - Scope scope = new Scope(); - scope.setName(apiScope.getName()); - scope.setDescription(apiScope.getDescription()); - scope.setKey(apiScope.getKey()); - scope.setRoles(apiScope.getRoles()); - publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); - } - } + addNewSharedScope(apiConfig.getScopes(), publisherRESTAPIServices, apiApplicationKey, + accessTokenInfo); APIInfo api = getAPI(apiConfig, true); JSONObject createdAPI = publisherRESTAPIServices.addAPI(apiApplicationKey, accessTokenInfo, api); if (apiConfig.getEndpointType() != null && "WS".equals(apiConfig.getEndpointType())) { @@ -202,7 +193,6 @@ public class APIPublisherServiceImpl implements APIPublisherService { } } else { if (WebappPublisherConfig.getInstance().isEnabledUpdateApi()) { - // With 4.x to 5.x upgrade // - there cannot be same local scope assigned in 2 different APIs // - local scopes will be deprecated in the future, so need to move all scopes as shared scopes @@ -217,50 +207,17 @@ public class APIPublisherServiceImpl implements APIPublisherService { // 1. add new scopes as shared scopes // 2. update the API adding scopes for the URI Templates - Set scopesToMoveAsSharedScopes = new HashSet<>(); - for (ApiScope apiScope : apiConfig.getScopes()) { - // if the scope is not available as shared scope, and it is assigned to an API as a local scope - // need remove the local scope and add as a shared scope - if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, - apiScope.getKey())) { - //resolve- todo:apim- resolve -// if (apiProvider.isScopeKeyAssignedLocally(apiIdentifier, apiScope.getKey(), tenantId)) { - if (true) { - // collect scope to move as shared scopes - scopesToMoveAsSharedScopes.add(apiScope); - } else { - // if new scope add as shared scope - Scope scope = new Scope(); - scope.setName(apiScope.getName()); - scope.setDescription(apiScope.getDescription()); - scope.setKey(apiScope.getKey()); - scope.setRoles(apiScope.getRoles()); - publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); + // It is guaranteed that there is no local scope if we update from 5.0.0 to the most + // recent version. Therefore, if the scope is not already available as a shared scope, + // new scopes must be added as shared scopes. Additionally, it is necessary to + // upgrade to 5.0.0 first before updating from 5.0.0 to the most recent version if we + // are updating from a version that is older than 5.0.0. - } - } - } + addNewSharedScope(apiConfig.getScopes(), publisherRESTAPIServices, apiApplicationKey, + accessTokenInfo); - // Get existing API - JSONObject existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, accessTokenInfo, - apiIdentifier); - if (scopesToMoveAsSharedScopes.size() > 0) { - // update API to remove local scopes - APIInfo api = getAPI(apiConfig, false); - api.setLifeCycleStatus(existingAPI.getString("lifeCycleStatus")); - publisherRESTAPIServices.updateApi(apiApplicationKey, accessTokenInfo, api); - - for (ApiScope apiScope : scopesToMoveAsSharedScopes) { - Scope scope = new Scope(); - scope.setName(apiScope.getName()); - scope.setDescription(apiScope.getDescription()); - scope.setKey(apiScope.getKey()); - scope.setRoles(apiScope.getRoles()); - publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); - } - } - - existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, accessTokenInfo, apiIdentifier); + JSONObject existingAPI = publisherRESTAPIServices.getApi(apiApplicationKey, + accessTokenInfo, apiIdentifier); APIInfo api = getAPI(apiConfig, true); api.setLastUpdatedTime(existingAPI.getString("lifeCycleStatus")); api.setId(existingAPI.getString("id")); @@ -408,6 +365,32 @@ public class APIPublisherServiceImpl implements APIPublisherService { } } + /** + * Add new Shared Scopes + * + * @param apiScopes set of API scopes + * @param publisherRESTAPIServices {@link PublisherRESTAPIServices} + * @param apiApplicationKey API application Key + * @param accessTokenInfo Details of access token + * @throws BadRequestException if invalid payload receives to add new shared scopes. + * @throws UnexpectedResponseException if the response is not either 200 or 400. + * @throws APIServicesException if error occurred while processing the response. + */ + private void addNewSharedScope(Set apiScopes, PublisherRESTAPIServices publisherRESTAPIServices, + APIApplicationKey apiApplicationKey, AccessTokenInfo accessTokenInfo) throws BadRequestException, UnexpectedResponseException, APIServicesException { + for (ApiScope apiScope : apiScopes) { + if (!publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, + apiScope.getKey())) { + Scope scope = new Scope(); + scope.setName(apiScope.getName()); + scope.setDescription(apiScope.getDescription()); + scope.setKey(apiScope.getKey()); + scope.setRoles(apiScope.getRoles()); + publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); + } + } + } + @Override public void updateScopeRoleMapping() throws APIManagerPublisherException { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java index 272a5b45b0..c5975cb500 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java @@ -55,16 +55,18 @@ public class OAuthUtils { try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(PrivilegedCarbonContext. - getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName()); + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminUserName(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); APIManagementProviderService apiManagementProviderService = (APIManagementProviderService) ctx. getOSGiService(APIManagementProviderService.class, null); apiApplicationKeyInfo = apiManagementProviderService. generateAndRetrieveApplicationKeys(registrationProfile.getApplicationName(), registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE, - null, registrationProfile.isAllowedToAllDomains(), - Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD); + username, registrationProfile.isAllowedToAllDomains(), + Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword()); } finally { PrivilegedCarbonContext.endTenantFlow(); } From 7826e5c285eabf7ef73b276aeb2b4b5d83c1bafa Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 13 Jun 2023 07:22:14 +0530 Subject: [PATCH 023/343] Fix key generation method --- .../APIManagementProviderServiceImpl.java | 10 ++- .../rest/api/ConsumerRESTAPIServices.java | 8 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 90 +++++++++++++++++-- 3 files changed, 100 insertions(+), 8 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 66ba639ea0..7ab72f71b3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -24,6 +24,7 @@ import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplication import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; import io.entgra.device.mgt.core.apimgt.application.extension.util.APIManagerUtil; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; @@ -172,7 +173,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); + KeyManager keyManager = consumerRESTAPIServices.getAllKeyManagers(applicationInfo)[0]; + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application, keyManager); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -210,7 +212,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; - //todo call the API key retrieving call, return apiApplicationKey; + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(applicationInfo, applicationId, keyMappingId); + ApiApplicationKey apiApplicationKey = null; + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; } catch (MetadataManagementException e) { String msg = "Error occurred while getting meta data for meta key: " + applicationName; log.error(msg, e); 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index fc90c14463..0eda468baa 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -37,6 +37,9 @@ public interface ConsumerRESTAPIServices { Application createApplication(ApiApplicationInfo applicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; + Application deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; @@ -49,7 +52,10 @@ public interface ConsumerRESTAPIServices { Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey generateApplicationKeys(ApiApplicationInfo applicationInfo, Application application) + ApplicationKey generateApplicationKeys(ApiApplicationInfo applicationInfo, Application application, KeyManager keyManager) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + + ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index fe341bc416..a4594d6678 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -179,6 +179,46 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public Application deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String deleteScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; + + Request request = new Request.Builder() + .url(deleteScopesUrl) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()) + .delete() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), Application.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return deleteApplication(refreshedApiApplicationInfo, applicationId); + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + 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(msg, e); + } + } + @Override public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { @@ -361,20 +401,20 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application) + public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application, KeyManager keyManager) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + Constants.SLASH + + String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + application.getApplicationId() + "/generate-keys"; String keyInfo = "{\n" + " \"keyType\": \"PRODUCTION\",\n" + - " \"keyManager\": \"Resident Key Manager\",\n" + + " \"keyManager\": \""+ keyManager.getName() +"\",\n" + " \"grantTypesToBeSupported\": [\n" + " \"password\",\n" + " \"client_credentials\"\n" + " ],\n" + - " \"callbackUrl\": \"http://sample.com/callback/url\",\n" + + " \"callbackUrl\": \"\",\n" + " \"scopes\": [\n" + " \"am_application_scope\",\n" + " \"default\"\n" + @@ -402,7 +442,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return generateApplicationKeys(refreshedApiApplicationKey, application); + return generateApplicationKeys(refreshedApiApplicationKey, application, keyManager); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -418,6 +458,46 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; + + Request request = new Request.Builder() + .url(getKeyDetails) + .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()) + .get() + .build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), ApplicationKey.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getKeyDetails(refreshedApiApplicationKey, applicationId, keyMapId); + } 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(msg, e); + } + } + @Override public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { From 1edaa8a2a506f3d1ed0382414c2bda7ea8b5c33a Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 13 Jun 2023 08:48:22 +0530 Subject: [PATCH 024/343] Improve API key generating method --- .../APIManagementProviderServiceImpl.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 7ab72f71b3..293faeabbb 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -173,7 +173,15 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { - KeyManager keyManager = consumerRESTAPIServices.getAllKeyManagers(applicationInfo)[0]; + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(applicationInfo); + KeyManager keyManager; + if (keyManagers.length == 1) { + keyManager = keyManagers[0]; + } else { + String msg = + "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; + throw new APIManagerException(msg); + } ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application, keyManager); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); @@ -199,21 +207,22 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe try { Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); if (metaData == null) { - String msg = - "Couldn't find application key data from meta data mgt service. Meta key: " + applicationName; + String msg = "Couldn't find application key data from meta data mgt service. Meta key: " + + applicationName; log.error(msg); throw new APIManagerException(msg); } String[] metaValues = metaData.getMetaValue().split(":"); if (metaValues.length != 2) { - String msg = "Found invalid Meta value for meta key: " + applicationName; + String msg = "Found invalid Meta value for meta key: " + applicationName + ". Meta Value: " + + metaData.getMetaValue(); log.error(msg); throw new APIManagerException(msg); } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(applicationInfo, applicationId, keyMappingId); - ApiApplicationKey apiApplicationKey = null; + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); return apiApplicationKey; @@ -222,7 +231,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe log.error(msg, e); throw new APIManagerException(msg, e); } - return null; } } catch (APIServicesException e) { String msg = "Error occurred while processing the response of APIM REST endpoints."; From d40dccc240ed908ba8d27ba07a94374272cbe045 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 14 Jun 2023 12:37:10 +0530 Subject: [PATCH 025/343] Add improvements to token generation for devices --- .../extension/service/KeyMgtServiceImpl.java | 1 + .../impl/DeviceManagementServiceImpl.java | 22 +++++++++++++++++++ .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 21 ++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 936011e90f..a9dd182ec2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -312,6 +312,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { * @throws KeyMgtException if any error occurs while creating response object */ private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags, int validityPeriod) throws KeyMgtException { + //todo modify this to pass the password as well String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod); RequestBody oauthAppCreationPayload = RequestBody.Companion.create(oauthAppCreationPayloadStr, JSON); kmConfig = getKeyManagerConfig(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 579f09c606..9bef3e44fc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -798,6 +798,28 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); try { //todo - lasantha - can't get password from here + + try { +// DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username, +// "client_credentials", null, new String[] {"device_management"}, false, validityTime); +// deviceConfig.setClientId(dcrResponse.getClientId()); +// deviceConfig.setClientSecret(dcrResponse.getClientSecret()); + + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + JWTClientManagerService jwtClientManagerService = (JWTClientManagerService) ctx. + getOSGiService(JWTClientManagerService.class, null); + JWTClient jwtClient = jwtClientManagerService.getJWTClient(); +// AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(apiApplicationKey.getConsumerKey(), +// apiApplicationKey.getConsumerSecret(), +// username, Constants.ApplicationInstall.SUBSCRIPTION_SCOPE); + } catch (JWTClientException e) { + String msg = "Error while generating an OAuth token for user " + username; + log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } + + //todo call REST APIs DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username, "client_credentials", null, new String[] {"device_management"}, false, validityTime); deviceConfig.setClientId(dcrResponse.getClientId()); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index 1073737ef5..7bba263529 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceTypeVersionWrapper; @@ -154,6 +155,7 @@ public class DeviceMgtAPIUtils { private static volatile SubscriptionManager subscriptionManager; private static volatile ApplicationManager applicationManager; + private static volatile ConsumerRESTAPIServices consumerRESTAPIServices; static { String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); @@ -387,6 +389,25 @@ public class DeviceMgtAPIUtils { return otpManagementService; } + /** + * Initializing and accessing method for APIM Consumer REST API. + * + * @return ConsumerRESTAPIServices instance + * @throws IllegalStateException if ConsumerRESTAPIServices cannot be initialized + */ + public static synchronized ConsumerRESTAPIServices getConsumerRESTAPIServices() { + if (consumerRESTAPIServices == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + consumerRESTAPIServices = (ConsumerRESTAPIServices) ctx.getOSGiService(ConsumerRESTAPIServices.class, null); + if (consumerRESTAPIServices == null) { + String msg = "Consumer Rest API service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + return consumerRESTAPIServices; + } + public static RegistryService getRegistryService() { RegistryService registryService; PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); From 7dfcc0e33cb346a36e537d95d6b36d7c33914663 Mon Sep 17 00:00:00 2001 From: Pasindu Rupasinghe Date: Thu, 15 Jun 2023 02:50:59 +0000 Subject: [PATCH 026/343] Get token separately for REST calls Co-authored-by: Pasindu Rupasinghe Co-committed-by: Pasindu Rupasinghe --- .../APIManagementProviderServiceImpl.java | 18 +- .../rest/api/ConsumerRESTAPIServices.java | 25 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 457 +++++++++++------- .../impl/DeviceManagementServiceImpl.java | 14 + 4 files changed, 331 insertions(+), 183 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 293faeabbb..2996174734 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -138,7 +138,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Map queryParams = new HashMap<>(); queryParams.put("tag", tag); - APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, queryParams, headerParams); + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, null, queryParams, headerParams); uniqueApiList.addAll(List.of(apiInfos)); Set taggedAPISet = new HashSet<>(uniqueApiList); @@ -147,21 +147,22 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName); + consumerRESTAPIServices.getAllApplications(applicationInfo, null, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; boolean isNewApplication = false; if (applications.length == 0) { isNewApplication = true; application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); - application = consumerRESTAPIServices.createApplication(applicationInfo, application); + application = consumerRESTAPIServices.createApplication(applicationInfo, null, application); addSubscriptions(application, uniqueApiList, applicationInfo); } else { if (applications.length == 1) { Optional applicationOpt = Arrays.stream(applications).findFirst(); application = applicationOpt.get(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, application.getApplicationId()); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, null, + application.getApplicationId()); Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); addSubscriptions(application, uniqueApiList, applicationInfo); } else { @@ -173,7 +174,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { - KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(applicationInfo); + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(applicationInfo, null); KeyManager keyManager; if (keyManagers.length == 1) { keyManager = keyManagers[0]; @@ -182,7 +183,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; throw new APIManagerException(msg); } - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application, keyManager); + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, null, + application.getApplicationId(), keyManager.getName(), keyType, validityTime); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -221,7 +223,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; - ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(applicationInfo, applicationId, keyMappingId); + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(applicationInfo, null, applicationId, keyMappingId); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -273,7 +275,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.getApplicationId()); subscriptionList.add(subscription); }); - consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, subscriptionList); + consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, null, subscriptionList); } /** 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index 0eda468baa..df81bff172 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -28,36 +28,39 @@ import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - Application[] getAllApplications(ApiApplicationInfo applicationInfo, String appName) + Application[] getAllApplications(ApiApplicationInfo applicationInfo, String accessToken, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application getDetailsOfAnApplication(ApiApplicationInfo applicationInfo, String applicationId) + Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application createApplication(ApiApplicationInfo applicationInfo, Application application) + Application createApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) + Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) + Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - APIInfo[] getAllApis(ApiApplicationInfo applicationInfo, Map queryParam, Map headerParams) + APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, String accessToken, Map queryParams, + Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, Subscription subscriptions) + Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, String accessToken, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) + Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, + List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey generateApplicationKeys(ApiApplicationInfo applicationInfo, Application application, KeyManager keyManager) + ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, + String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) + ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) + KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo, String accessToken) 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index a4594d6678..dc17ff623f 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -50,16 +50,22 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public Application[] getAllApplications(ApiApplicationInfo applicationInfo, String appName) + public Application[] getAllApplications(ApiApplicationInfo applicationInfo, String accessToken, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; - Request request = new Request.Builder() - .url(getAllApplicationsUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + applicationInfo.getAccess_token()) - .get() - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(getAllApplicationsUrl); + if (!(applicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + applicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); @@ -67,13 +73,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray applicationList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(applicationList.toString(), Application[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), - applicationInfo.getClientId(), applicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getAllApplications(refreshedApiApplicationInfo, appName); + if (!(applicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), + applicationInfo.getClientId(), applicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getAllApplications(refreshedApiApplicationInfo, null, appName); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -90,29 +102,41 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) + public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; - Request request = new Request.Builder() - .url(getAllApplicationsUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .get() - .build(); + String getDetailsOfAPPUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; + + Request.Builder builder = new Request.Builder(); + builder.url(getDetailsOfAPPUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getDetailsOfAnApplication(refreshedApiApplicationInfo, applicationId); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getDetailsOfAnApplication(refreshedApiApplicationInfo, null, applicationId); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -129,7 +153,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application createApplication(ApiApplicationInfo apiApplicationInfo, Application application) + public Application createApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; @@ -143,27 +167,38 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { " \"attributes\": " + application.getAttributes().toString() + ",\n" + " \"subscriptionScopes\": " + gson.toJson(application.getSubscriptionScopes()) + "\n" + "}"; - RequestBody requestBody = RequestBody.create(JSON, applicationInfo); - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .post(requestBody) - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(getAllScopesUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.post(requestBody); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return createApplication(refreshedApiApplicationInfo, application); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return createApplication(refreshedApiApplicationInfo, null, application); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -180,30 +215,41 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) + public Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String deleteScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; - Request request = new Request.Builder() - .url(deleteScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .delete() - .build(); + Request.Builder builder = new Request.Builder(); + builder.url(deleteScopesUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.delete(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - return gson.fromJson(response.body().string(), Application.class); + return true; } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return deleteApplication(refreshedApiApplicationInfo, applicationId); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return deleteApplication(refreshedApiApplicationInfo, null, applicationId); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -220,16 +266,22 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) + public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .get() - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(getAllScopesUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); @@ -237,13 +289,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray subscriptionList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(subscriptionList.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getAllSubscriptions(rehreshedApiApplicationInfo, applicationId); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getAllSubscriptions(rehreshedApiApplicationInfo, null, applicationId); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -260,20 +318,25 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public APIInfo[] getAllApis(ApiApplicationInfo applicationInfo, Map queryParams, + public APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, String accessToken, Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAPIsURL = endPointPrefix + Constants.DEV_PORTAL_API; + StringBuilder getAPIsURL = new StringBuilder(endPointPrefix + Constants.DEV_PORTAL_API); for (Map.Entry query : queryParams.entrySet()) { - getAPIsURL = getAPIsURL + Constants.AMPERSAND + query.getKey() + Constants.EQUAL + query.getValue(); + getAPIsURL.append(Constants.AMPERSAND).append(query.getKey()).append(Constants.EQUAL).append(query.getValue()); } Request.Builder builder = new Request.Builder(); - builder.url(getAPIsURL); - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + applicationInfo.getAccess_token()); + builder.url(getAPIsURL.toString()); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } for (Map.Entry header : headerParams.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); } @@ -286,13 +349,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray apiList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(apiList.toString(), APIInfo[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), - applicationInfo.getClientId(), applicationInfo.getClientSecret()); - ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getAllApis(rehreshedApiApplicationInfo, queryParams, headerParams); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getAllApis(rehreshedApiApplicationInfo, null, queryParams, headerParams); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -309,10 +378,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscription(ApiApplicationInfo applicationInfo, Subscription subscriptions) + public Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, String accessToken, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API; + String createSubscriptionUrl = endPointPrefix + Constants.SUBSCRIPTION_API; String subscriptionObject = "{\n" + " \"applicationId\": \"" + subscriptions.getApplicationId() + "\",\n" + @@ -322,25 +391,37 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { "}"; RequestBody requestBody = RequestBody.create(JSON, subscriptionObject); - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + applicationInfo.getAccess_token()) - .post(requestBody) - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(createSubscriptionUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.post(requestBody); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Subscription.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), - applicationInfo.getClientId(), applicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); - //TODO: max attempt count - return createSubscription(refreshedApiApplicationInfo, subscriptions); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return createSubscription(refreshedApiApplicationInfo, null, subscriptions); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -357,20 +438,26 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) + public Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, + List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; + String createSubscriptionsUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; String subscriptionsList = gson.toJson(subscriptions); - RequestBody requestBody = RequestBody.create(JSON, subscriptionsList); - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .post(requestBody) - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(createSubscriptionsUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.post(requestBody); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); @@ -378,13 +465,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray subscriptionsArray = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(subscriptionsArray.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return createSubscriptions(refreshedApiApplicationInfo, subscriptions); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return createSubscriptions(refreshedApiApplicationInfo, null, subscriptions); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -401,15 +494,16 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application, KeyManager keyManager) + public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, + String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException { - String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + - application.getApplicationId() + "/generate-keys"; + String generateApplicationKeysUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + + applicationId + "/generate-keys"; String keyInfo = "{\n" + - " \"keyType\": \"PRODUCTION\",\n" + - " \"keyManager\": \""+ keyManager.getName() +"\",\n" + + " \"keyType\": \"" + keyType + "\",\n" + + " \"keyManager\": \"" + keyManager + "\",\n" + " \"grantTypesToBeSupported\": [\n" + " \"password\",\n" + " \"client_credentials\"\n" + @@ -419,30 +513,42 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { " \"am_application_scope\",\n" + " \"default\"\n" + " ],\n" + - " \"validityTime\": 3600,\n" + + " \"validityTime\": " + validityTime + ",\n" + " \"additionalProperties\": {}\n" + "}"; RequestBody requestBody = RequestBody.create(JSON, keyInfo); - Request request = new Request.Builder() - .url(getAllScopesUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .post(requestBody) - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(generateApplicationKeysUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.post(requestBody); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return generateApplicationKeys(refreshedApiApplicationKey, application, keyManager); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return generateApplicationKeys(refreshedApiApplicationKey, null, applicationId, keyManager, validityTime, keyType); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -459,30 +565,41 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) + public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; - Request request = new Request.Builder() - .url(getKeyDetails) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .get() - .build(); + Request.Builder builder = new Request.Builder(); + builder.url(getKeyDetails); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getKeyDetails(refreshedApiApplicationKey, applicationId, keyMapId); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getKeyDetails(refreshedApiApplicationKey, null, applicationId, keyMapId); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -499,16 +616,22 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) + public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo, String accessToken) throws APIServicesException, BadRequestException, UnexpectedResponseException { String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; - Request request = new Request.Builder() - .url(getAllKeyManagersUrl) - .addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()) - .get() - .build(); + + Request.Builder builder = new Request.Builder(); + builder.url(getAllKeyManagersUrl); + if (!(apiApplicationInfo == null) && accessToken == null) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + accessToken); + } + builder.get(); + Request request = builder.build(); try { Response response = client.newCall(request).execute(); @@ -516,13 +639,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray keyManagerList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(keyManagerList.toString(), KeyManager[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - return getAllKeyManagers(refreshedApiApplicationInfo); + if (!(apiApplicationInfo == null) && accessToken == null) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + return getAllKeyManagers(refreshedApiApplicationInfo, null); + } else { + String msg = "Invalid or null access token"; + log.error(msg); + throw new BadRequestException(msg); + } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 9bef3e44fc..e4ab0647ef 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -19,6 +19,10 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import com.google.gson.Gson; +import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; +import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; +import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; @@ -825,6 +829,13 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { deviceConfig.setClientId(dcrResponse.getClientId()); deviceConfig.setClientSecret(dcrResponse.getClientSecret()); + APIManagementProviderService apiManagementProviderService = new APIManagementProviderServiceImpl(); + ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, + new String[] {"device_management"}, null, username, false, String.valueOf(validityTime), null); + + deviceConfig.setClientId(apiApplicationKey.getConsumerKey()); + deviceConfig.setClientSecret(apiApplicationKey.getConsumerSecret()); + StringBuilder scopes = new StringBuilder("device:" + type.replace(" ", "") + ":" + id); for (String topic : mqttEventTopicStructure) { if (topic.contains("${deviceId}")) { @@ -871,6 +882,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } catch (APIManagerException e) { + String msg = "Error while calling rest Call for application key generation"; + log.error(msg, e); } return Response.status(Response.Status.OK).entity(deviceConfig).build(); From 43ef801ac3219df6de87cae66d6bd86a5c8448f8 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 15 Jun 2023 09:48:36 +0530 Subject: [PATCH 027/343] Improvements in consumer rest apis --- .../rest/api/ConsumerRESTAPIServicesImpl.java | 120 +++++++++++------- 1 file changed, 73 insertions(+), 47 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index dc17ff623f..076d735112 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -50,16 +50,17 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public Application[] getAllApplications(ApiApplicationInfo applicationInfo, String accessToken, String appName) + public Application[] getAllApplications(ApiApplicationInfo apiApplicationInfo, String accessToken, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; Request.Builder builder = new Request.Builder(); builder.url(getAllApplicationsUrl); - if (!(applicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + applicationInfo.getAccess_token()); + + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + accessToken); @@ -73,18 +74,18 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray applicationList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(applicationList.toString(), Application[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(applicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(applicationInfo.getRefresh_token(), - applicationInfo.getClientId(), applicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(applicationInfo, refreshedAccessToken); + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count return getAllApplications(refreshedApiApplicationInfo, null, appName); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; @@ -105,11 +106,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getDetailsOfAPPUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); builder.url(getDetailsOfAPPUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -124,7 +126,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -133,9 +135,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return getDetailsOfAnApplication(refreshedApiApplicationInfo, null, applicationId); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; @@ -156,6 +158,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public Application createApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; String applicationInfo = "{\n" + @@ -171,7 +174,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -186,7 +189,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -195,9 +198,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return createApplication(refreshedApiApplicationInfo, null, application); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; @@ -218,11 +221,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String deleteScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); builder.url(deleteScopesUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -237,7 +241,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return true; } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -246,9 +250,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return deleteApplication(refreshedApiApplicationInfo, null, applicationId); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; @@ -269,11 +273,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -289,7 +294,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray subscriptionList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(subscriptionList.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -298,9 +303,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return getAllSubscriptions(rehreshedApiApplicationInfo, null, applicationId); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; @@ -322,6 +327,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); StringBuilder getAPIsURL = new StringBuilder(endPointPrefix + Constants.DEV_PORTAL_API); for (Map.Entry query : queryParams.entrySet()) { @@ -330,7 +336,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(getAPIsURL.toString()); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -349,7 +355,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray apiList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(apiList.toString(), APIInfo[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -358,9 +364,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return getAllApis(rehreshedApiApplicationInfo, null, queryParams, headerParams); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; @@ -381,6 +387,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, String accessToken, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String createSubscriptionUrl = endPointPrefix + Constants.SUBSCRIPTION_API; String subscriptionObject = "{\n" + @@ -394,7 +401,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(createSubscriptionUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -409,7 +416,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Subscription.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -418,9 +425,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return createSubscription(refreshedApiApplicationInfo, null, subscriptions); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; @@ -442,6 +449,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String createSubscriptionsUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; String subscriptionsList = gson.toJson(subscriptions); @@ -449,7 +457,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(createSubscriptionsUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -465,7 +473,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray subscriptionsArray = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(subscriptionsArray.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -474,9 +482,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return createSubscriptions(refreshedApiApplicationInfo, null, subscriptions); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; @@ -498,6 +506,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String generateApplicationKeysUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/generate-keys"; @@ -521,7 +530,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(generateApplicationKeysUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -536,7 +545,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -545,9 +554,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return generateApplicationKeys(refreshedApiApplicationKey, null, applicationId, keyManager, validityTime, keyType); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; @@ -568,11 +577,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; Request.Builder builder = new Request.Builder(); builder.url(getKeyDetails); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -587,7 +597,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -596,9 +606,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { //TODO: max attempt count return getKeyDetails(refreshedApiApplicationKey, null, applicationId, keyMapId); } else { - String msg = "Invalid or null access token"; + String msg = "Invalid access token. Unauthorized request"; log.error(msg); - throw new BadRequestException(msg); + throw new APIServicesException(msg); } } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; @@ -619,11 +629,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo, String accessToken) throws APIServicesException, BadRequestException, UnexpectedResponseException { + boolean token = isTokenNull(apiApplicationInfo, accessToken); String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; Request.Builder builder = new Request.Builder(); builder.url(getAllKeyManagersUrl); - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + apiApplicationInfo.getAccess_token()); } else { @@ -639,7 +650,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray keyManagerList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(keyManagerList.toString(), KeyManager[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!(apiApplicationInfo == null) && accessToken == null) { + if (!token) { APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), @@ -677,4 +688,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { return applicationInfo; } + + private boolean isTokenNull(ApiApplicationInfo apiApplicationInfo, String accessToken) throws BadRequestException { + + boolean token; + if ((!(accessToken == null) && apiApplicationInfo == null)) { + token = true; + } else if (!(apiApplicationInfo == null) && accessToken == null) { + token = false; + } else { + String msg = "Null access token or Rest Application info"; + log.error(msg); + throw new BadRequestException(msg); + } + return token; + } } From bfaeb1778f12b2f09efa82fd9dee806409c0d685 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Fri, 16 Jun 2023 08:03:11 +0530 Subject: [PATCH 028/343] Add JWT support --- .../APIManagementProviderService.java | 5 + .../APIManagementProviderServiceImpl.java | 149 ++++++++++++++++++ .../extension/api/KeyManagerServiceImpl.java | 4 +- .../extension/service/KeyMgtService.java | 3 +- .../extension/service/KeyMgtServiceImpl.java | 53 +++++-- .../impl/DeviceManagementServiceImpl.java | 42 ++--- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 21 +++ 7 files changed, 243 insertions(+), 34 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index 51ac50cf08..1e561ae465 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -55,6 +55,11 @@ public interface APIManagementProviderService { boolean isAllowedAllDomains, String validityTime, String password) throws APIManagerException; + ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, + String keyType, + boolean isAllowedAllDomains, + String validityTime, String accessToken) throws APIManagerException; + /** * Remove APIM Application. */ diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 2996174734..11953fa3dc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -114,6 +114,138 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } + @Override + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, + String keyType, + boolean isAllowedAllDomains, + String validityTime, String accessToken) throws APIManagerException { + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + try { + List uniqueApiList = new ArrayList<>(); + + Map headerParams = new HashMap<>(); + if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) { + headerParams.put("X-WSO2-Tenant", "carbon.super"); + } + + for (String tag : tags) { + Map queryParams = new HashMap<>(); + queryParams.put("tag", tag); + + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(null, accessToken, queryParams, headerParams); + + uniqueApiList.addAll(List.of(apiInfos)); + Set taggedAPISet = new HashSet<>(uniqueApiList); + uniqueApiList.clear(); + uniqueApiList.addAll(taggedAPISet); + } + + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = + consumerRESTAPIServices.getAllApplications(null, accessToken, applicationName); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; + boolean isNewApplication = false; + if (applications.length == 0) { + isNewApplication = true; + application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); + application.setName(applicationName); + application = consumerRESTAPIServices.createApplication(null, accessToken, application); + addSubscriptions(application, uniqueApiList, accessToken); + } else { + if (applications.length == 1) { + Optional applicationOpt = + Arrays.stream(applications).findFirst(); + application = applicationOpt.get(); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, accessToken, + application.getApplicationId()); + Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); + addSubscriptions(application, uniqueApiList, accessToken); + } else { + String msg = "Found more than one application for application name: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + } + + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); + if (isNewApplication) { + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(null, accessToken); + KeyManager keyManager; + if (keyManagers.length == 1) { + keyManager = keyManagers[0]; + } else { + String msg = + "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; + throw new APIManagerException(msg); + } + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(null, accessToken, + application.getApplicationId(), keyManager.getName(), keyType, validityTime); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + + Metadata metaData = new Metadata(); + metaData.setMetaKey(applicationName); + String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); + metaData.setMetaValue(metaValue); + try { + metadataManagementService.createMetadata(metaData); + return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (MetadataKeyAlreadyExistsException e) { + String msg = "Found duplicate meta value entry for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } + } else { + try { + Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); + if (metaData == null) { + String msg = "Couldn't find application key data from meta data mgt service. Meta key: " + + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + String[] metaValues = metaData.getMetaValue().split(":"); + if (metaValues.length != 2) { + String msg = "Found invalid Meta value for meta key: " + applicationName + ". Meta Value: " + + metaData.getMetaValue(); + log.error(msg); + throw new APIManagerException(msg); + } + String applicationId = metaValues[0]; + String keyMappingId = metaValues[1]; + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(null, accessToken, applicationId, + keyMappingId); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while getting meta data for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } + } + } catch (APIServicesException e) { + String msg = "Error occurred while processing the response of APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (BadRequestException e) { + String msg = "Provided incorrect payload when invoking APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (UnexpectedResponseException e) { + String msg = "Error occurred while invoking APIM REST endpoints."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } + } + @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, @@ -278,6 +410,23 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, null, subscriptionList); } + private void addSubscriptions( + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, + List apiInfos, String accessToken) + throws BadRequestException, UnexpectedResponseException, APIServicesException { + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + List subscriptionList = new ArrayList<>(); + apiInfos.forEach(apiInfo -> { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.getApplicationId()); + subscriptionList.add(subscription); + }); + consumerRESTAPIServices.createSubscriptions(null, accessToken, subscriptionList); + } + /** * {@inheritDoc} */ diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java index dbfee32906..8a5c49e4d6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.KeyMgtExcepti import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtService; import io.entgra.device.mgt.core.apimgt.keymgt.extension.service.KeyMgtServiceImpl; import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnAuthorizedException; +import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -47,7 +48,8 @@ public class KeyManagerServiceImpl implements KeyManagerService { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); //todo lasantha - can pass password from here - modify DCRRequest object DCRResponse resp = keyMgtService.dynamicClientRegistration(dcrRequest.getApplicationName(), dcrRequest.getUsername(), - dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod()); + dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), + dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod(), dcrRequest.getPassword()); return Response.status(Response.Status.CREATED).entity(gson.toJson(resp)).build(); } catch (KeyMgtException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java index f08f92d8c7..92015842ba 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java @@ -35,11 +35,12 @@ public interface KeyMgtService { * @param callBackUrl callback url of the application * @param tags api tags for api subscription of the application * @param isSaasApp if the application is a saas app + * @param password Password of the owner * @return @{@link DCRResponse} DCR Response object with client credentials * @throws KeyMgtException if any error occurs during DCR process */ DCRResponse dynamicClientRegistration(String clientName, String owner, String grantTypes, String callBackUrl, - String[] tags, boolean isSaasApp, int validityPeriod) throws KeyMgtException; + String[] tags, boolean isSaasApp, int validityPeriod, String password) throws KeyMgtException; /*** * This method will handle the access token requests diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index a9dd182ec2..9de536da5e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -19,9 +19,13 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.service; import com.google.gson.Gson; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.*; import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.BadRequestException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.KeyMgtException; +import io.entgra.device.mgt.core.apimgt.keymgt.extension.internal.KeyMgtDataHolder; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; import io.entgra.device.mgt.core.device.mgt.core.config.keymanager.KeyManagerConfigurations; @@ -62,7 +66,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { String subTenantUserUsername, subTenantUserPassword, keyManagerName, msg = null; public DCRResponse dynamicClientRegistration(String clientName, String owner, String grantTypes, String callBackUrl, - String[] tags, boolean isSaasApp, int validityPeriod) throws KeyMgtException { + String[] tags, boolean isSaasApp, int validityPeriod, String password) throws KeyMgtException { if (owner == null) { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -90,13 +94,14 @@ public class KeyMgtServiceImpl implements KeyMgtService { kmConfig = getKeyManagerConfig(); if (KeyMgtConstants.SUPER_TENANT.equals(tenantDomain)) { - OAuthApplication dcrApplication = createOauthApplication(clientName, kmConfig.getAdminUsername(), tags, validityPeriod); + OAuthApplication dcrApplication = createOauthApplication(clientName, kmConfig.getAdminUsername(), tags, + validityPeriod, kmConfig.getAdminPassword()); return new DCRResponse(dcrApplication.getClientId(), dcrApplication.getClientSecret()); } else { // super-tenant admin dcr and token generation OAuthApplication superTenantOauthApp = createOauthApplication( KeyMgtConstants.RESERVED_OAUTH_APP_NAME_PREFIX + KeyMgtConstants.SUPER_TENANT, - kmConfig.getAdminUsername(), null, validityPeriod); + kmConfig.getAdminUsername(), null, validityPeriod, kmConfig.getAdminPassword()); String superAdminAccessToken = createAccessToken(superTenantOauthApp); // create new key manager for the tenant, under super-tenant space @@ -119,7 +124,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { // DCR for the requesting user //todo lasantha -> need to pass password of user - OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod); + OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod, password); String requestingUserAccessToken = createAccessToken(dcrApplication); // get application id @@ -311,14 +316,16 @@ public class KeyMgtServiceImpl implements KeyMgtService { * @return @{@link OAuthApplication} OAuth application object * @throws KeyMgtException if any error occurs while creating response object */ - private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags, int validityPeriod) throws KeyMgtException { + private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags, + int validityPeriod, String ownerPassword) throws KeyMgtException { //todo modify this to pass the password as well - String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod); + String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod, ownerPassword); RequestBody oauthAppCreationPayload = RequestBody.Companion.create(oauthAppCreationPayloadStr, JSON); kmConfig = getKeyManagerConfig(); String dcrEndpoint = kmConfig.getServerUrl() + KeyMgtConstants.DCR_ENDPOINT; String username, password; + //todo why can't we use owner details here? if (KeyMgtConstants.SUPER_TENANT.equals(MultitenantUtils.getTenantDomain(owner))) { username = kmConfig.getAdminUsername(); password = kmConfig.getAdminPassword(); @@ -327,6 +334,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { password = subTenantUserPassword; } + //todo why can't we use owner details for authentication Request request = new Request.Builder() .url(dcrEndpoint) .addHeader(KeyMgtConstants.AUTHORIZATION_HEADER, Credentials.basic(username, password)) @@ -420,27 +428,46 @@ public class KeyMgtServiceImpl implements KeyMgtService { * @return @{@link Application} Application object * @throws KeyMgtException if any error occurs while retrieving the application */ - private Application getApplication(String applicationName, String owner) throws KeyMgtException { + private Application getApplication(String applicationName, String accessToken) throws KeyMgtException { try { APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance(); - APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner); +// APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner); + + ConsumerRESTAPIServices consumerRESTAPIServices = + KeyMgtDataHolder.getInstance().getConsumerRESTAPIServices(); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = + consumerRESTAPIServices.getAllApplications(null, accessToken, applicationName); + //todo map Application and return //todo modify the method signature and use access token and call REST API to get application data return null; // todo:apim - apiConsumer.getApplicationsByName(owner, applicationName, ""); // // curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" - } catch (APIManagementException e) { - msg = "Error while trying to retrieve the application"; - log.error(msg); - throw new KeyMgtException(msg); + } + +// catch (APIManagementException e) { +// msg = "Error while trying to retrieve the application"; +// log.error(msg); +// throw new KeyMgtException(msg); +// } + + catch (io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException e) { + e.printStackTrace(); + throw new KeyMgtException(""); + } catch (UnexpectedResponseException e) { + throw new KeyMgtException(""); + } catch (APIServicesException e) { + throw new KeyMgtException(""); } } - private String createOauthAppCreationPayload(String clientName, String owner, String[] tags, int validityPeriod) { + private String createOauthAppCreationPayload(String clientName, String owner, String[] tags, int validityPeriod, + String password) { JSONObject jsonObject = new JSONObject(); jsonObject.put("applicationName", clientName); jsonObject.put("username", owner); jsonObject.put("tags", tags); jsonObject.put("validityPeriod", validityPeriod); + jsonObject.put("password", password); return jsonObject.toString(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index e4ab0647ef..abcdbacc93 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -802,37 +802,40 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); try { //todo - lasantha - can't get password from here - + ApiApplicationKey apiApplicationKey = null; try { -// DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username, -// "client_credentials", null, new String[] {"device_management"}, false, validityTime); -// deviceConfig.setClientId(dcrResponse.getClientId()); -// deviceConfig.setClientSecret(dcrResponse.getClientSecret()); + DCRResponse adminDCRResponse = keyMgtService.dynamicClientRegistration(applicationName, + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminUserName(), + "client_credentials", null, new String[] {"device_management"}, false, validityTime, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword()); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); JWTClientManagerService jwtClientManagerService = (JWTClientManagerService) ctx. getOSGiService(JWTClientManagerService.class, null); JWTClient jwtClient = jwtClientManagerService.getJWTClient(); -// AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(apiApplicationKey.getConsumerKey(), -// apiApplicationKey.getConsumerSecret(), -// username, Constants.ApplicationInstall.SUBSCRIPTION_SCOPE); + AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(adminDCRResponse.getClientId(), + adminDCRResponse.getClientSecret(), + username, "appm:subscribe"); + + APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); + apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, + new String[] {"device_management"}, null, false, String.valueOf(validityTime), + accessTokenInfo.getAccessToken()); + } catch (JWTClientException e) { - String msg = "Error while generating an OAuth token for user " + username; + String msg = "Error while generating an application tokens for Tenant Admin."; + log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } catch (UserStoreException e) { + String msg = "Error while getting user credentials."; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } //todo call REST APIs - DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username, - "client_credentials", null, new String[] {"device_management"}, false, validityTime); - deviceConfig.setClientId(dcrResponse.getClientId()); - deviceConfig.setClientSecret(dcrResponse.getClientSecret()); - - APIManagementProviderService apiManagementProviderService = new APIManagementProviderServiceImpl(); - ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, - new String[] {"device_management"}, null, username, false, String.valueOf(validityTime), null); - deviceConfig.setClientId(apiApplicationKey.getConsumerKey()); deviceConfig.setClientSecret(apiApplicationKey.getConsumerSecret()); @@ -852,7 +855,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { // add scopes for update operation /tenantDomain/deviceType/deviceId/update/operation scopes.append(" perm:topic:pub:" + tenantDomain + ":" + type + ":" + id + ":update:operation"); - TokenRequest tokenRequest = new TokenRequest(dcrResponse.getClientId(), dcrResponse.getClientSecret(), + TokenRequest tokenRequest = new TokenRequest(apiApplicationKey.getConsumerKey(), + apiApplicationKey.getConsumerSecret(), null, scopes.toString(), "client_credentials", null, null, null, null, validityTime); TokenResponse tokenResponse = keyMgtService.generateAccessToken(tokenRequest); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index 7bba263529..a297bffd48 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; +import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; @@ -156,6 +157,7 @@ public class DeviceMgtAPIUtils { private static volatile SubscriptionManager subscriptionManager; private static volatile ApplicationManager applicationManager; private static volatile ConsumerRESTAPIServices consumerRESTAPIServices; + private static volatile APIManagementProviderService apiManagementProviderService; static { String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); @@ -408,6 +410,25 @@ public class DeviceMgtAPIUtils { return consumerRESTAPIServices; } + /** + * Initializing and accessing method for API management Provider Service. + * + * @return APIManagementProviderService instance + * @throws IllegalStateException if APIManagementProviderService cannot be initialized + */ + public static synchronized APIManagementProviderService getAPIManagementService() { + if (apiManagementProviderService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + apiManagementProviderService = (APIManagementProviderService) ctx.getOSGiService(APIManagementProviderService.class, null); + if (apiManagementProviderService == null) { + String msg = "API Management Provider service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + return apiManagementProviderService; + } + public static RegistryService getRegistryService() { RegistryService registryService; PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); From da1485d04f514d38ebd840a7a5e869f11762e4cb Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 16 Jun 2023 11:58:52 +0530 Subject: [PATCH 029/343] Fix getApplication method with Rest api calls --- .../api/bean/APIMConsumer/Application.java | 9 +++-- .../extension/service/KeyMgtServiceImpl.java | 39 ++++++++++++------- 2 files changed, 30 insertions(+), 18 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/bean/APIMConsumer/Application.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/APIMConsumer/Application.java index 50fb64147d..d56de0331d 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/bean/APIMConsumer/Application.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/APIMConsumer/Application.java @@ -18,9 +18,10 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; -import org.json.JSONObject; +import org.wso2.carbon.apimgt.api.model.APIKey; import java.util.List; +import java.util.Map; /** * This class represents the Consumer Application Information. @@ -36,7 +37,7 @@ public class Application { private List groups; private int subscriptionCount; private List keys; - private JSONObject attributes; + private Map attributes; private List subscriptionScopes; private String owner; private boolean hashEnabled; @@ -113,11 +114,11 @@ public class Application { this.keys = keys; } - public JSONObject getAttributes() { + public Map getAttributes() { return attributes; } - public void setAttributes(JSONObject attributes) { + public void setAttributes(Map attributes) { this.attributes = attributes; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 9de536da5e..36b40846f1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -35,6 +35,7 @@ import org.apache.commons.logging.LogFactory; import org.json.JSONObject; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; +import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.Application; import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.impl.utils.APIUtil; @@ -429,30 +430,40 @@ public class KeyMgtServiceImpl implements KeyMgtService { * @throws KeyMgtException if any error occurs while retrieving the application */ private Application getApplication(String applicationName, String accessToken) throws KeyMgtException { - try { - APIManagerFactory apiManagerFactory = APIManagerFactory.getInstance(); -// APIConsumer apiConsumer = apiManagerFactory.getAPIConsumer(owner); + try { ConsumerRESTAPIServices consumerRESTAPIServices = KeyMgtDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(null, accessToken, applicationName); - //todo map Application and return - //todo modify the method signature and use access token and call REST API to get application data - return null; // todo:apim - apiConsumer.getApplicationsByName(owner, applicationName, ""); - // // curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application applicationFromRestCall; + if (applications.length == 1) { + applicationFromRestCall = applications[0]; + } else { + String msg = + "Found invalid number of applications. No of applications found from the APIM: " + applications.length; + throw new KeyMgtException(msg); + } + + Application application = null; + application.setUUID(applicationFromRestCall.getApplicationId()); + application.setName(applicationFromRestCall.getName()); + application.setDescription(applicationFromRestCall.getDescription()); + application.setApplicationAttributes(applicationFromRestCall.getAttributes()); + application.setTokenType(applicationFromRestCall.getTokenType()); + application.setStatus(applicationFromRestCall.getStatus()); + application.setSubscriptionCount(applicationFromRestCall.getSubscriptionCount()); + application.setOwner(applicationFromRestCall.getOwner()); + application.setIsBlackListed(applicationFromRestCall.isHashEnabled()); + return application; } -// catch (APIManagementException e) { -// msg = "Error while trying to retrieve the application"; -// log.error(msg); -// throw new KeyMgtException(msg); -// } - catch (io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException e) { e.printStackTrace(); - throw new KeyMgtException(""); + msg = "Error while trying to retrieve the application"; + log.error(msg); + throw new KeyMgtException(msg); } catch (UnexpectedResponseException e) { throw new KeyMgtException(""); } catch (APIServicesException e) { From cb2fb990e700b73fcad7760ae482d14edeac800e Mon Sep 17 00:00:00 2001 From: Pasindu Rupasinghe Date: Mon, 19 Jun 2023 12:00:20 +0000 Subject: [PATCH 030/343] Get ApiApplicationInfo and access token into single object Co-authored-by: Pasindu Rupasinghe Co-committed-by: Pasindu Rupasinghe --- .../APIManagementProviderServiceImpl.java | 190 ++++-------------- .../rest/api/ConsumerRESTAPIServices.java | 27 ++- .../rest/api/ConsumerRESTAPIServicesImpl.java | 144 ++++++++----- .../extension/rest/api/dto/TokenInfo.java | 44 ++++ .../extension/service/KeyMgtServiceImpl.java | 6 +- 5 files changed, 188 insertions(+), 223 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/dto/TokenInfo.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 11953fa3dc..3174473b70 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -25,6 +25,7 @@ import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManag import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; import io.entgra.device.mgt.core.apimgt.application.extension.util.APIManagerUtil; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; @@ -119,131 +120,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe String keyType, boolean isAllowedAllDomains, String validityTime, String accessToken) throws APIManagerException { - ConsumerRESTAPIServices consumerRESTAPIServices = - APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + TokenInfo tokenInfo = new TokenInfo(); + tokenInfo.setApiApplicationInfo(null); + tokenInfo.setAccessToken(accessToken); - try { - List uniqueApiList = new ArrayList<>(); - - Map headerParams = new HashMap<>(); - if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) { - headerParams.put("X-WSO2-Tenant", "carbon.super"); - } - - for (String tag : tags) { - Map queryParams = new HashMap<>(); - queryParams.put("tag", tag); - - APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(null, accessToken, queryParams, headerParams); - - uniqueApiList.addAll(List.of(apiInfos)); - Set taggedAPISet = new HashSet<>(uniqueApiList); - uniqueApiList.clear(); - uniqueApiList.addAll(taggedAPISet); - } - - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(null, accessToken, applicationName); - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; - boolean isNewApplication = false; - if (applications.length == 0) { - isNewApplication = true; - application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); - application.setName(applicationName); - application = consumerRESTAPIServices.createApplication(null, accessToken, application); - addSubscriptions(application, uniqueApiList, accessToken); - } else { - if (applications.length == 1) { - Optional applicationOpt = - Arrays.stream(applications).findFirst(); - application = applicationOpt.get(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, accessToken, - application.getApplicationId()); - Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); - addSubscriptions(application, uniqueApiList, accessToken); - } else { - String msg = "Found more than one application for application name: " + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - } - - MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); - if (isNewApplication) { - KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(null, accessToken); - KeyManager keyManager; - if (keyManagers.length == 1) { - keyManager = keyManagers[0]; - } else { - String msg = - "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; - throw new APIManagerException(msg); - } - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(null, accessToken, - application.getApplicationId(), keyManager.getName(), keyType, validityTime); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - - Metadata metaData = new Metadata(); - metaData.setMetaKey(applicationName); - String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); - metaData.setMetaValue(metaValue); - try { - metadataManagementService.createMetadata(metaData); - return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } catch (MetadataKeyAlreadyExistsException e) { - String msg = "Found duplicate meta value entry for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - } else { - try { - Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); - if (metaData == null) { - String msg = "Couldn't find application key data from meta data mgt service. Meta key: " - + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - String[] metaValues = metaData.getMetaValue().split(":"); - if (metaValues.length != 2) { - String msg = "Found invalid Meta value for meta key: " + applicationName + ". Meta Value: " - + metaData.getMetaValue(); - log.error(msg); - throw new APIManagerException(msg); - } - String applicationId = metaValues[0]; - String keyMappingId = metaValues[1]; - ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(null, accessToken, applicationId, - keyMappingId); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while getting meta data for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - } - } catch (APIServicesException e) { - String msg = "Error occurred while processing the response of APIM REST endpoints."; - log.error(msg, e); - throw new APIManagerException(msg, e); - } catch (BadRequestException e) { - String msg = "Provided incorrect payload when invoking APIM REST endpoints."; - log.error(msg, e); - throw new APIManagerException(msg, e); - } catch (UnexpectedResponseException e) { - String msg = "Error occurred while invoking APIM REST endpoints."; - log.error(msg, e); - throw new APIManagerException(msg, e); - } + return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, null, isAllowedAllDomains, validityTime, tokenInfo); } @Override @@ -254,10 +135,23 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throws APIManagerException { + ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); + + TokenInfo tokenInfo = new TokenInfo(); + tokenInfo.setApiApplicationInfo(applicationInfo); + tokenInfo.setAccessToken(null); + + return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, username,isAllowedAllDomains, validityTime, tokenInfo); + } + + private ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, TokenInfo tokenInfo) throws APIManagerException { + ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); try { List uniqueApiList = new ArrayList<>(); @@ -270,7 +164,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Map queryParams = new HashMap<>(); queryParams.put("tag", tag); - APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(applicationInfo, null, queryParams, headerParams); + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(tokenInfo, queryParams, headerParams); uniqueApiList.addAll(List.of(apiInfos)); Set taggedAPISet = new HashSet<>(uniqueApiList); @@ -279,24 +173,23 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(applicationInfo, null, applicationName); + consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; boolean isNewApplication = false; if (applications.length == 0) { isNewApplication = true; application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); - application = consumerRESTAPIServices.createApplication(applicationInfo, null, application); - addSubscriptions(application, uniqueApiList, applicationInfo); + application = consumerRESTAPIServices.createApplication(tokenInfo, application); + addSubscriptions(application, uniqueApiList, tokenInfo); } else { if (applications.length == 1) { Optional applicationOpt = Arrays.stream(applications).findFirst(); application = applicationOpt.get(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, null, - application.getApplicationId()); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); - addSubscriptions(application, uniqueApiList, applicationInfo); + addSubscriptions(application, uniqueApiList, tokenInfo); } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); @@ -306,7 +199,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { - KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(applicationInfo, null); + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(tokenInfo); KeyManager keyManager; if (keyManagers.length == 1) { keyManager = keyManagers[0]; @@ -315,8 +208,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; throw new APIManagerException(msg); } - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, null, - application.getApplicationId(), keyManager.getName(), keyType, validityTime); + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), + keyManager.getName(), keyType, validityTime); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -355,7 +248,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; - ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(applicationInfo, null, applicationId, keyMappingId); + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(tokenInfo, applicationId, keyMappingId); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -387,7 +280,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe * * @param application {@link io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application} * @param apiInfos {@link List} - * @param apiApplicationInfo {@link ApiApplicationInfo} + * @param tokenInfo {@link TokenInfo} * * @throws BadRequestException if incorrect data provided to call subscribing REST API. * @throws UnexpectedResponseException if error occurred while processing the subscribing REST API. @@ -395,8 +288,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe */ private void addSubscriptions( io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, - List apiInfos, ApiApplicationInfo apiApplicationInfo) + List apiInfos, TokenInfo tokenInfo) throws BadRequestException, UnexpectedResponseException, APIServicesException { + ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -407,24 +301,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscription.setApplicationId(application.getApplicationId()); subscriptionList.add(subscription); }); - consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, null, subscriptionList); - } - private void addSubscriptions( - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, - List apiInfos, String accessToken) - throws BadRequestException, UnexpectedResponseException, APIServicesException { - ConsumerRESTAPIServices consumerRESTAPIServices = - APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - - List subscriptionList = new ArrayList<>(); - apiInfos.forEach(apiInfo -> { - Subscription subscription = new Subscription(); - subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.getApplicationId()); - subscriptionList.add(subscription); - }); - consumerRESTAPIServices.createSubscriptions(null, accessToken, subscriptionList); + consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); } /** @@ -766,7 +644,7 @@ Otherwise, Generate Application Keys and return them throw new APIManagerException(errorMsg, e); } - ApiApplicationInfo applicationInfo = null; + ApiApplicationInfo applicationInfo = new ApiApplicationInfo(); applicationInfo.setClientId(apiApplicationKey.getClientId()); applicationInfo.setClientSecret(apiApplicationKey.getClientSecret()); applicationInfo.setAccess_token(accessTokenInfo.getAccess_token()); 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index df81bff172..5ed98034e2 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -19,7 +19,7 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; 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; @@ -28,39 +28,36 @@ import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - Application[] getAllApplications(ApiApplicationInfo applicationInfo, String accessToken, String appName) + Application[] getAllApplications(TokenInfo tokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + Application getDetailsOfAnApplication(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application createApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, Application application) + Application createApplication(TokenInfo tokenInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + Boolean deleteApplication(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + Subscription[] getAllSubscriptions(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, String accessToken, Map queryParams, - Map headerParams) + APIInfo[] getAllApis(TokenInfo tokenInfo, Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, String accessToken, Subscription subscriptions) + Subscription createSubscription(TokenInfo tokenInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, - List subscriptions) + Subscription[] createSubscriptions(TokenInfo tokenInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, - String keyManager, String validityTime, String keyType) + ApplicationKey generateApplicationKeys(TokenInfo tokenInfo, String applicationId, String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, String keyMapId) + ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo, String accessToken) + KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index 076d735112..81ed4cd4e3 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; 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.dto.ApiApplicationInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; 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; @@ -50,10 +51,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public Application[] getAllApplications(ApiApplicationInfo apiApplicationInfo, String accessToken, String appName) + public Application[] getAllApplications(TokenInfo tokenInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; Request.Builder builder = new Request.Builder(); @@ -63,7 +65,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.get(); Request request = builder.build(); @@ -81,7 +83,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllApplications(refreshedApiApplicationInfo, null, appName); + tokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + tokenInfo.setAccessToken(null); + return getAllApplications(tokenInfo, appName); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -103,10 +107,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + public Application getDetailsOfAnApplication(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getDetailsOfAPPUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); @@ -116,7 +121,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.get(); Request request = builder.build(); @@ -133,7 +138,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getDetailsOfAnApplication(refreshedApiApplicationInfo, null, applicationId); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return getDetailsOfAnApplication(refreshedTokenInfo, applicationId); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -155,10 +163,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application createApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, Application application) + public Application createApplication(TokenInfo tokenInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; String applicationInfo = "{\n" + @@ -179,7 +188,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.post(requestBody); Request request = builder.build(); @@ -196,7 +205,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return createApplication(refreshedApiApplicationInfo, null, application); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return createApplication(refreshedTokenInfo, application); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -218,10 +230,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + public Boolean deleteApplication(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String deleteScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); @@ -231,7 +244,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.delete(); Request request = builder.build(); @@ -248,7 +261,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return deleteApplication(refreshedApiApplicationInfo, null, applicationId); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return deleteApplication(refreshedTokenInfo, applicationId); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -270,10 +286,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId) + public Subscription[] getAllSubscriptions(TokenInfo tokenInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; Request.Builder builder = new Request.Builder(); @@ -283,7 +300,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.get(); Request request = builder.build(); @@ -299,9 +316,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllSubscriptions(rehreshedApiApplicationInfo, null, applicationId); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return getAllSubscriptions(refreshedTokenInfo, applicationId); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -323,11 +343,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, String accessToken, Map queryParams, - Map headerParams) + public APIInfo[] getAllApis(TokenInfo tokenInfo, Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); StringBuilder getAPIsURL = new StringBuilder(endPointPrefix + Constants.DEV_PORTAL_API); for (Map.Entry query : queryParams.entrySet()) { @@ -341,7 +361,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } for (Map.Entry header : headerParams.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); @@ -360,9 +380,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo rehreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllApis(rehreshedApiApplicationInfo, null, queryParams, headerParams); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return getAllApis(refreshedTokenInfo, queryParams, headerParams); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -384,10 +407,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, String accessToken, Subscription subscriptions) + public Subscription createSubscription(TokenInfo tokenInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String createSubscriptionUrl = endPointPrefix + Constants.SUBSCRIPTION_API; String subscriptionObject = "{\n" + @@ -406,7 +430,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.post(requestBody); Request request = builder.build(); @@ -423,7 +447,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return createSubscription(refreshedApiApplicationInfo, null, subscriptions); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return createSubscription(refreshedTokenInfo, subscriptions); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -445,11 +472,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, String accessToken, - List subscriptions) + public Subscription[] createSubscriptions(TokenInfo tokenInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String createSubscriptionsUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; String subscriptionsList = gson.toJson(subscriptions); @@ -462,7 +489,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.post(requestBody); Request request = builder.build(); @@ -480,7 +507,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return createSubscriptions(refreshedApiApplicationInfo, null, subscriptions); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return createSubscriptions(refreshedTokenInfo, subscriptions); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -502,11 +532,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, - String keyManager, String validityTime, String keyType) + public ApplicationKey generateApplicationKeys(TokenInfo tokenInfo, String applicationId, String keyManager, + String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String generateApplicationKeysUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/generate-keys"; @@ -535,7 +566,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.post(requestBody); Request request = builder.build(); @@ -550,9 +581,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return generateApplicationKeys(refreshedApiApplicationKey, null, applicationId, keyManager, validityTime, keyType); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return generateApplicationKeys(refreshedTokenInfo, applicationId, keyManager, validityTime, keyType); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -574,10 +608,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String accessToken, String applicationId, String keyMapId) + public ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; Request.Builder builder = new Request.Builder(); @@ -587,7 +622,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.get(); Request request = builder.build(); @@ -602,9 +637,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { AccessTokenInfo refreshedAccessToken = apiApplicationServices. generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationKey = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getKeyDetails(refreshedApiApplicationKey, null, applicationId, keyMapId); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return getKeyDetails(refreshedTokenInfo, applicationId, keyMapId); } else { String msg = "Invalid access token. Unauthorized request"; log.error(msg); @@ -626,10 +664,11 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo, String accessToken) + public KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { - boolean token = isTokenNull(apiApplicationInfo, accessToken); + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; Request.Builder builder = new Request.Builder(); @@ -639,7 +678,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + apiApplicationInfo.getAccess_token()); } else { builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + accessToken); + + tokenInfo.getAccessToken()); } builder.get(); Request request = builder.build(); @@ -657,7 +696,10 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); //TODO: max attempt count - return getAllKeyManagers(refreshedApiApplicationInfo, null); + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return getAllKeyManagers(refreshedTokenInfo); } else { String msg = "Invalid or null access token"; log.error(msg); 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/dto/TokenInfo.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/TokenInfo.java new file mode 100644 index 0000000000..72100c982b --- /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/dto/TokenInfo.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018 - 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.dto; + +/** + * This holds the API application information and access token for REST APIS cals. + */ +public class TokenInfo { + + private ApiApplicationInfo apiApplicationInfo; + private String accessToken; + + public ApiApplicationInfo getApiApplicationInfo() { + return apiApplicationInfo; + } + + public void setApiApplicationInfo(ApiApplicationInfo apiApplicationInfo) { + this.apiApplicationInfo = apiApplicationInfo; + } + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 36b40846f1..7629403290 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.service; import com.google.gson.Gson; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.*; @@ -431,11 +432,14 @@ public class KeyMgtServiceImpl implements KeyMgtService { */ private Application getApplication(String applicationName, String accessToken) throws KeyMgtException { + TokenInfo tokenInfo = new TokenInfo(); + tokenInfo.setApiApplicationInfo(null); + tokenInfo.setAccessToken(accessToken); try { ConsumerRESTAPIServices consumerRESTAPIServices = KeyMgtDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(null, accessToken, applicationName); + consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application applicationFromRestCall; if (applications.length == 1) { From 342e201c4cc61057ff7191a560303b93f2962e6a Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 20 Jun 2023 09:39:49 +0530 Subject: [PATCH 031/343] Add improvements to APIM application creating logic --- .../APIManagementProviderService.java | 40 +- .../APIManagementProviderServiceImpl.java | 670 +++++++++--------- .../extension/service/KeyMgtServiceImpl.java | 44 +- .../impl/DeviceManagementServiceImpl.java | 2 +- .../client/extension/util/JWTClientUtil.java | 6 +- 5 files changed, 382 insertions(+), 380 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index 1e561ae465..14449cdf09 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -33,22 +33,22 @@ public interface APIManagementProviderService { */ boolean isTierLoaded(); - /** - * Generate and retreive application keys. if the application does exist then - * create it and subscribe to apis that are grouped with the tags. - * - * @param apiApplicationName name of the application. - * @param tags tags of the apis that application needs to be subscribed. - * @param keyType of the application. - * @param username to whom the application is created - * @param isAllowedAllDomains application is allowed to all the tenants - * @param validityTime validity period of the application - * @return consumerkey and secrete of the created application. - * @throws APIManagerException - */ - ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], - String keyType, String username, boolean isAllowedAllDomains, - String validityTime) throws APIManagerException; +// /** +// * Generate and retreive application keys. if the application does exist then +// * create it and subscribe to apis that are grouped with the tags. +// * +// * @param apiApplicationName name of the application. +// * @param tags tags of the apis that application needs to be subscribed. +// * @param keyType of the application. +// * @param username to whom the application is created +// * @param isAllowedAllDomains application is allowed to all the tenants +// * @param validityTime validity period of the application +// * @return consumerkey and secrete of the created application. +// * @throws APIManagerException +// */ +// ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], +// String keyType, String username, boolean isAllowedAllDomains, +// String validityTime) throws APIManagerException; ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, @@ -60,10 +60,10 @@ public interface APIManagementProviderService { boolean isAllowedAllDomains, String validityTime, String accessToken) throws APIManagerException; - /** - * Remove APIM Application. - */ - void removeAPIApplication(String applicationName, String username) throws APIManagerException; +// /** +// * Remove APIM Application. +// */ +// void removeAPIApplication(String applicationName, String username) throws APIManagerException; /** * To get access token for given scopes and for the given validity period diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3174473b70..730bb53c16 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -54,7 +54,6 @@ import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; import org.wso2.carbon.apimgt.api.model.API; import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; -import org.wso2.carbon.apimgt.api.model.Application; import org.wso2.carbon.apimgt.api.model.SubscribedAPI; import org.wso2.carbon.apimgt.api.model.Subscriber; import org.wso2.carbon.apimgt.impl.APIAdminImpl; @@ -97,23 +96,23 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return false; } - @Override - public void removeAPIApplication(String applicationName, String username) throws APIManagerException { - - try { - APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); - Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -// curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" - if (application != null) { - // todo:apim - apiConsumer.removeApplication(application, username); - //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X DELETE "https://localhost:9443/api/am/devportal/v3/applications/896658a0-b4ee-4535-bbfa-806c894a4015" - } - } catch (APIManagementException e) { - throw new APIManagerException("Failed to remove api application : " + applicationName, e); - } - - - } +// @Override +// public void removeAPIApplication(String applicationName, String username) throws APIManagerException { +// +// try { +// APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); +// Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +//// curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" +// if (application != null) { +// // todo:apim - apiConsumer.removeApplication(application, username); +// //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X DELETE "https://localhost:9443/api/am/devportal/v3/applications/896658a0-b4ee-4535-bbfa-806c894a4015" +// } +// } catch (APIManagementException e) { +// throw new APIManagerException("Failed to remove api application : " + applicationName, e); +// } +// +// +// } @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, @@ -123,8 +122,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe TokenInfo tokenInfo = new TokenInfo(); tokenInfo.setApiApplicationInfo(null); tokenInfo.setAccessToken(accessToken); - - return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, null, isAllowedAllDomains, validityTime, tokenInfo); + return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, isAllowedAllDomains, validityTime, tokenInfo); } @Override @@ -136,18 +134,16 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); - TokenInfo tokenInfo = new TokenInfo(); tokenInfo.setApiApplicationInfo(applicationInfo); tokenInfo.setAccessToken(null); - - return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, username,isAllowedAllDomains, validityTime, tokenInfo); + return generateAndRetrieveApplicationKeys(applicationName, tags, keyType,isAllowedAllDomains, validityTime, tokenInfo); } private ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime, TokenInfo tokenInfo) throws APIManagerException { + String keyType, + boolean isAllowedAllDomains, + String validityTime, TokenInfo tokenInfo) throws APIManagerException { ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -175,90 +171,47 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; - boolean isNewApplication = false; + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (applications.length == 0) { - isNewApplication = true; - application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); - application.setName(applicationName); - application = consumerRESTAPIServices.createApplication(tokenInfo, application); - addSubscriptions(application, uniqueApiList, tokenInfo); + return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); } else { if (applications.length == 1) { Optional applicationOpt = Arrays.stream(applications).findFirst(); application = applicationOpt.get(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); - Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); - addSubscriptions(application, uniqueApiList, tokenInfo); + + Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); + if (metaData == null) { + // Todo add a comment + consumerRESTAPIServices.deleteApplication(tokenInfo, application.getApplicationId()); + return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); + } else { + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); + Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); + addSubscriptions(application, uniqueApiList, tokenInfo); + + String[] metaValues = metaData.getMetaValue().split(":"); + if (metaValues.length != 2) { + String msg = "Found invalid Meta value for meta key: " + applicationName + ". Meta Value: " + + metaData.getMetaValue(); + log.error(msg); + throw new APIManagerException(msg); + } + String applicationId = metaValues[0]; + String keyMappingId = metaValues[1]; + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(tokenInfo, applicationId, keyMappingId); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; + } + } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); throw new APIManagerException(msg); } } - - MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); - if (isNewApplication) { - KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(tokenInfo); - KeyManager keyManager; - if (keyManagers.length == 1) { - keyManager = keyManagers[0]; - } else { - String msg = - "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; - throw new APIManagerException(msg); - } - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), - keyManager.getName(), keyType, validityTime); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - - Metadata metaData = new Metadata(); - metaData.setMetaKey(applicationName); - String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); - metaData.setMetaValue(metaValue); - try { - metadataManagementService.createMetadata(metaData); - return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } catch (MetadataKeyAlreadyExistsException e) { - String msg = "Found duplicate meta value entry for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - } else { - try { - Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); - if (metaData == null) { - String msg = "Couldn't find application key data from meta data mgt service. Meta key: " - + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - String[] metaValues = metaData.getMetaValue().split(":"); - if (metaValues.length != 2) { - String msg = "Found invalid Meta value for meta key: " + applicationName + ". Meta Value: " - + metaData.getMetaValue(); - log.error(msg); - throw new APIManagerException(msg); - } - String applicationId = metaValues[0]; - String keyMappingId = metaValues[1]; - ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(tokenInfo, applicationId, keyMappingId); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while getting meta data for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - } } catch (APIServicesException e) { String msg = "Error occurred while processing the response of APIM REST endpoints."; log.error(msg, e); @@ -271,6 +224,71 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe String msg = "Error occurred while invoking APIM REST endpoints."; log.error(msg, e); throw new APIManagerException(msg, e); + } catch (MetadataManagementException e) { + String msg = "Error occurred while getting meta data for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } + } + + + private ApiApplicationKey handleNewAPIApplication(String applicationName, List uniqueApiList, + TokenInfo tokenInfo, String keyType, String validityTime) throws APIManagerException { + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); + application.setName(applicationName); + + try { + application = consumerRESTAPIServices.createApplication(tokenInfo, application); + addSubscriptions(application, uniqueApiList, tokenInfo); + + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(tokenInfo); + KeyManager keyManager; + if (keyManagers.length == 1) { + keyManager = keyManagers[0]; + } else { + String msg = + "Found invalid number of key managers. No of key managers found from the APIM: " + keyManagers.length; + log.error(msg); + throw new APIManagerException(msg); + } + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), + keyManager.getName(), keyType, validityTime); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + + Metadata metaData = new Metadata(); + metaData.setMetaKey(applicationName); + String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); + metaData.setMetaValue(metaValue); + + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); + metadataManagementService.createMetadata(metaData); + return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating meta data for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (MetadataKeyAlreadyExistsException e) { + String msg = + "Since meta key:" + applicationName + " already exists, meta data creating process " + + "failed."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (BadRequestException e) { + String msg = "Provided incorrect payload when invoking APIM REST endpoints to handle new API application."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (UnexpectedResponseException e) { + String msg = "Error occurred while invoking APIM REST endpoints to handle new API application."; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (APIServicesException e) { + String msg = "Error occurred while processing the response of APIM REST endpoints to handle new API application."; + log.error(msg, e); + throw new APIManagerException(msg, e); } } @@ -305,234 +323,234 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); } - /** - * {@inheritDoc} - */ - @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, boolean isAllowedAllDomains, String validityTime) - throws APIManagerException { - - -/* - -todo - Modify generateAndRetrieveApplicationKeys - -Check the existence of the API application. - -if Application is not exists - Create the Application - -If super tenants - Get set of tagged APIs -If the tenant domain is not super tenant - Get set of tagged APIs from super tenant space - -If new Application - Subscribed to tagged APIs -Else - Get all subscribed APIs of application - Filter out APIs and subscribed to APIs which can be subscribed - Filter -> Use set of tagged APis - Remove already subscribed APIs from the set - Subscribed to remaining APIs - -Get Application keys from application - If API keys are there return API keys - -Otherwise, Generate Application Keys and return them - - */ - - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - if (StringUtils.isEmpty(username)) { - username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + tenantDomain; - } - try { - APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); - Application application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); - int applicationId = 0; - Subscriber subscriber = null; - if (application == null) { - subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); - if (subscriber == null) { - // create subscriber - // todo:resolve:apim - apiConsumer.addSubscriber(username, ""); - subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); - } - //create application - application = new Application(applicationName, subscriber); - application.setTier(ApiApplicationConstants.DEFAULT_TIER); - application.setGroupId(""); - application.setTokenType("OAUTH"); - // todo:resolve:apim - apiConsumer.addApplication(application, username); - application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); - } else { - subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); - } - - Set subscribedAPIs = - null; // todo:resolve:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); - - log.info("Already subscribed API count: " + subscribedAPIs.size()); - - // subscribe to apis. - APIConsumer apiConsumerAPIPublishedTenant = apiConsumer; - if (tags != null && tags.length > 0) { - for (String tag : tags) { - boolean startedTenantFlow = false; - Set apisWithTag = null; // todo:resolve:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); - - /** - * From APIM 4.0.0, APIs published in the super tenant can only be listed by - * APIConsumer, only if the APIConsumer belongs to the super tenant. So we - * are starting tenant flow if we are not already in super tenant(child - * tenant starting to create OAuth app). - */ - if (apisWithTag == null || apisWithTag.size() == 0) { - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, - true); - - try { - String superAdminUsername = PrivilegedCarbonContext - .getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName(); - apiConsumerAPIPublishedTenant = API_MANAGER_FACTORY.getAPIConsumer(superAdminUsername); - } catch (UserStoreException e) { - throw new APIManagerException("Failed to create api application for " + - "tenant: " + tenantDomain + - ". Caused by to inability to get super tenant username", e); - } - - apisWithTag = null; // todo:resolve:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - startedTenantFlow = true; - } - - Set apiTypeWrapperList = new HashSet<>(); - if (apisWithTag != null && apisWithTag.size() > 0) { - Set tempApiIds = new HashSet<>(); - for (API apiInfo : apisWithTag) { - String id = apiInfo.getId().getProviderName().replace("@", "-AT-") - + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion(); - boolean subscriptionExist = false; - if (subscribedAPIs.size() > 0) { - for (SubscribedAPI subscribedAPI : subscribedAPIs) { - // todo:resolve:apim -// if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { -// subscriptionExist = true; -// break; -// } - } - } - if (!subscriptionExist && !tempApiIds.contains(id)) { - ApiTypeWrapper apiTypeWrapper; - if (startedTenantFlow) { - /** - * This mean APIs were not found in the child tenant, so all - * calls to get info about APIs need to be to super tenant. - */ - apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( - apiInfo.getUuid(), MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - } else { - /** - * Ideally, in all usecases of IoT server, tenant domain here - * will be carbon.super. This block is kept to make sure in - * the future, if there are some APIs published to a specific - * tenant only. - */ - apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( - apiInfo.getUuid(), tenantDomain); - } - apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER); - apiTypeWrapperList.add(apiTypeWrapper); - tempApiIds.add(id); - } - } - if (startedTenantFlow) { - PrivilegedCarbonContext.endTenantFlow(); - } - - /** This is done in a redundant loop instead of doing in the same loop - * that populates apiTypeWrapperList because in a tenanted scenario, - * apiConsumerAPIPublishedTenant will belong to super tenant. So super - * tenant flow need to end before starting subscription to avoid adding - * subscriptions inside super tenant when we are trying to create an - * Oauth app for a child tenant. - */ - for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { - // todo:resolve:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); - } - } - } - } - //end of subscription - - List applicationKeys = application.getKeys(); - if (applicationKeys != null) { - for (APIKey applicationKey : applicationKeys) { - if (keyType.equals(applicationKey.getType())) { - if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; - } - } - } - } - - List allowedDomains = new ArrayList<>(); - if (isAllowedAllDomains) { - allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); - } else { - allowedDomains.add(APIManagerUtil.getTenantDomain()); - } - - APIAdmin apiAdmin = new APIAdminImpl(); - String keyManagerId = null; - try { - List keyManagerConfigurations = null; // todo:resolve:apim - - // apiAdmin.getKeyManagerConfigurationsByTenant(tenantDomain); - if (keyManagerConfigurations != null) { - for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { - keyManagerId = keyManagerConfigurationDTO.getUuid(); - } - } - String applicationAccessTokenExpiryTime = "N/A"; - if (!StringUtils.isEmpty(validityTime)) { - applicationAccessTokenExpiryTime = validityTime; - } - String jsonString = "{\"grant_types\":\"refresh_token,access_token," + - "urn:ietf:params:oauth:grant-type:saml2-bearer," + - "password,client_credentials,iwa:ntlm,urn:ietf:params:oauth:grant-type:jwt-bearer\"," + - "\"additionalProperties\":\"{\\\"application_access_token_expiry_time\\\":\\\"" + applicationAccessTokenExpiryTime + "\\\"," + - "\\\"user_access_token_expiry_time\\\":\\\"N\\/A\\\"," + - "\\\"refresh_token_expiry_time\\\":\\\"N\\/A\\\"," + - "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + - "\"username\":\"" + username + "\"}"; - - Map keyDetails = null; // todo:resolve:apim - apiConsumer -// .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", -// allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", -// jsonString, keyManagerId, tenantDomain); - - if (keyDetails != null) { - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey((String) keyDetails.get("consumerKey")); - apiApplicationKey.setConsumerSecret((String) keyDetails.get("consumerSecret")); - return apiApplicationKey; - } - throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); -// todo:resolve:apim - commected as it says never throw since we commented apim calls above -// cnt rm -// } catch (APIManagementException e) { - } catch (Exception e) { - throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); - } - } catch (APIManagementException e) { - throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); - } - } +// /** +// * {@inheritDoc} +// */ +// @Override +// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], +// String keyType, String username, boolean isAllowedAllDomains, String validityTime) +// throws APIManagerException { +// +// +///* +// +//todo - Modify generateAndRetrieveApplicationKeys +// +//Check the existence of the API application. +// +//if Application is not exists +// Create the Application +// +//If super tenants +// Get set of tagged APIs +//If the tenant domain is not super tenant +// Get set of tagged APIs from super tenant space +// +//If new Application +// Subscribed to tagged APIs +//Else +// Get all subscribed APIs of application +// Filter out APIs and subscribed to APIs which can be subscribed +// Filter -> Use set of tagged APis +// Remove already subscribed APIs from the set +// Subscribed to remaining APIs +// +//Get Application keys from application +// If API keys are there return API keys +// +//Otherwise, Generate Application Keys and return them +// +// */ +// +// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); +// if (StringUtils.isEmpty(username)) { +// username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + tenantDomain; +// } +// try { +// APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); +// Application application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +// int applicationId = 0; +// Subscriber subscriber = null; +// if (application == null) { +// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); +// if (subscriber == null) { +// // create subscriber +// // todo:resolve:apim - apiConsumer.addSubscriber(username, ""); +// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); +// } +// //create application +// application = new Application(applicationName, subscriber); +// application.setTier(ApiApplicationConstants.DEFAULT_TIER); +// application.setGroupId(""); +// application.setTokenType("OAUTH"); +// // todo:resolve:apim - apiConsumer.addApplication(application, username); +// application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); +// } else { +// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); +// } +// +// Set subscribedAPIs = +// null; // todo:resolve:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); +// +// log.info("Already subscribed API count: " + subscribedAPIs.size()); +// +// // subscribe to apis. +// APIConsumer apiConsumerAPIPublishedTenant = apiConsumer; +// if (tags != null && tags.length > 0) { +// for (String tag : tags) { +// boolean startedTenantFlow = false; +// Set apisWithTag = null; // todo:resolve:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); +// +// /** +// * From APIM 4.0.0, APIs published in the super tenant can only be listed by +// * APIConsumer, only if the APIConsumer belongs to the super tenant. So we +// * are starting tenant flow if we are not already in super tenant(child +// * tenant starting to create OAuth app). +// */ +// if (apisWithTag == null || apisWithTag.size() == 0) { +// PrivilegedCarbonContext.startTenantFlow(); +// PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, +// true); +// +// try { +// String superAdminUsername = PrivilegedCarbonContext +// .getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName(); +// apiConsumerAPIPublishedTenant = API_MANAGER_FACTORY.getAPIConsumer(superAdminUsername); +// } catch (UserStoreException e) { +// throw new APIManagerException("Failed to create api application for " + +// "tenant: " + tenantDomain + +// ". Caused by to inability to get super tenant username", e); +// } +// +// apisWithTag = null; // todo:resolve:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); +// startedTenantFlow = true; +// } +// +// Set apiTypeWrapperList = new HashSet<>(); +// if (apisWithTag != null && apisWithTag.size() > 0) { +// Set tempApiIds = new HashSet<>(); +// for (API apiInfo : apisWithTag) { +// String id = apiInfo.getId().getProviderName().replace("@", "-AT-") +// + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion(); +// boolean subscriptionExist = false; +// if (subscribedAPIs.size() > 0) { +// for (SubscribedAPI subscribedAPI : subscribedAPIs) { +// // todo:resolve:apim +//// if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { +//// subscriptionExist = true; +//// break; +//// } +// } +// } +// if (!subscriptionExist && !tempApiIds.contains(id)) { +// ApiTypeWrapper apiTypeWrapper; +// if (startedTenantFlow) { +// /** +// * This mean APIs were not found in the child tenant, so all +// * calls to get info about APIs need to be to super tenant. +// */ +// apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( +// apiInfo.getUuid(), MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); +// } else { +// /** +// * Ideally, in all usecases of IoT server, tenant domain here +// * will be carbon.super. This block is kept to make sure in +// * the future, if there are some APIs published to a specific +// * tenant only. +// */ +// apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( +// apiInfo.getUuid(), tenantDomain); +// } +// apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER); +// apiTypeWrapperList.add(apiTypeWrapper); +// tempApiIds.add(id); +// } +// } +// if (startedTenantFlow) { +// PrivilegedCarbonContext.endTenantFlow(); +// } +// +// /** This is done in a redundant loop instead of doing in the same loop +// * that populates apiTypeWrapperList because in a tenanted scenario, +// * apiConsumerAPIPublishedTenant will belong to super tenant. So super +// * tenant flow need to end before starting subscription to avoid adding +// * subscriptions inside super tenant when we are trying to create an +// * Oauth app for a child tenant. +// */ +// for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { +// // todo:resolve:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); +// } +// } +// } +// } +// //end of subscription +// +// List applicationKeys = application.getKeys(); +// if (applicationKeys != null) { +// for (APIKey applicationKey : applicationKeys) { +// if (keyType.equals(applicationKey.getType())) { +// if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { +// ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); +// apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); +// apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); +// return apiApplicationKey; +// } +// } +// } +// } +// +// List allowedDomains = new ArrayList<>(); +// if (isAllowedAllDomains) { +// allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); +// } else { +// allowedDomains.add(APIManagerUtil.getTenantDomain()); +// } +// +// APIAdmin apiAdmin = new APIAdminImpl(); +// String keyManagerId = null; +// try { +// List keyManagerConfigurations = null; // todo:resolve:apim - +// // apiAdmin.getKeyManagerConfigurationsByTenant(tenantDomain); +// if (keyManagerConfigurations != null) { +// for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { +// keyManagerId = keyManagerConfigurationDTO.getUuid(); +// } +// } +// String applicationAccessTokenExpiryTime = "N/A"; +// if (!StringUtils.isEmpty(validityTime)) { +// applicationAccessTokenExpiryTime = validityTime; +// } +// String jsonString = "{\"grant_types\":\"refresh_token,access_token," + +// "urn:ietf:params:oauth:grant-type:saml2-bearer," + +// "password,client_credentials,iwa:ntlm,urn:ietf:params:oauth:grant-type:jwt-bearer\"," + +// "\"additionalProperties\":\"{\\\"application_access_token_expiry_time\\\":\\\"" + applicationAccessTokenExpiryTime + "\\\"," + +// "\\\"user_access_token_expiry_time\\\":\\\"N\\/A\\\"," + +// "\\\"refresh_token_expiry_time\\\":\\\"N\\/A\\\"," + +// "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + +// "\"username\":\"" + username + "\"}"; +// +// Map keyDetails = null; // todo:resolve:apim - apiConsumer +//// .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", +//// allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", +//// jsonString, keyManagerId, tenantDomain); +// +// if (keyDetails != null) { +// ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); +// apiApplicationKey.setConsumerKey((String) keyDetails.get("consumerKey")); +// apiApplicationKey.setConsumerSecret((String) keyDetails.get("consumerSecret")); +// return apiApplicationKey; +// } +// throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); +//// todo:resolve:apim - commected as it says never throw since we commented apim calls above +//// cnt rm +//// } catch (APIManagementException e) { +// } catch (Exception e) { +// throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); +// } +// } catch (APIManagementException e) { +// throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); +// } +// } @Override public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 7629403290..69f51fff56 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -34,11 +34,8 @@ import okhttp3.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONObject; -import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.Application; -import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; @@ -132,8 +129,9 @@ public class KeyMgtServiceImpl implements KeyMgtService { // get application id //todo --> can use requestingUserAccessToken token here to get application data - modify getApplication // method signature - Application application = getApplication(clientName, owner); - String applicationUUID = application.getUUID(); + + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = getApplication(clientName, owner); + String applicationUUID = application.getApplicationId(); // do app key mapping mapApplicationKeys(dcrApplication.getClientId(), dcrApplication.getClientSecret(), keyManagerName, @@ -426,11 +424,11 @@ public class KeyMgtServiceImpl implements KeyMgtService { * Retrieves an application by name and owner * * @param applicationName name of the application - * @param owner owner of the application + * @param accessToken Access Token * @return @{@link Application} Application object * @throws KeyMgtException if any error occurs while retrieving the application */ - private Application getApplication(String applicationName, String accessToken) throws KeyMgtException { + private io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application getApplication(String applicationName, String accessToken) throws KeyMgtException { TokenInfo tokenInfo = new TokenInfo(); tokenInfo.setApiApplicationInfo(null); @@ -440,38 +438,26 @@ public class KeyMgtServiceImpl implements KeyMgtService { KeyMgtDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); - - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application applicationFromRestCall; if (applications.length == 1) { - applicationFromRestCall = applications[0]; + return applications[0]; } else { String msg = "Found invalid number of applications. No of applications found from the APIM: " + applications.length; + log.error(msg); throw new KeyMgtException(msg); } - - Application application = null; - application.setUUID(applicationFromRestCall.getApplicationId()); - application.setName(applicationFromRestCall.getName()); - application.setDescription(applicationFromRestCall.getDescription()); - application.setApplicationAttributes(applicationFromRestCall.getAttributes()); - application.setTokenType(applicationFromRestCall.getTokenType()); - application.setStatus(applicationFromRestCall.getStatus()); - application.setSubscriptionCount(applicationFromRestCall.getSubscriptionCount()); - application.setOwner(applicationFromRestCall.getOwner()); - application.setIsBlackListed(applicationFromRestCall.isHashEnabled()); - return application; - } - - catch (io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException e) { - e.printStackTrace(); + } catch (io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException e) { msg = "Error while trying to retrieve the application"; - log.error(msg); + log.error(msg, e); throw new KeyMgtException(msg); } catch (UnexpectedResponseException e) { - throw new KeyMgtException(""); + msg = "Received invalid response for the API applications retrieving REST API call."; + log.error(msg, e); + throw new KeyMgtException(msg); } catch (APIServicesException e) { - throw new KeyMgtException(""); + msg = "Error occurred while processing the API Response."; + log.error(msg, e); + throw new KeyMgtException(msg); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index abcdbacc93..09be7963fd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -802,7 +802,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); try { //todo - lasantha - can't get password from here - ApiApplicationKey apiApplicationKey = null; + ApiApplicationKey apiApplicationKey; try { DCRResponse adminDCRResponse = keyMgtService.dynamicClientRegistration(applicationName, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java index b223a98a66..e2e5d30bb4 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/util/JWTClientUtil.java @@ -218,8 +218,7 @@ public class JWTClientUtil { long nbf = currentTimeMillis + jwtConfig.getValidityPeriodFromCurrentTime() * 60 * 1000; String jti = jwtConfig.getJti(); if (jti == null) { - String defaultTokenId = currentTimeMillis + "" + new SecureRandom().nextInt(); - jti = defaultTokenId; + jti = currentTimeMillis + "" + new SecureRandom().nextInt(); } List aud = jwtConfig.getAudiences(); //set up the basic claims @@ -273,8 +272,7 @@ public class JWTClientUtil { JWSSigner signer = new RSASSASigner(rsaPrivateKey); SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.RS256), claimsSet.build()); signedJWT.sign(signer); - String assertion = signedJWT.serialize(); - return assertion; + return signedJWT.serialize(); } catch (KeyStoreException e) { throw new JWTClientException("Failed loading the keystore.", e); } catch (IOException e) { From c455bfe187dab810bfca35f514efff129825df17 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 21 Jun 2023 17:40:08 +0530 Subject: [PATCH 032/343] Fix consumer REST calls --- .../APIManagementProviderServiceImpl.java | 8 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 7 +- .../rest/api/bean/APIMConsumer/APIInfo.java | 211 ++++-------------- .../api/bean/APIMConsumer/Subscription.java | 8 +- 4 files changed, 52 insertions(+), 182 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 730bb53c16..b124fb4e91 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -80,6 +80,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe private static final Log log = LogFactory.getLog(APIManagementProviderServiceImpl.class); public static final APIManagerFactory API_MANAGER_FACTORY = APIManagerFactory.getInstance(); + private static final String UNLIMITED_TIER = "Unlimited"; @Override public boolean isTierLoaded() { @@ -238,6 +239,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application.setName(applicationName); + application.setThrottlingPolicy(UNLIMITED_TIER); try { application = consumerRESTAPIServices.createApplication(tokenInfo, application); @@ -254,7 +256,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), - keyManager.getName(), keyType, validityTime); + keyManager.getName(), validityTime, keyType); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -317,6 +319,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Subscription subscription = new Subscription(); subscription.setApiId(apiInfo.getId()); subscription.setApplicationId(application.getApplicationId()); + subscription.setThrottlingPolicy(UNLIMITED_TIER); + subscription.setRequestedThrottlingPolicy(UNLIMITED_TIER); subscriptionList.add(subscription); }); @@ -649,7 +653,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationKey apiApplicationKey; io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; try { - if (username == null && password == null) { + if (username == null || password == null) { apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); } else { apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index 81ed4cd4e3..293894ee71 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -176,7 +176,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { " \"description\": \"" + application.getDescription() + "\",\n" + " \"tokenType\": \"" + application.getTokenType() + "\",\n" + " \"groups\": " + gson.toJson(application.getGroups()) + ",\n" + - " \"attributes\": " + application.getAttributes().toString() + ",\n" + + " \"attributes\": " + gson.toJson(application.getAttributes()) + ",\n" + " \"subscriptionScopes\": " + gson.toJson(application.getSubscriptionScopes()) + "\n" + "}"; RequestBody requestBody = RequestBody.create(JSON, applicationInfo); @@ -291,7 +291,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); - String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId; + String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId + "&limit=1000"; Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); @@ -497,8 +497,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { try { Response response = client.newCall(request).execute(); if (HttpStatus.SC_OK == response.code()) { - JSONArray subscriptionsArray = (JSONArray) new JSONObject(response.body().string()).get("list"); - return gson.fromJson(subscriptionsArray.toString(), Subscription[].class); + return gson.fromJson(response.body().string(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { if (!token) { 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/bean/APIMConsumer/APIInfo.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/APIMConsumer/APIInfo.java index f18647899f..3dc4b6c570 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/bean/APIMConsumer/APIInfo.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/APIMConsumer/APIInfo.java @@ -36,31 +36,16 @@ public class APIInfo { private String context; private String version; private String provider; - private JSONObject apiDefinition; - private String wsdlUri; private String lifeCycleStatus; - private boolean isDefaultVersion; - private String type; - private Set transport; - private List operations; - private String authorizationHeader; - private String securityScheme; - private Set tags; - private List tiers; - private boolean hasThumbnail; - private String additionalProperties; - private JSONObject monetization; - private List endpointURLs; - private JSONObject businessInformation; - private List environmentList; - private List scopes; + private String thumbnailUri; private String avgRating; + private List throttlingPolicies; private JSONObject advertiseInfo; + private JSONObject businessInformation; private boolean isSubscriptionAvailable; - private List categories; - private List keyManagers = new ArrayList(); - private String createdTime; - private String lastUpdatedTime; + private String monetizationLabel; + private String gatewayVendor; + private List additionalProperties; public String getId() { return id; @@ -110,22 +95,6 @@ public class APIInfo { this.provider = provider; } - public JSONObject getApiDefinition() { - return apiDefinition; - } - - public void setApiDefinition(JSONObject apiDefinition) { - this.apiDefinition = apiDefinition; - } - - public String getWsdlUri() { - return wsdlUri; - } - - public void setWsdlUri(String wsdlUri) { - this.wsdlUri = wsdlUri; - } - public String getLifeCycleStatus() { return lifeCycleStatus; } @@ -134,124 +103,12 @@ public class APIInfo { this.lifeCycleStatus = lifeCycleStatus; } - public boolean isDefaultVersion() { - return isDefaultVersion; + public String getThumbnailUri() { + return thumbnailUri; } - public void setDefaultVersion(boolean defaultVersion) { - isDefaultVersion = defaultVersion; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Set getTransport() { - return transport; - } - - public void setTransport(Set transport) { - this.transport = transport; - } - - public List getOperations() { - return operations; - } - - public void setOperations(List operations) { - this.operations = operations; - } - - public String getAuthorizationHeader() { - return authorizationHeader; - } - - public void setAuthorizationHeader(String authorizationHeader) { - this.authorizationHeader = authorizationHeader; - } - - public String getSecurityScheme() { - return securityScheme; - } - - public void setSecurityScheme(String securityScheme) { - this.securityScheme = securityScheme; - } - - public Set getTags() { - return tags; - } - - public void setTags(Set tags) { - this.tags = tags; - } - - public List getTiers() { - return tiers; - } - - public void setTiers(List tiers) { - this.tiers = tiers; - } - - public boolean isHasThumbnail() { - return hasThumbnail; - } - - public void setHasThumbnail(boolean hasThumbnail) { - this.hasThumbnail = hasThumbnail; - } - - public String getAdditionalProperties() { - return additionalProperties; - } - - public void setAdditionalProperties(String additionalProperties) { - this.additionalProperties = additionalProperties; - } - - public JSONObject getMonetization() { - return monetization; - } - - public void setMonetization(JSONObject monetization) { - this.monetization = monetization; - } - - public List getEndpointURLs() { - return endpointURLs; - } - - public void setEndpointURLs(List endpointURLs) { - this.endpointURLs = endpointURLs; - } - - public JSONObject getBusinessInformation() { - return businessInformation; - } - - public void setBusinessInformation(JSONObject businessInformation) { - this.businessInformation = businessInformation; - } - - public List getEnvironmentList() { - return environmentList; - } - - public void setEnvironmentList(List environmentList) { - this.environmentList = environmentList; - } - - public List getScopes() { - return scopes; - } - - public void setScopes(List scopes) { - this.scopes = scopes; + public void setThumbnailUri(String thumbnailUri) { + this.thumbnailUri = thumbnailUri; } public String getAvgRating() { @@ -262,6 +119,14 @@ public class APIInfo { this.avgRating = avgRating; } + public List getThrottlingPolicies() { + return throttlingPolicies; + } + + public void setThrottlingPolicies(List throttlingPolicies) { + this.throttlingPolicies = throttlingPolicies; + } + public JSONObject getAdvertiseInfo() { return advertiseInfo; } @@ -270,6 +135,14 @@ public class APIInfo { this.advertiseInfo = advertiseInfo; } + public JSONObject getBusinessInformation() { + return businessInformation; + } + + public void setBusinessInformation(JSONObject businessInformation) { + this.businessInformation = businessInformation; + } + public boolean isSubscriptionAvailable() { return isSubscriptionAvailable; } @@ -278,35 +151,27 @@ public class APIInfo { isSubscriptionAvailable = subscriptionAvailable; } - public List getCategories() { - return categories; + public String getMonetizationLabel() { + return monetizationLabel; } - public void setCategories(List categories) { - this.categories = categories; + public void setMonetizationLabel(String monetizationLabel) { + this.monetizationLabel = monetizationLabel; } - public List getKeyManagers() { - return keyManagers; + public String getGatewayVendor() { + return gatewayVendor; } - public void setKeyManagers(List keyManagers) { - this.keyManagers = keyManagers; + public void setGatewayVendor(String gatewayVendor) { + this.gatewayVendor = gatewayVendor; } - public String getCreatedTime() { - return createdTime; + public List getAdditionalProperties() { + return additionalProperties; } - public void setCreatedTime(String createdTime) { - this.createdTime = createdTime; - } - - public String getLastUpdatedTime() { - return lastUpdatedTime; - } - - public void setLastUpdatedTime(String lastUpdatedTime) { - this.lastUpdatedTime = lastUpdatedTime; + public void setAdditionalProperties(List additionalProperties) { + this.additionalProperties = additionalProperties; } } 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java index 085b87785f..2ff525f5dc 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java @@ -18,13 +18,15 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; +import org.json.JSONObject; + public class Subscription { private String subscriptionId; private String applicationId; private String apiId; private APIInfo apiInfo; - private Application applicationInfo; + private JSONObject applicationInfo; private String throttlingPolicy; private String requestedThrottlingPolicy; private String status; @@ -62,11 +64,11 @@ public class Subscription { this.apiInfo = apiInfo; } - public Application getApplicationInfo() { + public JSONObject getApplicationInfo() { return applicationInfo; } - public void setApplicationInfo(Application applicationInfo) { + public void setApplicationInfo(JSONObject applicationInfo) { this.applicationInfo = applicationInfo; } From 1e9b38440b35acd6bc7c5c2e090fc55106c7f8d8 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 28 Jun 2023 09:33:27 +0530 Subject: [PATCH 033/343] Improve subscription filtering logic --- .../extension/APIManagementProviderServiceImpl.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index b124fb4e91..0808f11963 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -64,14 +64,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; /** * This class represents an implementation of APIManagementProviderService. @@ -188,7 +181,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); } else { Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); - Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove); + for (Subscription subscription : subscriptions) { + uniqueApiList.removeIf(apiInfo -> Objects.equals(apiInfo.getId(), subscription.getApiInfo().getId())); + } addSubscriptions(application, uniqueApiList, tokenInfo); String[] metaValues = metaData.getMetaValue().split(":"); From e7062b37b28310959c6f93dce6a167fcb3773ccc Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 28 Jun 2023 18:59:30 +0530 Subject: [PATCH 034/343] Fix Cron Expression defining issue --- .../mgt/core/task/ScheduledAppSubscriptionTaskManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java index 15ddee9618..325c2d8b9d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/task/ScheduledAppSubscriptionTaskManager.java @@ -158,7 +158,7 @@ public class ScheduledAppSubscriptionTaskManager { TaskManager taskManager = taskService.getTaskManager(SCHEDULED_APP_SUBSCRIPTION_TASK_TYPE); TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo(); - triggerInfo.setCronExpression("0 0 0/24 ? * * *"); + triggerInfo.setCronExpression("0 0 0 ? * * *"); String taskName = "SCHEDULED_APP_SUBSCRIPTION_CLEANUP_TASK"; TaskInfo taskInfo = new TaskInfo(taskName, ScheduledAppSubscriptionCleanupTask.class.getName(), null, From 35ee44f79921642bfe37ac510c219a64ee8fc93b Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 29 Jun 2023 15:46:35 +0530 Subject: [PATCH 035/343] Remove Capp Deploying service --- ...AnalyticsArtifactUploaderAdminService.java | 108 ---- ...yticsArtifactUploaderAdminServiceImpl.java | 500 ------------------ .../src/main/webapp/WEB-INF/cxf-servlet.xml | 1 - 3 files changed, 609 deletions(-) delete mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAnalyticsArtifactUploaderAdminService.java delete mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAnalyticsArtifactUploaderAdminServiceImpl.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAnalyticsArtifactUploaderAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAnalyticsArtifactUploaderAdminService.java deleted file mode 100644 index 286669e1ac..0000000000 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/DeviceAnalyticsArtifactUploaderAdminService.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2018 - 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.device.mgt.api.jaxrs.service.api.admin; - - -import io.entgra.device.mgt.core.apimgt.annotations.Scope; -import io.entgra.device.mgt.core.apimgt.annotations.Scopes; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; -import io.swagger.annotations.*; - -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; - -@SwaggerDefinition( - info = @Info( - version = "1.0.0", - title = "", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "DeviceAnalyticsArtifactUploaderAdminService"), - @ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/admin/publish-artifact"), - }) - } - ), - tags = { - @Tag(name = "device_management", description = "") - } -) -@Path("/admin/publish-artifact") -@Api(value = "Devicetype deployment Administrative Service", description = "This an API intended to be used to " + - "deploy device type components" + - "Further, this is strictly restricted to admin users only ") -@Scopes( - scopes = { - @Scope( - name = "Devicetype deployment", - description = "Deploy devicetype", - key = "perm:devicetype:deployment", - roles = {"Internal/devicemgt-admin"}, - permissions = {"/device-mgt/devicetype/deploy"} - ) - } -) - -public interface DeviceAnalyticsArtifactUploaderAdminService { - - @POST - @Path("/deploy/{type}") - @ApiOperation( - httpMethod = "POST", - value = "Deploy device type\n", - notes = "This is an API that can be used to deploy existing device type artifact for tenant", - response = Response.class, - tags = "Devicetype Deployment Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:devicetype:deployment") - }) - }) - - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "OK. \n Successfully deployed the artifacts.", - response = Response.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error.", - response = ErrorResponse.class), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The entity of the request was in a not supported format."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while checking the authorization" + - " for a specified set of devices.", - response = ErrorResponse.class) - }) - - Response doPublish( - @ApiParam(name = "type", - value = "The type of deployment." + - "INFO: Deploy artifact with given type.", - required = true) - @PathParam("type") String type); - -} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAnalyticsArtifactUploaderAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAnalyticsArtifactUploaderAdminServiceImpl.java deleted file mode 100644 index 67372a5e88..0000000000 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/DeviceAnalyticsArtifactUploaderAdminServiceImpl.java +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright (c) 2018 - 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.device.mgt.api.jaxrs.service.impl.admin; - -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.DeviceAnalyticsArtifactUploaderAdminService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; -import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; -import org.apache.axis2.AxisFault; -import org.apache.axis2.client.Options; -import org.apache.axis2.client.Stub; -import org.apache.axis2.java.security.SSLProtocolSocketFactory; -import org.apache.axis2.transport.http.HTTPConstants; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.httpclient.Header; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.core.util.Utils; -import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceStub; -import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManagerFactory; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; -import java.io.*; -import java.nio.file.Files; -import java.rmi.RemoteException; -import java.security.*; -import java.security.cert.CertificateException; -import java.util.ArrayList; -import java.util.List; - -@Path("/admin/publish-artifact") -public class DeviceAnalyticsArtifactUploaderAdminServiceImpl implements DeviceAnalyticsArtifactUploaderAdminService { - - /** - * required soap header for authorization - */ - private static final String AUTHORIZATION_HEADER = "Authorization"; - - /** - * required soap header value for mutualSSL - */ - private static final String AUTHORIZATION_HEADER_VALUE = "Bearer"; - - 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 KeyStore keyStore; - private KeyStore trustStore; - private char[] keyStorePassword; - private SSLContext sslContext; - - private String tenantDomain; - - private static final Log log = LogFactory.getLog(DeviceAnalyticsArtifactUploaderAdminServiceImpl.class); - private static final String DEFAULT_RESOURCE_LOCATION = "/resources/devicetypes"; - private static final String CAR_FILE_LOCATION = CarbonUtils.getCarbonHome() + File.separator + "repository" + - File.separator + "resources" + File.separator + "devicetypes"; - private static final String DAS_PORT = "${iot.analytics.https.port}"; - private static final String DAS_HOST_NAME = "${iot.analytics.host}"; - private static final String DEFAULT_HTTP_PROTOCOL = "https"; - private static final String IOT_MGT_PORT = "${iot.manager.https.port}"; - private static final String IOT_MGT_HOST_NAME = "${iot.manager.host}"; - private static final String DAS_URL = DEFAULT_HTTP_PROTOCOL + "://" + DAS_HOST_NAME - + ":" + DAS_PORT + "/services/CarbonAppUploader/"; - private static final String DAS_EVENT_RECEIVER_EP = DEFAULT_HTTP_PROTOCOL + "://" + DAS_HOST_NAME - + ":" + DAS_PORT + "/services/EventReceiverAdminService/"; - private static final String DAS_EVENT_STREAM_EP = DEFAULT_HTTP_PROTOCOL + "://" + DAS_HOST_NAME - + ":" + DAS_PORT + "/services/EventStreamAdminService/"; - - private static final String IOT_MGT_URL = DEFAULT_HTTP_PROTOCOL + "://" + IOT_MGT_HOST_NAME - + ":" + IOT_MGT_PORT + "/services/CarbonAppUploader/"; - private static final String MEDIA_TYPE_XML = "application/xml"; - private static final String DEVICE_MANAGEMENT_TYPE = "device_management"; - private static final String TENANT_DOMAIN_PROPERTY = "\\$\\{tenant-domain\\}"; - - - @Override - @POST - @Path("/deploy/{type}") - public Response doPublish(@PathParam("type") String type) { - try { - //Getting the tenant Domain - tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - String tenantAdminUser = username + "@" + tenantDomain; - - String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); - String trustStorePassword = ServerConfiguration.getInstance().getFirstProperty( - "Security.TrustStore.Password"); - String keyStoreLocation = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Location"); - String trustStoreLocation = ServerConfiguration.getInstance().getFirstProperty( - "Security.TrustStore.Location"); - - //Call to load the keystore. - loadKeyStore(keyStoreLocation, keyStorePassword); - //Call to load the TrustStore. - loadTrustStore(trustStoreLocation, trustStorePassword); - //Create the SSL context with the loaded TrustStore/keystore. - initSSLConnection(); - JWTClient jwtClient = DeviceMgtAPIUtils.getJWTClientManagerService().getJWTClient(); - - String authValue = AUTHORIZATION_HEADER_VALUE + " " + new String(Base64.encodeBase64( - jwtClient.getJwtToken(tenantAdminUser).getBytes())); - - List
list = new ArrayList<>(); - Header httpHeader = new Header(); - httpHeader.setName(AUTHORIZATION_HEADER); - httpHeader.setValue(authValue); - list.add(httpHeader);//"https" - - List streamFileList = getStreamsList(type); - List receiverFileList = getReceiversList(type); - - if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { - if (streamFileList != null) { - publishDynamicEventStream(type, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, streamFileList); - } - if (receiverFileList != null) { - publishDynamicEventReceivers(type, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, receiverFileList); - } - } - if (streamFileList != null) { - publishDynamicEventStream(type, tenantDomain, streamFileList); - } - //todo:analytics -// if (deployAnalyticsCapp(type, list)){ -// return Response.status(Response.Status.BAD_REQUEST) -// .entity("\"Error, Artifact does not exist.\"").build(); -// } - if (receiverFileList != null) { - publishDynamicEventReceivers(type, tenantDomain, receiverFileList); - } - return Response.status(Response.Status.CREATED).entity("\"OK. \\n Successfully uploaded the artifacts.\"") - .build(); - } catch (AxisFault e) { - log.error("failed to publish event definitions for tenantDomain:" + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (RemoteException e) { - log.error("Failed to connect with the remote services:" + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain:" + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (UserStoreException e) { - log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (CertificateException | UnrecoverableKeyException | KeyStoreException | - KeyManagementException | IOException | NoSuchAlgorithmException e) { - log.error("Failed to access keystore for, tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - //todo:analytics -// } catch (RegistryException e) { -// log.error("Failed to load tenant, tenantDomain: " + tenantDomain, e); -// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (ParseException e) { - log.error("Invalid stream definition for device type" + type + " for tenant, tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } - } - - //todo:analytics -// private boolean deployAnalyticsCapp(@PathParam("type") String type, List
list) throws IOException, RegistryException { -// CarbonAppUploaderStub carbonAppUploaderStub = null; -// try { -// File directory = new File(CAR_FILE_LOCATION + File.separator + type); -// if (directory.isDirectory() && directory.exists()) { -// UploadedFileItem[] uploadedFileItems = loadCappFromFileSystem(type); -// if (uploadedFileItems.length > 0) { -// if (DEVICE_MANAGEMENT_TYPE.equals(type.toLowerCase())) { -// carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty( -// IOT_MGT_URL)); -// Options appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions(); -// if (appUploaderOptions == null) { -// appUploaderOptions = new Options(); -// } -// appUploaderOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); -// appUploaderOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER -// , new Protocol(DEFAULT_HTTP_PROTOCOL, -// (ProtocolSocketFactory) new SSLProtocolSocketFactory -// (sslContext), Integer.parseInt(Utils.replaceSystemProperty( -// IOT_MGT_PORT)))); -// -// carbonAppUploaderStub._getServiceClient().setOptions(appUploaderOptions); -// carbonAppUploaderStub.uploadApp(uploadedFileItems); -// } else { -// carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty(DAS_URL)); -// Options appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions(); -// if (appUploaderOptions == null) { -// appUploaderOptions = new Options(); -// } -// appUploaderOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); -// appUploaderOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER -// , new Protocol(DEFAULT_HTTP_PROTOCOL -// , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) -// , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); -// -// carbonAppUploaderStub._getServiceClient().setOptions(appUploaderOptions); -// carbonAppUploaderStub.uploadApp(uploadedFileItems); -// } -// } -// } else { -// return true; -// } -// return false; -// } finally { -// cleanup(carbonAppUploaderStub); -// } -// } - - private void publishDynamicEventReceivers(String deviceType, String tenantDomain, List receiversList) - throws IOException, UserStoreException, JWTClientException { - - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); - EventReceiverAdminServiceStub receiverAdminServiceStub = null; - try { - receiverAdminServiceStub = new EventReceiverAdminServiceStub - (Utils.replaceSystemProperty(DAS_EVENT_RECEIVER_EP)); - Options eventReciverOptions = receiverAdminServiceStub._getServiceClient().getOptions(); - if (eventReciverOptions == null) { - eventReciverOptions = new Options(); - } - String username; - if(!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { - username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName()+"@"+tenantDomain; - }else { - username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName(); - } - - - JWTClient jwtClient = DeviceMgtAPIUtils.getJWTClientManagerService().getJWTClient(); - - String authValue = AUTHORIZATION_HEADER_VALUE + " " + new String(Base64.encodeBase64( - jwtClient.getJwtToken(username).getBytes())); - - List
list = new ArrayList<>(); - Header httpHeader = new Header(); - httpHeader.setName(AUTHORIZATION_HEADER); - httpHeader.setValue(authValue); - list.add(httpHeader);//"https" - - eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); - eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER - , new Protocol(DEFAULT_HTTP_PROTOCOL - , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) - , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); - - receiverAdminServiceStub._getServiceClient().setOptions(eventReciverOptions); - for (String receiverContent:receiversList) { - receiverAdminServiceStub.deployEventReceiverConfiguration(receiverContent); - } - } finally { - cleanup(receiverAdminServiceStub); - PrivilegedCarbonContext.endTenantFlow(); - } - } - - private void publishDynamicEventStream(String deviceType, String tenantDomain, List streamList) - throws IOException, UserStoreException, JWTClientException, ParseException { - - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); - EventStreamAdminServiceStub eventStreamAdminServiceStub = null; - try { - eventStreamAdminServiceStub = new EventStreamAdminServiceStub - (Utils.replaceSystemProperty(DAS_EVENT_STREAM_EP)); - Options eventReciverOptions = eventStreamAdminServiceStub._getServiceClient().getOptions(); - if (eventReciverOptions == null) { - eventReciverOptions = new Options(); - } - String username; - if(!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { - username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName()+"@"+tenantDomain; - }else { - username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName(); - } - - - JWTClient jwtClient = DeviceMgtAPIUtils.getJWTClientManagerService().getJWTClient(); - - String authValue = AUTHORIZATION_HEADER_VALUE + " " + new String(Base64.encodeBase64( - jwtClient.getJwtToken(username).getBytes())); - - List
list = new ArrayList<>(); - Header httpHeader = new Header(); - httpHeader.setName(AUTHORIZATION_HEADER); - httpHeader.setValue(authValue); - list.add(httpHeader);//"https" - - eventReciverOptions.setProperty(HTTPConstants.HTTP_HEADERS, list); - eventReciverOptions.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER - , new Protocol(DEFAULT_HTTP_PROTOCOL - , (ProtocolSocketFactory) new SSLProtocolSocketFactory(sslContext) - , Integer.parseInt(Utils.replaceSystemProperty(DAS_PORT)))); - - eventStreamAdminServiceStub._getServiceClient().setOptions(eventReciverOptions); - for (String streamContent:streamList) { - JSONParser jsonParser = new JSONParser(); - JSONObject steamJson = (JSONObject)jsonParser.parse(streamContent); - String name = (String) steamJson.get("name"); - String version = (String) steamJson.get("version"); - String streamId = name +":"+version; - if (eventStreamAdminServiceStub.getStreamDefinitionDto(streamId) == null) { - eventStreamAdminServiceStub.addEventStreamDefinitionAsString(streamContent); - } - } - } finally { - cleanup(eventStreamAdminServiceStub); - PrivilegedCarbonContext.endTenantFlow(); - } - } - - - private List getReceiversList(String deviceType) throws IOException { - File directory = new File(CAR_FILE_LOCATION + File.separator + deviceType+File.separator+"receiver"); - if (!directory.exists()) { - return null; - } - File[] receiverFiles = directory.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.toLowerCase().endsWith(".xml"); - } - }); - List receiverList = new ArrayList<>(); - for (File receiverFile:receiverFiles) { - String receiverContentTemplate =new String(Files.readAllBytes(receiverFile.toPath())); - final String receiverContent = receiverContentTemplate.replaceAll(TENANT_DOMAIN_PROPERTY, tenantDomain.toLowerCase()); - receiverList.add(receiverContent); - } - - return receiverList; - } - - private List getStreamsList(String deviceType) throws IOException { - File directory = new File(CAR_FILE_LOCATION + File.separator + deviceType+File.separator+"streams"); - if (!directory.exists()) { - return null; - } - File[] receiverFiles = directory.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.toLowerCase().endsWith(".json"); - } - }); - List streamList = new ArrayList<>(); - for (File StreamFile:receiverFiles) { - String streamContent =new String(Files.readAllBytes(StreamFile.toPath())); - streamList.add(streamContent); - } - return streamList; - } - - //todo:analytics -// private UploadedFileItem[] loadCappFromFileSystem(String deviceType) throws IOException { -// -// File directory = new File(CAR_FILE_LOCATION + File.separator + deviceType); -// File[] carFiles = directory.listFiles(new FilenameFilter() { -// @Override -// public boolean accept(File dir, String name) { -// return name.toLowerCase().endsWith(".car"); -// } -// }); -// List uploadedFileItemLis = new ArrayList<>(); -// if (carFiles != null) { -// -// for (File carFile : carFiles) { -// UploadedFileItem uploadedFileItem = new UploadedFileItem(); -// DataHandler param = new DataHandler(carFile.toURI().toURL()); -// uploadedFileItem.setDataHandler(param); -// uploadedFileItem.setFileName(carFile.getName()); -// uploadedFileItem.setFileType("jar"); -// uploadedFileItemLis.add(uploadedFileItem); -// } -// } -// UploadedFileItem[] fileItems = new UploadedFileItem[uploadedFileItemLis.size()]; -// fileItems = uploadedFileItemLis.toArray(fileItems); -// return fileItems; -// } - - /** - * Loads the keystore. - * - * @param keyStorePath - the path of the keystore - * @param ksPassword - the keystore password - */ - private void loadKeyStore(String keyStorePath, String ksPassword) - throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { - InputStream fis = null; - try { - keyStorePassword = ksPassword.toCharArray(); - keyStore = KeyStore.getInstance(KEY_STORE_TYPE); - fis = new FileInputStream(keyStorePath); - keyStore.load(fis, keyStorePassword); - } finally { - if (fis != null) { - fis.close(); - } - } - } - - /** - * Loads the trustore - * - * @param trustStorePath - the trustore path in the filesystem. - * @param tsPassword - the truststore password - */ - private void loadTrustStore(String trustStorePath, String tsPassword) - throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException { - - InputStream fis = null; - try { - trustStore = KeyStore.getInstance(TRUST_STORE_TYPE); - fis = new FileInputStream(trustStorePath); - trustStore.load(fis, tsPassword.toCharArray()); - } finally { - if (fis != null) { - fis.close(); - } - } - } - - /** - * Initializes the SSL Context - */ - private void initSSLConnection() throws NoSuchAlgorithmException, UnrecoverableKeyException, - KeyStoreException, KeyManagementException { - KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KEY_MANAGER_TYPE); - keyManagerFactory.init(keyStore, keyStorePassword); - TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TRUST_MANAGER_TYPE); - trustManagerFactory.init(trustStore); - - // Create and initialize SSLContext for HTTPS communication - sslContext = SSLContext.getInstance(SSLV3); - sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); - SSLContext.setDefault(sslContext); - } - - private void cleanup(Stub stub) { - if (stub != null) { - try { - stub.cleanup(); - } catch (AxisFault axisFault) { - //do nothing - } - } - } - -} - diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index bb05b0b2e3..46a6ff71ae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -94,7 +94,6 @@ - From 1c3cd7cd2f81f602db523114df78586d1bb4326f Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 30 Jun 2023 12:02:17 +0530 Subject: [PATCH 036/343] fixed webapp deploying failure --- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 46a6ff71ae..3643aa9a7b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -43,7 +43,6 @@ - From 2ff6e2e52968699091a6027d5e1005547deee275 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 30 Jun 2023 12:02:53 +0530 Subject: [PATCH 037/343] updated jackson-databind version --- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 4 ++-- pom.xml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index e274b0192a..45b7fd07c9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -53,7 +53,7 @@ Subtype Management Bundle io.entgra.device.mgt.core.subtype.mgt.internal - com.fasterxml.jackson.core;version="[2.10,3)", + com.fasterxml.jackson.core;version="[2.14,3)", com.google.common.cache;version="[31.0,32)", io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", @@ -331,7 +331,7 @@ provided - org.wso2.orbit.com.fasterxml.jackson.core + com.fasterxml.jackson.core jackson-databind provided diff --git a/pom.xml b/pom.xml index dd387b813a..28dfc7301b 100644 --- a/pom.xml +++ b/pom.xml @@ -1561,9 +1561,9 @@ ${jackson-annotations.version} - org.wso2.orbit.com.fasterxml.jackson.core + com.fasterxml.jackson.core jackson-databind - ${jackson-databind.version} + ${fasterxml.jackson.databind.version} @@ -2151,6 +2151,7 @@ [4.7.0, 4.9.0) [1.0.1, 2.0.0) [4.7.0, 5.0.0) + 2.14.1 From 204b5d956b557fc36ed01415ac01e21539a27f1e Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Tue, 4 Jul 2023 16:54:32 +0530 Subject: [PATCH 038/343] fixed unit tests of application-mgt --- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 7 +++++++ .../test/resources/user-test/user-mgt-registry-test.xml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 9c3ab8ff85..7134db16fc 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -153,6 +153,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + src/test/resources/testng.xml @@ -160,6 +164,9 @@ ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties + + org.ops4j.pax.logging + diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 From 9f19c1d1c1b899faa8225117385ba6759864de01 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 10:35:43 +0530 Subject: [PATCH 039/343] fixed unit tests in analytics-mgt --- .../pom.xml | 2 +- .../pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 82f30811ab..59c0b53f0c 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -295,7 +295,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 2e2888b88a..0089325b5d 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -211,7 +211,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 org.wso2.carbon From 1c4ee6cacc7ed5acc36095ec5ecadc89b87d4100 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 10:40:38 +0530 Subject: [PATCH 040/343] fixed mockito dependency issue --- .../io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index c0c72a2f65..0f030906b9 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -41,7 +41,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From b08f3fcc4939996b3405fa690931197cb91aafeb Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 13:15:02 +0530 Subject: [PATCH 041/343] fixed unit tests --- .../pom.xml | 9 +- .../src/test/resources/sql/CreateH2TestDB.sql | 247 ++++++++++-------- .../user-test/user-mgt-registry-test.xml | 2 +- .../pom.xml | 9 +- .../carbon-home/dbscripts/dm-db-h2.sql | 169 +++++++----- .../conf/datasources/data-source-config.xml | 2 +- .../pom.xml | 2 +- 7 files changed, 256 insertions(+), 184 deletions(-) diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 6887a4f3e5..5e7d63b270 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -116,12 +116,19 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/log4j.properties src/test/resources/testng.xml + + org.ops4j.pax.logging + @@ -254,7 +261,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index defd753f33..6c906a5c49 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -1,3 +1,51 @@ + DROP VIEW IF EXISTS FEATURE_NON_COMPLIANCE_INFO; + ALTER TABLE IF EXISTS DM_DEVICE DROP CONSTRAINT IF EXISTS fk_DM_DEVICE_DM_DEVICE_TYPE2; +-- ALTER TABLE IF EXISTS DM_DEVICE_TYPE_PLATFORM DROP CONSTRAINT IF EXISTS DM_DEVICE_TYPE_DM_DEVICE_TYPE_PLATFORM_MAPPING; + ALTER TABLE IF EXISTS DM_ROLE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_ROLE_GROUP_MAP_DM_GROUP2; + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_MAP_DM_GROUP2; + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_POLICY DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_POLICY; +-- ALTER TABLE IF EXISTS DM_GEOFENCE_GROUP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_GEOFENCE_GROUP_MAPPING_GROUP; +-- ALTER TABLE IF EXISTS DM_DEVICE_EVENT_GROUP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_EVENT_GROUP_MAPPING_GROUP; + + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_MAP_DM_DEVICE2; + ALTER TABLE IF EXISTS DM_ENROLMENT DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_ENROLMENT; + ALTER TABLE IF EXISTS DM_DEVICE_STATUS DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_STATUS_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_POLICY DROP CONSTRAINT IF EXISTS FK_DEVICE_DEVICE_POLICY; + ALTER TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED DROP CONSTRAINT IF EXISTS FK_DM_POLICY_DEVCIE_APPLIED; + ALTER TABLE IF EXISTS DM_APPLICATION DROP CONSTRAINT IF EXISTS FK_DM_DEVICE; + ALTER TABLE IF EXISTS DM_NOTIFICATION DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_NOTIFICATION; + ALTER TABLE IF EXISTS DM_DEVICE_INFO DROP CONSTRAINT IF EXISTS DM_DEVICE_INFO_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_LOCATION DROP CONSTRAINT IF EXISTS DM_DEVICE_LOCATION_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_DETAIL DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_DETAILS_DEVICE; + + ALTER TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_MAPPING_OPERATION; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_OPERATION; + + ALTER TABLE IF EXISTS DM_DEVICE_STATUS DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_STATUS_ENROLMENT; + ALTER TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_MAPPING_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_ENROLLMENT; + ALTER TABLE IF EXISTS DM_APPLICATION DROP CONSTRAINT IF EXISTS FK_DM_ENROLEMENT; + ALTER TABLE IF EXISTS DM_DEVICE_INFO DROP CONSTRAINT IF EXISTS DM_DEVICE_INFO_DEVICE_ENROLLMENT; + ALTER TABLE IF EXISTS DM_DEVICE_LOCATION DROP CONSTRAINT IF EXISTS DM_DEVICE_LOCATION_DM_ENROLLMENT; + ALTER TABLE IF EXISTS DM_DEVICE_DETAIL DROP CONSTRAINT IF EXISTS FK_DM_ENROLMENT_DEVICE_DETAILS; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_EN_OP_MAP_RESPONSE; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE_LARGE DROP CONSTRAINT IF EXISTS FK_DM_EN_OP_MAP_RESPONSE_LARGE; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE_LARGE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_LARGE_MAPPING; +-- + ALTER TABLE IF EXISTS DM_POLICY DROP CONSTRAINT IF EXISTS FK_DM_PROFILE_DM_POLICY; + ALTER TABLE IF EXISTS DM_PROFILE_FEATURES DROP CONSTRAINT IF EXISTS FK_DM_PROFILE_DM_POLICY_FEATURES; +-- + ALTER TABLE IF EXISTS DM_DEVICE_POLICY DROP CONSTRAINT IF EXISTS FK_POLICY_DEVICE_POLICY; + ALTER TABLE IF EXISTS DM_DEVICE_TYPE_POLICY DROP CONSTRAINT IF EXISTS FK_DEVICE_TYPE_POLICY; + ALTER TABLE IF EXISTS DM_POLICY_CORRECTIVE_ACTION DROP CONSTRAINT IF EXISTS FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION; + ALTER TABLE IF EXISTS DM_ROLE_POLICY DROP CONSTRAINT IF EXISTS FK_ROLE_POLICY_POLICY; + ALTER TABLE IF EXISTS DM_USER_POLICY DROP CONSTRAINT IF EXISTS DM_POLICY_USER_POLICY; + ALTER TABLE IF EXISTS DM_POLICY_CRITERIA DROP CONSTRAINT IF EXISTS FK_POLICY_POLICY_CRITERIA; + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_POLICY DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_DM_POLICY; + ALTER TABLE IF EXISTS DM_POLICY_CRITERIA DROP CONSTRAINT IF EXISTS FK_CRITERIA_POLICY_CRITERIA; + ALTER TABLE IF EXISTS DM_POLICY_CRITERIA_PROPERTIES DROP CONSTRAINT IF EXISTS FK_POLICY_CRITERIA_PROPERTIES; + ALTER TABLE IF EXISTS DM_POLICY_COMPLIANCE_FEATURES DROP CONSTRAINT IF EXISTS FK_COMPLIANCE_FEATURES_STATUS; + DROP TABLE IF EXISTS DM_DEVICE_TYPE; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( ID INT AUTO_INCREMENT NOT NULL, @@ -13,24 +61,22 @@ DROP TABLE IF EXISTS DM_GROUP; CREATE TABLE IF NOT EXISTS DM_GROUP ( ID INTEGER AUTO_INCREMENT NOT NULL, GROUP_NAME VARCHAR(100) DEFAULT NULL, - DESCRIPTION TEXT DEFAULT NULL, STATUS VARCHAR(50) DEFAULT NULL, - DATE_OF_CREATE BIGINT DEFAULT NULL, - DATE_OF_LAST_UPDATE BIGINT DEFAULT NULL, - OWNER VARCHAR(45) DEFAULT NULL, + DESCRIPTION TEXT DEFAULT NULL, + OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); - -DROP TABLE IF EXISTS DM_DEVICE_CERTIFICATE; -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) +DROP TABLE IF EXISTS DM_ROLE_GROUP_MAP; +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 ); DROP TABLE IF EXISTS DM_DEVICE; @@ -38,13 +84,14 @@ 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_TYPE_ID INT 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 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) ); DROP TABLE IF EXISTS DM_DEVICE_PROPERTIES; @@ -53,8 +100,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES ( DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, PROPERTY_NAME VARCHAR(100) DEFAULT 0, PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, - TENANT_ID VARCHAR(100) DEFAULT NULL, - PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME) + TENANT_ID VARCHAR(100), + PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME, TENANT_ID) ); DROP TABLE IF EXISTS GROUP_PROPERTIES; @@ -74,9 +121,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( 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 NO ACTION ON UPDATE NO ACTION, + 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 NO ACTION ON UPDATE NO ACTION + REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS DM_OPERATION; @@ -96,7 +143,7 @@ DROP TABLE IF EXISTS DM_ENROLMENT; CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OWNER VARCHAR(50) NOT NULL, + OWNER VARCHAR(255) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, IS_TRANSFERRED BOOLEAN NOT NULL DEFAULT FALSE, @@ -105,7 +152,8 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( 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 + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID) ); DROP TABLE IF EXISTS DM_DEVICE_STATUS; CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( @@ -119,7 +167,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES - DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING; CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( @@ -167,10 +215,14 @@ 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 ); @@ -181,30 +233,25 @@ 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(20) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , - PRIMARY KEY (ID) , - CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE ) - REFERENCES DM_DEVICE_TYPE (NAME ) - ON DELETE NO ACTION - ON UPDATE NO ACTION + PRIMARY KEY (ID) ); DROP TABLE IF EXISTS DM_POLICY; CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , - PAYLOAD_VERSION VARCHAR (45) DEFAULT NULL, DESCRIPTION VARCHAR(1000) NULL, - TENANT_ID INT(11) NOT NULL , - PROFILE_ID INT(11) NOT NULL , + PAYLOAD_VERSION VARCHAR (45) NULL, + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -213,31 +260,13 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); - -DROP TABLE IF EXISTS DM_POLICY_CORRECTIVE_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 -); - - DROP TABLE IF EXISTS DM_DEVICE_POLICY; 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, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -253,29 +282,24 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( DROP TABLE IF EXISTS DM_DEVICE_TYPE_POLICY; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , - DEVICE_TYPE VARCHAR(20) NOT NULL , - POLICY_ID INT(11) NOT NULL , + ID INT NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , + POLICY_ID INT 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, - CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE ) - REFERENCES DM_DEVICE_TYPE (NAME) - ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_PROFILE_FEATURES; CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, - DEVICE_TYPE VARCHAR(20) NOT NULL, - TENANT_ID INT(11) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL, + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -285,11 +309,26 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ON UPDATE NO ACTION ); +CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( + ID INT NOT NULL AUTO_INCREMENT, + ACTION_TYPE VARCHAR(45) NOT NULL, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT 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 +); + DROP TABLE IF EXISTS DM_ROLE_POLICY; CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -315,11 +354,11 @@ DROP TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED; 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -363,7 +402,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( POLICY_CRITERION_ID INT NOT NULL, PROP_KEY VARCHAR(45) NULL, PROP_VALUE VARCHAR(100) NULL, - CONTENT BLOB NULL COMMENT 'This is used to ', + CONTENT BLOB NULL, PRIMARY KEY (ID), CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES FOREIGN KEY (POLICY_CRITERION_ID) @@ -376,7 +415,7 @@ DROP TABLE IF EXISTS DM_POLICY_COMPLIANCE_STATUS; 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -391,8 +430,8 @@ DROP TABLE IF EXISTS DM_POLICY_CHANGE_MGT; CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, - DEVICE_TYPE VARCHAR(20) NOT NULL, - TENANT_ID INT(11) NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL , + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -423,7 +462,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -434,7 +473,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT FK_DM_APP_MAP_DM_ENROL + CONSTRAINT fk_dm_enrolement FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION @@ -448,15 +487,14 @@ DROP TABLE IF EXISTS DM_NOTIFICATION; CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OPERATION_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NULL, TENANT_ID INTEGER NOT NULL, STATUS VARCHAR(10) NULL, - DESCRIPTION VARCHAR(100) 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, - CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES - DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- NOTIFICATION TABLE END -- @@ -494,7 +532,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT 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) @@ -507,6 +549,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +DROP INDEX IF EXISTS DM_DEVICE_LOCATION_GEO_hashx; +CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC); DROP TABLE IF EXISTS DM_DEVICE_DETAIL; CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( @@ -527,8 +571,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( 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, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -553,15 +597,14 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( CONSTRAINT FK_DM_DEVICE_GROUP_POLICY FOREIGN KEY (DEVICE_GROUP_ID) REFERENCES DM_GROUP (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION, + ON DELETE CASCADE + ON UPDATE CASCADE , CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY FOREIGN KEY (POLICY_ID) REFERENCES DM_POLICY (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION + ON DELETE CASCADE + ON UPDATE CASCADE ); - -- END OF POLICY AND DEVICE GROUP MAPPING -- -- DASHBOARD RELATED VIEWS -- @@ -621,22 +664,4 @@ DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID ORDER BY TENANT_ID, DEVICE_ID; -/* - * Copyright (c) 2018 - 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. - */ - -- END OF DASHBOARD RELATED VIEWS -- diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 45b7fd07c9..8add23b3d8 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -114,6 +114,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/carbon-home/repository/conf/log4j.properties @@ -121,6 +125,9 @@ src/test/resources/testng.xml + + org.ops4j.pax.logging + @@ -342,7 +349,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 40ad63072f..df3277920d 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, OWNER VARCHAR(255) DEFAULT NULL, - PARENT_PATH VARCHAR(255) DEFAULT '/', + PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); @@ -42,7 +42,7 @@ 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_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -84,8 +84,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( 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, + CREATED_TIMESTAMP BIGINT NOT NULL, + RECEIVED_TIMESTAMP BIGINT NULL, OPERATION_CODE VARCHAR(1000) NOT NULL, INITIATED_BY VARCHAR(100) NULL, OPERATION_DETAILS BLOB DEFAULT NULL, @@ -108,7 +108,19 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( 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_DEVICE_STATUS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + DEVICE_ID INTEGER NOT NULL, + STATUS VARCHAR(50) DEFAULT NULL, + UPDATE_TIME TIMESTAMP DEFAULT NULL, + CHANGED_BY VARCHAR(255) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES + DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE +); CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -176,17 +188,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT 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 , + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -197,11 +209,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); 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, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -216,9 +228,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,11 +240,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -243,11 +255,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT(11) NOT NULL AUTO_INCREMENT, + ID INT 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, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT DEFAULT NULL, IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID), CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION @@ -258,9 +270,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -284,11 +296,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -341,7 +353,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -356,7 +368,7 @@ 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, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -385,7 +397,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -405,6 +417,16 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- +CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ICON_PATH VARCHAR(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR(150) NOT NULL, + VERSION VARCHAR(50) DEFAULT '1.1.0', + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, @@ -425,7 +447,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( DEVICE_ID INT NULL, ENROLMENT_ID INT NOT NULL, KEY_FIELD VARCHAR(45) NULL, - VALUE_FIELD VARCHAR(1000) NULL, + VALUE_FIELD VARCHAR(1500) NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) @@ -454,7 +476,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -491,8 +513,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( 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, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -519,7 +541,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT(15) NOT NULL, + TIMESTAMP BIGINT NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -744,24 +766,6 @@ CREATE TABLE IF NOT EXISTS DM_EXT_DEVICE_MAPPING ( STATUS INT DEFAULT 0, PRIMARY KEY (ID) ); -/* - * Copyright (c) 2018 - 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. - */ - -- END OF DM_EXT_DEVICE_MAPPING TABLE-- -- END OF DM_EXT_PERMISSION_MAPPING TABLE-- @@ -773,23 +777,23 @@ CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING ( -- 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) + 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 + 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-- @@ -802,5 +806,34 @@ 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-- --- END OF DM_DEVICE_SUB_TYPE TABLE-- \ No newline at end of file +-- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- +CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_NAME VARCHAR(100) NOT NULL, + IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, + TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, + TRACCAR_USENAME VARCHAR(100) NULL, + STATUS VARCHAR(100) NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- + +-- SUB_OPERATION_TEMPLATE TABLE-- +CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, + OPERATION_DEFINITION TEXT NOT NULL, + OPERATION_CODE VARCHAR(100) NOT NULL, + SUB_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), + CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), +-- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), + CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) +); + +-- END OF SUB_OPERATION_TEMPLATE TABLE-- diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index ad8165fc67..2e591b07c9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 6476fc0aa6..f9972e1ef0 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -273,7 +273,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From 97595201576a2b397189bb283d5581ab03a1f734 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:22:21 +0530 Subject: [PATCH 042/343] fixed unit tests --- .../pom.xml | 14 +++++++++++++- .../client/extension/service/JWTClientTest.java | 3 ++- .../resources/user-test/user-mgt-registry-test.xml | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 8b646fa964..f35ea73b60 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -155,7 +155,12 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 + test + + + org.mockito + mockito-core test @@ -253,12 +258,19 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/log4j.properties src/test/resources/testng.xml + + org.ops4j.pax.logging + diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java index d497d5e108..beb7db9962 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java @@ -43,9 +43,10 @@ import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; import java.util.Properties; +import org.powermock.modules.testng.PowerMockTestCase; @PrepareForTest(JWTClientUtil.class) -public class JWTClientTest { +public class JWTClientTest extends PowerMockTestCase{ private static final Log log = LogFactory.getLog(JWTClientTest.class); @ObjectFactory diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 From 78f9f746d8204d21aab4e461702d600ab2533024 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:26:32 +0530 Subject: [PATCH 043/343] fixed unit tests --- .../pom.xml | 9 ++++++++- .../src/test/resources/data-source-config.xml | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index d23f1863cd..35621201eb 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -111,6 +111,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + src/test/resources/testng.xml @@ -118,6 +122,9 @@ ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties + + org.ops4j.pax.logging + @@ -175,7 +182,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml index 27b6dfeaeb..533fd82959 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon From 935238240665a1adcdd9828de147c28846a627dc Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:50:32 +0530 Subject: [PATCH 044/343] fixed unit tests --- .../pom.xml | 20 +- .../pom.xml | 34 + .../pom.xml | 29 + .../src/test/resources/conf/carbon.xml | 658 ------------------ .../test/resources/repository/conf/carbon.xml | 0 5 files changed, 81 insertions(+), 660 deletions(-) delete mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 38ba36543d..7bd5e03b5b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -106,13 +106,19 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + - file:src/test/resources/carbon-home/repository/conf/log4j.properties - + file:src/test/resources/log4j.properties src/test/resources/testng.xml + + org.ops4j.pax.logging + @@ -207,5 +213,15 @@ org.wso2.orbit.javax.xml.bind jaxb-api + + com.sun.xml.bind + jaxb-core + test + + + com.sun.xml.bind + jaxb-impl + test + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 8b1dc93e22..16d45fccce 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -104,6 +104,21 @@ io.entgra.device.mgt.core.device.mgt.core test + + org.mockito + mockito-core + test + + + com.sun.xml.bind + jaxb-core + test + + + com.sun.xml.bind + jaxb-impl + test + @@ -157,6 +172,25 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + + + file:src/test/resources/log4j.properties + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + org.jacoco jacoco-maven-plugin diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index ed434c7873..ec115c2905 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -122,6 +122,16 @@ powermock-module-testng test + + org.wso2.carbon + org.wso2.carbon.securevault + test + + + org.mockito + mockito-core + test + @@ -189,6 +199,25 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + + + file:src/test/resources/log4j.properties + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml deleted file mode 100644 index a5518cb720..0000000000 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml +++ /dev/null @@ -1,658 +0,0 @@ - - - - - - - - - ${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/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml new file mode 100644 index 0000000000..e69de29bb2 From edcf235ff8eaa7fb0d246791d81ef7c81aeafac8 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:54:56 +0530 Subject: [PATCH 045/343] fixed unit tests --- .../pom.xml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index a4673c3e6e..fffcfba429 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -76,12 +76,20 @@ org.apache.maven.plugins maven-surefire-plugin - - file:src/test/resources/log4j.properties - + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + src/test/resources/testng.xml + + ${basedir}/target/coverage-reports/jacoco-unit.exec + file:src/test/resources/log4j.properties + + + org.ops4j.pax.logging + @@ -255,7 +263,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From b7c0a8fb9bdfb6346a0f49bec3e974a7dea54c70 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 17:06:48 +0530 Subject: [PATCH 046/343] fixed unit tests --- pom.xml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 28dfc7301b..ec8f446882 100644 --- a/pom.xml +++ b/pom.xml @@ -833,6 +833,16 @@ jaxb-api ${version.org.wso2.orbit.javax.xml.bind} + + com.sun.xml.bind + jaxb-core + 2.3.0.1 + + + com.sun.xml.bind + jaxb-impl + 2.3.1 + org.apache.axis2.transport @@ -1654,7 +1664,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 ${power.mock.version} test @@ -1741,6 +1751,11 @@ mockito-inline ${mokito.version} + + org.mockito + mockito-core + ${mokito.version} + org.ops4j.pax.logging pax-logging-api @@ -1888,7 +1903,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.0 + 2.22.2 ${basedir}/target/coverage-reports/jacoco-ut.exec @@ -2113,7 +2128,7 @@ 0.7.8 0.7.5.201505241946 1.0b3 - 1.7.4 + 2.0.2 1.4.0.wso2v1 1.7.25 @@ -2136,7 +2151,7 @@ [1.6.0, 2.0.0) [1.2.0,1.3.0) - 4.2.0 + 2.23.4 2.8.1.wso2v2 4.3.1.wso2v1 2.1.210.wso2v1 From 013df183cd5574e2b8952315eb382cabcc767d5b Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 7 Jul 2023 11:11:31 +0530 Subject: [PATCH 047/343] operation template related unit test fixes --- .../pom.xml | 7 + .../carbon-home/dbscripts/dm-db-h2.sql | 199 ++++++++++++------ .../repository/conf/cdm-config.xml | 92 +++++--- .../conf/datasources/data-source-config.xml | 2 +- 4 files changed, 207 insertions(+), 93 deletions(-) diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index c71669f41e..a4ef16008e 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -119,6 +119,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/carbon-home/repository/conf/log4j.properties @@ -126,6 +130,9 @@ src/test/resources/testng.xml + + org.ops4j.pax.logging + diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 6052156588..df3277920d 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, OWNER VARCHAR(255) DEFAULT NULL, - PARENT_PATH VARCHAR(255) DEFAULT '/', + PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); @@ -42,7 +42,7 @@ 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_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -84,8 +84,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( 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, + CREATED_TIMESTAMP BIGINT NOT NULL, + RECEIVED_TIMESTAMP BIGINT NULL, OPERATION_CODE VARCHAR(1000) NOT NULL, INITIATED_BY VARCHAR(100) NULL, OPERATION_DETAILS BLOB DEFAULT NULL, @@ -108,7 +108,19 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( 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_DEVICE_STATUS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + DEVICE_ID INTEGER NOT NULL, + STATUS VARCHAR(50) DEFAULT NULL, + UPDATE_TIME TIMESTAMP DEFAULT NULL, + CHANGED_BY VARCHAR(255) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES + DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE +); CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -176,17 +188,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT 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 , + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -197,11 +209,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); 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, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -216,9 +228,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,11 +240,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -243,11 +255,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT(11) NOT NULL AUTO_INCREMENT, + ID INT 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, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT DEFAULT NULL, IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID), CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION @@ -258,9 +270,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -284,11 +296,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -341,7 +353,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -356,7 +368,7 @@ 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, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -385,7 +397,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -405,6 +417,16 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- +CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ICON_PATH VARCHAR(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR(150) NOT NULL, + VERSION VARCHAR(50) DEFAULT '1.1.0', + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, @@ -425,7 +447,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( DEVICE_ID INT NULL, ENROLMENT_ID INT NOT NULL, KEY_FIELD VARCHAR(45) NULL, - VALUE_FIELD VARCHAR(1000) NULL, + VALUE_FIELD VARCHAR(1500) NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) @@ -454,7 +476,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -491,8 +513,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( 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, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -519,7 +541,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT(15) NOT NULL, + TIMESTAMP BIGINT NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -588,8 +610,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 -- @@ -725,52 +746,94 @@ 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, - 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, 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, + DEVICE_NAME VARCHAR(100) NOT NULL, + IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, + TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, + TRACCAR_USENAME VARCHAR(100) NULL, + STATUS VARCHAR(100) NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- + -- SUB_OPERATION_TEMPLATE TABLE-- -CREATE TABLE SUB_OPERATION_TEMPLATE ( - SUB_OPERATION_TEMPLATE_ID int NOT NULL AUTO_INCREMENT, +CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, OPERATION_DEFINITION TEXT NOT NULL, - OPERATION_CODE varchar(100) NOT NULL, - SUB_TYPE_ID int NOT NULL, + OPERATION_CODE VARCHAR(100) NOT NULL, + SUB_TYPE_ID INT NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, - CREATE_TIMESTAMP timestamp NULL DEFAULT NULL, - UPDATE_TIMESTAMP timestamp NULL DEFAULT NULL, + CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), - UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID,OPERATION_CODE, DEVICE_TYPE), + CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), +-- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) ); -/* - * Copyright (c) 2018 - 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. - */ - -- END OF SUB_OPERATION_TEMPLATE TABLE-- - -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/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml index b6c2900db7..3ce48daefe 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -31,18 +31,10 @@ 60000 true - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider - - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider - - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider - - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider - + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider @@ -50,16 +42,16 @@ https://localhost:9443 - admin - admin + ${admin.username} + ${admin.username} https://localhost:9443 - admin - admin + ${admin.username} + ${admin.username} - org.wso2.carbon.policy.mgt + io.entgra.device.mgt.core.policy.mgt true 60000 5 @@ -90,7 +82,7 @@ device caching for upto configured expiry-time in seconds. In clustered setup all worker nodes can enable the device-cache to improve performance. --> - false + true 600 10000 + + true + 600 + 10000 + true - false + true 86400 @@ -120,6 +114,11 @@ false + false + + DM_DB + ARCHIVAL_DB + io.entgra.device.mgt.core.device.mgt.core.task.impl.ArchivalTask 0 0 0 1/1 * ? * @@ -159,7 +158,7 @@ true - wss://localhost:9443 + ws://localhost:9763 2 100 20 @@ -167,5 +166,50 @@ 640 BYOD,COPE + + false + false + io.entgra.device.mgt.core.device.mgt.common.enrollment.notification.EnrollmentNotifier + http://localhost:8280 + + + false + + + test_role + + /permission/admin/Login + + + + + + + + <a href='https://entgra.io' target='_blank'> + Entgra + </a> + IoT Server 5.2.0 | © 2023 + , All Rights Reserved. + + Entgra + + repository/resources/whitelabel + favicon.png + logo.png + icon.png + default + + + + + + + + + + false + Replace with mail + diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index ad8165fc67..2e591b07c9 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon From 2e5579fdc228af9d5605e305e582016201c74816 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 7 Jul 2023 11:16:53 +0530 Subject: [PATCH 048/343] fixed operation template unit tests --- .../template/mock/BaseOperationTemplatePluginTest.java | 1 + .../test/resources/carbon-home/dbscripts/insert-subtypes.sql | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java index c563311602..58c7e8b65f 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java @@ -144,6 +144,7 @@ public abstract class BaseOperationTemplatePluginTest { conn = ConnectionManagerUtils.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/insert-subtypes.sql'"); } finally { TestUtils.cleanupResources(conn, stmt, null); } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql new file mode 100644 index 0000000000..ffa001a086 --- /dev/null +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql @@ -0,0 +1,3 @@ +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}'); \ No newline at end of file From 11efc83b06d1fed400c8104373f2f9f5295e09df Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 11 Jul 2023 11:43:26 +0530 Subject: [PATCH 049/343] Fix dependency importing issue --- .../pom.xml | 4 ++++ .../jaxrs/service/api/GroupManagementService.java | 15 ++++++++------- .../pom.xml | 4 ++++ .../mgt/core/mgt/impl/PolicyManagerImpl.java | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index f9931aae6c..fde1c89087 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -411,6 +411,10 @@ org.wso2.carbon.ntask.core provided + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.notification.logger + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java index 17ac84779a..1240e86437 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java @@ -28,6 +28,7 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -1302,11 +1303,11 @@ public interface GroupManagementService { "Server error occurred while creating the group or adding devices or sharing the group.", response = ErrorResponse.class) }) - Response createGroupWithRoles(@ApiParam( - name = "group", - value = "Define the group object with data.", - required = true) - @Valid DeviceGroupRoleWrapper group - ); - + Response createGroupWithRoles( + @ApiParam( + name = "group", + value = "Define the group object with data.", + required = true) + @Valid DeviceGroupRoleWrapper group + ); } diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index cd75cd10c5..f93f462924 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -283,6 +283,10 @@ org.wso2.orbit.javax.xml.bind jaxb-api + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.notification.logger + diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 3e6aa49292..6b710b259b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; +import com.google.gson.Gson; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest; From 78aee58c1a3dafaffa7310c6cf9d35c27b3947b2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 11 Jul 2023 12:13:53 +0530 Subject: [PATCH 050/343] Fix build failure --- .../device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 27617e89ae..0c2e5663fe 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -364,7 +364,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index b97dba2a91..26f6603912 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -473,7 +473,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 org.wso2.carbon.multitenancy diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 585aeafeaa..c12f494f37 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -78,7 +78,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From 3bf6f7dd75d98fc708e3184632daca2729f453e0 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 12 Jul 2023 00:05:02 +0530 Subject: [PATCH 051/343] Improve functionality and fix formatting issues --- .../mgt/core/impl/ApplicationManagerImpl.java | 6 +++--- .../mgt/core/impl/SubscriptionManagerImpl.java | 12 +++++++++++- .../core/application/mgt/core/util/Constants.java | 3 +++ .../service/impl/RoleManagementServiceImpl.java | 7 +++++-- .../mgt/core/operation/mgt/OperationManagerImpl.java | 9 ++++++++- .../service/DeviceManagementProviderServiceImpl.java | 10 +++++++++- .../service/GroupManagementProviderServiceImpl.java | 2 +- 7 files changed, 40 insertions(+), 9 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index b214f7d3bb..ddbf68b2e7 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -1286,7 +1286,7 @@ public class ApplicationManagerImpl implements ApplicationManager { this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger); } } - if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { + if (Constants.ENTERPRISE_APP_TYPE.equals(applicationDTO.getType()) || Constants.PUBLIC_APP_TYPE.equals(applicationDTO.getType())) { persistAppIconInfo(applicationReleaseDTO); } applicationReleaseEntities.add(applicationReleaseDTO); @@ -1726,8 +1726,8 @@ public class ApplicationManagerImpl implements ApplicationManager { List allMetadata; allMetadata = APIUtil.getMetadataManagementService().retrieveAllMetadata(); if (allMetadata != null && !allMetadata.isEmpty()) { - for(Metadata metadata : allMetadata){ - if(Constants.SHOW_ALL_ROLES.equals(metadata.getMetaKey())){ + for (Metadata metadata : allMetadata) { + if (Constants.SHOW_ALL_ROLES.equals(metadata.getMetaKey())) { String metaValue = metadata.getMetaValue(); if (metaValue != null) { JSONObject jsonObject; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 3bc5bcb013..f928793bda 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -713,7 +713,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action, properties); activityList.add(activity); for (DeviceIdentifier identifier : deviceIdentifiers) { - log.info(String.format("App %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build()); + log.info(String.format("App %s triggered", action), appInstallLogContextBuilder + .setAppId(String.valueOf(applicationDTO.getId())) + .setAppName(applicationDTO.getName()) + .setAppType(applicationDTO.getType()) + .setSubType(subType) + .setTenantId(tenantId) + .setTenantDomain(tenantDomain) + .setDevice(String.valueOf(identifier)) + .setUserName(username) + .setAction(action) + .build()); } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java index efd848cdb1..c3e7c49160 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java @@ -94,6 +94,9 @@ public class Constants { public static final String MSI = "MSI"; public static final String APPX = "APPX"; + public static final String ENTERPRISE_APP_TYPE = "ENTERPRISE"; + public static final String PUBLIC_APP_TYPE = "ENTERPRISE"; + private static final Map AGENT_DATA = new HashMap<>(); static { AGENT_DATA.put("android", "android-agent.apk"); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 0d54346c5c..1c28dc33e1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import com.google.common.base.Strings; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; @@ -34,6 +35,7 @@ import org.apache.commons.logging.LogFactory; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; +import org.springframework.util.StringUtils; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; @@ -72,6 +74,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import static io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants.PRIMARY_USER_STORE; @@ -136,7 +139,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { if (limit == 0){ limit = Constants.DEFAULT_PAGE_LIMIT; } - if (domain != null && !domain.isEmpty()) { + if (!Strings.isNullOrEmpty(domain)) { username = domain + '/' + username; } Metadata metadata; @@ -149,7 +152,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { JSONObject jsonObject = (JSONObject) parser.parse(metaValue); boolean decision = (boolean) jsonObject.get(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); if (decision) { - if (userStore == null || "".equals(userStore)){ + if (Strings.isNullOrEmpty(userStore)){ userStore = PRIMARY_USER_STORE; } try { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index ad437f445a..db2ac921aa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -719,7 +719,14 @@ public class OperationManagerImpl implements OperationManager { DeviceCacheManagerImpl.getInstance().removeDeviceFromCache(deviceId, tenantId); break; } - log.info("Device Connected", deviceConnectivityLogContextBuilder.setDeviceId(deviceId.getId()).setDeviceType(deviceId.getType()).setActionTag("PENDING_OPERATION").setTenantDomain(tenantDomain).setTenantId(String.valueOf(tenantId)).setUserName(userName).build()); + log.info("Device Connected", deviceConnectivityLogContextBuilder + .setDeviceId(deviceId.getId()) + .setDeviceType(deviceId.getType()) + .setActionTag("PENDING_OPERATION") + .setTenantDomain(tenantDomain) + .setTenantId(String.valueOf(tenantId)) + .setUserName(userName) + .build()); return getOperations(deviceId, Operation.Status.PENDING, enrolmentId); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index acdd7976da..0a526d0283 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -344,7 +344,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + "'"); } - log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(existingDevice.getId())).setDeviceType(String.valueOf(existingDevice.getType())).setOwner(newEnrolmentInfo.getOwner()).setOwnership(String.valueOf(newEnrolmentInfo.getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); + log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder + .setDeviceId(String.valueOf(existingDevice.getId())) + .setDeviceType(String.valueOf(existingDevice.getType())) + .setOwner(newEnrolmentInfo.getOwner()) + .setOwnership(String.valueOf(newEnrolmentInfo.getOwnership())) + .setTenantID(String.valueOf(tenantId)) + .setTenantDomain(tenantDomain) + .setUserName(userName) + .build()); status = true; } else { log.warn("Unable to update device enrollment for device : " + device.getDeviceIdentifier() + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index a9815526d6..c9bb42dcbf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -298,7 +298,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid newParentPath = DeviceGroupConstants.HierarchicalGroup.SEPERATOR; } childrenGroup.setParentPath(newParentPath); - if (!newParentPath.equals(DeviceGroupConstants.HierarchicalGroup.SEPERATOR)) { + if (!DeviceGroupConstants.HierarchicalGroup.SEPERATOR.equals(newParentPath)) { String[] groupIds = newParentPath.split(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); int latestGroupId = Integer.parseInt(groupIds[groupIds.length - 1]); childrenGroup.setParentGroupId(latestGroupId); From a66d6389f921bb8232da44464bbab325a8911a2d Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 12 Jul 2023 00:39:31 +0530 Subject: [PATCH 052/343] Fix formatting issue --- .../mgt/core/impl/SubscriptionManagerImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index f928793bda..7c3ee9694e 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -706,7 +706,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager { entry.getKey(), action, properties); activityList.add(activity); for (DeviceIdentifier identifier : deviceIdentifiers) { - log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build()); + log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder + .setAppId(String.valueOf(applicationDTO.getId())) + .setAppName(applicationDTO.getName()) + .setAppType(applicationDTO.getType()) + .setSubType(subType) + .setTenantId(tenantId) + .setTenantDomain(tenantDomain) + .setDevice(String.valueOf(identifier)) + .setUserName(username) + .setAction(action) + .build()); } } } else { From 2cfa73206d471041fff18c3f6ff39abad86de6f5 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 13 Jul 2023 07:54:34 +0530 Subject: [PATCH 053/343] Fix OSGI service unbinding issue --- .../internal/DeviceManagementDataHolder.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java index a901ffeddf..3fa8fdc453 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -118,18 +118,18 @@ public class DeviceManagementDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } public TenantManager getTenantManager() { - return tenantManager; - } - - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); } - this.tenantManager = realmService.getTenantManager(); + return tenantManager; } + + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public DeviceManagementProviderService getDeviceManagementProvider() { From 1d94fb7de14b42ccd01d2bdcdd7adf935dbc5b84 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 18 Jul 2023 09:16:25 +0530 Subject: [PATCH 054/343] Fix test case failing --- .../pom.xml | 15 +++++++++++---- .../mgt/core/mgt/impl/PolicyManagerImpl.java | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index f93f462924..0e518faf96 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -70,6 +70,8 @@ io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.task.impl;version="[5.0,6)", + io.entgra.device.mgt.core.notification.logger;version="[5.0,6)", + io.entgra.device.mgt.core.notification.logger.impl;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.common;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.common.monitor;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.core.cache, @@ -126,9 +128,9 @@ src/test/resources/testng.xml - - org.ops4j.pax.logging - + + + @@ -169,7 +171,7 @@ org.ops4j.pax.logging pax-logging-api - provided + org.wso2.carbon @@ -283,9 +285,14 @@ org.wso2.orbit.javax.xml.bind jaxb-api + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.extensions.logger + io.entgra.device.mgt.core io.entgra.device.mgt.core.notification.logger + provided diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 6b710b259b..63eb01b200 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -642,8 +642,8 @@ public class PolicyManagerImpl implements PolicyManager { @Override public void activatePolicy(int policyId) throws PolicyManagementException { + Policy policy = this.getPolicy(policyId); try { - Policy policy = this.getPolicy(policyId); PolicyManagementDAOFactory.beginTransaction(); policyDAO.activatePolicy(policyId); policyDAO.recordUpdatedPolicy(policy); From 349bb0a3dc0c4a8ff2feff9a113c5013945655da Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 18 Jul 2023 09:33:33 +0530 Subject: [PATCH 055/343] Fix test case failure --- .../pom.xml | 5 + .../user-test/user-mgt-registry-test.xml | 2 +- .../resources/carbon-home/dbscripts/h2.sql | 19 --- .../conf/datasources/data-source-config.xml | 2 +- .../pom.xml | 41 +++++- .../impl/ConfigurationServiceImplTest.java | 3 +- .../service/impl/DeviceAgentServiceTest.java | 2 +- .../impl/DeviceManagementServiceImplTest.java | 2 +- .../DeviceTypeManagementAdminServiceTest.java | 2 +- .../impl/DeviceTypeManagementServiceTest.java | 7 +- .../impl/GroupManagementServiceImplTest.java | 6 +- ...NotificationManagementServiceImplTest.java | 2 +- .../impl/UserManagementServiceImplTest.java | 2 +- .../pom.xml | 11 +- .../mgt/PermissionManagerServiceTest.java | 4 + .../mgt/core/search/ProcessorImplTest.java | 5 +- .../core/search/util/ChangeEnumValues.java | 122 ------------------ .../datasource/data-source-config-mock.xml | 2 +- .../data-source-config-no-table.xml | 2 +- .../config/datasource/data-source-config.xml | 2 +- .../src/test/resources/sql/h2.sql | 70 ++++------ .../user-test/user-mgt-registry-test.xml | 2 +- .../pom.xml | 21 ++- .../resources/carbon-home/dbscripts/h2.sql | 18 --- .../conf/datasource/data-source-config.xml | 2 +- .../src/test/resources/sql-files/h2.sql | 93 +++++++------ .../user-test/user-mgt-registry-test.xml | 2 +- .../pom.xml | 1 - .../pom.xml | 11 +- .../user-test/user-mgt-registry-test.xml | 2 +- pom.xml | 12 +- 31 files changed, 172 insertions(+), 305 deletions(-) delete mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/util/ChangeEnumValues.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 7e3ef60c38..3307c0bd73 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -44,6 +44,11 @@ powermock-api-mockito2 test + + org.mockito + mockito-core + test + org.testng testng diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/resources/user-test/user-mgt-registry-test.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/resources/user-test/user-mgt-registry-test.xml index 1ced8bb1f1..4d53df601c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/dbscripts/h2.sql b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/dbscripts/h2.sql index 2f96eeba79..7f20466a6f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/dbscripts/h2.sql +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/dbscripts/h2.sql @@ -16,24 +16,6 @@ * under the License. */ -/* - * Copyright (c) 2021, 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. - */ - CREATE TABLE IF NOT EXISTS REG_CLUSTER_LOCK ( REG_LOCK_NAME VARCHAR (20), REG_LOCK_STATUS VARCHAR (20), @@ -104,7 +86,6 @@ CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_PATH_ID_NAME ON REG_RESOURCE(REG_ CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_UUID ON REG_RESOURCE(REG_UUID); CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_TENANT ON REG_RESOURCE(REG_TENANT_ID, REG_UUID); CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_TYPE ON REG_RESOURCE(REG_TENANT_ID, REG_MEDIA_TYPE); - CREATE TABLE IF NOT EXISTS REG_RESOURCE_HISTORY ( REG_PATH_ID INTEGER NOT NULL, REG_NAME VARCHAR(256), diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index ad8165fc67..2e591b07c9 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 0c2e5663fe..72c30b6d93 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -38,6 +38,10 @@ org.apache.maven.plugins maven-compiler-plugin + + 1.8 + 1.8 + org.apache.maven.plugins @@ -151,16 +155,25 @@ spring-web provided - - org.apache.cxf - cxf-bundle-jaxrs - provided - commons-httpclient.wso2 commons-httpclient provided + + org.apache.cxf + cxf-rt-frontend-jaxrs + + + javax.ws.rs + jsr311-api + + + org.apache.cxf + cxf-rt-core + + + org.wso2.carbon org.wso2.carbon.utils @@ -213,6 +226,14 @@ javassist javassist + + javax.ws.rs + jsr311-api + + + javax.ws.rs + javax.ws.rs-api + @@ -295,6 +316,10 @@ org.slf4j slf4j-api + + javax.ws.rs + jsr311-api + @@ -329,6 +354,12 @@ org.wso2.carbon.registry org.wso2.carbon.registry.resource + + + javax.ws.rs + javax.ws.rs-api + + provided diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java index 8bc2f8c0c7..5fa7eecb6b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java @@ -43,10 +43,11 @@ import java.util.List; /** * This is a test class for {@link ConfigurationServiceImpl}. */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.CarbonContext"}) @PrepareForTest({DeviceMgtAPIUtils.class, PolicyManagerUtil.class}) +//@PowerMockIgnore("org.mockito.*") public class ConfigurationServiceImplTest { private ConfigurationManagementService configurationManagementService; private PlatformConfigurationManagementService platformConfigurationManagementService; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java index b61f4254b2..4a5a370d0f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java @@ -69,7 +69,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This class holds the unit tests for the class {@link DeviceAgentServiceImpl} */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.CarbonContext", "org.wso2.carbon.context.internal.CarbonContextDataHolder"}) @PrepareForTest({DeviceMgtAPIUtils.class, DeviceManagementProviderService.class, diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java index dd98043164..25cdd5168c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java @@ -72,7 +72,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This class includes unit tests for testing the functionality of {@link DeviceManagementServiceImpl} */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.CarbonContext", "org.wso2.carbon.user.core.service.RealmService"}) @PrepareForTest({DeviceMgtAPIUtils.class, MultitenantUtils.class, CarbonContext.class, RealmService.class}) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java index f18426501c..4fe4473930 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java @@ -51,7 +51,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This class holds the unit tests for the class {@link DeviceTypeManagementAdminService} */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.PrivilegedCarbonContext"}) @PrepareForTest({DeviceMgtAPIUtils.class, DeviceManagementProviderService.class, CarbonContext.class}) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java index c6ff5a3b95..24f8841ca8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java @@ -48,7 +48,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This class holds the unit tests for the class {@link DeviceTypeManagementService} */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils"}) @PrepareForTest({DeviceMgtAPIUtils.class, DeviceManagementProviderService.class}) public class DeviceTypeManagementServiceTest { @@ -129,8 +129,9 @@ public class DeviceTypeManagementServiceTest { FeatureManager featureManager = Mockito.mock(FeatureManager.class); Mockito.when(this.deviceManagementProviderService.getFeatureManager(Mockito.anyString())).thenReturn (featureManager); - Mockito.when((featureManager).getFeatures(Mockito.anyString())).thenThrow(new DeviceManagementException()); - Mockito.when((featureManager).getFeatures(Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new DeviceManagementException()); + Mockito.when(featureManager.getFeatures(Mockito.anyString())).thenThrow(new DeviceManagementException()); + Mockito.when(featureManager.getFeatures(Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new DeviceManagementException()); + Mockito.when(featureManager.getFeatures(Mockito.any(), Mockito.anyBoolean())).thenThrow(new DeviceManagementException()); Response response = this.deviceTypeManagementService.getFeatures(TEST_DEVICE_TYPE, null, "false", MODIFIED_SINCE); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java index dc94b03ab8..42f6c80383 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java @@ -51,7 +51,7 @@ import java.util.List; /** * This is a test case for {@link GroupManagementServiceImpl}. */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "javax.xml.parsers"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "javax.xml.parsers", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.PrivilegedCarbonContext"}) @PrepareForTest({DeviceMgtAPIUtils.class, CarbonContext.class}) @@ -125,13 +125,13 @@ public class GroupManagementServiceImplTest { PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext")) .toReturn(context); Mockito.doReturn(2).when(groupManagementProviderService) - .getGroupCount(Mockito.anyString(), Mockito.anyString()); + .getGroupCount(Mockito.anyString(), Mockito.any()); Response response = groupManagementService.getGroupCount(); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "GetGroupCount request failed with valid parameters"); Mockito.reset(groupManagementProviderService); Mockito.doThrow(new GroupManagementException()).when(groupManagementProviderService) - .getGroupCount(Mockito.anyString(), Mockito.anyString()); + .getGroupCount(Mockito.anyString(), Mockito.any()); response = groupManagementService.getGroupCount(); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), "GetGroupCount request succeeded with in-valid parameters"); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java index e15c12e677..d40b8bd406 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java @@ -46,7 +46,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This is a test class for {@link NotificationManagementServiceImpl}. */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.CarbonContext"}) @PrepareForTest({DeviceMgtAPIUtils.class, MultitenantUtils.class, CarbonContext.class}) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java index f584bb31ec..5b2417c4db 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java @@ -61,7 +61,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This is a test case for {@link UserManagementService}. */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.CarbonContext"}) @PrepareForTest({DeviceMgtAPIUtils.class, MultitenantUtils.class, CarbonContext.class}) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 26f6603912..6846df32e0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -514,7 +514,16 @@ jaxb-api compile + + com.sun.xml.bind + jaxb-core + compile + + + com.sun.xml.bind + jaxb-impl + compile + - diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java index 9af3c4a94b..5b99437470 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java @@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionMana import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.testng.Assert; import org.testng.IObjectFactory; @@ -40,6 +41,9 @@ import static org.mockito.MockitoAnnotations.initMocks; * This contains unit tests for PermissionManagerService class. */ @PrepareForTest(PermissionUtils.class) +@PowerMockIgnore("org.mockito.*") + +//@PowerMockIgnore({"javax.management.*", "javax.script.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) public class PermissionManagerServiceTest { private static final Log log = LogFactory.getLog(PermissionManagerServiceTest.class);; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java index 089b945f95..1818bd1277 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java @@ -29,7 +29,6 @@ import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementServic import io.entgra.device.mgt.core.device.mgt.core.search.mgt.InvalidOperatorException; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.SearchMgtException; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.impl.ProcessorImpl; -import io.entgra.device.mgt.core.device.mgt.core.search.util.ChangeEnumValues; import io.entgra.device.mgt.core.device.mgt.core.search.util.Utils; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; @@ -131,8 +130,6 @@ public class ProcessorImplTest extends BaseDeviceManagementTest { public void testInvalidState() throws SearchMgtException { SearchContext context = new SearchContext(); List conditions = new ArrayList<>(); - ChangeEnumValues.addEnum(Condition.State.class, "BLA"); - Condition.State state = Condition.State.valueOf("BLA"); Condition cond = new Condition(); cond.setKey("batteryLevel"); @@ -152,7 +149,7 @@ public class ProcessorImplTest extends BaseDeviceManagementTest { cond3.setKey("batteryLevel"); cond3.setOperator("="); cond3.setValue("23.0"); - cond3.setState(state); + cond3.setState(Condition.State.AND); conditions.add(cond3); context.setConditions(conditions); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/util/ChangeEnumValues.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/util/ChangeEnumValues.java deleted file mode 100644 index e5a9d3399e..0000000000 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/util/ChangeEnumValues.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2018 - 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.device.mgt.core.search.util; - -import io.entgra.device.mgt.core.device.mgt.common.search.Condition; -import sun.reflect.ConstructorAccessor; -import sun.reflect.FieldAccessor; -import sun.reflect.ReflectionFactory; - -import java.lang.reflect.AccessibleObject; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Changes the Enum values of a given class. - */ -public class ChangeEnumValues { - - private static ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); - - public ChangeEnumValues() {} - - private static void setFailSafeFieldValue(Field field, Object target, Object value) throws NoSuchFieldException, - IllegalAccessException { - field.setAccessible(true); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - int modifiers = modifiersField.getInt(field); - modifiers &= ~Modifier.FINAL; - modifiersField.setInt(field, modifiers); - FieldAccessor fa = reflectionFactory.newFieldAccessor(field, false); - fa.set(target, value); - } - - private static void blankField(Class enumClass, String fieldName) throws NoSuchFieldException, - IllegalAccessException { - for (Field field : Class.class.getDeclaredFields()) { - if (field.getName().contains(fieldName)) { - AccessibleObject.setAccessible(new Field[]{field}, true); - setFailSafeFieldValue(field, enumClass, null); - break; - } - } - } - - private static void cleanEnumCache(Class enumClass) throws NoSuchFieldException, IllegalAccessException { - blankField(enumClass, "enumConstantDirectory"); - blankField(enumClass, "enumConstants"); - } - - private static ConstructorAccessor getConstructorAccessor(Class enumClass, Class[] additionalParameterTypes) - throws NoSuchMethodException { - Class[] parameterTypes = new Class[additionalParameterTypes.length + 2]; - parameterTypes[0] = String.class; - parameterTypes[1] = int.class; - System.arraycopy(additionalParameterTypes, 0, parameterTypes, 2, additionalParameterTypes.length); - return reflectionFactory.newConstructorAccessor(enumClass.getDeclaredConstructor(parameterTypes)); - } - - private static Object makeEnum(Class enumClass, String value, int ordinal, Class[] additionalTypes, - Object[] additionalValues) throws Exception { - Object[] parms = new Object[additionalValues.length + 2]; - parms[0] = value; - parms[1] = ordinal; - System.arraycopy(additionalValues, 0, parms, 2, additionalValues.length); - return enumClass.cast(getConstructorAccessor(enumClass, additionalTypes).newInstance(parms)); - } - - /** - * Add an enum instance to the enum class given as argument - * - * @param the type of the enum - * @param enumType the class of the enum to be modified - * @param enumName the name of the new enum instance to be added to the class. - */ - public static > void addEnum(Class enumType, String enumName) { - - if (!Enum.class.isAssignableFrom(enumType)) { - throw new RuntimeException("class " + enumType + " is not an instance of Enum"); - } - - Field valuesField = null; - Field[] fields = Condition.State.class.getDeclaredFields(); - for (Field field : fields) { - if (field.getName().contains("$VALUES")) { - valuesField = field; - break; - } - } - AccessibleObject.setAccessible(new Field[]{valuesField}, true); - - try { - T[] previousValues = (T[]) valuesField.get(enumType); - List values = new ArrayList(Arrays.asList(previousValues)); - T newValue = (T) makeEnum(enumType, enumName, values.size(), new Class[]{}, new Object[]{}); - values.add(newValue); - setFailSafeFieldValue(valuesField, null, values.toArray((T[]) Array.newInstance(enumType, 0))); - cleanEnumCache(enumType); - } catch (Exception e) { - throw new RuntimeException(e.getMessage(), e); - } - } -} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-mock.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-mock.xml index f6031ebc08..35a3fcf16c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-mock.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-mock.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE io.entgra.device.mgt.core.device.mgt.core.mock.MockJDBCDriver wso2carbon wso2carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-no-table.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-no-table.xml index b28626efe7..71e35416f3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-no-table.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-no-table.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:nodb-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:nodb-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config.xml index 27b6dfeaeb..533fd82959 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index 4f83fa5b5e..ace89fc192 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -34,7 +34,7 @@ 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_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -180,16 +180,18 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, - TENANT_ID INT(11) NOT NULL , - PROFILE_ID INT(11) NOT NULL , + PAYLOAD_VERSION VARCHAR (45) NULL, + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, + POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY FOREIGN KEY (PROFILE_ID ) @@ -199,11 +201,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); 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, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -218,9 +220,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -230,11 +232,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -245,9 +247,9 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -271,11 +273,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -328,7 +330,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -343,7 +345,7 @@ 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, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -372,7 +374,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -439,7 +441,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_LOCATION_DEVICE FOREIGN KEY (DEVICE_ID) @@ -472,8 +474,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( 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, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -487,24 +489,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( ON UPDATE NO ACTION ); -/* - * Copyright (c) 2018 - 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. - */ - -- POLICY AND DEVICE GROUP MAPPING -- CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( ID INT NOT NULL AUTO_INCREMENT, diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index c12f494f37..3af053e025 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -66,6 +66,12 @@ org.wso2.carbon org.wso2.carbon.utils + + + org.eclipse.platform + org.eclipse.osgi + + org.wso2.carbon @@ -111,10 +117,10 @@ org.wso2.carbon.governance.registry.extensions test - - jaxen - jaxen - + + jaxen + jaxen + @@ -145,6 +151,11 @@ org.wso2.orbit.javax.xml.bind jaxb-api + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.notification.logger + provided + @@ -263,8 +274,6 @@ - - diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/dbscripts/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/dbscripts/h2.sql index 2f96eeba79..620b98e321 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/dbscripts/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/dbscripts/h2.sql @@ -16,24 +16,6 @@ * under the License. */ -/* - * Copyright (c) 2021, 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. - */ - CREATE TABLE IF NOT EXISTS REG_CLUSTER_LOCK ( REG_LOCK_NAME VARCHAR (20), REG_LOCK_STATUS VARCHAR (20), diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/repository/conf/datasource/data-source-config.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/repository/conf/datasource/data-source-config.xml index 27b6dfeaeb..533fd82959 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/repository/conf/datasource/data-source-config.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/repository/conf/datasource/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql index 2b2200bb2b..a1cf506655 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql @@ -31,7 +31,7 @@ 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_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -177,16 +177,16 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, - TENANT_ID INT(11) NOT NULL , - PROFILE_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY FOREIGN KEY (PROFILE_ID ) @@ -196,11 +196,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); 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, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -215,9 +215,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -227,11 +227,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -242,9 +242,9 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -268,11 +268,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -325,7 +325,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -340,7 +340,7 @@ 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, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -369,10 +369,22 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER 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) + 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 ); CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( @@ -380,34 +392,15 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( DEVICE_ID INTEGER NOT NULL, APPLICATION_ID INTEGER NOT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID), - CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES + CONSTRAINT fk_dm_device_tb FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); - -/* - * Copyright (c) 2018 - 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. - */ - -- POLICY RELATED TABLES FINISHED -- -- NOTIFICATION TABLE -- @@ -451,7 +444,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_LOCATION_DEVICE FOREIGN KEY (DEVICE_ID) @@ -463,6 +456,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( 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, @@ -477,13 +471,18 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( 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, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT 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 ); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/user-test/user-mgt-registry-test.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/user-test/user-mgt-registry-test.xml index 1ced8bb1f1..4d53df601c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 70ca947ed2..72e84ab493 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -36,7 +36,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.testng diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 0e518faf96..0d3faea08b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -70,8 +70,6 @@ io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.task.impl;version="[5.0,6)", - io.entgra.device.mgt.core.notification.logger;version="[5.0,6)", - io.entgra.device.mgt.core.notification.logger.impl;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.common;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.common.monitor;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.core.cache, @@ -128,9 +126,6 @@ src/test/resources/testng.xml - - - @@ -171,7 +166,7 @@ org.ops4j.pax.logging pax-logging-api - + provided org.wso2.carbon @@ -285,10 +280,6 @@ org.wso2.orbit.javax.xml.bind jaxb-api - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.device.mgt.extensions.logger - io.entgra.device.mgt.core io.entgra.device.mgt.core.notification.logger diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/resources/user-test/user-mgt-registry-test.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/resources/user-test/user-mgt-registry-test.xml index 1ced8bb1f1..4d53df601c 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/pom.xml b/pom.xml index 1a0eab8a0f..3c62c474e2 100644 --- a/pom.xml +++ b/pom.xml @@ -843,7 +843,6 @@ jaxb-impl 2.3.1 - org.apache.axis2.transport axis2-transport-mail @@ -1903,7 +1902,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.1.2 ${basedir}/target/coverage-reports/jacoco-ut.exec @@ -2084,7 +2083,7 @@ [7.3, 8) - 2.0.1 + 2.1.1 1.6.9 1.6.9 4.0.1 @@ -2096,7 +2095,7 @@ 2.8.2.wso2v1 1.2.0.wso2v1 - 5.0.2.Final + 5.1.2.Final [0.0.0,1.0.0) [0.0.0,1.0.0) @@ -2125,8 +2124,7 @@ true - 0.7.8 - 0.7.5.201505241946 + 0.8.10 1.0b3 2.0.2 1.4.0.wso2v1 @@ -2135,8 +2133,6 @@ 1.21 2.6.5 - 1.7.6 - v12.18.1 3.1.0 From 74041070f9cc22ba103c27c19dbc21b399e0c8fc Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Mon, 24 Jul 2023 20:22:54 +0530 Subject: [PATCH 056/343] Fix class def not found issue --- .../io.entgra.device.mgt.core.device.mgt.api/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 72c30b6d93..abbc0e9875 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -192,6 +192,10 @@ org.slf4j jcl-over-slf4j + + org.ops4j.pax.logging + pax-logging-log4j2 + From 5b6b11dc8c82ab4766baddc2e4886595d03953a1 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Tue, 4 Jul 2023 16:54:32 +0530 Subject: [PATCH 057/343] fixed unit tests of application-mgt --- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 7 +++++++ .../test/resources/user-test/user-mgt-registry-test.xml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 9c3ab8ff85..7134db16fc 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -153,6 +153,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + src/test/resources/testng.xml @@ -160,6 +164,9 @@ ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties + + org.ops4j.pax.logging + diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 From defb0aed04141090facf8cd80fb9efa9ff2a394c Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 10:35:43 +0530 Subject: [PATCH 058/343] fixed unit tests in analytics-mgt --- .../pom.xml | 2 +- .../pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 82f30811ab..59c0b53f0c 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -295,7 +295,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 2e2888b88a..0089325b5d 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -211,7 +211,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 org.wso2.carbon From c855b707e7d980fae0ace659f82df7c9e612b124 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 10:40:38 +0530 Subject: [PATCH 059/343] fixed mockito dependency issue --- .../io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index c0c72a2f65..0f030906b9 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -41,7 +41,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From bc66555a0489a0a8e6b26110a21604d31d456b7d Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 13:15:02 +0530 Subject: [PATCH 060/343] fixed unit tests --- .../pom.xml | 9 +- .../src/test/resources/sql/CreateH2TestDB.sql | 247 ++++++++++-------- .../user-test/user-mgt-registry-test.xml | 2 +- .../pom.xml | 9 +- .../carbon-home/dbscripts/dm-db-h2.sql | 169 +++++++----- .../conf/datasources/data-source-config.xml | 2 +- .../pom.xml | 2 +- 7 files changed, 256 insertions(+), 184 deletions(-) diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 6887a4f3e5..5e7d63b270 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -116,12 +116,19 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/log4j.properties src/test/resources/testng.xml + + org.ops4j.pax.logging + @@ -254,7 +261,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index defd753f33..6c906a5c49 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -1,3 +1,51 @@ + DROP VIEW IF EXISTS FEATURE_NON_COMPLIANCE_INFO; + ALTER TABLE IF EXISTS DM_DEVICE DROP CONSTRAINT IF EXISTS fk_DM_DEVICE_DM_DEVICE_TYPE2; +-- ALTER TABLE IF EXISTS DM_DEVICE_TYPE_PLATFORM DROP CONSTRAINT IF EXISTS DM_DEVICE_TYPE_DM_DEVICE_TYPE_PLATFORM_MAPPING; + ALTER TABLE IF EXISTS DM_ROLE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_ROLE_GROUP_MAP_DM_GROUP2; + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_MAP_DM_GROUP2; + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_POLICY DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_POLICY; +-- ALTER TABLE IF EXISTS DM_GEOFENCE_GROUP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_GEOFENCE_GROUP_MAPPING_GROUP; +-- ALTER TABLE IF EXISTS DM_DEVICE_EVENT_GROUP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_EVENT_GROUP_MAPPING_GROUP; + + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_MAP_DM_DEVICE2; + ALTER TABLE IF EXISTS DM_ENROLMENT DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_ENROLMENT; + ALTER TABLE IF EXISTS DM_DEVICE_STATUS DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_STATUS_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_POLICY DROP CONSTRAINT IF EXISTS FK_DEVICE_DEVICE_POLICY; + ALTER TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED DROP CONSTRAINT IF EXISTS FK_DM_POLICY_DEVCIE_APPLIED; + ALTER TABLE IF EXISTS DM_APPLICATION DROP CONSTRAINT IF EXISTS FK_DM_DEVICE; + ALTER TABLE IF EXISTS DM_NOTIFICATION DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_NOTIFICATION; + ALTER TABLE IF EXISTS DM_DEVICE_INFO DROP CONSTRAINT IF EXISTS DM_DEVICE_INFO_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_LOCATION DROP CONSTRAINT IF EXISTS DM_DEVICE_LOCATION_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_DETAIL DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_DETAILS_DEVICE; + + ALTER TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_MAPPING_OPERATION; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_OPERATION; + + ALTER TABLE IF EXISTS DM_DEVICE_STATUS DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_STATUS_ENROLMENT; + ALTER TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_MAPPING_DEVICE; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_ENROLLMENT; + ALTER TABLE IF EXISTS DM_APPLICATION DROP CONSTRAINT IF EXISTS FK_DM_ENROLEMENT; + ALTER TABLE IF EXISTS DM_DEVICE_INFO DROP CONSTRAINT IF EXISTS DM_DEVICE_INFO_DEVICE_ENROLLMENT; + ALTER TABLE IF EXISTS DM_DEVICE_LOCATION DROP CONSTRAINT IF EXISTS DM_DEVICE_LOCATION_DM_ENROLLMENT; + ALTER TABLE IF EXISTS DM_DEVICE_DETAIL DROP CONSTRAINT IF EXISTS FK_DM_ENROLMENT_DEVICE_DETAILS; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_EN_OP_MAP_RESPONSE; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE_LARGE DROP CONSTRAINT IF EXISTS FK_DM_EN_OP_MAP_RESPONSE_LARGE; + ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE_LARGE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_LARGE_MAPPING; +-- + ALTER TABLE IF EXISTS DM_POLICY DROP CONSTRAINT IF EXISTS FK_DM_PROFILE_DM_POLICY; + ALTER TABLE IF EXISTS DM_PROFILE_FEATURES DROP CONSTRAINT IF EXISTS FK_DM_PROFILE_DM_POLICY_FEATURES; +-- + ALTER TABLE IF EXISTS DM_DEVICE_POLICY DROP CONSTRAINT IF EXISTS FK_POLICY_DEVICE_POLICY; + ALTER TABLE IF EXISTS DM_DEVICE_TYPE_POLICY DROP CONSTRAINT IF EXISTS FK_DEVICE_TYPE_POLICY; + ALTER TABLE IF EXISTS DM_POLICY_CORRECTIVE_ACTION DROP CONSTRAINT IF EXISTS FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION; + ALTER TABLE IF EXISTS DM_ROLE_POLICY DROP CONSTRAINT IF EXISTS FK_ROLE_POLICY_POLICY; + ALTER TABLE IF EXISTS DM_USER_POLICY DROP CONSTRAINT IF EXISTS DM_POLICY_USER_POLICY; + ALTER TABLE IF EXISTS DM_POLICY_CRITERIA DROP CONSTRAINT IF EXISTS FK_POLICY_POLICY_CRITERIA; + ALTER TABLE IF EXISTS DM_DEVICE_GROUP_POLICY DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_DM_POLICY; + ALTER TABLE IF EXISTS DM_POLICY_CRITERIA DROP CONSTRAINT IF EXISTS FK_CRITERIA_POLICY_CRITERIA; + ALTER TABLE IF EXISTS DM_POLICY_CRITERIA_PROPERTIES DROP CONSTRAINT IF EXISTS FK_POLICY_CRITERIA_PROPERTIES; + ALTER TABLE IF EXISTS DM_POLICY_COMPLIANCE_FEATURES DROP CONSTRAINT IF EXISTS FK_COMPLIANCE_FEATURES_STATUS; + DROP TABLE IF EXISTS DM_DEVICE_TYPE; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( ID INT AUTO_INCREMENT NOT NULL, @@ -13,24 +61,22 @@ DROP TABLE IF EXISTS DM_GROUP; CREATE TABLE IF NOT EXISTS DM_GROUP ( ID INTEGER AUTO_INCREMENT NOT NULL, GROUP_NAME VARCHAR(100) DEFAULT NULL, - DESCRIPTION TEXT DEFAULT NULL, STATUS VARCHAR(50) DEFAULT NULL, - DATE_OF_CREATE BIGINT DEFAULT NULL, - DATE_OF_LAST_UPDATE BIGINT DEFAULT NULL, - OWNER VARCHAR(45) DEFAULT NULL, + DESCRIPTION TEXT DEFAULT NULL, + OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); - -DROP TABLE IF EXISTS DM_DEVICE_CERTIFICATE; -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) +DROP TABLE IF EXISTS DM_ROLE_GROUP_MAP; +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 ); DROP TABLE IF EXISTS DM_DEVICE; @@ -38,13 +84,14 @@ 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_TYPE_ID INT 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 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) ); DROP TABLE IF EXISTS DM_DEVICE_PROPERTIES; @@ -53,8 +100,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES ( DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, PROPERTY_NAME VARCHAR(100) DEFAULT 0, PROPERTY_VALUE VARCHAR(100) DEFAULT NULL, - TENANT_ID VARCHAR(100) DEFAULT NULL, - PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME) + TENANT_ID VARCHAR(100), + PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME, TENANT_ID) ); DROP TABLE IF EXISTS GROUP_PROPERTIES; @@ -74,9 +121,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( 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 NO ACTION ON UPDATE NO ACTION, + 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 NO ACTION ON UPDATE NO ACTION + REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS DM_OPERATION; @@ -96,7 +143,7 @@ DROP TABLE IF EXISTS DM_ENROLMENT; CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OWNER VARCHAR(50) NOT NULL, + OWNER VARCHAR(255) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, IS_TRANSFERRED BOOLEAN NOT NULL DEFAULT FALSE, @@ -105,7 +152,8 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( 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 + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT uk_dm_device_enrolment UNIQUE (DEVICE_ID, OWNER, OWNERSHIP, TENANT_ID) ); DROP TABLE IF EXISTS DM_DEVICE_STATUS; CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( @@ -119,7 +167,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES - DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE ); DROP TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING; CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( @@ -167,10 +215,14 @@ 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 ); @@ -181,30 +233,25 @@ 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(20) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , - PRIMARY KEY (ID) , - CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE ) - REFERENCES DM_DEVICE_TYPE (NAME ) - ON DELETE NO ACTION - ON UPDATE NO ACTION + PRIMARY KEY (ID) ); DROP TABLE IF EXISTS DM_POLICY; CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , - PAYLOAD_VERSION VARCHAR (45) DEFAULT NULL, DESCRIPTION VARCHAR(1000) NULL, - TENANT_ID INT(11) NOT NULL , - PROFILE_ID INT(11) NOT NULL , + PAYLOAD_VERSION VARCHAR (45) NULL, + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -213,31 +260,13 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); - -DROP TABLE IF EXISTS DM_POLICY_CORRECTIVE_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 -); - - DROP TABLE IF EXISTS DM_DEVICE_POLICY; 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, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -253,29 +282,24 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( DROP TABLE IF EXISTS DM_DEVICE_TYPE_POLICY; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , - DEVICE_TYPE VARCHAR(20) NOT NULL , - POLICY_ID INT(11) NOT NULL , + ID INT NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL , + POLICY_ID INT 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, - CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE ) - REFERENCES DM_DEVICE_TYPE (NAME) - ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_PROFILE_FEATURES; CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, - DEVICE_TYPE VARCHAR(20) NOT NULL, - TENANT_ID INT(11) NOT NULL , + DEVICE_TYPE VARCHAR(300) NOT NULL, + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -285,11 +309,26 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ON UPDATE NO ACTION ); +CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( + ID INT NOT NULL AUTO_INCREMENT, + ACTION_TYPE VARCHAR(45) NOT NULL, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT 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 +); + DROP TABLE IF EXISTS DM_ROLE_POLICY; CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -315,11 +354,11 @@ DROP TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED; 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -363,7 +402,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( POLICY_CRITERION_ID INT NOT NULL, PROP_KEY VARCHAR(45) NULL, PROP_VALUE VARCHAR(100) NULL, - CONTENT BLOB NULL COMMENT 'This is used to ', + CONTENT BLOB NULL, PRIMARY KEY (ID), CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES FOREIGN KEY (POLICY_CRITERION_ID) @@ -376,7 +415,7 @@ DROP TABLE IF EXISTS DM_POLICY_COMPLIANCE_STATUS; 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -391,8 +430,8 @@ DROP TABLE IF EXISTS DM_POLICY_CHANGE_MGT; CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, - DEVICE_TYPE VARCHAR(20) NOT NULL, - TENANT_ID INT(11) NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL , + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -423,7 +462,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -434,7 +473,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT FK_DM_APP_MAP_DM_ENROL + CONSTRAINT fk_dm_enrolement FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION @@ -448,15 +487,14 @@ DROP TABLE IF EXISTS DM_NOTIFICATION; CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OPERATION_ID INTEGER NOT NULL, + OPERATION_ID INTEGER NULL, TENANT_ID INTEGER NOT NULL, STATUS VARCHAR(10) NULL, - DESCRIPTION VARCHAR(100) 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, - CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES - DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- NOTIFICATION TABLE END -- @@ -494,7 +532,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT 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) @@ -507,6 +549,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +DROP INDEX IF EXISTS DM_DEVICE_LOCATION_GEO_hashx; +CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC); DROP TABLE IF EXISTS DM_DEVICE_DETAIL; CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( @@ -527,8 +571,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( 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, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -553,15 +597,14 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( CONSTRAINT FK_DM_DEVICE_GROUP_POLICY FOREIGN KEY (DEVICE_GROUP_ID) REFERENCES DM_GROUP (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION, + ON DELETE CASCADE + ON UPDATE CASCADE , CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY FOREIGN KEY (POLICY_ID) REFERENCES DM_POLICY (ID) - ON DELETE NO ACTION - ON UPDATE NO ACTION + ON DELETE CASCADE + ON UPDATE CASCADE ); - -- END OF POLICY AND DEVICE GROUP MAPPING -- -- DASHBOARD RELATED VIEWS -- @@ -621,22 +664,4 @@ DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID ORDER BY TENANT_ID, DEVICE_ID; -/* - * Copyright (c) 2018 - 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. - */ - -- END OF DASHBOARD RELATED VIEWS -- diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 45b7fd07c9..8add23b3d8 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -114,6 +114,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/carbon-home/repository/conf/log4j.properties @@ -121,6 +125,9 @@ src/test/resources/testng.xml + + org.ops4j.pax.logging + @@ -342,7 +349,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 40ad63072f..df3277920d 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, OWNER VARCHAR(255) DEFAULT NULL, - PARENT_PATH VARCHAR(255) DEFAULT '/', + PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); @@ -42,7 +42,7 @@ 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_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -84,8 +84,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( 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, + CREATED_TIMESTAMP BIGINT NOT NULL, + RECEIVED_TIMESTAMP BIGINT NULL, OPERATION_CODE VARCHAR(1000) NOT NULL, INITIATED_BY VARCHAR(100) NULL, OPERATION_DETAILS BLOB DEFAULT NULL, @@ -108,7 +108,19 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( 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_DEVICE_STATUS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + DEVICE_ID INTEGER NOT NULL, + STATUS VARCHAR(50) DEFAULT NULL, + UPDATE_TIME TIMESTAMP DEFAULT NULL, + CHANGED_BY VARCHAR(255) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES + DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE +); CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -176,17 +188,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT 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 , + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -197,11 +209,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); 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, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -216,9 +228,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,11 +240,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -243,11 +255,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT(11) NOT NULL AUTO_INCREMENT, + ID INT 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, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT DEFAULT NULL, IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID), CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION @@ -258,9 +270,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -284,11 +296,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -341,7 +353,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -356,7 +368,7 @@ 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, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -385,7 +397,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -405,6 +417,16 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- +CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ICON_PATH VARCHAR(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR(150) NOT NULL, + VERSION VARCHAR(50) DEFAULT '1.1.0', + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, @@ -425,7 +447,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( DEVICE_ID INT NULL, ENROLMENT_ID INT NOT NULL, KEY_FIELD VARCHAR(45) NULL, - VALUE_FIELD VARCHAR(1000) NULL, + VALUE_FIELD VARCHAR(1500) NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) @@ -454,7 +476,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -491,8 +513,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( 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, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -519,7 +541,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT(15) NOT NULL, + TIMESTAMP BIGINT NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -744,24 +766,6 @@ CREATE TABLE IF NOT EXISTS DM_EXT_DEVICE_MAPPING ( STATUS INT DEFAULT 0, PRIMARY KEY (ID) ); -/* - * Copyright (c) 2018 - 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. - */ - -- END OF DM_EXT_DEVICE_MAPPING TABLE-- -- END OF DM_EXT_PERMISSION_MAPPING TABLE-- @@ -773,23 +777,23 @@ CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING ( -- 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) + 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 + 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-- @@ -802,5 +806,34 @@ 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-- --- END OF DM_DEVICE_SUB_TYPE TABLE-- \ No newline at end of file +-- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- +CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_NAME VARCHAR(100) NOT NULL, + IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, + TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, + TRACCAR_USENAME VARCHAR(100) NULL, + STATUS VARCHAR(100) NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- + +-- SUB_OPERATION_TEMPLATE TABLE-- +CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, + OPERATION_DEFINITION TEXT NOT NULL, + OPERATION_CODE VARCHAR(100) NOT NULL, + SUB_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR(25) NOT NULL, + CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), + CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), +-- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), + CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) +); + +-- END OF SUB_OPERATION_TEMPLATE TABLE-- diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index ad8165fc67..2e591b07c9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 6476fc0aa6..f9972e1ef0 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -273,7 +273,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From da8fa5b89502858dc014244674c7df888a32c9ac Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:22:21 +0530 Subject: [PATCH 061/343] fixed unit tests --- .../pom.xml | 14 +++++++++++++- .../client/extension/service/JWTClientTest.java | 3 ++- .../resources/user-test/user-mgt-registry-test.xml | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 8b646fa964..f35ea73b60 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -155,7 +155,12 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 + test + + + org.mockito + mockito-core test @@ -253,12 +258,19 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/log4j.properties src/test/resources/testng.xml + + org.ops4j.pax.logging + diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java index d497d5e108..beb7db9962 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java @@ -43,9 +43,10 @@ import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; import java.util.Properties; +import org.powermock.modules.testng.PowerMockTestCase; @PrepareForTest(JWTClientUtil.class) -public class JWTClientTest { +public class JWTClientTest extends PowerMockTestCase{ private static final Log log = LogFactory.getLog(JWTClientTest.class); @ObjectFactory diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 From c286fec27bded7cfcd3152ac355e36b0aeb1333b Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:26:32 +0530 Subject: [PATCH 062/343] fixed unit tests --- .../pom.xml | 9 ++++++++- .../src/test/resources/data-source-config.xml | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index d23f1863cd..35621201eb 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -111,6 +111,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + src/test/resources/testng.xml @@ -118,6 +122,9 @@ ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties + + org.ops4j.pax.logging + @@ -175,7 +182,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml index 27b6dfeaeb..533fd82959 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon From ce37fdb4be94219fd46494e6c5666386439f2e0e Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:50:32 +0530 Subject: [PATCH 063/343] fixed unit tests --- .../pom.xml | 20 +- .../pom.xml | 34 + .../pom.xml | 29 + .../src/test/resources/conf/carbon.xml | 658 ------------------ .../test/resources/repository/conf/carbon.xml | 0 5 files changed, 81 insertions(+), 660 deletions(-) delete mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 38ba36543d..7bd5e03b5b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -106,13 +106,19 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + - file:src/test/resources/carbon-home/repository/conf/log4j.properties - + file:src/test/resources/log4j.properties src/test/resources/testng.xml + + org.ops4j.pax.logging + @@ -207,5 +213,15 @@ org.wso2.orbit.javax.xml.bind jaxb-api + + com.sun.xml.bind + jaxb-core + test + + + com.sun.xml.bind + jaxb-impl + test + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 8b1dc93e22..16d45fccce 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -104,6 +104,21 @@ io.entgra.device.mgt.core.device.mgt.core test + + org.mockito + mockito-core + test + + + com.sun.xml.bind + jaxb-core + test + + + com.sun.xml.bind + jaxb-impl + test + @@ -157,6 +172,25 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + + + file:src/test/resources/log4j.properties + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + org.jacoco jacoco-maven-plugin diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index ed434c7873..ec115c2905 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -122,6 +122,16 @@ powermock-module-testng test + + org.wso2.carbon + org.wso2.carbon.securevault + test + + + org.mockito + mockito-core + test + @@ -189,6 +199,25 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + + + file:src/test/resources/log4j.properties + + + src/test/resources/testng.xml + + + org.ops4j.pax.logging + + + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml deleted file mode 100644 index a5518cb720..0000000000 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml +++ /dev/null @@ -1,658 +0,0 @@ - - - - - - - - - ${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/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml new file mode 100644 index 0000000000..e69de29bb2 From f63a6ee65b88c67d53ab7661dc79a2371cdfc84a Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 14:54:56 +0530 Subject: [PATCH 064/343] fixed unit tests --- .../pom.xml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index a4673c3e6e..fffcfba429 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -76,12 +76,20 @@ org.apache.maven.plugins maven-surefire-plugin - - file:src/test/resources/log4j.properties - + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + src/test/resources/testng.xml + + ${basedir}/target/coverage-reports/jacoco-unit.exec + file:src/test/resources/log4j.properties + + + org.ops4j.pax.logging + @@ -255,7 +263,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From be6db5c5d54ac2c4ecf4894bcc4e90ada4171a32 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Thu, 6 Jul 2023 17:06:48 +0530 Subject: [PATCH 065/343] fixed unit tests --- pom.xml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 28dfc7301b..ec8f446882 100644 --- a/pom.xml +++ b/pom.xml @@ -833,6 +833,16 @@ jaxb-api ${version.org.wso2.orbit.javax.xml.bind} + + com.sun.xml.bind + jaxb-core + 2.3.0.1 + + + com.sun.xml.bind + jaxb-impl + 2.3.1 + org.apache.axis2.transport @@ -1654,7 +1664,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 ${power.mock.version} test @@ -1741,6 +1751,11 @@ mockito-inline ${mokito.version} + + org.mockito + mockito-core + ${mokito.version} + org.ops4j.pax.logging pax-logging-api @@ -1888,7 +1903,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.0 + 2.22.2 ${basedir}/target/coverage-reports/jacoco-ut.exec @@ -2113,7 +2128,7 @@ 0.7.8 0.7.5.201505241946 1.0b3 - 1.7.4 + 2.0.2 1.4.0.wso2v1 1.7.25 @@ -2136,7 +2151,7 @@ [1.6.0, 2.0.0) [1.2.0,1.3.0) - 4.2.0 + 2.23.4 2.8.1.wso2v2 4.3.1.wso2v1 2.1.210.wso2v1 From 80b42315d7fc928ce0a45cbdbc50883601102576 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 7 Jul 2023 11:11:31 +0530 Subject: [PATCH 066/343] operation template related unit test fixes --- .../pom.xml | 7 + .../carbon-home/dbscripts/dm-db-h2.sql | 199 ++++++++++++------ .../repository/conf/cdm-config.xml | 92 +++++--- .../conf/datasources/data-source-config.xml | 2 +- 4 files changed, 207 insertions(+), 93 deletions(-) diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index c71669f41e..a4ef16008e 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -119,6 +119,10 @@ org.apache.maven.plugins maven-surefire-plugin + + --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED + file:src/test/resources/carbon-home/repository/conf/log4j.properties @@ -126,6 +130,9 @@ src/test/resources/testng.xml + + org.ops4j.pax.logging + diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 6052156588..df3277920d 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, OWNER VARCHAR(255) DEFAULT NULL, - PARENT_PATH VARCHAR(255) DEFAULT '/', + PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); @@ -42,7 +42,7 @@ 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_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -84,8 +84,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( 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, + CREATED_TIMESTAMP BIGINT NOT NULL, + RECEIVED_TIMESTAMP BIGINT NULL, OPERATION_CODE VARCHAR(1000) NOT NULL, INITIATED_BY VARCHAR(100) NULL, OPERATION_DETAILS BLOB DEFAULT NULL, @@ -108,7 +108,19 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( 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_DEVICE_STATUS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + DEVICE_ID INTEGER NOT NULL, + STATUS VARCHAR(50) DEFAULT NULL, + UPDATE_TIME TIMESTAMP DEFAULT NULL, + CHANGED_BY VARCHAR(255) NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES + DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE +); CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -176,17 +188,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT 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 , + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -197,11 +209,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); 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, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -216,9 +228,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,11 +240,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -243,11 +255,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT(11) NOT NULL AUTO_INCREMENT, + ID INT 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, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT DEFAULT NULL, IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID), CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION @@ -258,9 +270,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -284,11 +296,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -341,7 +353,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -356,7 +368,7 @@ 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, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -385,7 +397,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -405,6 +417,16 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- +CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( + ID INTEGER AUTO_INCREMENT NOT NULL, + ICON_PATH VARCHAR(150) DEFAULT NULL, + PACKAGE_NAME VARCHAR(150) NOT NULL, + VERSION VARCHAR(50) DEFAULT '1.1.0', + CREATED_TIMESTAMP TIMESTAMP NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, @@ -425,7 +447,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( DEVICE_ID INT NULL, ENROLMENT_ID INT NOT NULL, KEY_FIELD VARCHAR(45) NULL, - VALUE_FIELD VARCHAR(1000) NULL, + VALUE_FIELD VARCHAR(1500) NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) @@ -454,7 +476,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -491,8 +513,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( 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, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -519,7 +541,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT(15) NOT NULL, + TIMESTAMP BIGINT NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -588,8 +610,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 -- @@ -725,52 +746,94 @@ 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, - 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, 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, + DEVICE_NAME VARCHAR(100) NOT NULL, + IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, + TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, + TRACCAR_USENAME VARCHAR(100) NULL, + STATUS VARCHAR(100) NULL, + TENANT_ID INTEGER DEFAULT 0, + PRIMARY KEY (ID) +); +-- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- + -- SUB_OPERATION_TEMPLATE TABLE-- -CREATE TABLE SUB_OPERATION_TEMPLATE ( - SUB_OPERATION_TEMPLATE_ID int NOT NULL AUTO_INCREMENT, +CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, OPERATION_DEFINITION TEXT NOT NULL, - OPERATION_CODE varchar(100) NOT NULL, - SUB_TYPE_ID int NOT NULL, + OPERATION_CODE VARCHAR(100) NOT NULL, + SUB_TYPE_ID INT NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, - CREATE_TIMESTAMP timestamp NULL DEFAULT NULL, - UPDATE_TIMESTAMP timestamp NULL DEFAULT NULL, + CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), - UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID,OPERATION_CODE, DEVICE_TYPE), + CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), +-- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) ); -/* - * Copyright (c) 2018 - 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. - */ - -- END OF SUB_OPERATION_TEMPLATE TABLE-- - -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/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml index b6c2900db7..3ce48daefe 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -31,18 +31,10 @@ 60000 true - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider - - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider - - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider - - - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider - + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider @@ -50,16 +42,16 @@ https://localhost:9443 - admin - admin + ${admin.username} + ${admin.username} https://localhost:9443 - admin - admin + ${admin.username} + ${admin.username} - org.wso2.carbon.policy.mgt + io.entgra.device.mgt.core.policy.mgt true 60000 5 @@ -90,7 +82,7 @@ device caching for upto configured expiry-time in seconds. In clustered setup all worker nodes can enable the device-cache to improve performance. --> - false + true 600 10000 + + true + 600 + 10000 + true - false + true 86400 @@ -120,6 +114,11 @@ false + false + + DM_DB + ARCHIVAL_DB + io.entgra.device.mgt.core.device.mgt.core.task.impl.ArchivalTask 0 0 0 1/1 * ? * @@ -159,7 +158,7 @@ true - wss://localhost:9443 + ws://localhost:9763 2 100 20 @@ -167,5 +166,50 @@ 640 BYOD,COPE + + false + false + io.entgra.device.mgt.core.device.mgt.common.enrollment.notification.EnrollmentNotifier + http://localhost:8280 + + + false + + + test_role + + /permission/admin/Login + + + + + + + + <a href='https://entgra.io' target='_blank'> + Entgra + </a> + IoT Server 5.2.0 | © 2023 + , All Rights Reserved. + + Entgra + + repository/resources/whitelabel + favicon.png + logo.png + icon.png + default + + + + + + + + + + false + Replace with mail + diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index ad8165fc67..2e591b07c9 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon From 5b85778d271712eea79eba77089f4eec93338bd6 Mon Sep 17 00:00:00 2001 From: Amalka Subasinghe Date: Fri, 7 Jul 2023 11:16:53 +0530 Subject: [PATCH 067/343] fixed operation template unit tests --- .../template/mock/BaseOperationTemplatePluginTest.java | 1 + .../test/resources/carbon-home/dbscripts/insert-subtypes.sql | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java index c563311602..58c7e8b65f 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java @@ -144,6 +144,7 @@ public abstract class BaseOperationTemplatePluginTest { conn = ConnectionManagerUtils.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/insert-subtypes.sql'"); } finally { TestUtils.cleanupResources(conn, stmt, null); } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql new file mode 100644 index 0000000000..ffa001a086 --- /dev/null +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql @@ -0,0 +1,3 @@ +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}'); \ No newline at end of file From effc35d52d82cf6f77aa2b7d06c7e9a1f9e02af4 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Thu, 25 May 2023 21:19:05 +0530 Subject: [PATCH 068/343] Update admin credentials in webapp-auth-config template --- .../src/main/resources/conf/webapp-authenticator-config.xml | 4 ++-- .../repository/conf/etc/webapp-authenticator-config.xml.j2 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml index bf5d2e00e2..c3bb4569b8 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml @@ -24,8 +24,8 @@ false https://${iot.keymanager.host}:${iot.keymanager.https.port} - ${admin.username} - ${admin.password} + {{super_admin.username}} + {{super_admin.password}} 100 100 diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 index 7c3ce35486..6c51e0f2b6 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 @@ -14,8 +14,8 @@ false https://${iot.keymanager.host}:${iot.keymanager.https.port} - ${admin.username} - ${admin.password} + {{super_admin.username}} + {{super_admin.password}} 100 100 From 74e06047f1076dd9de989d7bf7f782b0bbeea980 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Tue, 13 Jun 2023 09:19:43 +0530 Subject: [PATCH 069/343] Fix class def not found in grafana component --- .../pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 0089325b5d..e8197e4426 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -124,7 +124,7 @@ org.wso2.carbon.utils;version="[4.8,5)" - !io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.internal, + !io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal, io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.* From 7ad3a0e21be981216104a4338f25ff2e6d2c872a Mon Sep 17 00:00:00 2001 From: Kavin Prathaban Date: Fri, 16 Jun 2023 10:06:30 +0000 Subject: [PATCH 070/343] Add custom loggers (#136) * Fixes https://roadmap.entgra.net/issues/10117 * Added custom logs for below cases: 1. Device connectivity events 2. Policy payload change events 3. Device enrollment history events 4. App install events **1. Device connectivity logs** - logs for newly added operations and calls for pending operations Pattern : {DateTime} {LogLevel} - {ActionTag} {OperationCode} {DeviceId} {DeviceType} {TenantDomain} {TenantId} {UserName} - log_message ``` [2023-06-15 00:12:09,093] INFO - [ADD_OPERATION] [DEVICE_LOCATION] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:12:10,344] INFO - [PENDING_OPERATION] [DEVICE_LOCATION] [675c60a9d31492d6] [android] [carbon.super] [-1234] [admin]- Device Connected [2023-06-15 00:13:49,755] INFO - [ADD_OPERATION] [DEVICE_LOCK] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:13:56,513] INFO - [ADD_OPERATION] [DEVICE_MUTE] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:14:23,839] INFO - [PENDING_OPERATION] [DEVICE_MUTE] [2023-06-15 00:15:12,549] INFO - [ADD_OPERATION] [INSTALL_APPLICATION] [97] [android] [carbon.super] [-1234] [admin]- Operation added [2023-06-15 00:15:29,703] INFO - [PENDING_OPERATION] [INSTALL_APPLICATION] [675c60a9d31492d6] [android] [carbon.super] [-1234] [admin]- Device Connected ``` **2. Policy payload change events** - logs for creating policy, updating policy, deleting policy, change policy priorities and apply changes to device logs Pattern : {DateTime} {LogLevel} - {ActionTag} {PolicyName} {TenantDomain} {TenantId} {Payload} {UserName} - log_message ``` [2023-06-15 00:15:53,264] INFO - [UPDATE_POLICY] [passcodeios] [carbon.super] [-1234] [{"policyPayloadVersion":"2.0","id":33,"priorityId":1,"profile":{"profileId":33,"profileName":"passcodeios","tenantId":0,"deviceType":"ios","updatedDate":"Jun 15, 2023 12:15:53 AM","profileFeaturesList":[{"id":33,"featureCode":"PASSCODE_POLICY","profileId":0,"deviceType":"ios","content":"{\"forcePIN\":true,\"allowSimple\":true,\"requireAlphanumeric\":true,\"minLength\":7.0,\"minComplexChars\":4.0,\"pinHistory\":\"\"}","correctiveActions":[]}]},"policyName":"passcodeios","generic":false,"roles":["ANY"],"devices":[],"users":[],"active":false,"updated":false,"description":"test","compliance":"enforce","tenantId":-1234,"profileId":33,"policyType":"GENERAL"}] [admin] - Policy updated [2023-06-15 00:34:38,980] INFO - [ADD_POLICY] [application management policy] [carbon.super] [-1234] [{"policyPayloadVersion":"2.0","id":65,"priorityId":0,"profile":{"profileId":65,"profileName":"application management policy","tenantId":0,"deviceType":"windows","createdDate":"Jun 15, 2023 12:34:38 AM","updatedDate":"Jun 15, 2023 12:34:38 AM","profileFeaturesList":[{"id":65,"featureCode":"ALLOW_ALL_TRUSTED_APPS","profileId":0,"deviceType":"windows","content":"{\"enabled\":true}","correctiveActions":[]},{"id":73,"featureCode":"RESTRICT_APP_TO_SYSTEM_VOLUME","profileId":0,"deviceType":"windows","content":"{\"enabled\":false}","correctiveActions":[]}]},"policyName":"application management policy","generic":false,"roles":["ANY"],"devices":[],"users":[],"active":false,"updated":false,"description":"test","compliance":"enforce","tenantId":-1234,"profileId":0,"policyType":"GENERAL"}] [admin] - Policy created [2023-06-15 00:35:05,420] INFO - [DELETE_POLICY] [passcodeios] [carbon.super] [-1234] [{"policyPayloadVersion":"2.0","id":33,"priorityId":1,"profile":{"profileId":33,"profileName":"passcodeios","tenantId":-1234,"deviceType":"ios","createdDate":"Jun 13, 2023 10:24:30 PM","updatedDate":"Jun 15, 2023 12:15:53 AM","profileFeaturesList":[{"id":33,"featureCode":"PASSCODE_POLICY","profileId":33,"deviceType":"ios","content":"{\"forcePIN\":true,\"allowSimple\":true,\"requireAlphanumeric\":true,\"minLength\":7.0,\"minComplexChars\":4.0,\"pinHistory\":\"\"}","correctiveActions":[]}]},"policyName":"passcodeios","generic":false,"roles":["ANY"],"devices":[],"users":[],"active":false,"updated":true,"description":"test","compliance":"enforce","policyCriterias":[],"tenantId":-1234,"profileId":33,"deviceGroups":[],"policyType":"GENERAL"}] [admin] - Policy deleted [2023-06-15 00:35:12,768] INFO - [UPDATE_POLICY_PRIORITIES] [] [carbon.super] [-1234] [[{"id":65,"priorityId":1,"generic":false,"active":false,"updated":false,"tenantId":0,"profileId":0},{"id":34,"priorityId":2,"generic":false,"active":false,"updated":false,"tenantId":0,"profileId":0}]] [admin] - Policy priorities updated [2023-06-15 00:35:25,395] INFO - [PUBLISH_CHANGES] [] [carbon.super] [-1234] [] [admin] - Apply changes to device ``` **3. Device enrollment history events** - logs for device enrollment and dis-enrollment Pattern : {DateTime} {LogLevel} - {DeviceId} {DeviceType} {Owner} {Ownership} {TenantId} {TenantDomain} {UserName} - log_message ``` [2023-06-15 00:12:09,078] INFO - [97] [android] [admin] [BYOD] [-1234] [carbon.super] [admin] - Device enrolled successfully [2023-06-15 00:47:36,278] INFO - [97] [android] [admin] [BYOD] [-1234] [carbon.super] [admin] - Device disenrolled successfully ``` **4. App install events** - logs for app installation and uninstallation Pattern : {DateTime} {LogLevel} - {AppId} {AppName} {AppType} {SubType} {Action} {Device} {TenantId} {TenantDomain} {UserName} - log_message ``` [2023-06-15 00:15:12,550] INFO - [1] [Calculator] [PUBLIC] [DEVICE] [install] [deviceId {id='675c60a9d31492d6', type='android'}] [-1234] [carbon.super] [admin] - App install triggered [2023-06-15 00:46:24,454] INFO - [2] [Sololearn] [ENTERPRISE] [DEVICE] [install] [deviceId {id='675c60a9d31492d6', type='android'}] [-1234] [carbon.super] [admin] - App install triggered [2023-06-15 00:46:40,498] INFO - [3] [Engineering] [WEB_CLIP] [DEVICE] [install] [deviceId {id='675c60a9d31492d6', type='android'}] [-1234] [carbon.super] [admin] - Web app install triggered ``` * https://repository.entgra.net/proprietary/product-uem/pulls/6 Co-authored-by: prathabanKavin Co-authored-by: Pahansith Gunathilake Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/136 Co-authored-by: Kavin Prathaban Co-committed-by: Kavin Prathaban --- .../core/impl/SubscriptionManagerImpl.java | 18 +- .../operation/mgt/OperationManagerImpl.java | 38 ++- .../DeviceManagementProviderServiceImpl.java | 37 +- .../logger/AppInstallLogContext.java | 181 ++++++++++ .../logger/DeviceConnectivityLogContext.java | 150 +++++++++ .../logger/DeviceEnrolmentLogContext.java | 149 ++++++++ .../notification/logger/PolicyLogContext.java | 133 ++++++++ .../impl/EntgraAppInstallLoggerImpl.java | 318 ++++++++++++++++++ .../EntgraDeviceConnectivityLoggerImpl.java | 318 ++++++++++++++++++ .../impl/EntgraDeviceEnrolmentLoggerImpl.java | 318 ++++++++++++++++++ .../logger/impl/EntgraDeviceLoggerImpl.java | 7 - .../logger/impl/EntgraPolicyLoggerImpl.java | 318 ++++++++++++++++++ .../logger/impl/EntgraUserLoggerImpl.java | 2 - .../logger/util/MDCContextUtil.java | 102 +++++- .../impl/PolicyAdministratorPointImpl.java | 10 +- .../mgt/core/mgt/impl/PolicyManagerImpl.java | 39 ++- 16 files changed, 2114 insertions(+), 24 deletions(-) create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java create mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index cae569bbd3..92c1a93f18 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -19,6 +19,10 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import com.google.gson.Gson; +import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraAppInstallLoggerImpl; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.application.mgt.common.*; @@ -87,8 +91,8 @@ import java.util.stream.Collectors; * This is the default implementation for the Subscription Manager. */ public class SubscriptionManagerImpl implements SubscriptionManager { - - private static final Log log = LogFactory.getLog(SubscriptionManagerImpl.class); + AppInstallLogContext.Builder appInstallLogContextBuilder = new AppInstallLogContext.Builder(); + private static final EntgraLogger log = new EntgraAppInstallLoggerImpl(SubscriptionManagerImpl.class); private SubscriptionDAO subscriptionDAO; private ApplicationDAO applicationDAO; private LifecycleStateManager lifecycleStateManager; @@ -620,7 +624,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Properties properties, boolean isOperationReExecutingDisabled) throws ApplicationManagementException { - + String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); //Get app subscribing info of each device SubscribingDeviceIdHolder subscribingDeviceIdHolder = getSubscribingDeviceIdHolder(devices, applicationDTO.getApplicationReleaseDTOs().get(0).getId()); @@ -670,10 +676,16 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Activity activity = addAppOperationOnDevices(applicationDTO, new ArrayList<>(entry.getValue()), entry.getKey(), action, properties); activityList.add(activity); + for (DeviceIdentifier identifier : deviceIdentifiers) { + log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build()); + } } } else { Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action, properties); activityList.add(activity); + for (DeviceIdentifier identifier : deviceIdentifiers) { + log.info(String.format("App %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build()); + } } ApplicationInstallResponse applicationInstallResponse = new ApplicationInstallResponse(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index 5e5ca5c13d..92cf1818a7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -19,6 +19,23 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt; import io.entgra.device.mgt.core.device.mgt.common.*; +import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceConnectivityLoggerImpl; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; +import org.apache.commons.lang.StringUtils; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; +import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; @@ -68,7 +85,8 @@ import java.util.concurrent.ThreadPoolExecutor; */ public class OperationManagerImpl implements OperationManager { - private static final Log log = LogFactory.getLog(OperationManagerImpl.class); + DeviceConnectivityLogContext.Builder deviceConnectivityLogContextBuilder = new DeviceConnectivityLogContext.Builder(); + private static final EntgraLogger log = new EntgraDeviceConnectivityLoggerImpl(OperationManagerImpl.class); private static final int CACHE_VALIDITY_PERIOD = 5 * 60 * 1000; private static final String NOTIFIER_TYPE_LOCAL = "LOCAL"; private static final String SYSTEM = "system"; @@ -151,6 +169,8 @@ public class OperationManagerImpl implements OperationManager { } } + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); DeviceIDHolder deviceValidationResult = DeviceManagerUtil.validateDeviceIdentifiers(deviceIds); List validDeviceIds = deviceValidationResult.getValidDeviceIDList(); if (!validDeviceIds.isEmpty()) { @@ -227,6 +247,10 @@ public class OperationManagerImpl implements OperationManager { activity.setActivityStatus( this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult)); } + for (DeviceIdentifier deviceId : authorizedDeviceIds) { + device = getDevice(deviceId); + log.info("Operation added", deviceConnectivityLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(deviceType).setActionTag("ADD_OPERATION").setTenantDomain(tenantDomain).setTenantId(tenantId).setUserName(initiatedBy).setOperationCode(operationCode).build()); + } return activity; } catch (OperationManagementDAOException e) { OperationManagementDAOFactory.rollbackTransaction(); @@ -673,7 +697,9 @@ public class OperationManagerImpl implements OperationManager { if (log.isDebugEnabled()) { log.debug("Device identifier id:[" + deviceId.getId() + "] type:[" + deviceId.getType() + "]"); } - + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); EnrolmentInfo enrolmentInfo = this.getActiveEnrolmentInfo(deviceId); if (enrolmentInfo == null) { throw new OperationManagementException("Device not found for the given device Identifier:" + @@ -686,16 +712,18 @@ public class OperationManagerImpl implements OperationManager { case INACTIVE: case UNREACHABLE: this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceCacheManagerImpl.getInstance().removeDeviceFromCache(deviceId, tenantId); break; } - + log.info("Device Connected", deviceConnectivityLogContextBuilder.setDeviceId(deviceId.getId()).setDeviceType(deviceId.getType()).setActionTag("PENDING_OPERATION").setTenantDomain(tenantDomain).setTenantId(String.valueOf(tenantId)).setUserName(userName).build()); return getOperations(deviceId, Operation.Status.PENDING, enrolmentId); } @Override public List getPendingOperations(Device device) throws OperationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo(); if (enrolmentInfo == null) { throw new OperationManagementException("Device not found for the given device Identifier:" + @@ -713,10 +741,10 @@ public class OperationManagerImpl implements OperationManager { this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE); device.setEnrolmentInfo(enrolmentInfo); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceCacheManagerImpl.getInstance().addDeviceToCache(deviceIdentifier, device, tenantId); break; } + log.info("Device Connected", deviceConnectivityLogContextBuilder.setDeviceId(device.getDeviceIdentifier()).setDeviceType(device.getType()).setActionTag("PENDING_OPERATION").setTenantDomain(tenantDomain).setTenantId(String.valueOf(tenantId)).setUserName(userName).build()); return getOperations(deviceIdentifier, Operation.Status.PENDING, enrolmentId); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 02d6b010eb..e6a32ba4f4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -21,6 +21,30 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceEnrolmentLoggerImpl; +import org.apache.commons.collections.map.SingletonMap; +import org.apache.commons.lang.StringUtils; +import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.Billing; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceEnrollmentInfoNotification; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManager; +import io.entgra.device.mgt.core.device.mgt.common.DeviceNotification; +import io.entgra.device.mgt.core.device.mgt.common.DevicePropertyNotification; +import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; +import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; +import io.entgra.device.mgt.core.device.mgt.common.InitialOperationConfig; +import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; +import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.StartupOperationConfig; +import io.entgra.device.mgt.core.device.mgt.common.BillingResponse; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.*; @@ -117,7 +141,9 @@ import java.util.stream.Collectors; public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService, PluginInitializationListener { - private static final Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class); + DeviceEnrolmentLogContext.Builder deviceEnrolmentLogContextBuilder = new DeviceEnrolmentLogContext.Builder(); + + private static final EntgraLogger log = new EntgraDeviceEnrolmentLoggerImpl(DeviceManagementProviderServiceImpl.class); private static final String OPERATION_RESPONSE_EVENT_STREAM_DEFINITION = "org.wso2.iot.OperationResponseStream"; private final DeviceManagementPluginRepository pluginRepository; @@ -205,6 +231,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } return false; } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); EnrollmentConfiguration enrollmentConfiguration = DeviceManagerUtil.getEnrollmentConfigurationEntry(); String deviceSerialNumber = null; if (enrollmentConfiguration != null) { @@ -291,6 +319,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + "'"); } + log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(existingDevice.getId())).setDeviceType(String.valueOf(existingDevice.getType())).setOwner(newEnrolmentInfo.getOwner()).setOwnership(String.valueOf(newEnrolmentInfo.getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); status = true; } else { log.warn("Unable to update device enrollment for device : " + device.getDeviceIdentifier() + @@ -327,6 +356,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } device.setEnrolmentInfo(enrollment); DeviceManagementDAOFactory.commitTransaction(); + log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(String.valueOf(device.getType())).setOwner(enrollment.getOwner()).setOwnership(String.valueOf(enrollment.getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); } else { DeviceManagementDAOFactory.rollbackTransaction(); throw new DeviceManagementException("No device type registered with name - " + device.getType() @@ -515,7 +545,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } int tenantId = this.getTenantId(); - + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); Device device = this.getDevice(deviceId, false); if (device == null) { if (log.isDebugEnabled()) { @@ -549,7 +580,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } } //procees to dis-enroll a device from traccar ends - + log.info("Device disenrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(String.valueOf(device.getType())).setOwner(device.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(device.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while dis-enrolling '" + deviceId.getType() + diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java new file mode 100644 index 0000000000..33cffac366 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2018 - 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.notification.logger; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; + +public class AppInstallLogContext extends LogContext { + private final String appId; + private final String appName; + private final String appType; + private final String subType; + private final String tenantId; + private final String tenantDomain; + private final String device; + private final String userName; + private final String action; + + private AppInstallLogContext(Builder builder) { + this.appId = builder.appId; + this.appName = builder.appName; + this.appType = builder.appType; + this.subType = builder.subType; + this.tenantId = builder.tenantId; + this.tenantDomain = builder.tenantDomain; + this.device = builder.device; + this.userName = builder.userName; + this.action = builder.action; + } + + public String getAppId() { + return appId; + } + + public String getAppName() { + return appName; + } + + public String getAppType() { + return appType; + } + + public String getSubType() { + return subType; + } + + public String getTenantId() { + return tenantId; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public String getDevice() { + return device; + } + + public String getUserName() { + return userName; + } + + public String getAction() { + return action; + } + + public static class Builder { + private String appId; + private String appName; + private String appType; + private String subType; + private String tenantId; + private String tenantDomain; + private String device; + private String userName; + private String action; + + public Builder() { + } + + public String getUserName() { + return userName; + } + + public Builder setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getAppId() { + return appId; + } + + public Builder setAppId(String appId) { + this.appId = appId; + return this; + } + + public String getAppName() { + return appName; + } + + public Builder setAppName(String appName) { + this.appName = appName; + return this; + } + + public String getAppType() { + return appType; + } + + public Builder setAppType(String appType) { + this.appType = appType; + return this; + } + + public String getSubType() { + return subType; + } + + public Builder setSubType(String subType) { + this.subType = subType; + return this; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public Builder setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + return this; + } + + public String getTenantId() { + return tenantId; + } + + public Builder setTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + public String getDevice() { + return device; + } + + public Builder setDevice(String device) { + this.device = device; + return this; + } + + public String getAction() { + return action; + } + + public Builder setAction(String action) { + this.action = action; + return this; + } + + public AppInstallLogContext build() { + return new AppInstallLogContext(this); + } + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java new file mode 100644 index 0000000000..d110e84a43 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2018 - 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.notification.logger; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; + +public class DeviceConnectivityLogContext extends LogContext { + + private final String deviceId; + private final String deviceType; + private final String actionTag; + private final String operationCode; + private final String tenantId; + private final String tenantDomain; + private final String userName; + + private DeviceConnectivityLogContext(Builder builder) { + this.deviceId = builder.deviceId; + this.deviceType = builder.deviceType; + this.actionTag = builder.actionTag; + this.operationCode = builder.operationCode; + this.tenantId = builder.tenantId; + this.tenantDomain = builder.tenantDomain; + this.userName = builder.userName; + } + + public String getDeviceId() { + return deviceId; + } + + public String getDeviceType() { + return deviceType; + } + + public String getActionTag() { + return actionTag; + } + + public String getOperationCode() { + return operationCode; + } + + public String getTenantId() { + return tenantId; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public String getUserName() { + return userName; + } + + public static class Builder { + private String deviceId; + private String deviceType; + private String operationCode; + private String actionTag; + private String tenantId; + private String tenantDomain; + private String userName; + + public Builder() { + } + + public String getDeviceId() { + return deviceId; + } + + public Builder setDeviceId(String deviceId) { + this.deviceId = deviceId; + return this; + } + + public String getDeviceType() { + return deviceType; + } + + public Builder setDeviceType(String deviceType) { + this.deviceType = deviceType; + return this; + } + + public String getOperationCode() { + return operationCode; + } + + public Builder setOperationCode(String operationCode) { + this.operationCode = operationCode; + return this; + } + + public String getTenantId() { + return tenantId; + } + + public Builder setTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public Builder setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + return this; + } + + public String getUserName() { + return userName; + } + + public Builder setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getActionTag() { + return actionTag; + } + + public Builder setActionTag(String actionTag) { + this.actionTag = actionTag; + return this; + } + + public DeviceConnectivityLogContext build() { + return new DeviceConnectivityLogContext(this); + } + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java new file mode 100644 index 0000000000..b355b29671 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2018 - 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.notification.logger; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; + +public class DeviceEnrolmentLogContext extends LogContext { + private final String deviceId; + private final String deviceType; + private final String owner; + private final String ownership; + private final String tenantID; + private final String tenantDomain; + private final String userName; + + private DeviceEnrolmentLogContext(Builder builder) { + this.deviceId = builder.deviceId; + this.deviceType = builder.deviceType; + this.owner = builder.owner; + this.ownership = builder.ownership; + this.tenantID = builder.tenantID; + this.tenantDomain = builder.tenantDomain; + this.userName = builder.userName; + } + + public String getTenantID() { + return tenantID; + } + + public String getDeviceId() { + return deviceId; + } + + public String getOwner() { + return owner; + } + + public String getDeviceType() { + return deviceType; + } + + public String getOwnership() { + return ownership; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public String getUserName() { + return userName; + } + public static class Builder { + private String deviceId; + private String deviceType; + private String owner; + private String ownership; + private String tenantID; + private String tenantDomain; + private String userName; + + public Builder() { + } + + public String getDeviceType() { + return deviceType; + } + + public Builder setDeviceType(String deviceType) { + this.deviceType = deviceType; + return this; + } + + public String getTenantID() { + return tenantID; + } + + public Builder setTenantID(String tenantID) { + this.tenantID = tenantID; + return this; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public Builder setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + return this; + } + + public String getUserName() { + return userName; + } + + public Builder setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getDeviceId() { + return deviceId; + } + + public Builder setDeviceId(String deviceId) { + this.deviceId = deviceId; + return this; + } + + public String getOwner() { + return owner; + } + + public Builder setOwner(String owner) { + this.owner = owner; + return this; + } + + public String getOwnership() { + return ownership; + } + + public Builder setOwnership(String ownership) { + this.ownership = ownership; + return this; + } + + public DeviceEnrolmentLogContext build() { + return new DeviceEnrolmentLogContext(this); + } + + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java new file mode 100644 index 0000000000..9dbd10a059 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2018 - 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.notification.logger; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; + +public class PolicyLogContext extends LogContext { + private final String policyName; + private final String payload; + private final String actionTag; + private final String userName; + private final String tenantID; + private final String tenantDomain; + + private PolicyLogContext(Builder builder) { + this.policyName = builder.policyName; + this.payload = builder.payload; + this.actionTag = builder.actionTag; + this.userName = builder.userName; + this.tenantID = builder.tenantID; + this.tenantDomain = builder.tenantDomain; + } + + public String getPolicyName() { + return policyName; + } + + public String getPayload() { + return payload; + } + + public String getActionTag() { + return actionTag; + } + + public String getUserName() { + return userName; + } + + public String getTenantID() { + return tenantID; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public static class Builder { + private String policyName; + private String payload; + private String actionTag; + private String userName; + private String tenantID; + private String tenantDomain; + + public Builder() { + } + + public String getPolicyName() { + return policyName; + } + + public Builder setPolicyName(String policyName) { + this.policyName = policyName; + return this; + } + + public String getPayload() { + return payload; + } + + public Builder setPayload(String payload) { + this.payload = payload; + return this; + } + + public String getActionTag() { + return actionTag; + } + + public Builder setActionTag(String actionTag) { + this.actionTag = actionTag; + return this; + } + + public String getUserName() { + return userName; + } + + public Builder setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getTenantID() { + return tenantID; + } + + public Builder setTenantID(String tenantID) { + this.tenantID = tenantID; + return this; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public Builder setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + return this; + } + + public PolicyLogContext build() { + return new PolicyLogContext(this); + } + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java new file mode 100644 index 0000000000..81f071c2af --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2018 - 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.notification.logger.impl; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; +import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.MDC; + +public class EntgraAppInstallLoggerImpl implements EntgraLogger { + + private static Log log = null; + + public EntgraAppInstallLoggerImpl(Class clazz) { + log = LogFactory.getLog(clazz); + } + + public void info(String message) { + log.info(message); + } + + public void info(String message, Throwable t) { + log.info(message, t); + } + + @Override + public void info(Object o) { + log.info(o); + } + + @Override + public void info(Object o, Throwable throwable) { + log.info(o, throwable); + } + + @Override + public void info(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.info(message); + } + + @Override + public void info(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.info(object); + } + + @Override + public void info(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.info(object, t); + } + + public void debug(String message) { + log.debug(message); + } + + public void debug(String message, Throwable t) { + log.debug(message, t); + } + + @Override + public void debug(Object o) { + log.debug(o); + } + + @Override + public void debug(Object o, Throwable throwable) { + log.debug(o, throwable); + } + + @Override + public void debug(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.debug(message); + } + + @Override + public void debug(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.debug(object); + } + + @Override + public void debug(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.debug(object, t); + } + + public void error(String message) { + log.error(message); + } + + public void error(String message, Throwable t) { + log.error(message, t); + } + + @Override + public void error(Object o) { + log.error(o); + } + + @Override + public void error(Object o, Throwable throwable) { + log.error(o, throwable); + } + + @Override + public void error(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.error(message); + } + + @Override + public void error(String message, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.error(message, t); + } + + @Override + public void error(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.error(object); + } + + @Override + public void error(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.error(object, t); + } + + public void warn(String message) { + log.warn(message); + } + + public void warn(String message, Throwable t) { + log.warn(message, t); + } + + @Override + public void warn(Object o) { + log.warn(o); + } + + @Override + public void warn(Object o, Throwable throwable) { + log.warn(o, throwable); + } + + @Override + public void warn(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.warn(message); + } + + @Override + public void warn(String message, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.warn(message, t); + } + + @Override + public void warn(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.warn(object); + } + + @Override + public void warn(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.warn(object, t); + } + + public void trace(String message) { + log.trace(message); + } + + public void trace(String message, Throwable t) { + log.trace(message, t); + } + + @Override + public void trace(Object o) { + log.trace(o); + } + + @Override + public void trace(Object o, Throwable throwable) { + log.trace(o, throwable); + } + + @Override + public void trace(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.trace(message); + } + + @Override + public void trace(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.trace(object); + } + + @Override + public void trace(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.trace(object, t); + } + + public void fatal(String message) { + log.fatal(message); + } + + public void fatal(String message, Throwable t) { + log.fatal(message, t); + } + + @Override + public void fatal(Object o) { + log.fatal(0); + } + + @Override + public void fatal(Object o, Throwable throwable) { + log.fatal(0, throwable); + } + + @Override + public void fatal(String message, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.fatal(message); + } + + @Override + public void fatal(Object object, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.fatal(object); + } + + @Override + public void fatal(Object object, Throwable t, LogContext logContext) { + AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; + MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); + log.fatal(object, t); + } + + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return log.isErrorEnabled(); + } + + @Override + public boolean isFatalEnabled() { + return log.isFatalEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + @Override + public boolean isTraceEnabled() { + return log.isTraceEnabled(); + } + + @Override + public boolean isWarnEnabled() { + return log.isWarnEnabled(); + } + + @Override + public void clearLogContext() { + MDC.clear(); + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java new file mode 100644 index 0000000000..aaa62bf488 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2018 - 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.notification.logger.impl; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContext; +import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.MDC; + +public class EntgraDeviceConnectivityLoggerImpl implements EntgraLogger { + + private static Log log = null; + + public EntgraDeviceConnectivityLoggerImpl(Class clazz) { + log = LogFactory.getLog(clazz); + } + + public void info(String message) { + log.info(message); + } + + public void info(String message, Throwable t) { + log.info(message, t); + } + + @Override + public void info(Object o) { + log.info(o); + } + + @Override + public void info(Object o, Throwable throwable) { + log.info(o, throwable); + } + + @Override + public void info(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.info(message); + } + + @Override + public void info(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.info(object); + } + + @Override + public void info(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.info(object, t); + } + + public void debug(String message) { + log.debug(message); + } + + public void debug(String message, Throwable t) { + log.debug(message, t); + } + + @Override + public void debug(Object o) { + log.debug(o); + } + + @Override + public void debug(Object o, Throwable throwable) { + log.debug(o, throwable); + } + + @Override + public void debug(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.debug(message); + } + + @Override + public void debug(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.debug(object); + } + + @Override + public void debug(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.debug(object, t); + } + + public void error(String message) { + log.error(message); + } + + public void error(String message, Throwable t) { + log.error(message, t); + } + + @Override + public void error(Object o) { + log.error(o); + } + + @Override + public void error(Object o, Throwable throwable) { + log.error(o, throwable); + } + + @Override + public void error(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.error(message); + } + + @Override + public void error(String message, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.error(message, t); + } + + @Override + public void error(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.error(object); + } + + @Override + public void error(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.error(object, t); + } + + public void warn(String message) { + log.warn(message); + } + + public void warn(String message, Throwable t) { + log.warn(message, t); + } + + @Override + public void warn(Object o) { + log.warn(o); + } + + @Override + public void warn(Object o, Throwable throwable) { + log.warn(o, throwable); + } + + @Override + public void warn(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.warn(message); + } + + @Override + public void warn(String message, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.warn(message, t); + } + + @Override + public void warn(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.warn(object); + } + + @Override + public void warn(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.warn(object, t); + } + + public void trace(String message) { + log.trace(message); + } + + public void trace(String message, Throwable t) { + log.trace(message, t); + } + + @Override + public void trace(Object o) { + log.trace(o); + } + + @Override + public void trace(Object o, Throwable throwable) { + log.trace(o, throwable); + } + + @Override + public void trace(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.trace(message); + } + + @Override + public void trace(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.trace(object); + } + + @Override + public void trace(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.trace(object, t); + } + + public void fatal(String message) { + log.fatal(message); + } + + public void fatal(String message, Throwable t) { + log.fatal(message, t); + } + + @Override + public void fatal(Object o) { + log.fatal(0); + } + + @Override + public void fatal(Object o, Throwable throwable) { + log.fatal(0, throwable); + } + + @Override + public void fatal(String message, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.fatal(message); + } + + @Override + public void fatal(Object object, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.fatal(object); + } + + @Override + public void fatal(Object object, Throwable t, LogContext logContext) { + DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; + MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); + log.fatal(object, t); + } + + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return log.isErrorEnabled(); + } + + @Override + public boolean isFatalEnabled() { + return log.isFatalEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + @Override + public boolean isTraceEnabled() { + return log.isTraceEnabled(); + } + + @Override + public boolean isWarnEnabled() { + return log.isWarnEnabled(); + } + + @Override + public void clearLogContext() { + MDC.clear(); + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java new file mode 100644 index 0000000000..db0b7dd265 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2018 - 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.notification.logger.impl; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext; +import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.MDC; + +public class EntgraDeviceEnrolmentLoggerImpl implements EntgraLogger { + + private static Log log = null; + + public EntgraDeviceEnrolmentLoggerImpl(Class clazz) { + log = LogFactory.getLog(clazz); + } + + public void info(String message) { + log.info(message); + } + + public void info(String message, Throwable t) { + log.info(message, t); + } + + @Override + public void info(Object o) { + log.info(o); + } + + @Override + public void info(Object o, Throwable throwable) { + log.info(o, throwable); + } + + @Override + public void info(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.info(message); + } + + @Override + public void info(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.info(object); + } + + @Override + public void info(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.info(object, t); + } + + public void debug(String message) { + log.debug(message); + } + + public void debug(String message, Throwable t) { + log.debug(message, t); + } + + @Override + public void debug(Object o) { + log.debug(o); + } + + @Override + public void debug(Object o, Throwable throwable) { + log.debug(o, throwable); + } + + @Override + public void debug(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.debug(message); + } + + @Override + public void debug(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.debug(object); + } + + @Override + public void debug(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.debug(object, t); + } + + public void error(String message) { + log.error(message); + } + + public void error(String message, Throwable t) { + log.error(message, t); + } + + @Override + public void error(Object o) { + log.error(o); + } + + @Override + public void error(Object o, Throwable throwable) { + log.error(o, throwable); + } + + @Override + public void error(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.error(message); + } + + @Override + public void error(String message, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.error(message, t); + } + + @Override + public void error(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.error(object); + } + + @Override + public void error(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.error(object, t); + } + + public void warn(String message) { + log.warn(message); + } + + public void warn(String message, Throwable t) { + log.warn(message, t); + } + + @Override + public void warn(Object o) { + log.warn(o); + } + + @Override + public void warn(Object o, Throwable throwable) { + log.warn(o, throwable); + } + + @Override + public void warn(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.warn(message); + } + + @Override + public void warn(String message, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.warn(message, t); + } + + @Override + public void warn(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.warn(object); + } + + @Override + public void warn(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.warn(object, t); + } + + public void trace(String message) { + log.trace(message); + } + + public void trace(String message, Throwable t) { + log.trace(message, t); + } + + @Override + public void trace(Object o) { + log.trace(o); + } + + @Override + public void trace(Object o, Throwable throwable) { + log.trace(o, throwable); + } + + @Override + public void trace(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.trace(message); + } + + @Override + public void trace(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.trace(object); + } + + @Override + public void trace(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.trace(object, t); + } + + public void fatal(String message) { + log.fatal(message); + } + + public void fatal(String message, Throwable t) { + log.fatal(message, t); + } + + @Override + public void fatal(Object o) { + log.fatal(0); + } + + @Override + public void fatal(Object o, Throwable throwable) { + log.fatal(0, throwable); + } + + @Override + public void fatal(String message, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.fatal(message); + } + + @Override + public void fatal(Object object, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.fatal(object); + } + + @Override + public void fatal(Object object, Throwable t, LogContext logContext) { + DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; + MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); + log.fatal(object, t); + } + + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return log.isErrorEnabled(); + } + + @Override + public boolean isFatalEnabled() { + return log.isFatalEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + @Override + public boolean isTraceEnabled() { + return log.isTraceEnabled(); + } + + @Override + public boolean isWarnEnabled() { + return log.isWarnEnabled(); + } + + @Override + public void clearLogContext() { + MDC.clear(); + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java index ae10ae87c2..a51987463f 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java @@ -17,7 +17,6 @@ */ package io.entgra.device.mgt.core.notification.logger.impl; - import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; @@ -26,7 +25,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.MDC; - public class EntgraDeviceLoggerImpl implements EntgraLogger { private static Log log = null; @@ -74,7 +72,6 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.info(object, t); } - public void debug(String message) { log.debug(message); } @@ -114,7 +111,6 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.debug(object, t); } - public void error(String message) { log.error(message); } @@ -161,7 +157,6 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.error(object, t); } - public void warn(String message) { log.warn(message); } @@ -208,7 +203,6 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.warn(object, t); } - public void trace(String message) { log.trace(message); } @@ -248,7 +242,6 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.trace(object, t); } - public void fatal(String message) { log.fatal(message); } diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java new file mode 100644 index 0000000000..218252f260 --- /dev/null +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2018 - 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.notification.logger.impl; + +import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; +import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.MDC; + +public class EntgraPolicyLoggerImpl implements EntgraLogger { + + private static Log log = null; + + public EntgraPolicyLoggerImpl(Class clazz) { + log = LogFactory.getLog(clazz); + } + + public void info(String message) { + log.info(message); + } + + public void info(String message, Throwable t) { + log.info(message, t); + } + + @Override + public void info(Object o) { + log.info(o); + } + + @Override + public void info(Object o, Throwable throwable) { + log.info(o, throwable); + } + + @Override + public void info(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.info(message); + } + + @Override + public void info(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.info(object); + } + + @Override + public void info(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.info(object, t); + } + + public void debug(String message) { + log.debug(message); + } + + public void debug(String message, Throwable t) { + log.debug(message, t); + } + + @Override + public void debug(Object o) { + log.debug(o); + } + + @Override + public void debug(Object o, Throwable throwable) { + log.debug(o, throwable); + } + + @Override + public void debug(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.debug(message); + } + + @Override + public void debug(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.debug(object); + } + + @Override + public void debug(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.debug(object, t); + } + + public void error(String message) { + log.error(message); + } + + public void error(String message, Throwable t) { + log.error(message, t); + } + + @Override + public void error(Object o) { + log.error(o); + } + + @Override + public void error(Object o, Throwable throwable) { + log.error(o, throwable); + } + + @Override + public void error(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.error(message); + } + + @Override + public void error(String message, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.error(message, t); + } + + @Override + public void error(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.error(object); + } + + @Override + public void error(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.error(object, t); + } + + public void warn(String message) { + log.warn(message); + } + + public void warn(String message, Throwable t) { + log.warn(message, t); + } + + @Override + public void warn(Object o) { + log.warn(o); + } + + @Override + public void warn(Object o, Throwable throwable) { + log.warn(o, throwable); + } + + @Override + public void warn(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.warn(message); + } + + @Override + public void warn(String message, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.warn(message, t); + } + + @Override + public void warn(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.warn(object); + } + + @Override + public void warn(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.warn(object, t); + } + + public void trace(String message) { + log.trace(message); + } + + public void trace(String message, Throwable t) { + log.trace(message, t); + } + + @Override + public void trace(Object o) { + log.trace(o); + } + + @Override + public void trace(Object o, Throwable throwable) { + log.trace(o, throwable); + } + + @Override + public void trace(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.trace(message); + } + + @Override + public void trace(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.trace(object); + } + + @Override + public void trace(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.trace(object, t); + } + + public void fatal(String message) { + log.fatal(message); + } + + public void fatal(String message, Throwable t) { + log.fatal(message, t); + } + + @Override + public void fatal(Object o) { + log.fatal(0); + } + + @Override + public void fatal(Object o, Throwable throwable) { + log.fatal(0, throwable); + } + + @Override + public void fatal(String message, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.fatal(message); + } + + @Override + public void fatal(Object object, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.fatal(object); + } + + @Override + public void fatal(Object object, Throwable t, LogContext logContext) { + PolicyLogContext policyLogContext = (PolicyLogContext) logContext; + MDCContextUtil.populatePolicyMDCContext(policyLogContext); + log.fatal(object, t); + } + + @Override + public boolean isDebugEnabled() { + return log.isDebugEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return log.isErrorEnabled(); + } + + @Override + public boolean isFatalEnabled() { + return log.isFatalEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return log.isInfoEnabled(); + } + + @Override + public boolean isTraceEnabled() { + return log.isTraceEnabled(); + } + + @Override + public boolean isWarnEnabled() { + return log.isWarnEnabled(); + } + + @Override + public void clearLogContext() { + MDC.clear(); + } +} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java index 6a082b013d..fa482605f6 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java @@ -17,7 +17,6 @@ */ package io.entgra.device.mgt.core.notification.logger.impl; - import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.UserLogContext; @@ -26,7 +25,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.MDC; - public class EntgraUserLoggerImpl implements EntgraLogger { private static Log log = null; diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java index 09f903188a..dc046e8eeb 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java @@ -17,8 +17,7 @@ */ package io.entgra.device.mgt.core.notification.logger.util; -import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; -import io.entgra.device.mgt.core.notification.logger.UserLogContext; +import io.entgra.device.mgt.core.notification.logger.*; import org.apache.log4j.MDC; public final class MDCContextUtil { @@ -62,6 +61,105 @@ public final class MDCContextUtil { } } + + public static void populatePolicyMDCContext(final PolicyLogContext mdcContext) { + if (mdcContext.getPolicyName() != null) { + MDC.put("PolicyName", mdcContext.getPolicyName()); + } + if (mdcContext.getPayload() != null) { + MDC.put("Payload", mdcContext.getPayload()); + } + if (mdcContext.getActionTag() != null) { + MDC.put("ActionTag", mdcContext.getActionTag()); + } + if (mdcContext.getUserName() != null) { + MDC.put("UserName", mdcContext.getUserName()); + } + if (mdcContext.getTenantDomain() != null) { + MDC.put("TenantDomain", mdcContext.getTenantDomain()); + } + if (mdcContext.getTenantID() != null) { + MDC.put("TenantId", mdcContext.getTenantID()); + } + } + + public static void populateAppInstallMDCContext(final AppInstallLogContext mdcContext) { + if (mdcContext.getAppId() != null) { + MDC.put("AppId", mdcContext.getAppId()); + } + if (mdcContext.getAppName() != null) { + MDC.put("AppName", mdcContext.getAppName()); + } + if (mdcContext.getAppType() != null) { + MDC.put("AppType", mdcContext.getAppType()); + } + if (mdcContext.getSubType() != null) { + MDC.put("SubType", mdcContext.getSubType()); + } + if (mdcContext.getDevice() != null) { + MDC.put("Device", mdcContext.getDevice()); + } + if (mdcContext.getTenantDomain() != null) { + MDC.put("TenantDomain", mdcContext.getTenantDomain()); + } + if (mdcContext.getTenantId() != null) { + MDC.put("TenantId", mdcContext.getTenantId()); + } + if (mdcContext.getUserName() != null) { + MDC.put("UserName", mdcContext.getUserName()); + } + if (mdcContext.getAction() != null) { + MDC.put("Action", mdcContext.getAction()); + } + } + + public static void populateDeviceConnectivityMDCContext(final DeviceConnectivityLogContext mdcContext) { + if (mdcContext.getDeviceId() != null) { + MDC.put("DeviceId", mdcContext.getDeviceId()); + } + if (mdcContext.getDeviceType() != null) { + MDC.put("DeviceType", mdcContext.getDeviceType()); + } + if (mdcContext.getOperationCode() != null) { + MDC.put("OperationCode", mdcContext.getOperationCode()); + } + if (mdcContext.getTenantDomain() != null) { + MDC.put("TenantDomain", mdcContext.getTenantDomain()); + } + if (mdcContext.getTenantId() != null) { + MDC.put("TenantId", mdcContext.getTenantId()); + } + if (mdcContext.getUserName() != null) { + MDC.put("UserName", mdcContext.getUserName()); + } + if (mdcContext.getActionTag() != null) { + MDC.put("ActionTag", mdcContext.getActionTag()); + } + } + + public static void populateDeviceEnrolmentMDCContext(final DeviceEnrolmentLogContext mdcContext) { + if (mdcContext.getDeviceId() != null) { + MDC.put("DeviceId", mdcContext.getDeviceId()); + } + if (mdcContext.getDeviceType() != null) { + MDC.put("DeviceType", mdcContext.getDeviceType()); + } + if (mdcContext.getOwner() != null) { + MDC.put("Owner", mdcContext.getOwner()); + } + if (mdcContext.getOwnership() != null) { + MDC.put("Ownership", mdcContext.getOwnership()); + } + if (mdcContext.getTenantID() != null) { + MDC.put("TenantId", mdcContext.getTenantID()); + } + if (mdcContext.getTenantDomain() != null) { + MDC.put("TenantDomain", mdcContext.getTenantDomain()); + } + if (mdcContext.getUserName() != null) { + MDC.put("UserName", mdcContext.getUserName()); + } + } } diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java index b07f311ce1..c5d661c567 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java @@ -19,6 +19,9 @@ package io.entgra.device.mgt.core.policy.mgt.core.impl; import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -54,7 +57,8 @@ import java.util.Set; public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { - private static final Log log = LogFactory.getLog(PolicyAdministratorPointImpl.class); + PolicyLogContext.Builder policyLogContextBuilder = new PolicyLogContext.Builder(); + private static final EntgraLogger log = new EntgraPolicyLoggerImpl(PolicyAdministratorPointImpl.class); private PolicyManager policyManager; private ProfileManager profileManager; @@ -135,6 +139,8 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { try { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService(); if (log.isDebugEnabled()) { @@ -168,11 +174,13 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { properties, triggerInfo); taskManager.registerTask(taskInfo); taskManager.scheduleTask(taskInfo.getName()); + log.info("Apply changes to device", policyLogContextBuilder.setActionTag("PUBLISH_CHANGES").setUserName(userName).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).build()); } else { if (!taskManager.isTaskScheduled(taskName)) { TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ, properties, triggerInfo); taskManager.scheduleTask(taskInfo.getName()); + log.info("Apply changes to device", policyLogContextBuilder.setActionTag("PUBLISH_CHANGES").setUserName(userName).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).build()); } else { throw new PolicyManagementException("There is a task already running for policy changes. Please try " + "to apply " + diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 5cc0dc35b8..d0534e28ac 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -18,6 +18,10 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; +import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest; @@ -48,6 +52,7 @@ import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.SQLException; import java.sql.Timestamp; @@ -55,12 +60,13 @@ import java.util.*; public class PolicyManagerImpl implements PolicyManager { + PolicyLogContext.Builder policyLogContextBuilder = new PolicyLogContext.Builder(); private final PolicyDAO policyDAO; private final ProfileDAO profileDAO; private final FeatureDAO featureDAO; private final ProfileManager profileManager; private final PolicyConfiguration policyConfiguration; - private static final Log log = LogFactory.getLog(PolicyManagerImpl.class); + private static final EntgraLogger log = new EntgraPolicyLoggerImpl(PolicyManagerImpl.class); public PolicyManagerImpl() { this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO(); @@ -72,6 +78,9 @@ public class PolicyManagerImpl implements PolicyManager { @Override public Policy addPolicy(Policy policy) throws PolicyManagementException { + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); try { PolicyManagementDAOFactory.beginTransaction(); if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) { @@ -153,11 +162,16 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } + String stringPayload = new Gson().toJson(policy); + log.info("Policy created", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("ADD_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return policy; } @Override public Policy updatePolicy(Policy policy) throws PolicyManagementException { + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); try { // Previous policy needs to be obtained before beginning the transaction Policy previousPolicy = this.getPolicy(policy.getId()); @@ -299,6 +313,8 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } + String stringPayload = new Gson().toJson(policy); + log.info("Policy updated", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("UPDATE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return policy; } @@ -488,6 +504,10 @@ public class PolicyManagerImpl implements PolicyManager { @Override public boolean updatePolicyPriorities(List policies) throws PolicyManagementException { + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); + String stringPayload = new Gson().toJson(policies); boolean bool; try { List existingPolicies; @@ -516,18 +536,24 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } + log.info("Policy priorities updated", policyLogContextBuilder.setPayload(stringPayload).setActionTag("UPDATE_POLICY_PRIORITIES").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return bool; } @Override public boolean deletePolicy(Policy policy) throws PolicyManagementException { try { + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); PolicyManagementDAOFactory.beginTransaction(); policyDAO.deleteAllPolicyRelatedConfigs(policy.getId()); policyDAO.deletePolicy(policy.getId()); featureDAO.deleteFeaturesOfProfile(policy.getProfileId()); profileDAO.deleteProfile(policy.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); + String stringPayload = new Gson().toJson(policy); + log.info("Policy deleted", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("DELETE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return true; } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); @@ -548,6 +574,9 @@ public class PolicyManagerImpl implements PolicyManager { @Override public boolean deletePolicy(int policyId) throws PolicyManagementException { + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); boolean bool; List policies = this.getPolicies(); Policy pol = null; @@ -578,6 +607,8 @@ public class PolicyManagerImpl implements PolicyManager { featureDAO.deleteFeaturesOfProfile(policy.getProfileId()); profileDAO.deleteProfile(policy.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); + String stringPayload = new Gson().toJson(policy); + log.info("Policy deleted", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("DELETE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return bool; } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); @@ -636,6 +667,9 @@ public class PolicyManagerImpl implements PolicyManager { List deviceList = new ArrayList<>(); DeviceManagementProviderService deviceManagementService = PolicyManagementDataHolder .getInstance().getDeviceManagementService(); + String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); for (DeviceIdentifier deviceIdentifier : deviceIdentifierList) { try { Device device = deviceManagementService.getDevice(deviceIdentifier, false); @@ -664,6 +698,9 @@ public class PolicyManagerImpl implements PolicyManager { } policy.setDevices(deviceList); } + String policyPayload = new Gson().toJson(policy); + String deviceListPayload = new Gson().toJson(deviceList); + log.info("Policy added to devices", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(" Policy: " + policyPayload + " DeviceList: " + deviceListPayload).setActionTag("ADD_POLICY_TO_DEVICE").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); throw new PolicyManagementException("Error occurred while adding the policy (" From ce4276c93a34870f67882e9cc415d333a6b7696a Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Tue, 4 Apr 2023 03:01:09 +0530 Subject: [PATCH 071/343] pom.xml updated by pull --- .../org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index ce7fb6b507..e8baa01f8b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -47,7 +47,7 @@ testng - org.wso2.tomcat + org. wso2.tomcat tomcat From 88356c57aa962bb86a0ed10a934bb670eac1e4c8 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Tue, 4 Apr 2023 13:52:03 +0530 Subject: [PATCH 072/343] Add hierarchical grouping feature --- .../service/api/GroupManagementService.java | 87 ++++++++++ .../admin/GroupManagementAdminService.java | 85 +++++++++- .../impl/GroupManagementServiceImpl.java | 63 +++++++ .../GroupManagementAdminServiceImpl.java | 41 +++++ .../group/mgt/DeviceGroupRoleWrapper.java | 155 ++++++++++++++++++ .../core/device/mgt/core/dao/GroupDAO.java | 30 ++++ .../core/dao/impl/AbstractGroupDAOImpl.java | 100 +++++++++-- .../impl/group/PostgreSQLGroupDAOImpl.java | 42 ++++- .../core/dao/util/GroupManagementDAOUtil.java | 1 + .../GroupManagementProviderService.java | 11 ++ .../GroupManagementProviderServiceImpl.java | 84 ++++++++++ .../src/test/resources/sql/h2.sql | 1 + .../pom.xml | 2 +- .../src/test/resources/sql/CreateH2TestDB.sql | 1 + .../src/main/resources/dbscripts/cdm/h2.sql | 1 + .../main/resources/dbscripts/cdm/mssql.sql | 1 + .../main/resources/dbscripts/cdm/mysql.sql | 1 + .../main/resources/dbscripts/cdm/oracle.sql | 1 + .../resources/dbscripts/cdm/postgresql.sql | 1 + 19 files changed, 691 insertions(+), 17 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java index cfe12bc3f8..be792d22c1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java @@ -26,6 +26,13 @@ import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.swagger.annotations.*; import org.apache.axis2.transport.http.HTTPConstants; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import javax.validation.Valid; import javax.ws.rs.*; @@ -159,6 +166,13 @@ import java.util.List; key = "perm:groups:devices-types", roles = {"Internal/devicemgt-user"}, permissions = {"/device-mgt/groups/devices/types"} + ), + @Scope( + name = "View whether the groups has relevant device types", + description = "View whether the groups has relevant device types", + key = "perm:groups:add", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/groups/device-types"} ) } ) @@ -1206,4 +1220,77 @@ public interface GroupManagementService { required = true) List identifiers); + + @POST + @Path("/roles/share") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_POST, + value = "Consolidated API for Creating a Device Group, Adding Devices, and Sharing", + notes = "This API can be used to create a new device group, add devices to the group, and share the group with user roles.", + tags = "Device Group Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:add") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 201, + message = "Created. \n Device group has successfully been created.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The URL of the created group."), + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body."), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests.") + } + ), + @ApiResponse( + code = 303, + message = "See Other. \n Source can be retrieved from the URL specified at the Location " + + "header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 401, + message = "Unauthorized. \n Current logged in user is not authorized to perform the operation.", + response = ErrorResponse.class), + @ApiResponse( + code = 404, + message = "Group not found.", + response = ErrorResponse.class), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while creating the group or adding devices or sharing the group.", + response = ErrorResponse.class) + }) + Response createGroupWithRoles(@ApiParam( + name = "group", + value = "Define the group object with data.", + required = true) + @Valid DeviceGroupRoleWrapper group + ); + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java index 393389340f..eb5f791ab6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java @@ -27,8 +27,16 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.swagger.annotations.*; import org.apache.axis2.transport.http.HTTPConstants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import javax.validation.Valid; -import javax.ws.rs.*; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -358,4 +366,79 @@ public interface GroupManagementAdminService { required = true) @Valid DeviceGroup group); + + + @POST + @Path("/roles/share") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_POST, + value = "Consolidated API for Creating a Device Group, Adding Devices, and Sharing", + notes = "This API can be used to create a new device group, add devices to the group, and share the group with user roles.", + tags = "Device Group Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:add") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 201, + message = "Created. \n Device group has successfully been created.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The URL of the created group."), + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body."), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests.") + } + ), + @ApiResponse( + code = 303, + message = "See Other. \n Source can be retrieved from the URL specified at the Location " + + "header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 401, + message = "Unauthorized. \n Current logged in user is not authorized to perform the operation.", + response = ErrorResponse.class), + @ApiResponse( + code = 404, + message = "Group not found.", + response = ErrorResponse.class), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while creating the group or adding devices or sharing the group.", + response = ErrorResponse.class) + }) + Response createGroupWithRoles(@ApiParam( + name = "group", + value = "Define the group object with data.", + required = true) + @Valid DeviceGroupRoleWrapper group + + ); + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index f0122835e1..b7e9ba8271 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -18,6 +18,27 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.CarbonConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; @@ -39,6 +60,14 @@ import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.ws.rs.*; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.transaction.UserTransaction; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; @@ -416,4 +445,38 @@ public class GroupManagementServiceImpl implements GroupManagementService { } } + @POST + @Path("/roles/share") + @Override + public Response createGroupWithRoles(DeviceGroupRoleWrapper groups) { + String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + if (groups == null) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + groups.setOwner(owner); + groups.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); + try { + DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(groups, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); + DeviceGroup group = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroup(groups.getName(), owner.isEmpty()); + if (group != null) { + DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), groups.getUserRoles()); + return Response.status(Response.Status.CREATED).entity(group.getGroupId()).build(); + } else { + String msg = "Error occurred while retrieving newly created group."; + log.error(msg); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } catch (GroupManagementException e) { + String msg = "Error occurred while adding new group."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (GroupAlreadyExistException e) { + String msg = "Group already exists with name : " + groups.getName() + "."; + log.warn(msg); + return Response.status(Response.Status.CONFLICT).entity(msg).build(); + } catch (RoleDoesNotExistException e) { + return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + } + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 5f6d8a7bae..3ff5bcdb48 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -29,9 +29,25 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistEx import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupManagementAdminService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; @@ -144,4 +160,29 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ return Response.status(Response.Status.CONFLICT).entity(msg).build(); } } + @POST + @Path("/roles/share") + @Override + public Response createGroupWithRoles(DeviceGroupRoleWrapper group) { + String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + if (group == null) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + group.setOwner(owner); + group.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); + try { + DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); + DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), group.getUserRoles()); + return Response.status(Response.Status.CREATED).build(); + } catch (GroupManagementException e) { + String msg = "Error occurred while adding new group."; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (GroupAlreadyExistException e) { + String msg = "Group already exists with name : " + group.getName() + "."; + return Response.status(Response.Status.CONFLICT).entity(msg).build(); + } catch (RoleDoesNotExistException e) { + return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + } + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java new file mode 100644 index 0000000000..132730e915 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2018 - 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.device.mgt.common.group.mgt; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiParam; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * Holds Device Group details and expose to external access + */ +@ApiModel(value = "DeviceGroupRoleWrapper", description = "This class carries all information related to a managed device group.") +public class DeviceGroupRoleWrapper implements Serializable { + + private static final long serialVersionUID = 1998121711L; + + @ApiModelProperty(name = "id", value = "ID of the device group in the device group information database.") + private int id; + + @ApiModelProperty(name = "description", value = "The device group description that can be set on the device group by the user.", + required = true) + private String description; + + @ApiModelProperty(name = "name", value = "The device group name that can be set on the device group by the user.", + required = true) + private String name; + + private String owner; + + @ApiModelProperty(name = "status", value = "The status of group that needs updating/retrieval.") + private String status; + + @ApiModelProperty(name = "parentGroupId", value = "Group ID of parent group") + private int parentGroupId; + + @ApiModelProperty(name = "parentPath", value = "Path of parent group") + private String parentPath; + + @ApiModelProperty(name = "childrenGroups", value = "Children groups") + private List childrenGroups; + + @ApiModelProperty(name = "userRoles", value = "User roles") + private List userRoles; + +// @ApiModelProperty(name = "DeviceGroupRoleWrapper", value = "Device group role wrapper") +// private List DeviceGroupRoleWrapper; + + public DeviceGroupRoleWrapper() {} + + public DeviceGroupRoleWrapper(String name) { + this.name = name; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + private Map groupProperties; + + public int getGroupId() { + return id; + } + + public void setGroupId(int id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public Map getGroupProperties() { + return groupProperties; + } + + public void setGroupProperties(Map groupProperties) { + this.groupProperties = groupProperties; + } + + public int getParentGroupId() { + return parentGroupId; + } + + public void setParentGroupId(int parentGroupId) { + this.parentGroupId = parentGroupId; + } + + public String getParentPath() { + return parentPath; + } + + public void setParentPath(String parentPath) { + this.parentPath = parentPath; + } + + public List getChildrenGroups() { + return childrenGroups; + } + + public void setChildrenGroups(List childrenGroups) { + this.childrenGroups = childrenGroups; + } + + public List getUserRoles() { + return userRoles; + } + + public void setUserRoles(List userRoles) { + this.userRoles = userRoles; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 16ac6f62be..8ee4b7d869 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -22,6 +22,7 @@ import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import java.util.List; import java.util.Map; @@ -40,6 +41,21 @@ public interface GroupDAO { */ int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException; + + /** + * Add properties for device group. + * Note that groupId parameter is considered seperately due to the groupId parameter passed with + * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. + * + * @param groups to be added. + * @param tenantId of the group. + * @return sql execution result. + * @throws GroupManagementDAOException + */ + int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException; + + + /** * Add properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with @@ -50,8 +66,22 @@ public interface GroupDAO { * @return sql execution result. * @throws GroupManagementDAOException */ + boolean addGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException; + /** + * Update properties for device group. + * Note that groupId parameter is considered seperately due to the groupId parameter passed with + * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. + * + * @param groups to be updated. + * @param tenantId of the group. + * @return sql execution result. + * @throws GroupManagementDAOException + */ + + boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) throws GroupManagementDAOException; + /** * Update properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 803526e593..db38b8eb90 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; @@ -49,7 +50,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "WHERE TENANT_ID = ?"; if (StringUtils.isNotBlank(request.getGroupName())) { sql += " AND GROUP_NAME LIKE ?"; @@ -111,7 +112,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP WHERE TENANT_ID = ?"; + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE TENANT_ID = ?"; if (StringUtils.isNotBlank(request.getGroupName())) { sql += " AND GROUP_NAME LIKE ?"; } @@ -175,11 +176,11 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { Connection conn = GroupManagementDAOFactory.getConnection(); String sql; if (deviceGroup.getStatus() == null || deviceGroup.getStatus().isEmpty()) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " - + "VALUES (?, ?, ?, ?, ?)"; - } else { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " + "VALUES (?, ?, ?, ?, ?, ?)"; + } else { + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID, STATUS) " + + "VALUES (?, ?, ?, ?, ?, ?, ?)"; hasStatus = true; } stmt = conn.prepareStatement(sql, new String[]{"ID"}); @@ -188,8 +189,9 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(3, deviceGroup.getOwner()); stmt.setInt(4, tenantId); stmt.setString(5, deviceGroup.getParentPath()); + stmt.setInt(6, deviceGroup.getParentGroupId()); if (hasStatus) { - stmt.setString(6, deviceGroup.getStatus()); + stmt.setString(7, deviceGroup.getStatus()); } stmt.executeUpdate(); @@ -206,6 +208,48 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } + public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs; + int groupId = -1; + boolean hasStatus = false; + try { + Connection conn = GroupManagementDAOFactory.getConnection(); + String sql; + if (groups.getStatus() == null || groups.getStatus().isEmpty()) { + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " + + "VALUES (?, ?, ?, ?, ?, ?)"; + } else { + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID, STATUS) " + + "VALUES (?, ?, ?, ?, ?, ?, ?)"; + hasStatus = true; + } + stmt = conn.prepareStatement(sql, new String[]{"ID"}); + stmt.setString(1, groups.getDescription()); + stmt.setString(2, groups.getName()); + stmt.setString(3, groups.getOwner()); + stmt.setInt(4, tenantId); + stmt.setString(5, groups.getParentPath()); + stmt.setInt(6, groups.getParentGroupId()); + if (hasStatus) { + stmt.setString(7, groups.getStatus()); + } + + + stmt.executeUpdate(); + rs = stmt.getGeneratedKeys(); + if (rs.next()) { + groupId = rs.getInt(1); + } + return groupId; + } catch (SQLException e) { + throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" + + groups.getName() + "'", e); + } finally { + GroupManagementDAOUtil.cleanupResources(stmt, null); + } + } + public boolean addGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException { boolean status; @@ -234,6 +278,34 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { return status; } + public boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) + throws GroupManagementDAOException { + boolean status; + PreparedStatement stmt = null; + try { + Connection conn = GroupManagementDAOFactory.getConnection(); + stmt = conn.prepareStatement( + "INSERT INTO GROUP_PROPERTIES(GROUP_ID, PROPERTY_NAME, " + + "PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?)"); + for (Map.Entry entry : groups.getGroupProperties().entrySet()) { + stmt.setInt(1, groupId); + stmt.setString(2, entry.getKey()); + stmt.setString(3, entry.getValue()); + stmt.setInt(4, tenantId); + stmt.addBatch(); + } + stmt.executeBatch(); + status = true; + } catch (SQLException e) { + String msg = "Error occurred while adding properties for group '" + + groups.getName() + "' values : " + groups.getGroupProperties(); + throw new GroupManagementDAOException(msg, e); + } finally { + GroupManagementDAOUtil.cleanupResources(stmt, null); + } + return status; + } + public boolean updateGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException { boolean status; @@ -491,7 +563,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { ResultSet resultSet = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP WHERE ID = ? " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE ID = ? " + "AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, groupId); @@ -514,7 +586,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { public List getChildrenGroups(String parentPath, int tenantId) throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "WHERE PARENT_PATH LIKE ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, parentPath + "%"); @@ -539,7 +611,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { public List getRootGroups(int tenantId) throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "WHERE PARENT_PATH LIKE ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, "/"); @@ -567,7 +639,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupBuilders = new ArrayList<>(); try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT G.ID, G.GROUP_NAME, G.DESCRIPTION, G.OWNER, G.STATUS, G.PARENT_PATH FROM DM_GROUP G " + + String sql = "SELECT G.ID, G.GROUP_NAME, G.DESCRIPTION, G.OWNER, G.STATUS, G.PARENT_PATH, G.PARENT_GROUP_ID FROM DM_GROUP G " + "INNER JOIN DM_DEVICE_GROUP_MAP GM ON G.ID = GM.GROUP_ID " + "WHERE GM.DEVICE_ID = ? AND GM.TENANT_ID = ?"; stmt = conn.prepareStatement(sql); @@ -705,7 +777,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = - "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "WHERE LOWER(GROUP_NAME) = LOWER(?) AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, groupName); @@ -876,7 +948,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupList = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP g, " + + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID P FROM DM_GROUP g, " + "(SELECT GROUP_ID FROM DM_ROLE_GROUP_MAP WHERE ROLE IN ("; int index = 0; @@ -990,7 +1062,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupList = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "WHERE OWNER = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, username); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java index f2aeaed327..eec480abd7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.group; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; @@ -49,7 +50,7 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { Connection conn = GroupManagementDAOFactory.getConnection(); String sql; if(StringUtils.isEmpty(deviceGroup.getStatus())) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " + "VALUES (?, ?, ?, ?) RETURNING ID"; } else { sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + @@ -79,6 +80,45 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { } } + public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { + PreparedStatement stmt = null; + ResultSet rs; + int groupId = -1; + boolean hasStatus = false; + try { + Connection conn = GroupManagementDAOFactory.getConnection(); + String sql; + if(StringUtils.isEmpty(groups.getStatus())) { + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + + "VALUES (?, ?, ?, ?) RETURNING ID"; + } else { + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + + "VALUES (?, ?, ?, ?, ?) RETURNING ID"; + hasStatus = true; + } + stmt = conn.prepareStatement(sql); + stmt.setString(1, groups.getDescription()); + stmt.setString(2, groups.getName()); + stmt.setString(3, groups.getOwner()); + stmt.setInt(4, tenantId); + stmt.setString(5, groups.getParentPath()); + if(hasStatus) { + stmt.setString(6, groups.getStatus()); + } + stmt.execute(); + rs = stmt.getGeneratedKeys(); + if (rs.next()) { + groupId = rs.getInt(1); + } + return groupId; + } catch (SQLException e) { + throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" + + groups.getName() + "'", e); + } finally { + GroupManagementDAOUtil.cleanupResources(stmt, null); + } + } + @Override public List getDevices(int groupId, int startIndex, int rowCount, int tenantId) throws GroupManagementDAOException { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java index acf8d4c614..42307e6b74 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java @@ -87,6 +87,7 @@ public final class GroupManagementDAOUtil { group.setOwner(resultSet.getString("OWNER")); group.setStatus(resultSet.getString("STATUS")); group.setParentPath(resultSet.getString("PARENT_PATH")); + group.setParentGroupId(resultSet.getInt("PARENT_GROUP_ID")); return group; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index 1bae5b30ce..729c9f0abe 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -43,6 +43,17 @@ public interface GroupManagementProviderService { void createGroup(DeviceGroup deviceGroup, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException; + /** + * Add new device group and create default role with default permissions. + * + * @param groups to add + * @param defaultRole of the deviceGroup + * @param defaultPermissions of the default role + * @throws GroupManagementException + */ + void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, + String[] defaultPermissions )throws GroupManagementException, GroupAlreadyExistException, RoleDoesNotExistException; + /** * Update existing device group. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index c605a8ebe7..2cc0be6640 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -19,6 +19,23 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import io.entgra.device.mgt.core.device.mgt.common.*; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.core.dao.GroupDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; @@ -41,6 +58,11 @@ import org.wso2.carbon.user.api.UserStoreManager; import java.sql.SQLException; import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; @@ -125,6 +147,68 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } + + public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) + throws GroupManagementException, GroupAlreadyExistException { + if (groups == null) { + String msg = "Received incomplete data for createGroup"; + log.error(msg); + throw new GroupManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Creating group '" + groups.getName() + "'"); + } + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + GroupManagementDAOFactory.beginTransaction(); + DeviceGroup existingGroup = this.groupDAO.getGroup(groups.getName(), tenantId); + if (existingGroup == null) { + if (groups.getParentGroupId() == 0) { + groups.setParentPath(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); + } else { + DeviceGroup immediateParentGroup = groupDAO.getGroup(groups.getParentGroupId(), tenantId); + if (immediateParentGroup == null) { + String msg = "Parent group with group ID '" + groups.getParentGroupId() + + "' does not exist. Hence creating of group '" + groups.getName() + + "' was not success"; + log.error(msg); + throw new GroupManagementException(msg); + } + String parentPath = DeviceManagerUtil.createParentPath(immediateParentGroup); + groups.setParentPath(parentPath); + } + int updatedGroupID = this.groupDAO.addGroupWithRoles(groups, tenantId); + if (groups.getGroupProperties() != null && groups.getGroupProperties().size() > 0) { + this.groupDAO.addGroupPropertiesWithRoles(groups, updatedGroupID, tenantId); + } + GroupManagementDAOFactory.commitTransaction(); + } else { + throw new GroupAlreadyExistException("Group exist with name " + groups.getName()); + } + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while adding deviceGroup '" + groups.getName() + "' to database."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (GroupAlreadyExistException ex) { + throw ex; + } catch (Exception e) { + String msg = "Error occurred in creating group '" + groups.getName() + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + + if (log.isDebugEnabled()) { + log.debug("DeviceGroup added: " + groups.getName()); + } + } + /** * {@inheritDoc} */ diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index d22d8f312f..4f83fa5b5e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -16,6 +16,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(45) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index e8baa01f8b..ce7fb6b507 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -47,7 +47,7 @@ testng - org. wso2.tomcat + org.wso2.tomcat tomcat diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index 6c906a5c49..e3ed0cd6ec 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -66,6 +66,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); DROP TABLE IF EXISTS DM_ROLE_GROUP_MAP; diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index df3277920d..15ffa69605 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -25,6 +25,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index c162d41e06..5b6b3b93f1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -41,6 +41,7 @@ IF NOT EXISTS(SELECT * OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 6dcc7bec44..86da197b12 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -29,6 +29,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ) ENGINE = InnoDB; diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index a6f87c9cb6..6cc55f7e74 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -52,6 +52,7 @@ CREATE TABLE DM_GROUP ( OWNER VARCHAR2(255) DEFAULT NULL, PARENT_PATH VARCHAR2(255) DEFAULT NULL, TENANT_ID NUMBER(10) DEFAULT 0, + PARENT_GROUP_ID NUMBER(10) DEFAULT 0, CONSTRAINT PK_DM_GROUP PRIMARY KEY (ID) ) / diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 8c601111b7..b1fc128cf9 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -23,6 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(45) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, + PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ) ; From 32e5456f215348b6ebec8136fb3e622ffa34011f Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Wed, 14 Jun 2023 17:16:38 +0530 Subject: [PATCH 073/343] fixes line issues --- .../group/mgt/DeviceGroupRoleWrapper.java | 20 ++-- .../core/device/mgt/core/dao/GroupDAO.java | 92 +++++++++---------- 2 files changed, 52 insertions(+), 60 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java index 132730e915..768fe55524 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java @@ -37,12 +37,10 @@ public class DeviceGroupRoleWrapper implements Serializable { @ApiModelProperty(name = "id", value = "ID of the device group in the device group information database.") private int id; - @ApiModelProperty(name = "description", value = "The device group description that can be set on the device group by the user.", - required = true) + @ApiModelProperty(name = "description", value = "The device group description that can be set on the device group by the user.", required = true) private String description; - @ApiModelProperty(name = "name", value = "The device group name that can be set on the device group by the user.", - required = true) + @ApiModelProperty(name = "name", value = "The device group name that can be set on the device group by the user.", required = true) private String name; private String owner; @@ -62,10 +60,8 @@ public class DeviceGroupRoleWrapper implements Serializable { @ApiModelProperty(name = "userRoles", value = "User roles") private List userRoles; -// @ApiModelProperty(name = "DeviceGroupRoleWrapper", value = "Device group role wrapper") -// private List DeviceGroupRoleWrapper; - - public DeviceGroupRoleWrapper() {} + public DeviceGroupRoleWrapper() { + } public DeviceGroupRoleWrapper(String name) { this.name = name; @@ -79,7 +75,7 @@ public class DeviceGroupRoleWrapper implements Serializable { this.status = status; } - private Map groupProperties; + private Map groupProperties; public int getGroupId() { return id; @@ -113,11 +109,11 @@ public class DeviceGroupRoleWrapper implements Serializable { this.owner = owner; } - public Map getGroupProperties() { + public Map getGroupProperties() { return groupProperties; } - public void setGroupProperties(Map groupProperties) { + public void setGroupProperties(Map groupProperties) { this.groupProperties = groupProperties; } @@ -152,4 +148,4 @@ public class DeviceGroupRoleWrapper implements Serializable { public void setUserRoles(List userRoles) { this.userRoles = userRoles; } -} +} \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 8ee4b7d869..6072d52ee7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -31,6 +31,7 @@ import java.util.Map; * This interface represents the key operations associated with persisting group related information. */ public interface GroupDAO { + /** * Add new Device Group. * @@ -41,21 +42,18 @@ public interface GroupDAO { */ int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException; - /** * Add properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. * - * @param groups to be added. - * @param tenantId of the group. + * @param groups to be added. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException; - - /** * Add properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with @@ -66,7 +64,6 @@ public interface GroupDAO { * @return sql execution result. * @throws GroupManagementDAOException */ - boolean addGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException; /** @@ -74,12 +71,11 @@ public interface GroupDAO { * Note that groupId parameter is considered seperately due to the groupId parameter passed with * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. * - * @param groups to be updated. - * @param tenantId of the group. + * @param groups to be updated. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ - boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) throws GroupManagementDAOException; /** @@ -97,8 +93,8 @@ public interface GroupDAO { /** * Remove properties for device group. * - * @param groupId to be deleted. - * @param tenantId of the group. + * @param groupId to be deleted. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void deleteAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; @@ -115,19 +111,19 @@ public interface GroupDAO { /** * Retrives all properties stored against a group. * - * @param groupId to be deleted. - * @param tenantId of the group. + * @param groupId to be deleted. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ - Map getAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; + Map getAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; /** * Update an existing Device Group. * * @param deviceGroup group to update. - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void updateGroup(DeviceGroup deviceGroup, int groupId, int tenantId) @@ -137,7 +133,7 @@ public interface GroupDAO { * Update existing Device Groups. * * @param deviceGroups groups to update. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during updating of groups */ void updateGroups(List deviceGroups, int tenantId) throws GroupManagementDAOException; @@ -145,8 +141,8 @@ public interface GroupDAO { /** * Delete an existing Device Group. * - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void deleteGroup(int groupId, int tenantId) throws GroupManagementDAOException; @@ -155,7 +151,7 @@ public interface GroupDAO { * Delete mappings of Device Groups. * * @param groupIds of Device Groups. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during deletion of mappings of groups */ void deleteGroupsMapping(List groupIds, int tenantId) throws GroupManagementDAOException; @@ -164,7 +160,7 @@ public interface GroupDAO { * Delete existing Device Groups. * * @param groupIds of Device Groups. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during deletion of groups */ void deleteGroups(List groupIds, int tenantId) throws GroupManagementDAOException; @@ -172,8 +168,8 @@ public interface GroupDAO { /** * Get device group by id. * - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @return Device Group in tenant with specified name. * @throws GroupManagementDAOException */ @@ -183,7 +179,7 @@ public interface GroupDAO { * Get children groups by parent path. * * @param parentPath of parent group. - * @param tenantId of the group. + * @param tenantId of the group. * @return {@link List} list of children device groups * @throws GroupManagementDAOException on error during retrieval of children groups */ @@ -192,7 +188,7 @@ public interface GroupDAO { /** * Get root groups. * - * @param tenantId of the group. + * @param tenantId of the group. * @return {@link List} list of root device groups * @throws GroupManagementDAOException on error during retrieval of root groups */ @@ -200,6 +196,7 @@ public interface GroupDAO { /** * Get the groups of device with device id provided + * * @param deviceId * @return groups which has the device. * @throws GroupManagementDAOException @@ -210,7 +207,7 @@ public interface GroupDAO { * Get paginated list of Device Groups in tenant. * * @param paginationRequest to filter results. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return List of all Device Groups in tenant. * @throws GroupManagementDAOException */ @@ -250,7 +247,7 @@ public interface GroupDAO { * Get paginated count of Device Groups in tenant. * * @param paginationRequest to filter results. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return List of all Device Groups in tenant. * @throws GroupManagementDAOException */ @@ -260,7 +257,7 @@ public interface GroupDAO { * Check group already existed with given name. * * @param groupName of the Device Group. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return existence of group with name * @throws GroupManagementDAOException */ @@ -269,7 +266,7 @@ public interface GroupDAO { /** * Add device to a given Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -279,7 +276,7 @@ public interface GroupDAO { /** * Remove device from the Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -289,7 +286,7 @@ public interface GroupDAO { /** * Check device is belonging to a Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -300,7 +297,7 @@ public interface GroupDAO { /** * Get count of devices in a Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param tenantId of user's tenant. * @return device count. * @throws GroupManagementDAOException @@ -310,10 +307,10 @@ public interface GroupDAO { /** * Get paginated result of devices of a given tenant and device group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param startIndex for pagination. - * @param rowCount for pagination. - * @param tenantId of user's tenant. + * @param rowCount for pagination. + * @param tenantId of user's tenant. * @return list of device in group * @throws GroupManagementDAOException */ @@ -323,9 +320,9 @@ public interface GroupDAO { /** * Get All the devices that are in one of the given device status and belongs to given group * - * @param groupName Group name + * @param groupName Group name * @param deviceStatuses Device Statuses - * @param tenantId Tenant Id + * @param tenantId Tenant Id * @return List of devices * @throws GroupManagementDAOException if error occurred while retreving list of devices that are in one of the * given device status and belongs to the given group @@ -388,8 +385,8 @@ public interface GroupDAO { /** * Get count of all device groups which shared with a user role. * - * @param roles of the group. - * @param tenantId of user's tenant. + * @param roles of the group. + * @param tenantId of user's tenant. * @param parentPath of the group. * @return count of device groups. * @throws GroupManagementDAOException @@ -419,27 +416,26 @@ public interface GroupDAO { /** * Get count of device groups which owned by user. * - * @param username of the owner. - * @param tenantId of user's tenant. + * @param username of the owner. + * @param tenantId of user's tenant. * @param parentPath of the group. * @return count of device groups. * @throws GroupManagementDAOException */ int getOwnGroupsCount(String username, int tenantId, String parentPath) throws GroupManagementDAOException; - /** - * Get device Ids of devices which are assigned to groups. + components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java * Get device Ids of devices which are assigned to groups. * * @param paginationRequest Request object with offset and limit. - * @param groupNames default group names that should be omitted when checking the device - * whether they have been assigned to groups - * @throws GroupManagementDAOException Might occur while retrieving information of group - * unassigned devices + * @param groupNames default group names that should be omitted when checking the device + * whether they have been assigned to groups * @return details of devices that are unassigned to groups. + * @throws GroupManagementDAOException Might occur while retrieving information of group + * unassigned devices */ List getGroupUnassignedDevices(PaginationRequest paginationRequest, List groupNames) throws GroupManagementDAOException; -} +} \ No newline at end of file From d842fc4085ad0ba335cb907b693c18489e5dc6c0 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Wed, 14 Jun 2023 17:45:27 +0530 Subject: [PATCH 074/343] remove unnecessary imports, fixes line issues --- .../mgt/core/service/GroupManagementProviderService.java | 5 ++--- .../core/service/GroupManagementProviderServiceImpl.java | 8 ++------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index 729c9f0abe..ab4e7aa926 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -46,13 +46,12 @@ public interface GroupManagementProviderService { /** * Add new device group and create default role with default permissions. * - * @param groups to add + * @param groups to add * @param defaultRole of the deviceGroup * @param defaultPermissions of the default role * @throws GroupManagementException */ - void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, - String[] defaultPermissions )throws GroupManagementException, GroupAlreadyExistException, RoleDoesNotExistException; + void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException, RoleDoesNotExistException; /** * Update existing device group. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 2cc0be6640..44dea24fe4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -147,9 +147,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - - public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) - throws GroupManagementException, GroupAlreadyExistException { + public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException { if (groups == null) { String msg = "Received incomplete data for createGroup"; log.error(msg); @@ -168,9 +166,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } else { DeviceGroup immediateParentGroup = groupDAO.getGroup(groups.getParentGroupId(), tenantId); if (immediateParentGroup == null) { - String msg = "Parent group with group ID '" + groups.getParentGroupId() - + "' does not exist. Hence creating of group '" + groups.getName() - + "' was not success"; + String msg = "Parent group with group ID '" + groups.getParentGroupId() + "' does not exist. Hence creating of group '" + groups.getName() + "' was not success"; log.error(msg); throw new GroupManagementException(msg); } From 13545f1c7c1ef13d5d48195c1bb5f4b53cd35a44 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Wed, 14 Jun 2023 18:38:11 +0530 Subject: [PATCH 075/343] remove unnecessary code lines --- .../core/device/mgt/core/dao/GroupDAO.java | 85 +++++++++---------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 6072d52ee7..75a6979410 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -31,7 +31,6 @@ import java.util.Map; * This interface represents the key operations associated with persisting group related information. */ public interface GroupDAO { - /** * Add new Device Group. * @@ -47,8 +46,8 @@ public interface GroupDAO { * Note that groupId parameter is considered seperately due to the groupId parameter passed with * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. * - * @param groups to be added. - * @param tenantId of the group. + * @param groups to be added. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ @@ -71,8 +70,8 @@ public interface GroupDAO { * Note that groupId parameter is considered seperately due to the groupId parameter passed with * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. * - * @param groups to be updated. - * @param tenantId of the group. + * @param groups to be updated. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ @@ -93,8 +92,8 @@ public interface GroupDAO { /** * Remove properties for device group. * - * @param groupId to be deleted. - * @param tenantId of the group. + * @param groupId to be deleted. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void deleteAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; @@ -111,19 +110,19 @@ public interface GroupDAO { /** * Retrives all properties stored against a group. * - * @param groupId to be deleted. - * @param tenantId of the group. + * @param groupId to be deleted. + * @param tenantId of the group. * @return sql execution result. * @throws GroupManagementDAOException */ - Map getAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; + Map getAllGroupProperties(int groupId, int tenantId) throws GroupManagementDAOException; /** * Update an existing Device Group. * * @param deviceGroup group to update. - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void updateGroup(DeviceGroup deviceGroup, int groupId, int tenantId) @@ -133,7 +132,7 @@ public interface GroupDAO { * Update existing Device Groups. * * @param deviceGroups groups to update. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during updating of groups */ void updateGroups(List deviceGroups, int tenantId) throws GroupManagementDAOException; @@ -141,8 +140,8 @@ public interface GroupDAO { /** * Delete an existing Device Group. * - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @throws GroupManagementDAOException */ void deleteGroup(int groupId, int tenantId) throws GroupManagementDAOException; @@ -151,7 +150,7 @@ public interface GroupDAO { * Delete mappings of Device Groups. * * @param groupIds of Device Groups. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during deletion of mappings of groups */ void deleteGroupsMapping(List groupIds, int tenantId) throws GroupManagementDAOException; @@ -160,7 +159,7 @@ public interface GroupDAO { * Delete existing Device Groups. * * @param groupIds of Device Groups. - * @param tenantId of the group. + * @param tenantId of the group. * @throws GroupManagementDAOException on error during deletion of groups */ void deleteGroups(List groupIds, int tenantId) throws GroupManagementDAOException; @@ -168,8 +167,8 @@ public interface GroupDAO { /** * Get device group by id. * - * @param groupId of Device Group. - * @param tenantId of the group. + * @param groupId of Device Group. + * @param tenantId of the group. * @return Device Group in tenant with specified name. * @throws GroupManagementDAOException */ @@ -179,7 +178,7 @@ public interface GroupDAO { * Get children groups by parent path. * * @param parentPath of parent group. - * @param tenantId of the group. + * @param tenantId of the group. * @return {@link List} list of children device groups * @throws GroupManagementDAOException on error during retrieval of children groups */ @@ -188,7 +187,7 @@ public interface GroupDAO { /** * Get root groups. * - * @param tenantId of the group. + * @param tenantId of the group. * @return {@link List} list of root device groups * @throws GroupManagementDAOException on error during retrieval of root groups */ @@ -196,7 +195,6 @@ public interface GroupDAO { /** * Get the groups of device with device id provided - * * @param deviceId * @return groups which has the device. * @throws GroupManagementDAOException @@ -207,7 +205,7 @@ public interface GroupDAO { * Get paginated list of Device Groups in tenant. * * @param paginationRequest to filter results. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return List of all Device Groups in tenant. * @throws GroupManagementDAOException */ @@ -247,7 +245,7 @@ public interface GroupDAO { * Get paginated count of Device Groups in tenant. * * @param paginationRequest to filter results. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return List of all Device Groups in tenant. * @throws GroupManagementDAOException */ @@ -257,7 +255,7 @@ public interface GroupDAO { * Check group already existed with given name. * * @param groupName of the Device Group. - * @param tenantId of user's tenant. + * @param tenantId of user's tenant. * @return existence of group with name * @throws GroupManagementDAOException */ @@ -266,7 +264,7 @@ public interface GroupDAO { /** * Add device to a given Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -276,7 +274,7 @@ public interface GroupDAO { /** * Remove device from the Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -286,7 +284,7 @@ public interface GroupDAO { /** * Check device is belonging to a Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param deviceId of the device. * @param tenantId of user's tenant. * @throws GroupManagementDAOException @@ -297,7 +295,7 @@ public interface GroupDAO { /** * Get count of devices in a Device Group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param tenantId of user's tenant. * @return device count. * @throws GroupManagementDAOException @@ -307,10 +305,10 @@ public interface GroupDAO { /** * Get paginated result of devices of a given tenant and device group. * - * @param groupId of Device Group. + * @param groupId of Device Group. * @param startIndex for pagination. - * @param rowCount for pagination. - * @param tenantId of user's tenant. + * @param rowCount for pagination. + * @param tenantId of user's tenant. * @return list of device in group * @throws GroupManagementDAOException */ @@ -320,9 +318,9 @@ public interface GroupDAO { /** * Get All the devices that are in one of the given device status and belongs to given group * - * @param groupName Group name + * @param groupName Group name * @param deviceStatuses Device Statuses - * @param tenantId Tenant Id + * @param tenantId Tenant Id * @return List of devices * @throws GroupManagementDAOException if error occurred while retreving list of devices that are in one of the * given device status and belongs to the given group @@ -385,8 +383,8 @@ public interface GroupDAO { /** * Get count of all device groups which shared with a user role. * - * @param roles of the group. - * @param tenantId of user's tenant. + * @param roles of the group. + * @param tenantId of user's tenant. * @param parentPath of the group. * @return count of device groups. * @throws GroupManagementDAOException @@ -416,22 +414,23 @@ public interface GroupDAO { /** * Get count of device groups which owned by user. * - * @param username of the owner. - * @param tenantId of user's tenant. + * @param username of the owner. + * @param tenantId of user's tenant. * @param parentPath of the group. * @return count of device groups. * @throws GroupManagementDAOException */ int getOwnGroupsCount(String username, int tenantId, String parentPath) throws GroupManagementDAOException; + /** - components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java * Get device Ids of devices which are assigned to groups. + * Get device Ids of devices which are assigned to groups. * * @param paginationRequest Request object with offset and limit. - * @param groupNames default group names that should be omitted when checking the device - * whether they have been assigned to groups - * @return details of devices that are unassigned to groups. + * @param groupNames default group names that should be omitted when checking the device + * whether they have been assigned to groups * @throws GroupManagementDAOException Might occur while retrieving information of group - * unassigned devices + * unassigned devices + * @return details of devices that are unassigned to groups. */ List getGroupUnassignedDevices(PaginationRequest paginationRequest, From cd9d127a5e1b1616ac5d0409fe225e0c93114f33 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Thu, 15 Jun 2023 11:15:23 +0530 Subject: [PATCH 076/343] remove unnecessary variable, change error msg --- .../jaxrs/service/impl/GroupManagementServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index b7e9ba8271..262e51eb9f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -449,15 +449,15 @@ public class GroupManagementServiceImpl implements GroupManagementService { @Path("/roles/share") @Override public Response createGroupWithRoles(DeviceGroupRoleWrapper groups) { - String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (groups == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } - groups.setOwner(owner); + groups.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); groups.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); try { DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(groups, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); - DeviceGroup group = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroup(groups.getName(), owner.isEmpty()); + DeviceGroup group = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroup(groups.getName(), + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername().isEmpty()); if (group != null) { DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), groups.getUserRoles()); return Response.status(Response.Status.CREATED).entity(group.getGroupId()).build(); @@ -467,7 +467,7 @@ public class GroupManagementServiceImpl implements GroupManagementService { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } catch (GroupManagementException e) { - String msg = "Error occurred while adding new group."; + String msg = "Error occurred while adding " + groups.getName() + " group"; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupAlreadyExistException e) { From 7d05446a38cd6359aa5802e1f0f3c38888ea30f2 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Thu, 15 Jun 2023 14:29:10 +0530 Subject: [PATCH 077/343] add error log --- .../impl/admin/GroupManagementAdminServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 3ff5bcdb48..cd53637812 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -164,21 +164,22 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ @Path("/roles/share") @Override public Response createGroupWithRoles(DeviceGroupRoleWrapper group) { - String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (group == null) { return Response.status(Response.Status.BAD_REQUEST).build(); } - group.setOwner(owner); + group.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); group.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); try { DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), group.getUserRoles()); return Response.status(Response.Status.CREATED).build(); } catch (GroupManagementException e) { - String msg = "Error occurred while adding new group."; + String msg = "Error occurred while adding " + group.getName() + " group"; + log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupAlreadyExistException e) { String msg = "Group already exists with name : " + group.getName() + "."; + log.warn(msg); return Response.status(Response.Status.CONFLICT).entity(msg).build(); } catch (RoleDoesNotExistException e) { return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); From 4a239887cb717c996b3506ad49c2668adf586ddb Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Fri, 16 Jun 2023 01:58:42 +0530 Subject: [PATCH 078/343] add try with resources --- .../core/dao/impl/AbstractGroupDAOImpl.java | 70 +++++++++---------- .../impl/group/PostgreSQLGroupDAOImpl.java | 46 ++++++------ .../GroupManagementProviderService.java | 7 ++ .../GroupManagementProviderServiceImpl.java | 15 ++-- 4 files changed, 71 insertions(+), 67 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index db38b8eb90..37a10f9c23 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -208,9 +208,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } + @Override public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs; int groupId = -1; boolean hasStatus = false; try { @@ -224,29 +223,29 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { + "VALUES (?, ?, ?, ?, ?, ?, ?)"; hasStatus = true; } - stmt = conn.prepareStatement(sql, new String[]{"ID"}); - stmt.setString(1, groups.getDescription()); - stmt.setString(2, groups.getName()); - stmt.setString(3, groups.getOwner()); - stmt.setInt(4, tenantId); - stmt.setString(5, groups.getParentPath()); - stmt.setInt(6, groups.getParentGroupId()); - if (hasStatus) { - stmt.setString(7, groups.getStatus()); + try (PreparedStatement stmt = conn.prepareStatement(sql, new String[]{"ID"})) { + stmt.setString(1, groups.getDescription()); + stmt.setString(2, groups.getName()); + stmt.setString(3, groups.getOwner()); + stmt.setInt(4, tenantId); + stmt.setString(5, groups.getParentPath()); + stmt.setInt(6, groups.getParentGroupId()); + if (hasStatus) { + stmt.setString(7, groups.getStatus()); + } + stmt.executeUpdate(); + try (ResultSet rs = stmt.getGeneratedKeys();) { + if (rs.next()) { + groupId = rs.getInt(1); + } + return groupId; + } } - - - stmt.executeUpdate(); - rs = stmt.getGeneratedKeys(); - if (rs.next()) { - groupId = rs.getInt(1); - } - return groupId; } catch (SQLException e) { - throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" + - groups.getName() + "'", e); - } finally { - GroupManagementDAOUtil.cleanupResources(stmt, null); + String msg = "Error occurred while adding deviceGroup '" + + groups.getName() + "'"; + log.error(msg); + throw new GroupManagementDAOException(msg, e); } } @@ -281,27 +280,26 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { public boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) throws GroupManagementDAOException { boolean status; - PreparedStatement stmt = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - stmt = conn.prepareStatement( + try (PreparedStatement stmt = conn.prepareStatement( "INSERT INTO GROUP_PROPERTIES(GROUP_ID, PROPERTY_NAME, " + - "PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?)"); - for (Map.Entry entry : groups.getGroupProperties().entrySet()) { - stmt.setInt(1, groupId); - stmt.setString(2, entry.getKey()); - stmt.setString(3, entry.getValue()); - stmt.setInt(4, tenantId); - stmt.addBatch(); + "PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?)")) { + for (Map.Entry entry : groups.getGroupProperties().entrySet()) { + stmt.setInt(1, groupId); + stmt.setString(2, entry.getKey()); + stmt.setString(3, entry.getValue()); + stmt.setInt(4, tenantId); + stmt.addBatch(); + } + stmt.executeBatch(); + status = true; } - stmt.executeBatch(); - status = true; } catch (SQLException e) { String msg = "Error occurred while adding properties for group '" + groups.getName() + "' values : " + groups.getGroupProperties(); + log.error(msg); throw new GroupManagementDAOException(msg, e); - } finally { - GroupManagementDAOUtil.cleanupResources(stmt, null); } return status; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java index eec480abd7..6a786a0bfd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java @@ -19,6 +19,8 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.group; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; @@ -40,6 +42,7 @@ import java.util.List; */ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { + private static final Log log = LogFactory.getLog(PostgreSQLGroupDAOImpl.class); @Override public int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException { PreparedStatement stmt = null; @@ -80,15 +83,14 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { } } + @Override public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs; int groupId = -1; boolean hasStatus = false; try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql; - if(StringUtils.isEmpty(groups.getStatus())) { + if (StringUtils.isEmpty(groups.getStatus())) { sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + "VALUES (?, ?, ?, ?) RETURNING ID"; } else { @@ -96,26 +98,28 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { "VALUES (?, ?, ?, ?, ?) RETURNING ID"; hasStatus = true; } - stmt = conn.prepareStatement(sql); - stmt.setString(1, groups.getDescription()); - stmt.setString(2, groups.getName()); - stmt.setString(3, groups.getOwner()); - stmt.setInt(4, tenantId); - stmt.setString(5, groups.getParentPath()); - if(hasStatus) { - stmt.setString(6, groups.getStatus()); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, groups.getDescription()); + stmt.setString(2, groups.getName()); + stmt.setString(3, groups.getOwner()); + stmt.setInt(4, tenantId); + stmt.setString(5, groups.getParentPath()); + if (hasStatus) { + stmt.setString(6, groups.getStatus()); + } + stmt.execute(); + try (ResultSet rs = stmt.getGeneratedKeys()) { + if (rs.next()) { + groupId = rs.getInt(1); + } + return groupId; + } } - stmt.execute(); - rs = stmt.getGeneratedKeys(); - if (rs.next()) { - groupId = rs.getInt(1); - } - return groupId; } catch (SQLException e) { - throw new GroupManagementDAOException("Error occurred while adding deviceGroup '" + - groups.getName() + "'", e); - } finally { - GroupManagementDAOUtil.cleanupResources(stmt, null); + String msg = "Error occurred while adding deviceGroup '" + + groups.getName() + "'"; + log.error(msg); + throw new GroupManagementDAOException(msg, e); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index ab4e7aa926..b263ea1234 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -24,6 +24,13 @@ import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.*; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; import java.util.List; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 44dea24fe4..2dd39081a3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -49,6 +49,7 @@ import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.netbeans.lib.cvsclient.commandLine.command.status; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -147,7 +148,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException { + public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException { if (groups == null) { String msg = "Received incomplete data for createGroup"; log.error(msg); @@ -179,23 +180,17 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } GroupManagementDAOFactory.commitTransaction(); } else { - throw new GroupAlreadyExistException("Group exist with name " + groups.getName()); + throw new GroupManagementException("Group exist with name " + groups.getName()); } - } catch (GroupManagementDAOException e) { + } catch (GroupManagementDAOException | GroupManagementException e) { GroupManagementDAOFactory.rollbackTransaction(); - String msg = "Error occurred while adding deviceGroup '" + groups.getName() + "' to database."; + String msg = e.getMessage(); log.error(msg, e); throw new GroupManagementException(msg, e); } catch (TransactionManagementException e) { String msg = "Error occurred while initiating transaction."; log.error(msg, e); throw new GroupManagementException(msg, e); - } catch (GroupAlreadyExistException ex) { - throw ex; - } catch (Exception e) { - String msg = "Error occurred in creating group '" + groups.getName() + "'"; - log.error(msg, e); - throw new GroupManagementException(msg, e); } finally { GroupManagementDAOFactory.closeConnection(); } From ae131693774e346f159e8b99ba4a98a16dc632e4 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Fri, 16 Jun 2023 09:48:52 +0530 Subject: [PATCH 079/343] add rollback --- .../mgt/core/service/GroupManagementProviderServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 2dd39081a3..7c8f64768d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -167,6 +167,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } else { DeviceGroup immediateParentGroup = groupDAO.getGroup(groups.getParentGroupId(), tenantId); if (immediateParentGroup == null) { + GroupManagementDAOFactory.rollbackTransaction(); String msg = "Parent group with group ID '" + groups.getParentGroupId() + "' does not exist. Hence creating of group '" + groups.getName() + "' was not success"; log.error(msg); throw new GroupManagementException(msg); @@ -182,7 +183,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } else { throw new GroupManagementException("Group exist with name " + groups.getName()); } - } catch (GroupManagementDAOException | GroupManagementException e) { + } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); String msg = e.getMessage(); log.error(msg, e); From 4c1963a32b9dd9b14b7e1b21f9cf16e9fb8d4178 Mon Sep 17 00:00:00 2001 From: builder Date: Wed, 21 Jun 2023 13:48:19 +0530 Subject: [PATCH 080/343] [maven-release-plugin] prepare release v5.0.26 --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 6 ++---- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 5 ++--- features/operation-template-mgt-plugin-feature/pom.xml | 5 ++--- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 132 files changed, 137 insertions(+), 141 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 59c0b53f0c..838561b6a7 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index a05f1959a3..abce130619 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index e8197e4426..075c39b37c 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 0b495a83a8..a8220d602c 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index abf6339213..2aa9999730 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../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 e647b5f2dc..7fee2e5bb2 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 io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 1732b47585..68e72db692 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 37082c6fc6..757cbfadbc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 7434c58e54..8e1e32e95a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml 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 7d4ef0501d..bcae043d9a 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 io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 2392078c2e..a28e93feb4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 53374f48c6..4588b2c460 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 0f030906b9..b4ff8dc017 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index bee1ec2744..fd85f36d34 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index c9eafdb800..6ee268bcd6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 7134db16fc..e9d33caae3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 512aef9700..9711c6d8dc 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 82a035ace6..57f9f2b74b 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 0691f0648c..518d4c61da 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 35621201eb..755a7dbcc4 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 98c20d369b..9284098a0f 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 7bd5e03b5b..d97bfd8d08 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 16d45fccce..bf9d815d0c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index f984260692..3a17f1cc24 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index a50c455f80..1c73e6e36b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index c357cd7566..1a8656bd8e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 17a7c4b6ff..20904653a9 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index ec115c2905..8d33680a7e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 6291d849a5..97ff50cdbc 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index cab0ec4896..ce27031777 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index c6914f5733..7d28fa77ee 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 09ac87fdb8..75c85b84d7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index d8323a431c..390405ef56 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index fffcfba429..922b19e1b2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 521ff65c5c..3840cd7f58 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index a9814241de..1b8a25de66 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 57ff12e288..06f017db31 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index cb1c9dba67..348fcfff2f 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 9971311788..b61f46b42d 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 819685280b..1ed1fc7ee8 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index fa60f27f1e..a72c50d97e 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index f35ea73b60..ef17a87683 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 216bfb4d71..78584bb5ad 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 324934a4dd..3614aaa0cb 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.26-SNAPSHOT + 5.0.26 io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index cb85a7f88c..a5fe3c705e 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index a4ef16008e..8a50c339ea 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index d83ea2e190..77e08cf802 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 0eff71e8f9..a4a640a299 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 10fa65047d..00c531c249 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 52d3c6c045..de99ae8d4a 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 5e7d63b270..d982303296 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 2daade26a6..5315ea8535 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 8add23b3d8..de517a3697 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 0f4e0f5f5a..9ec655ddde 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 0913807c9c..678ecb939d 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index daf623b335..67c0f7eff9 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 802b4fc403..c94144c21f 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 9ea2215ea7..8b6639a9a4 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index e6c32be204..789defab64 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 456c573204..341eca5abf 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 1d07439a11..a0e6646599 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 5ed3918990..ebeea083b9 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index ce01e21a9c..287ff5b16d 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 2b70f9001d..edfdb7eab8 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 77c2cf12cb..cc85951b7f 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index a2140712f7..da419f1132 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 2e0dd266f5..c272274dc5 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index fceb5e77d1..9e2ccfccfd 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index e91b0ed983..0e7b666ae5 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 6eda7374a9..a6e36e35a8 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index a58b6b40ae..9218d9ce08 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 47912a8465..b046f3bde9 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index f9972e1ef0..da2f37f83c 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index f5f2d2c1f3..8406a3140d 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index e7d57bd4b7..5de76a344c 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 01debfaf07..10387c44a8 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 2087a82870..dff8e55869 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 168b828243..f08e83b047 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../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 73abea954f..e3be4ee404 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index f13b9e3927..68350054e9 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index b0f3a595a5..da47b18dcc 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -17,14 +17,12 @@ ~ under the License. --> - + io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 636cc8c34e..e4f84c6659 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 1a2cb3b77e..093920714d 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 9c37daadae..6ed13d9ce2 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index eaa8ffa5c7..be0ded82eb 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 4877de4bbe..50795abc02 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index 5617820cf5..cec153f56b 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index c21ff6fb19..6caf1a3128 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 3867d0806e..bc9d33470d 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 3acaabfd9d..8d4d88f357 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index ee3a2da42a..a421535337 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 5d58fe1956..2980c90d10 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 6ba482a99f..f82ffa6891 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 89babbcd7a..97815f9369 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 9dacdae6ba..f57f9a299b 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index e37e6fbd26..4d4a4ce0ff 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index f74312e6a3..b5f933fbd7 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 810e45e3b7..31706389f4 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index e02dcb8012..82fb243a6d 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 845e0f69d7..0a3cdfc6bf 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 2a2c6468b1..2b5c4de3bd 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 904012948e..c2729e73ff 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 6455ab6f05..7b7fb9f736 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index cb5841a715..99869dbb9a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 230fa3700f..72be1ce3db 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index e1b4db491a..6020dcde00 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index f551b3e518..cded4f70a4 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 57b1438027..157c01609a 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 3220ebb7da..4277e38122 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 1bfe57fa69..0c6ee1ce8a 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index f4b3d3e41a..d25fa68234 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index f9f8ce9f41..ebb95d9957 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -17,13 +17,12 @@ ~ under the License. --> - + io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index a16c219134..a0b620e134 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -17,13 +17,12 @@ ~ under the License. --> - + io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 7f96d0da93..9a5ef37eaa 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 97a7746320..d3de369a85 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index cf0e00a0b5..3bf3514e5e 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index f37cf1d8f3..13ce5f1747 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 7984cd5521..02d53d0dd7 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index a70cbbc67a..2d6b9ce586 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 001cc0dd34..63421e7713 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index a19947d332..da2cb6e32f 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 73986be63f..dabb999aa0 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index a75c167bfa..4a711fe135 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index ee58261e6c..fc2aa0d8ba 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 5dcab5c654..70b0166a43 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index d9b3cb564c..fc9d04a3d6 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index d60cefe7be..66617d8db4 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 90ba4c04cc..124abdc31f 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 45b132211d..97230de6c0 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index ce0141f915..c4b8dee97b 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.26-SNAPSHOT + 5.0.26 ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 5aaec7c6b5..c507f7b23b 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26-SNAPSHOT + 5.0.26 ../../pom.xml diff --git a/pom.xml b/pom.xml index ec8f446882..d954e1fcdd 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.26-SNAPSHOT + 5.0.26 WSO2 Carbon - Device Management - Parent https://entgra.io WSO2 Connected Device Manager Components @@ -1794,7 +1794,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.26 @@ -1997,7 +1997,7 @@ 1.2.11-wso2v25 - 5.0.26-SNAPSHOT + 5.0.26 4.9.2 From 48801a3b8edf35d97c695b64c01dfb4971921044 Mon Sep 17 00:00:00 2001 From: builder Date: Wed, 21 Jun 2023 13:48:25 +0530 Subject: [PATCH 081/343] [maven-release-plugin] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 132 files changed, 134 insertions(+), 134 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 838561b6a7..c198c72364 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index abce130619..3cbdb071e5 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 075c39b37c..d16b2ad8c9 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index a8220d602c..110c64f553 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 2aa9999730..6482bc57da 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-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 7fee2e5bb2..d2e2ca34c7 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 io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 68e72db692..5dc407ca23 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 757cbfadbc..022d3a8a51 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 8e1e32e95a..9ace7f0c33 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml 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 bcae043d9a..45c9ab231f 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 io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index a28e93feb4..82957d2b0d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 4588b2c460..201515986f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index b4ff8dc017..7e3ef60c38 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index fd85f36d34..2094510334 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 6ee268bcd6..6a8a238623 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index e9d33caae3..f9931aae6c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 9711c6d8dc..2e2e67a22f 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 57f9f2b74b..b67ccf20ef 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 518d4c61da..3a7526f408 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 755a7dbcc4..d24319a34f 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 9284098a0f..7833296e8a 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index d97bfd8d08..d8a79858c6 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index bf9d815d0c..610f4f6cda 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index 3a17f1cc24..da2c459069 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 1c73e6e36b..f238d4d5d4 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 1a8656bd8e..1608581ec7 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 20904653a9..c2899b36e3 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 8d33680a7e..aeaed8655c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 97ff50cdbc..d1c6c2206c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index ce27031777..e18d86ef10 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 7d28fa77ee..1223822167 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 75c85b84d7..27617e89ae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index 390405ef56..bec50d0782 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 922b19e1b2..c00dc59b3b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 3840cd7f58..b97dba2a91 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 1b8a25de66..585aeafeaa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 06f017db31..d0ecba2064 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 348fcfff2f..7e01efb324 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index b61f46b42d..e6848b89c8 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 1ed1fc7ee8..7bf1a8fbdb 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index a72c50d97e..8bf81024df 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index ef17a87683..e5157d6a82 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 78584bb5ad..bc0478f310 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 3614aaa0cb..70ca947ed2 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.26 + 5.0.27-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index a5fe3c705e..c4dfdd014b 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 8a50c339ea..c8af2e9003 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 77e08cf802..94c29533fe 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index a4a640a299..0439397aff 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 00c531c249..eac063769d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index de99ae8d4a..fbfb70849b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index d982303296..cd75cd10c5 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 5315ea8535..0d6b866dea 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index de517a3697..8c1e357da7 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 9ec655ddde..91d04c4c33 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 678ecb939d..26e51edae7 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 67c0f7eff9..06997c8f17 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index c94144c21f..20edac784a 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 8b6639a9a4..f0eb908782 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 789defab64..7c15343e73 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 341eca5abf..d14ddd7d18 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index a0e6646599..b4ba0d60bf 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index ebeea083b9..8163f936a3 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 287ff5b16d..bdc00ce03d 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index edfdb7eab8..6550c0c17b 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index cc85951b7f..06b561b237 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index da419f1132..7c275e0a25 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index c272274dc5..9abdfa3735 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 9e2ccfccfd..60dcfdbe95 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 0e7b666ae5..a23d2d922d 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index a6e36e35a8..18baf3dd9d 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 9218d9ce08..685e75809d 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index b046f3bde9..0faab0c2fa 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index da2f37f83c..44862e66e7 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 8406a3140d..252b96df53 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 5de76a344c..c087fc0b4a 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 10387c44a8..570f87276f 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index dff8e55869..7dd4d6fb94 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index f08e83b047..2ebf097dd7 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-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 e3be4ee404..c0456a9c1c 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index 68350054e9..b157b5afa6 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index da47b18dcc..98ac163d22 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index e4f84c6659..696558150f 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 093920714d..6ed2466109 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 6ed13d9ce2..7e04260393 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index be0ded82eb..2841167689 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 50795abc02..499e95ba46 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index cec153f56b..da7eeda702 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 6caf1a3128..b434483af3 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index bc9d33470d..ad2d1c068c 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 8d4d88f357..366cffe69e 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index a421535337..7a33d7ebef 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 2980c90d10..bd44c707b0 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index f82ffa6891..0798f33b74 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 97815f9369..dfbd7c1aa5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index f57f9a299b..3e3e688d59 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 4d4a4ce0ff..844427fea5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index b5f933fbd7..8648168dca 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 31706389f4..1c2f9f450a 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 82fb243a6d..84e33b2daf 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 0a3cdfc6bf..8f8ec91fba 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 2b5c4de3bd..406388f422 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index c2729e73ff..062cc6df3e 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 7b7fb9f736..9ef814e62f 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 99869dbb9a..80ed932a53 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 72be1ce3db..96c5194c45 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 6020dcde00..096683db82 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index cded4f70a4..a2d4bed8ba 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 157c01609a..13e974fbdb 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 4277e38122..c3e2fafa70 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 0c6ee1ce8a..fd4fb89fd9 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index d25fa68234..34a5aa4ccf 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index ebb95d9957..3eb94e0b04 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index a0b620e134..8351d50946 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 9a5ef37eaa..02b8f172a5 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index d3de369a85..5eaac22ad1 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 3bf3514e5e..30094f7686 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 13ce5f1747..3cccf87ad1 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 02d53d0dd7..3243b26827 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 2d6b9ce586..d7e84d2782 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 63421e7713..002b18f48f 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index da2cb6e32f..8f87de9b1f 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index dabb999aa0..ee105d34b8 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 4a711fe135..53fcfbaee9 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index fc2aa0d8ba..23513d7ed8 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 70b0166a43..b6dd0dcc5c 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index fc9d04a3d6..c7f0a53f58 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 66617d8db4..8350d1b2d2 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 124abdc31f..53903a27e5 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 97230de6c0..a3ead6185d 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index c4b8dee97b..f8aa63d70f 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.26 + 5.0.27-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index c507f7b23b..adbbd92316 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.26 + 5.0.27-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index d954e1fcdd..1a0eab8a0f 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.26 + 5.0.27-SNAPSHOT WSO2 Carbon - Device Management - Parent https://entgra.io WSO2 Connected Device Manager Components @@ -1794,7 +1794,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.26 + HEAD @@ -1997,7 +1997,7 @@ 1.2.11-wso2v25 - 5.0.26 + 5.0.27-SNAPSHOT 4.9.2 From 566942694cd3ade245b81ac8475e16198b6e71ed Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Wed, 21 Jun 2023 23:32:48 +0530 Subject: [PATCH 082/343] Remove apim_reserved_user when fetching users --- .../jaxrs/service/impl/UserManagementServiceImpl.java | 9 +++++++++ .../mgt/core/device/mgt/api/jaxrs/util/Constants.java | 1 + 2 files changed, 10 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java index 5209ace472..286c0a47aa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java @@ -424,6 +424,9 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(users.size()); BasicUserInfo user; for (String username : users) { + if (Constants.APIM_RESERVED_USER.equals(username)) { + continue; + } user = getBasicUserInfo(username); userList.add(user); } @@ -484,6 +487,9 @@ public class UserManagementServiceImpl implements UserManagementService { if (StringUtils.isNotEmpty(username)) { commonUsers = getUserList(null, username); } + if (commonUsers != null) { + commonUsers.remove(Constants.APIM_RESERVED_USER); + } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(firstName)) { tempList = getUserList(Constants.USER_CLAIM_FIRST_NAME, firstName); @@ -658,6 +664,9 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(); UserInfo user; for (String username : users) { + if (Constants.APIM_RESERVED_USER.equals(username)) { + continue; + } user = new UserInfo(); user.setUsername(username); user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS)); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java index 300e47b147..c9ad2e182e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java @@ -30,6 +30,7 @@ public class Constants { public static final String USER_CLAIM_MODIFIED = "http://wso2.org/claims/modified"; public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices"; public static final String PRIMARY_USER_STORE = "PRIMARY"; + public static final String APIM_RESERVED_USER = "apim_reserved_user"; public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; From c6cc0f9a6781708b13f72e7ffb41fd5f74279f0c Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Thu, 22 Jun 2023 19:45:11 +0530 Subject: [PATCH 083/343] Fix incorrect clear app scope --- .../src/main/resources/conf/mdm-ui-config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 46114821a2..809c856038 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -224,7 +224,7 @@ perm:admin:tenant:view perm:admin:metadata:view perm:admin:usage:view - perm:android:clear-applicatio + perm:android:clear-application perm:android:suspend-package perm:android:alternate-install From cfe7e520ab71d178bc53a1186a2a77dc76b291a5 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Tue, 20 Jun 2023 23:37:12 +0530 Subject: [PATCH 084/343] iOS user enrollment support Fixes https://roadmap.entgra.net/issues/10149 --- .../mgt/common/general/QREnrollmentDetails.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java index df0719d152..fede2e3780 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java @@ -18,10 +18,21 @@ package io.entgra.device.mgt.core.device.mgt.common.general; +import java.util.Map; + public class QREnrollmentDetails { String ownershipType; String username; String enrollmentMode; + Map customValues; + + public Map getCustomValues() { + return customValues; + } + + public void setCustomValues(Map customValues) { + this.customValues = customValues; + } public String getOwnershipType() { return ownershipType; } From 8b928a4acabf2253387dece125f15ecdcd387a45 Mon Sep 17 00:00:00 2001 From: Oshani Silva Date: Sun, 25 Jun 2023 19:14:59 +0000 Subject: [PATCH 085/343] Remove unwanted check in billing logic Co-authored-by: Oshani Silva Co-committed-by: Oshani Silva --- .../DeviceManagementProviderServiceImpl.java | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index e6a32ba4f4..cbcf07c9b7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -135,6 +135,18 @@ import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.*; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -1037,7 +1049,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv dateDiff = endDate.getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); } } - long dateInDays = TimeUnit.DAYS.convert(dateDiff, TimeUnit.MILLISECONDS); + + // Convert dateDiff to days as a decimal value + double dateDiffInDays = (double) dateDiff / (24 * 60 * 60 * 1000); + + if (dateDiffInDays % 1 >= 0.9) { + dateDiffInDays = Math.ceil(dateDiffInDays); + } + + long dateInDays = (long) dateDiffInDays; double cost = (tenantCost.getCost() / 365) * dateInDays; totalCost += cost; device.setCost(Math.round(cost * 100.0) / 100.0); @@ -1104,9 +1124,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv long difference_In_Days = (difference_In_Time / (1000 * 60 * 60 * 24)) % 365; + if (difference_In_Time % (1000 * 60 * 60 * 24) >= 0.9 * (1000 * 60 * 60 * 24)) { + difference_In_Days++; + } + for (int i = 1; i <= difference_In_Years; i++) { List allDevicesPerYear = new ArrayList<>(); - LocalDateTime oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); + LocalDateTime oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; Timestamp newStartDate; Timestamp newEndDate; @@ -1115,14 +1139,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv remainingDaysConsidered = true; oneYearAfterStart = startDate.toLocalDateTime(); newEndDate = endDate; - } else if (Timestamp.valueOf(oneYearAfterStart).getTime() >= endDate.getTime()) { - newEndDate = Timestamp.valueOf(oneYearAfterStart); } else { - oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); + oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; newEndDate = Timestamp.valueOf(oneYearAfterStart); } } else { - oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); + oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; newEndDate = Timestamp.valueOf(oneYearAfterStart); } @@ -1145,7 +1167,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv allDevices.addAll(billingResponse.getDevice()); totalCost = totalCost + billingResponse.getTotalCostPerYear(); deviceCount = deviceCount + billingResponse.getDeviceCount(); - LocalDateTime nextStartDate = oneYearAfterStart.plusDays(1); + LocalDateTime nextStartDate = oneYearAfterStart.plusDays(1).with(LocalTime.of(00, 00, 00)); startDate = Timestamp.valueOf(nextStartDate); } From 19048ef3410991edd859d5d3a77138a056985125 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Sun, 9 Apr 2023 11:50:14 +0530 Subject: [PATCH 086/343] Add SCEP support fixes https://roadmap.entgra.net/issues/10042 --- .../mgt/core/impl/CertificateGenerator.java | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index bc98fae4a5..dfa0a2b616 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -55,10 +55,28 @@ import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; import org.bouncycastle.pkcs.PKCS10CertificationRequest; import org.bouncycastle.util.Store; -import org.jscep.message.*; +import org.jscep.message.CertRep; +import org.jscep.message.MessageDecodingException; +import org.jscep.message.MessageEncodingException; +import org.jscep.message.PkcsPkiEnvelopeDecoder; +import org.jscep.message.PkcsPkiEnvelopeEncoder; +import org.jscep.message.PkiMessage; +import org.jscep.message.PkiMessageDecoder; +import org.jscep.message.PkiMessageEncoder; import org.jscep.transaction.FailInfo; import org.jscep.transaction.Nonce; import org.jscep.transaction.TransactionId; +import org.wso2.carbon.certificate.mgt.core.dao.CertificateDAO; +import org.wso2.carbon.certificate.mgt.core.dao.CertificateManagementDAOException; +import org.wso2.carbon.certificate.mgt.core.dao.CertificateManagementDAOFactory; +import org.wso2.carbon.certificate.mgt.core.dto.CAStatus; +import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse; +import org.wso2.carbon.certificate.mgt.core.dto.SCEPResponse; +import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException; +import org.wso2.carbon.certificate.mgt.core.exception.TransactionManagementException; +import org.wso2.carbon.certificate.mgt.core.util.CertificateManagementConstants; +import org.wso2.carbon.certificate.mgt.core.util.CommonUtil; +import org.wso2.carbon.certificate.mgt.core.util.Serializer; import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.naming.InvalidNameException; @@ -70,12 +88,35 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; -import java.security.*; +import java.security.InvalidKeyException; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.SecureRandom; +import java.security.Security; +import java.security.SignatureException; import java.security.cert.Certificate; import java.security.cert.*; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; import java.util.*; +import java.security.cert.CertificateEncodingException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateExpiredException; +import java.security.cert.CertificateFactory; +import java.security.cert.CertificateNotYetValidException; +import java.security.cert.X509Certificate; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.X509EncodedKeySpec; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +>>>>>>> dfe957b019 (Add SCEP support):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java import java.util.concurrent.TimeUnit; public class CertificateGenerator { @@ -773,6 +814,7 @@ public class CertificateGenerator { BigInteger serialNumber = BigInteger.valueOf(System.currentTimeMillis()); +<<<<<<< HEAD:components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java //Reversing the order of components of the subject DN due to Nginx not verifying the client certificate //generated by Java using this subject DN. //Ref: https://stackoverflow.com/questions/33769978 & engineering mail SCEP implementation for Android @@ -783,6 +825,10 @@ public class CertificateGenerator { } String subjectDn = joiner.toString(); X500Name issuerName = new X500Name(subjectDn); +======= + X500Name issuerName = new X500Name(certCA.getSubjectDN().getName()); + +>>>>>>> dfe957b019 (Add SCEP support):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst() .getValue().toString(); X500Name subjectName = new X500Name("O=" + commonName + "O=AndroidDevice,CN=" + From 1e252dd67fa34d46ba14e74fdba188e5be3e0ec8 Mon Sep 17 00:00:00 2001 From: Pahansith Gunathilake Date: Wed, 19 Apr 2023 06:46:09 +0000 Subject: [PATCH 087/343] Fix issue with Nginx not recognizing the SCEP client certificate (#105) Co-authored-by: Pahansith Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/105 Co-authored-by: Pahansith Gunathilake Co-committed-by: Pahansith Gunathilake --- .../certificate/mgt/core/impl/CertificateGenerator.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index dfa0a2b616..a569b12fd3 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -116,7 +116,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; ->>>>>>> dfe957b019 (Add SCEP support):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java import java.util.concurrent.TimeUnit; public class CertificateGenerator { @@ -815,6 +814,9 @@ public class CertificateGenerator { BigInteger serialNumber = BigInteger.valueOf(System.currentTimeMillis()); <<<<<<< HEAD:components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +<<<<<<< HEAD:components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +======= +>>>>>>> d34adaae96 (Fix issue with Nginx not recognizing the SCEP client certificate (#105)):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java //Reversing the order of components of the subject DN due to Nginx not verifying the client certificate //generated by Java using this subject DN. //Ref: https://stackoverflow.com/questions/33769978 & engineering mail SCEP implementation for Android @@ -825,10 +827,6 @@ public class CertificateGenerator { } String subjectDn = joiner.toString(); X500Name issuerName = new X500Name(subjectDn); -======= - X500Name issuerName = new X500Name(certCA.getSubjectDN().getName()); - ->>>>>>> dfe957b019 (Add SCEP support):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst() .getValue().toString(); X500Name subjectName = new X500Name("O=" + commonName + "O=AndroidDevice,CN=" + From a603a69f3ef79c45c2acfca79de1b5f4688ba360 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Wed, 24 May 2023 13:54:10 +0530 Subject: [PATCH 088/343] OTP for enrollment with Mutual TLS Fixes https://roadmap.entgra.net/issues/10093 --- .../mgt/common/DeviceManagementConstants.java | 2 + .../common/general/QREnrollmentDetails.java | 9 ++++ .../mgt/common/otp/mgt/OTPEmailTypes.java | 2 +- .../mgt/common/spi/OTPManagementService.java | 6 +-- .../dao/impl/GenericOTPManagementDAOImpl.java | 12 ++++- .../mgt/service/OTPManagementServiceImpl.java | 51 +++++++++---------- .../authenticator/BasicAuthAuthenticator.java | 31 +++++++++-- .../CertificateAuthenticator.java | 9 ++++ .../OneTimeTokenAuthenticator.java | 14 ++++- 9 files changed, 98 insertions(+), 38 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java index fb4c749b82..6fd2fedde9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java @@ -134,6 +134,8 @@ public final class DeviceManagementConstants { public static final String LAST_NAME = "last-name"; public static final String TENANT_ADMIN_USERNAME = "tenant-admin-username"; public static final String TENANT_ADMIN_PASSWORD = "tenant-admin-password"; + + public static final int OTP_DEFAULT_EXPIRY_SECONDS = 3600; } public static final class EventServices { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java index fede2e3780..08a334bf2f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java @@ -33,6 +33,7 @@ public class QREnrollmentDetails { public void setCustomValues(Map customValues) { this.customValues = customValues; } + int tokenExpiry; public String getOwnershipType() { return ownershipType; } @@ -45,4 +46,12 @@ public class QREnrollmentDetails { public String getEnrollmentMode() { return enrollmentMode; } public void setEnrollmentMode(String enrollmentMode) { this.enrollmentMode = enrollmentMode; } + + public int getTokenExpiry() { + return tokenExpiry; + } + + public void setTokenExpiry(int tokenExpiry) { + this.tokenExpiry = tokenExpiry; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java index afb1d6b0fa..d8f49d79ec 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java @@ -19,5 +19,5 @@ package io.entgra.device.mgt.core.device.mgt.common.otp.mgt; public enum OTPEmailTypes { - USER_VERIFY, DEVICE_ENROLLMENT + USER_VERIFY, DEVICE_ENROLLMENT, USER_INVITE } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java index c89d311cda..e4cfa042b6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java @@ -35,7 +35,8 @@ public interface OTPManagementService { * @throws OTPManagementException if error occurred whle verifying validity of the OPT * @throws BadRequestException if found an null value for OTP */ - OneTimePinDTO isValidOTP(String oneTimeToken) throws OTPManagementException, BadRequestException; + OneTimePinDTO isValidOTP(String oneTimeToken, boolean requireRenewal) throws + OTPManagementException, BadRequestException; /** * Invalidate the OTP and send welcome mail @@ -59,8 +60,7 @@ public interface OTPManagementService { boolean hasEmailRegistered(String email, String emailDomain) throws OTPManagementException, DeviceManagementException; - OneTimePinDTO generateOneTimePin(String email, String emailType, String userName, Object metaDataObj, - int tenantId, boolean persistPin) throws OTPManagementException; + OneTimePinDTO generateOneTimePin(OneTimePinDTO oneTimePinData, boolean persistPin) throws OTPManagementException; OneTimePinDTO getRenewedOtpByEmailAndMailType(String email, String emailType) throws OTPManagementException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java index eaac0bf827..c11ff6ab0c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java @@ -25,7 +25,12 @@ import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.OTPManagementDAO; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.exception.OTPManagementDAOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.exceptions.DBConnectionException; +import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; +import org.wso2.carbon.device.mgt.core.otp.mgt.dao.AbstractDAOImpl; +import org.wso2.carbon.device.mgt.core.otp.mgt.dao.OTPManagementDAO; +import org.wso2.carbon.device.mgt.core.otp.mgt.exception.OTPManagementDAOException; import java.sql.*; import java.util.Calendar; import java.util.List; @@ -51,7 +56,8 @@ public class GenericOTPManagementDAOImpl extends AbstractDAOImpl implements OTPM + "META_INFO, " + "CREATED_AT," + "TENANT_ID," - + "USERNAME) VALUES (?, ?, ?, ?, ?, ?, ?)"; + + "USERNAME, " + + "EXPIRY_TIME) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; try { Connection conn = this.getDBConnection(); Calendar calendar = Calendar.getInstance(); @@ -65,6 +71,8 @@ public class GenericOTPManagementDAOImpl extends AbstractDAOImpl implements OTPM stmt.setTimestamp(5, timestamp); stmt.setInt(6, oneTimePinDTO.getTenantId()); stmt.setString(7, oneTimePinDTO.getUsername()); + stmt.setInt(8, oneTimePinDTO.getExpiryTime() == 0 + ? DeviceManagementConstants.OTPProperties.OTP_DEFAULT_EXPIRY_SECONDS : oneTimePinDTO.getExpiryTime()); stmt.addBatch(); } stmt.executeBatch(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java index 087cf3851f..ee087d3c68 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java @@ -117,7 +117,8 @@ public class OTPManagementServiceImpl implements OTPManagementService { } @Override - public OneTimePinDTO isValidOTP(String oneTimeToken) throws OTPManagementException, BadRequestException { + public OneTimePinDTO isValidOTP(String oneTimeToken, boolean requireRenewal) throws OTPManagementException, + BadRequestException { if (StringUtils.isBlank(oneTimeToken)){ String msg = "Received blank OTP to verify. OTP: " + oneTimeToken; log.error(msg); @@ -141,17 +142,19 @@ public class OTPManagementServiceImpl implements OTPManagementService { oneTimePinDTO.getCreatedAt().getTime() + oneTimePinDTO.getExpiryTime() * 1000L); if (currentTimestamp.after(expiredTimestamp)) { - String renewedOTP = UUID.randomUUID().toString(); - renewOTP(oneTimePinDTO, renewedOTP); - Gson gson = new Gson(); - Tenant tenant = gson.fromJson(oneTimePinDTO.getMetaInfo(), Tenant.class); + if (requireRenewal) { + String renewedOTP = UUID.randomUUID().toString(); + renewOTP(oneTimePinDTO, renewedOTP); + Gson gson = new Gson(); + Tenant tenant = gson.fromJson(oneTimePinDTO.getMetaInfo(), Tenant.class); - Properties props = new Properties(); - props.setProperty("first-name", tenant.getAdminFirstName()); - props.setProperty("otp-token", renewedOTP); - props.setProperty("email", oneTimePinDTO.getEmail()); - props.setProperty("type", oneTimePinDTO.getEmailType()); - sendMail(props, oneTimePinDTO.getEmail(), DeviceManagementConstants.EmailAttributes.USER_VERIFY_TEMPLATE); + Properties props = new Properties(); + props.setProperty("first-name", tenant.getAdminFirstName()); + props.setProperty("otp-token", renewedOTP); + props.setProperty("email", oneTimePinDTO.getEmail()); + props.setProperty("type", oneTimePinDTO.getEmailType()); + sendMail(props, oneTimePinDTO.getEmail(), DeviceManagementConstants.EmailAttributes.USER_VERIFY_TEMPLATE); + } return null; } return oneTimePinDTO; @@ -234,8 +237,14 @@ public class OTPManagementServiceImpl implements OTPManagementService { for (String username : deviceEnrollmentInvitation.getUsernames()) { String emailAddress = DeviceManagerUtil.getUserClaimValue( username, DeviceManagementConstants.User.CLAIM_EMAIL_ADDRESS); - oneTimePinDTO = generateOneTimePin(emailAddress, OTPEmailTypes.DEVICE_ENROLLMENT.toString(), username, - null, tenantId, false); + + OneTimePinDTO oneTimePinData = new OneTimePinDTO(); + oneTimePinData.setEmail(emailAddress); + oneTimePinData.setTenantId(tenantId); + oneTimePinData.setUsername(username); + oneTimePinData.setEmailType(OTPEmailTypes.USER_INVITE.toString()); + + oneTimePinDTO = generateOneTimePin(oneTimePinData, false); oneTimePinDTOList.add(oneTimePinDTO); props.setProperty("first-name", DeviceManagerUtil. getUserClaimValue(username, DeviceManagementConstants.User.CLAIM_FIRST_NAME)); @@ -269,27 +278,17 @@ public class OTPManagementServiceImpl implements OTPManagementService { /** * Create One Time Token - * @param email email - * @param emailType email type - * @param userName username - * @param metaDataObj meta data object - * @param tenantId tenant Id + * @param oneTimePinDTO Data related to the one time pin * @return {@link OneTimePinDTO} */ @Override - public OneTimePinDTO generateOneTimePin(String email, String emailType, String userName, Object metaDataObj, - int tenantId, boolean persistPin) throws OTPManagementException { + public OneTimePinDTO generateOneTimePin(OneTimePinDTO oneTimePinDTO, boolean persistPin) throws OTPManagementException { String otpValue = UUID.randomUUID().toString(); Gson gson = new Gson(); - String metaInfo = gson.toJson(metaDataObj); + String metaInfo = gson.toJson(oneTimePinDTO.getMetaInfo()); - OneTimePinDTO oneTimePinDTO = new OneTimePinDTO(); - oneTimePinDTO.setEmail(email); - oneTimePinDTO.setTenantId(tenantId); - oneTimePinDTO.setUsername(userName); - oneTimePinDTO.setEmailType(emailType); oneTimePinDTO.setMetaInfo(metaInfo); oneTimePinDTO.setOtpToken(otpValue); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java index 6545b7bbab..11395eef60 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java @@ -35,6 +35,7 @@ import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.nio.charset.Charset; import java.util.Base64; import java.util.Properties; +import java.util.StringTokenizer; public class BasicAuthAuthenticator implements WebappAuthenticator { @@ -50,15 +51,23 @@ public class BasicAuthAuthenticator implements WebappAuthenticator { @Override public boolean canHandle(Request request) { /* - This is done to avoid every endpoint being able to use basic auth. Add the following to - the required web.xml of the web app. + This is done to avoid every web app being able to use basic auth. Add the following to + the required web.xml of the web app. This is a global config for a web app to allow all + contexts of the web app to use basic auth basicAuth true + + Adding the basicAuthAllowList parameter allows to selectively allow some context paths in a + web app to use basic auth while all the other context remain unavailable with basic auth. + If this parameter is present, any context that requires basic auth must be specially + added as comma separated list to the param-value of basicAuthAllowList. */ - if (!isAuthenticationSupported(request)) { - return false; + if (!isAllowListedForBasicAuth(request)) { + if (!isAuthenticationSupported(request)) { + return false; + } } if (request.getCoyoteRequest() == null || request.getCoyoteRequest().getMimeHeaders() == null) { return false; @@ -75,6 +84,20 @@ public class BasicAuthAuthenticator implements WebappAuthenticator { return false; } + private boolean isAllowListedForBasicAuth(Request request) { + String param = request.getContext().findParameter("basicAuthAllowList"); + if (param != null && !param.isEmpty()) { + //Add the nonSecured end-points to cache + String[] basicAuthAllowList = param.split(","); + for (String contexPath : basicAuthAllowList) { + if (request.getRequestURI().toString().endsWith(contexPath.trim())) { + return true; + } + } + } + return false; + } + @Override public AuthenticationInfo authenticate(Request request, Response response) { AuthenticationInfo authenticationInfo = new AuthenticationInfo(); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java index 5238828dd0..c968905e78 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java @@ -74,21 +74,30 @@ public class CertificateAuthenticator implements WebappAuthenticator { // When there is a load balancer terminating mutual SSL, it should pass this header along and // as the value of this header, the client certificate subject dn should be passed. if (request.getHeader(PROXY_MUTUAL_AUTH_HEADER) != null) { + log.info("PROXY_MUTUAL_AUTH_HEADER " + request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifySubjectDN(request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); + log.info("clientCertificate" + certificateResponse.getSerialNumber()); + log.info("clientCertificate" + certificateResponse.getCommonName()); authenticationInfo = checkCertificateResponse(certificateResponse); + log.info("username" + authenticationInfo.getUsername()); } else if (request.getHeader(MUTUAL_AUTH_HEADER) != null) { + log.info("MUTUAL_AUTH_HEADER"); Object object = request.getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); X509Certificate[] clientCertificate = null; if (object instanceof X509Certificate[]) { + log.info("clientCertificate"); clientCertificate = (X509Certificate[]) request. getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); } if (clientCertificate != null && clientCertificate[0] != null) { CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifyPEMSignature(clientCertificate[0]); + log.info("clientCertificate" + certificateResponse.getSerialNumber()); + log.info("clientCertificate" + certificateResponse.getCommonName()); authenticationInfo = checkCertificateResponse(certificateResponse); + log.info("username" + authenticationInfo.getUsername()); } else { authenticationInfo.setStatus(Status.FAILURE); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java index 82e592524b..29392b63f5 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java @@ -49,8 +49,18 @@ public class OneTimeTokenAuthenticator implements WebappAuthenticator { try { OTPManagementService otpManagementService = AuthenticatorFrameworkDataHolder.getInstance() .getOtpManagementService(); - OneTimePinDTO validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders - .ONE_TIME_TOKEN_HEADER)); + OneTimePinDTO validOTP; + if (request.getRequestURI().toString().endsWith("cloud/download-url") + || request.getRequestURI().toString().endsWith("cloud/tenant")) { + validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders + .ONE_TIME_TOKEN_HEADER), true); + } else { + log.info("Validating OTP for enrollments PIN: " + request.getHeader(Constants + .HTTPHeaders.ONE_TIME_TOKEN_HEADER)); + validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders + .ONE_TIME_TOKEN_HEADER), false); + } + if (validOTP != null) { authenticationInfo.setStatus(Status.CONTINUE); authenticationInfo.setTenantId(validOTP.getTenantId()); From 84563078d3d496717a0c6eb457decd6185ae6b43 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Sat, 13 May 2023 12:56:56 +0530 Subject: [PATCH 089/343] Add tenant based storing and loading SCEP certificates --- .../mgt/core/dao/CertificateDAO.java | 10 +++++ .../dao/impl/AbstractCertificateDAOImpl.java | 36 +++++++++++++++++ .../mgt/core/impl/CertificateGenerator.java | 39 ++++++++++++------- .../mgt/core/impl/KeyStoreReader.java | 37 ++++++++++++++++++ .../exception/StorageManagementException.java | 32 +++++++++++++++ 5 files changed, 141 insertions(+), 13 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java index de3be1856a..dcd20bbde5 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java @@ -51,6 +51,16 @@ public interface CertificateDAO { */ CertificateResponse retrieveCertificate(String serialNumber) throws CertificateManagementDAOException; + /** + * Obtain a certificated stored in the database by providing the common name and the tenant ID + * + * @param serialNumber Serial number (Common name) of the certificate + * @param tenantId ID of the certificate owning tenant + * @return representation of the certificate. + * @throws CertificateManagementDAOException if fails to read the certificate from the database + */ + CertificateResponse retrieveCertificate(String serialNumber, int tenantId) throws CertificateManagementDAOException; + /** * Get all the certificates in a paginated manner. * diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java index 45a7e7c56f..fad84f8309 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java @@ -119,6 +119,42 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ return certificateResponse; } + @Override + public CertificateResponse retrieveCertificate(String serialNumber, int tenantId) throws CertificateManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + ResultSet resultSet = null; + CertificateResponse certificateResponse = null; + try { + conn = this.getConnection(); + String query = + "SELECT CERTIFICATE, SERIAL_NUMBER, TENANT_ID, USERNAME FROM" + + " DM_DEVICE_CERTIFICATE WHERE SERIAL_NUMBER = ? AND TENANT_ID = ? "; + stmt = conn.prepareStatement(query); + stmt.setString(1, serialNumber); + stmt.setInt(2, tenantId); + resultSet = stmt.executeQuery(); + + if (resultSet.next()) { + certificateResponse = new CertificateResponse(); + byte[] certificateBytes = resultSet.getBytes("CERTIFICATE"); + certificateResponse.setCertificate(certificateBytes); + certificateResponse.setSerialNumber(resultSet.getString("SERIAL_NUMBER")); + certificateResponse.setTenantId(resultSet.getInt("TENANT_ID")); + certificateResponse.setUsername(resultSet.getString("USERNAME")); + CertificateGenerator.extractCertificateDetails(certificateBytes, certificateResponse); + } + } catch (SQLException e) { + String errorMsg = + "Unable to get the read the certificate with serial" + serialNumber; + log.error(errorMsg, e); + throw new CertificateManagementDAOException(errorMsg, e); + } finally { + CertificateManagementDAOUtil.cleanupResources(stmt, resultSet); + } + return certificateResponse; + } + @Override public List searchCertificate(String serialNumber) throws CertificateManagementDAOException { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index a569b12fd3..acb9796bc2 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -376,15 +376,31 @@ public class CertificateGenerator { CertificateResponse lookUpCertificate = null; KeyStoreReader keyStoreReader = new KeyStoreReader(); if (distinguishedName != null && !distinguishedName.isEmpty()) { - if (distinguishedName.contains("/CN=")) { - String[] dnSplits = distinguishedName.split("/"); - for (String dnPart : dnSplits) { - if (dnPart.contains("CN=")) { - String commonNameExtracted = dnPart.replace("CN=", ""); - lookUpCertificate = keyStoreReader.getCertificateBySerial(commonNameExtracted); - break; + if (distinguishedName.contains("CN=")) { + String[] dnSplits = null; + if (distinguishedName.contains("/")) { + dnSplits = distinguishedName.split("/"); + } else if (distinguishedName.contains(",")) { + //some older versions of nginx will forward the client certificate subject dn separated with commas + dnSplits = distinguishedName.split(","); + } + String commonNameExtracted = null; + int tenantId = 0; + if (dnSplits != null && dnSplits.length >= 1) { + for (String dnPart : dnSplits) { + if (dnPart.contains("CN=")) { + commonNameExtracted = dnPart.replace("CN=", ""); + } else if (dnPart.contains("OU=")) { + //the OU of the certificate will be like OU=tenant_ ex: OU=tenant_-1234 + //splitting by underscore to extract the tenant domain + String[] orgUnitSplits = dnPart.split("_"); + tenantId = Integer.parseInt(orgUnitSplits[1]); + } } } + + lookUpCertificate = keyStoreReader.getCertificateBySerial(commonNameExtracted, tenantId); + } else { LdapName ldapName; try { @@ -813,10 +829,6 @@ public class CertificateGenerator { BigInteger serialNumber = BigInteger.valueOf(System.currentTimeMillis()); -<<<<<<< HEAD:components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java -<<<<<<< HEAD:components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java -======= ->>>>>>> d34adaae96 (Fix issue with Nginx not recognizing the SCEP client certificate (#105)):components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/src/main/java/org/wso2/carbon/certificate/mgt/core/impl/CertificateGenerator.java //Reversing the order of components of the subject DN due to Nginx not verifying the client certificate //generated by Java using this subject DN. //Ref: https://stackoverflow.com/questions/33769978 & engineering mail SCEP implementation for Android @@ -829,8 +841,9 @@ public class CertificateGenerator { X500Name issuerName = new X500Name(subjectDn); String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst() .getValue().toString(); - X500Name subjectName = new X500Name("O=" + commonName + "O=AndroidDevice,CN=" + - serialNumber); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + X500Name subjectName = new X500Name("O=" + commonName + ",CN=" + + serialNumber + ", OU=tenant_"+tenantId); Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(365 * 100)); diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java index 56ec2bb6f5..94cab378bf 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java @@ -271,6 +271,43 @@ public class KeyStoreReader { return raPrivateKey; } + public CertificateResponse getCertificateBySerial(String serialNumber, int tenantId) throws KeystoreException { + CertificateResponse certificateResponse = null; + try { + CertificateCacheManager cacheManager = CertificateCacheManagerImpl.getInstance(); + certificateResponse = cacheManager.getCertificateBySerial(serialNumber); + if (certificateResponse == null) { + try { + CertificateManagementDAOFactory.openConnection(); + certificateResponse = certDao.retrieveCertificate(serialNumber, tenantId); + } catch (SQLException e) { + String errorMsg = "Error when making a connection to the database."; + throw new KeystoreException(errorMsg, e); + } finally { + CertificateManagementDAOFactory.closeConnection(); + } + if (certificateResponse != null && certificateResponse.getCertificate() != null) { + Certificate certificate = (Certificate) Serializer.deserialize(certificateResponse.getCertificate()); + if (certificate instanceof X509Certificate) { + X509Certificate x509cert = (X509Certificate) certificate; + String commonName = CertificateGenerator.getCommonName(x509cert); + certificateResponse.setCommonName(commonName); + cacheManager.addCertificateBySerial(serialNumber, certificateResponse); + } + } + } + } catch (CertificateManagementDAOException e) { + String errorMsg = "Error when retrieving certificate from the the database for the serial number: " + + serialNumber; + throw new KeystoreException(errorMsg, e); + + } catch (ClassNotFoundException | IOException e) { + String errorMsg = "Error when de-serializing saved certificate."; + throw new KeystoreException(errorMsg, e); + } + return certificateResponse; + } + public CertificateResponse getCertificateBySerial(String serialNumber) throws KeystoreException { CertificateResponse certificateResponse = null; try { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java new file mode 100644 index 0000000000..38985716de --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java @@ -0,0 +1,32 @@ +/* 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 org.wso2.carbon.device.mgt.core.common.exception; + +/** + * Represents the exception thrown during storing and retrieving the artifacts. + */ +public class StorageManagementException extends Exception { + public StorageManagementException(String message, Throwable ex) { + super(message, ex); + } + + public StorageManagementException(String message) { + super(message); + } +} + From 9a55a83af47ab8f35eebf04b4084947d9a1bef18 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Wed, 21 Jun 2023 06:20:17 +0530 Subject: [PATCH 090/343] Add OTP based remote session implementation --- .../mgt/common/otp/mgt/OTPEmailTypes.java | 2 +- .../interceptor/DefaultTokenHandler.java | 99 ++++++------------- .../ui/request/interceptor/UserHandler.java | 1 + .../interceptor/util/HandlerConstants.java | 1 + .../request/interceptor/util/HandlerUtil.java | 13 +++ 5 files changed, 48 insertions(+), 68 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java index d8f49d79ec..53113c5b75 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java @@ -19,5 +19,5 @@ package io.entgra.device.mgt.core.device.mgt.common.otp.mgt; public enum OTPEmailTypes { - USER_VERIFY, DEVICE_ENROLLMENT, USER_INVITE + USER_VERIFY, DEVICE_ENROLLMENT, USER_INVITE, REMOTE_SESSION } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java index 1d757b421e..a40dcafefd 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import com.google.gson.Gson; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; @@ -27,13 +26,22 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.StringUtils; +import io.entgra.ui.request.interceptor.util.HandlerConstants; +import io.entgra.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; import org.apache.http.entity.ContentType; +import io.entgra.ui.request.interceptor.beans.ProxyResponse; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.exceptions.OTPManagementException; +import org.wso2.carbon.device.mgt.common.otp.mgt.OTPEmailTypes; +import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; +import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.core.service.RealmService; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -55,71 +63,28 @@ public class DefaultTokenHandler extends HttpServlet { HttpSession httpSession = req.getSession(false); if (httpSession != null) { - AuthData authData = (AuthData) httpSession.getAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY); - if (authData == null) { - HandlerUtil.sendUnAuthorizeResponse(resp); - return; + String userWithDomain = (String) httpSession.getAttribute(HandlerConstants.USERNAME_WITH_DOMAIN); + String[] userNameParts = userWithDomain.split("@"); + + OneTimePinDTO oneTimePinData = new OneTimePinDTO(); + oneTimePinData.setEmail(OTPEmailTypes.REMOTE_SESSION.toString()); + oneTimePinData.setEmailType(OTPEmailTypes.REMOTE_SESSION.toString()); + oneTimePinData.setUsername(userNameParts[0]); + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); + try { + oneTimePinData.setTenantId(realmService.getTenantManager().getTenantId(userNameParts[1])); + } catch (UserStoreException e) { + throw new RuntimeException(e); } - - AuthData defaultAuthData = (AuthData) httpSession - .getAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY); - if (defaultAuthData != null) { - HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultAuthData.getAccessToken())); - return; - } - - String clientId = authData.getClientId(); - String clientSecret = authData.getClientSecret(); - - String queryString = req.getQueryString(); - String scopeString = ""; - if (StringUtils.isNotEmpty(queryString)) { - scopeString = req.getParameter("scopes"); - if (scopeString != null) { - scopeString = "?scopes=" + scopeString; - } - } - - String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR - + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - String tokenUrl = iotsCoreUrl + "/api/device-mgt/v1.0/devices/" + clientId - + "/" + clientSecret + "/default-token" + scopeString; - - HttpGet defaultTokenRequest = new HttpGet(tokenUrl); - defaultTokenRequest - .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); - defaultTokenRequest - .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); - ProxyResponse tokenResultResponse = HandlerUtil.execute(defaultTokenRequest); - - if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { - log.error("Error occurred while invoking the API to get default token data."); - HandlerUtil.handleError(resp, tokenResultResponse); - return; - } - String tokenResult = tokenResultResponse.getData(); - if (tokenResult == null) { - log.error("Invalid default token response is received."); - HandlerUtil.handleError(resp, tokenResultResponse); - return; - } - - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResult); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - AuthData newDefaultAuthData = new AuthData(); - newDefaultAuthData.setClientId(clientId); - newDefaultAuthData.setClientSecret(clientSecret); - - String defaultToken = jTokenResultAsJsonObject.get("accessToken").getAsString(); - newDefaultAuthData.setAccessToken(defaultToken); - newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refreshToken").getAsString()); - newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scopes").getAsString()); - httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); - - HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken)); + oneTimePinData.setExpiryTime(DeviceManagementConstants.OTPProperties.OTP_DEFAULT_EXPIRY_SECONDS); + OTPManagementService otpManagementService = HandlerUtil.getOTPManagementService(); + try { + oneTimePinData = otpManagementService.generateOneTimePin(oneTimePinData, true); + HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(oneTimePinData.getOtpToken())); + } catch (OTPManagementException e) { + log.error("Failed while generating remote session OTP for user " + userWithDomain, e); + HandlerUtil.handleError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR); } } else { HandlerUtil.sendUnAuthorizeResponse(resp); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index d5e8d2bf4d..c0f6c7f6ee 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -120,6 +120,7 @@ public class UserHandler extends HttpServlet { proxyResponse.setData( jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", "")); HandlerUtil.handleSuccess(resp, proxyResponse); + httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); } } catch (IOException e) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java index 239cf1c944..9aa9cb9fe6 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java @@ -106,4 +106,5 @@ public class HandlerConstants { public static final String IOT_REPORTING_WEBAPP_HOST_ENV_VAR = "iot.reporting.webapp.host"; public static final String USER_SCOPES = "userScopes"; public static final String HUBSPOT_CHAT_URL = "api.hubapi.com"; + public static final String USERNAME_WITH_DOMAIN = "usernameWithDomain"; } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 5a05a19425..f15215067e 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -51,6 +51,9 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.Document; +import io.entgra.ui.request.interceptor.beans.ProxyResponse; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; import org.xml.sax.SAXException; import javax.servlet.http.HttpServletRequest; @@ -70,6 +73,8 @@ public class HandlerUtil { private static boolean isLoginCacheInitialized = false; private static AuthData authData; + private static OTPManagementService otpManagementService; + /*** * * @param httpRequest - httpMethod e.g:- HttpPost, HttpGet @@ -742,4 +747,12 @@ public class HandlerUtil { public static boolean isPropertyDefined(String property) { return StringUtils.isEmpty(System.getProperty(property)); } + + public static OTPManagementService getOTPManagementService() { + if (otpManagementService == null) { + otpManagementService = (OTPManagementService) PrivilegedCarbonContext + .getThreadLocalCarbonContext().getOSGiService(OTPManagementService.class, null); + } + return otpManagementService; + } } From 2dd804f1a869038dc9b3aea019f1884f5fe387ea Mon Sep 17 00:00:00 2001 From: inoshperera Date: Sun, 18 Jun 2023 12:22:01 +0530 Subject: [PATCH 091/343] Add the logic to save device id to certificate DB partialy fixes https://roadmap.entgra.net/issues/10145 --- .../mgt/core/bean/Certificate.java | 9 +++++ .../mgt/core/dao/CertificateDAO.java | 11 ++++++ .../dao/impl/AbstractCertificateDAOImpl.java | 34 +++++++++++++++++++ .../mgt/core/impl/CertificateGenerator.java | 27 +++++++++++++-- 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java index e3e55c330f..acf63daa07 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java @@ -25,6 +25,15 @@ public class Certificate { X509Certificate certificate; int tenantId; String tenantDomain; + String deviceIdentifier; + + public String getDeviceIdentifier() { + return deviceIdentifier; + } + + public void setDeviceIdentifier(String deviceIdentifier) { + this.deviceIdentifier = deviceIdentifier; + } public int getTenantId() { return tenantId; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java index dcd20bbde5..779251761e 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java @@ -41,6 +41,17 @@ public interface CertificateDAO { void addCertificate(List certificate) throws CertificateManagementDAOException; + /** + * This can be used to store a certificate in the database, where it will be stored against the serial number + * of the certificate. + * + * @param certificate Holds the certificate and relevant details. + * @throws CertificateManagementDAOException + * + */ + void addCertificate(Certificate certificate) + throws CertificateManagementDAOException; + /** * Usage is to obtain a certificate stored in the database by providing the common name. * diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java index fad84f8309..0a8e9e3066 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java @@ -81,6 +81,40 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ } } + @Override + public void addCertificate(Certificate certificate) + throws CertificateManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + try { + conn = this.getConnection(); + stmt = conn.prepareStatement( + "INSERT INTO DM_DEVICE_CERTIFICATE (SERIAL_NUMBER, CERTIFICATE, TENANT_ID," + + " USERNAME, DEVICE_IDENTIFIER) VALUES (?,?,?,?,?)"); + PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext. + getThreadLocalCarbonContext(); + String username = threadLocalCarbonContext.getUsername(); + // the serial number of the certificate used for its creation is set as its alias. + String serialNumber = certificate.getSerial(); + if (serialNumber == null || serialNumber.isEmpty()) { + serialNumber = String.valueOf(certificate.getCertificate().getSerialNumber()); + } + byte[] bytes = Serializer.serialize(certificate.getCertificate()); + + stmt.setString(1, serialNumber); + stmt.setBytes(2, bytes); + stmt.setInt(3, certificate.getTenantId()); + stmt.setString(4, username); + stmt.setString(5, certificate.getDeviceIdentifier()); + stmt.executeUpdate(); + } catch (SQLException | IOException e) { + throw new CertificateManagementDAOException("Error occurred while saving the " + + "certificate. ", e); + } finally { + CertificateManagementDAOUtil.cleanupResources(stmt, null); + } + } + @Override public CertificateResponse retrieveCertificate(String serialNumber) throws CertificateManagementDAOException { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index acb9796bc2..b8109e74fc 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -727,6 +727,29 @@ public class CertificateGenerator { throw new KeystoreException(errorMsg, e); } } + public void saveCertificate(org.wso2.carbon.certificate.mgt.core.bean.Certificate + certificate) throws KeystoreException { + + if (certificate == null) { + return; + } + + try { + CertificateDAO certificateDAO = CertificateManagementDAOFactory.getCertificateDAO(); + CertificateManagementDAOFactory.beginTransaction(); + certificateDAO.addCertificate(certificate); + CertificateManagementDAOFactory.commitTransaction(); + } catch (CertificateManagementDAOException e) { + String errorMsg = "Error occurred when saving the generated certificate in database"; + log.error(errorMsg); + CertificateManagementDAOFactory.rollbackTransaction(); + throw new KeystoreException(errorMsg, e); + } catch (TransactionManagementException e) { + String errorMsg = "Error occurred when saving the generated certificate in database"; + log.error(errorMsg); + throw new KeystoreException(errorMsg, e); + } + } public void saveCertInKeyStore(List certificate) throws KeystoreException { @@ -866,8 +889,8 @@ public class CertificateGenerator { List certificates = new ArrayList<>(); certificate.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); certificate.setCertificate(issuedCert); - certificates.add(certificate); - saveCertInKeyStore(certificates); + certificate.setDeviceIdentifier(commonName); + saveCertificate(certificate); } catch (OperatorCreationException e) { String errorMsg = "Error creating the content signer"; From 6299d0fd83a7d52bdd1f4d2f4f5ddd7cc4d29eb2 Mon Sep 17 00:00:00 2001 From: rajitha Date: Thu, 15 Jun 2023 14:08:46 +0530 Subject: [PATCH 092/343] Add otp token --- .../DeviceManagementConfigService.java | 7 ++- .../DeviceManagementConfigServiceImpl.java | 57 ++++++++++++++++++- .../config/api/util/DeviceMgtAPIUtils.java | 17 ++++++ 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java index eac30a6de6..729e477c00 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java @@ -139,7 +139,12 @@ public interface DeviceManagementConfigService { value = "The properties list using for query a device", required = true) @QueryParam("properties") - String properties); + String properties, + @ApiParam( + name = "withAccessToken", + value = "Whether to use access token or otp token for device configuration") + @QueryParam("withAccessToken") + boolean withAccessToken); @PUT @Path("/device/transfer") diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java index f387dfea32..d32ac76676 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java @@ -48,6 +48,30 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.AppRegistrationCredentials; +import org.wso2.carbon.device.mgt.common.ApplicationRegistrationException; +import org.wso2.carbon.device.mgt.common.DeviceTransferRequest; +import org.wso2.carbon.device.mgt.common.configuration.mgt.AmbiguousConfigurationException; +import org.wso2.carbon.device.mgt.common.configuration.mgt.DeviceConfiguration; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException; +import org.wso2.carbon.device.mgt.common.exceptions.OTPManagementException; +import org.wso2.carbon.device.mgt.common.general.TenantDetail; +import org.wso2.carbon.device.mgt.common.otp.mgt.OTPEmailTypes; +import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; +import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagementException; +import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; +import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; +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.keymanager.KeyManagerConfigurations; +import org.wso2.carbon.device.mgt.core.config.ui.UIConfiguration; +import org.wso2.carbon.device.mgt.core.config.ui.UIConfigurationManager; +import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionUtils; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; +import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; +import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.Tenant; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; @@ -70,7 +94,8 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig @Path("/configurations") @Produces(MediaType.APPLICATION_JSON) public Response getConfiguration(@HeaderParam("token") String token, - @QueryParam("properties") String properties) { + @QueryParam("properties") String properties, + @QueryParam("withAccessToken") boolean withAccessToken) { DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService(); try { if (token == null || token.isEmpty()) { @@ -95,7 +120,8 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig deviceProps.put("token", token); DeviceConfiguration devicesConfiguration = dms.getDeviceConfiguration(deviceProps); - setAccessTokenToDeviceConfigurations(devicesConfiguration); + if (withAccessToken) setAccessTokenToDeviceConfigurations(devicesConfiguration); + else setOTPTokenToDeviceConfigurations(devicesConfiguration); return Response.status(Response.Status.OK).entity(devicesConfiguration).build(); } catch (DeviceManagementException e) { String msg = "Error occurred while retrieving configurations"; @@ -207,6 +233,33 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig } } + private void setOTPTokenToDeviceConfigurations(DeviceConfiguration deviceConfiguration) + throws DeviceManagementException { + OneTimePinDTO oneTimePinData = new OneTimePinDTO(); + oneTimePinData.setEmail(OTPEmailTypes.DEVICE_ENROLLMENT.toString()); + oneTimePinData.setEmailType(OTPEmailTypes.DEVICE_ENROLLMENT.toString()); + oneTimePinData.setUsername(deviceConfiguration.getDeviceOwner()); + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( + deviceConfiguration.getTenantDomain(), true); + oneTimePinData.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + PrivilegedCarbonContext.endTenantFlow(); + OTPManagementService otpManagementService = DeviceMgtAPIUtils.getOtpManagementService(); + try { + OneTimePinDTO oneTimePinDTO = otpManagementService.generateOneTimePin(oneTimePinData, true); + if (oneTimePinDTO == null) { + String msg = "Null value returned when generating OTP token for " + oneTimePinData.getOtpToken(); + log.error(msg); + throw new DeviceManagementException(msg); + } + deviceConfiguration.setAccessToken(oneTimePinDTO.getOtpToken()); + } catch (OTPManagementException ex) { + String msg = "Error occurred while generating one time pin: " + ex.getMessage(); + log.error(msg, ex); + throw new DeviceManagementException(msg, ex); + } + } + @Override @Path("/tenants") @GET diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java index 1dd6052def..fbe57c8928 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java @@ -22,6 +22,8 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.user.core.service.RealmService; /** @@ -34,6 +36,8 @@ public class DeviceMgtAPIUtils { private static DeviceManagementProviderService deviceManagementProviderService = null; private static RealmService realmService = null; + private static OTPManagementService otpManagementService = null; + public static DeviceManagementProviderService getDeviceManagementService() { if (deviceManagementProviderService == null) { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -48,6 +52,19 @@ public class DeviceMgtAPIUtils { return deviceManagementProviderService; } + public static OTPManagementService getOtpManagementService() { + if (otpManagementService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + otpManagementService = (OTPManagementService) ctx.getOSGiService(OTPManagementService.class, null); + if (otpManagementService == null) { + String msg = "OTP Management Service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + return otpManagementService; + } + public static RealmService getRealmService() { if (realmService == null) { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); From 469c4988c5aaa9da44e16b189ef8508e6b4ee363 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Fri, 23 Jun 2023 20:39:12 +0530 Subject: [PATCH 093/343] Remove unnecessary logs --- .../CertificateAuthenticator.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java index c968905e78..cb9bf50215 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java @@ -74,31 +74,29 @@ public class CertificateAuthenticator implements WebappAuthenticator { // When there is a load balancer terminating mutual SSL, it should pass this header along and // as the value of this header, the client certificate subject dn should be passed. if (request.getHeader(PROXY_MUTUAL_AUTH_HEADER) != null) { - log.info("PROXY_MUTUAL_AUTH_HEADER " + request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); + if (log.isDebugEnabled()) { + log.debug("PROXY_MUTUAL_AUTH_HEADER " + request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); + } CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifySubjectDN(request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); - log.info("clientCertificate" + certificateResponse.getSerialNumber()); - log.info("clientCertificate" + certificateResponse.getCommonName()); authenticationInfo = checkCertificateResponse(certificateResponse); - log.info("username" + authenticationInfo.getUsername()); + if (log.isDebugEnabled()) { + log.debug("Certificate Serial : " + certificateResponse.getSerialNumber() + + ", CN : " + certificateResponse.getCommonName() + + " , username" + authenticationInfo.getUsername()); + } } else if (request.getHeader(MUTUAL_AUTH_HEADER) != null) { - log.info("MUTUAL_AUTH_HEADER"); Object object = request.getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); X509Certificate[] clientCertificate = null; if (object instanceof X509Certificate[]) { - log.info("clientCertificate"); clientCertificate = (X509Certificate[]) request. getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); } if (clientCertificate != null && clientCertificate[0] != null) { CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifyPEMSignature(clientCertificate[0]); - log.info("clientCertificate" + certificateResponse.getSerialNumber()); - log.info("clientCertificate" + certificateResponse.getCommonName()); authenticationInfo = checkCertificateResponse(certificateResponse); - log.info("username" + authenticationInfo.getUsername()); - } else { authenticationInfo.setStatus(Status.FAILURE); authenticationInfo.setMessage("No client certificate is present"); From e979130e550981042059454a4c3625be52c6c592 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Mon, 26 Jun 2023 13:43:13 +0530 Subject: [PATCH 094/343] Fix missing imports --- .../api/service/impl/DeviceManagementConfigServiceImpl.java | 4 ++++ .../core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java | 1 + 2 files changed, 5 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java index d32ac76676..de80a541d2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java @@ -21,6 +21,10 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.OTPManagementException; +import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.OTPEmailTypes; +import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto.OneTimePinDTO; +import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; import io.entgra.device.mgt.core.device.mgt.common.AppRegistrationCredentials; import io.entgra.device.mgt.core.device.mgt.common.ApplicationRegistrationException; import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java index c11ff6ab0c..02373de936 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto.OneTimePinDTO; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.AbstractDAOImpl; From f9b9f76a3c858a5de7fcca2d245be007bb6864c2 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Mon, 26 Jun 2023 14:15:29 +0530 Subject: [PATCH 095/343] Fix skip app release error --- .../application/mgt/core/impl/ApplicationManagerImpl.java | 6 +++--- .../device/mgt/core/application/mgt/core/util/APIUtil.java | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index 9a50d0d00a..6bb2edc88e 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -1239,13 +1239,13 @@ public class ApplicationManagerImpl implements ApplicationManager { this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger); } } + if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { + persistAppIconInfo(applicationReleaseDTO); + } applicationReleaseEntities.add(applicationReleaseDTO); } applicationDTO.setId(appId); applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities); - if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { - persistAppIconInfo(applicationReleaseDTO); - } return APIUtil.appDtoToAppResponse(applicationDTO); } } catch (LifeCycleManagementDAOException e) { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java index 4b78b9e1c2..40b0762380 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java @@ -514,7 +514,6 @@ public class APIUtil { public static String createAppIconPath(ApplicationReleaseDTO applicationReleaseDTO, int tenantId) throws ApplicationManagementException { String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + applicationReleaseDTO .getAppHashValue() + Constants.FORWARD_SLASH; - String iconPath = basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); - return iconPath; + return basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); } } From 5a8bcf671148b1c2eea4b8f24d6cef75b33aa705 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Sun, 25 Jun 2023 20:04:36 +0530 Subject: [PATCH 096/343] Add device enrolment log for modifyenrolment --- .../mgt/core/service/DeviceManagementProviderServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index cbcf07c9b7..31b77ebef3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -446,6 +446,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (log.isDebugEnabled()) { log.debug("Modifying enrollment for device: " + device.getId() + " of type '" + device.getType() + "'"); } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); DeviceManager deviceManager = this.getDeviceManager(device.getType()); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); if (deviceManager == null) { @@ -474,6 +476,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId); DeviceManagementDAOFactory.commitTransaction(); + log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(currentDevice.getId())).setDeviceType(String.valueOf(currentDevice.getType())).setOwner(currentDevice.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(currentDevice.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); this.removeDeviceFromCache(deviceIdentifier); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); From 729f1fd85fbbdeef584ea667f8c1aceef2bfaa85 Mon Sep 17 00:00:00 2001 From: rajitha Date: Tue, 27 Jun 2023 13:26:05 +0530 Subject: [PATCH 097/343] Update invite link --- .../mgt/service/OTPManagementServiceImpl.java | 19 ------------------- .../email/templates/user-enrollment.vm | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java index ee087d3c68..074eb8eed7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java @@ -227,9 +227,6 @@ public class OTPManagementServiceImpl implements OTPManagementService { } } } - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - OneTimePinDTO oneTimePinDTO; - List oneTimePinDTOList = new ArrayList<>(); Properties props = new Properties(); props.setProperty("enrollment-steps", enrollmentSteps.toString()); try { @@ -237,22 +234,11 @@ public class OTPManagementServiceImpl implements OTPManagementService { for (String username : deviceEnrollmentInvitation.getUsernames()) { String emailAddress = DeviceManagerUtil.getUserClaimValue( username, DeviceManagementConstants.User.CLAIM_EMAIL_ADDRESS); - - OneTimePinDTO oneTimePinData = new OneTimePinDTO(); - oneTimePinData.setEmail(emailAddress); - oneTimePinData.setTenantId(tenantId); - oneTimePinData.setUsername(username); - oneTimePinData.setEmailType(OTPEmailTypes.USER_INVITE.toString()); - - oneTimePinDTO = generateOneTimePin(oneTimePinData, false); - oneTimePinDTOList.add(oneTimePinDTO); props.setProperty("first-name", DeviceManagerUtil. getUserClaimValue(username, DeviceManagementConstants.User.CLAIM_FIRST_NAME)); props.setProperty("username", username); - props.setProperty("otp-token", oneTimePinDTO.getOtpToken()); sendMail(props, emailAddress, DeviceManagementConstants.EmailAttributes.USER_ENROLLMENT_TEMPLATE); } - this.otpManagementDAO.addOTPData(oneTimePinDTOList); ConnectionManagerUtil.commitDBTransaction(); } catch (UserStoreException e) { String msg = "Error occurred while getting claim values to invite user"; @@ -266,11 +252,6 @@ public class OTPManagementServiceImpl implements OTPManagementService { String msg = "SQL Error occurred when adding OPT data to send device enrollment Invitation."; log.error(msg, e); throw new OTPManagementException(msg, e); - } catch (OTPManagementDAOException e) { - ConnectionManagerUtil.rollbackDBTransaction(); - String msg = "Error occurred while saving the OTP data."; - log.error(msg, e); - throw new OTPManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm index 7765bcdda2..ef5307de33 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm @@ -37,7 +37,7 @@

You have been invited to enrol your device in Entgra IoT Server. - Click here to begin device enrolment.

+ Click here to begin device enrolment.

Enrollment Steps are as below, From 0ce7cd954c8642acceafaa873f77cdec2ac9a80f Mon Sep 17 00:00:00 2001 From: Thilina Sandaruwan Date: Tue, 27 Jun 2023 08:57:23 +0000 Subject: [PATCH 098/343] HierarchicalGrouping (#153) Goals Complete hierarchical grouping task https://roadmap.entgra.net/issues/9528 and https://roadmap.entgra.net/issues/9529 Approach Fix the encountered issues Co-authored-by: ThilinaPremachandra Co-authored-by: Pahansith Gunathilake Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/153 Co-authored-by: Thilina Sandaruwan Co-committed-by: Thilina Sandaruwan --- .../core/device/mgt/core/dao/GroupDAO.java | 13 ++++ .../core/dao/impl/AbstractGroupDAOImpl.java | 78 +++++++++++++++++-- .../GroupManagementProviderServiceImpl.java | 14 +++- 3 files changed, 97 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 75a6979410..777cdb922f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -211,6 +211,19 @@ public interface GroupDAO { */ List getGroups(GroupPaginationRequest paginationRequest, int tenantId) throws GroupManagementDAOException; + /** + * Get paginated list of Device Groups in tenant with specified device group ids. + * + * @param paginationRequest to filter results. + * @param deviceGroupIds of groups required. + * @param tenantId of user's tenant. + * @param isWithParentPath of user's ParentPath. + * @return List of all Device Groups in tenant. + * @throws GroupManagementDAOException + */ + List getGroups(GroupPaginationRequest paginationRequest, List deviceGroupIds, + int tenantId, boolean isWithParentPath) throws GroupManagementDAOException; + /** * Get paginated list of Device Groups in tenant with specified device group ids. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 37a10f9c23..9705c5772c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -104,7 +104,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { @Override public List getGroups(GroupPaginationRequest request, List deviceGroupIds, - int tenantId) throws GroupManagementDAOException { + int tenantId) throws GroupManagementDAOException { int deviceGroupIdsCount = deviceGroupIds.size(); if (deviceGroupIdsCount == 0) { return new ArrayList<>(); @@ -165,6 +165,73 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throw new GroupManagementDAOException(msg, e); } } + @Override + public List getGroups(GroupPaginationRequest request, List deviceGroupIds, + int tenantId, boolean isWithParentPath) throws GroupManagementDAOException { + int deviceGroupIdsCount = deviceGroupIds.size(); + if (deviceGroupIdsCount == 0) { + return new ArrayList<>(); + } + + try { + Connection conn = GroupManagementDAOFactory.getConnection(); + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE TENANT_ID = ?"; + if (StringUtils.isNotBlank(request.getGroupName())) { + sql += " AND GROUP_NAME LIKE ?"; + } + if (StringUtils.isNotBlank(request.getOwner())) { + sql += " AND OWNER LIKE ?"; + } + if (StringUtils.isNotBlank(request.getParentPath())) { + if(isWithParentPath){ + sql += " AND PARENT_PATH LIKE ?"; + } + } + sql += " AND ID IN ("; + for (int i = 0; i < deviceGroupIdsCount; i++) { + sql += (deviceGroupIdsCount - 1 != i) ? "?," : "?"; + } + sql += ")"; + if (request.getRowCount() != 0) { + sql += " LIMIT ? OFFSET ?"; + } + + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + int paramIndex = 1; + stmt.setInt(paramIndex++, tenantId); + if (StringUtils.isNotBlank(request.getGroupName())) { + stmt.setString(paramIndex++, request.getGroupName() + "%"); + } + if (StringUtils.isNotBlank(request.getOwner())) { + stmt.setString(paramIndex++, request.getOwner() + "%"); + } + if (StringUtils.isNotBlank(request.getParentPath())) { + if(isWithParentPath){ + stmt.setString(paramIndex++, request.getParentPath()); + } + } + for (Integer deviceGroupId : deviceGroupIds) { + stmt.setInt(paramIndex++, deviceGroupId); + } + if (request.getRowCount() != 0) { + stmt.setInt(paramIndex++, request.getRowCount()); + stmt.setInt(paramIndex, request.getStartIndex()); + } + List deviceGroupList = new ArrayList<>(); + try (ResultSet resultSet = stmt.executeQuery()) { + while (resultSet.next()) { + deviceGroupList.add(GroupManagementDAOUtil.loadGroup(resultSet)); + } + } + return deviceGroupList; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving groups of groups IDs " + deviceGroupIds.toString() + + " in tenant: " + tenantId; + log.error(msg); + throw new GroupManagementDAOException(msg, e); + } + } @Override public int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException { @@ -373,7 +440,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = "UPDATE DM_GROUP SET DESCRIPTION = ?, GROUP_NAME = ?, OWNER = ?, STATUS = ?, " - + "PARENT_PATH = ? WHERE ID = ? AND TENANT_ID = ?"; + + "PARENT_PATH = ?, PARENT_GROUP_ID = ? WHERE ID = ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)){ for (DeviceGroup deviceGroup : deviceGroups) { stmt.setString(1, deviceGroup.getDescription()); @@ -381,8 +448,9 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(3, deviceGroup.getOwner()); stmt.setString(4, deviceGroup.getStatus()); stmt.setString(5, deviceGroup.getParentPath()); - stmt.setInt(6, deviceGroup.getGroupId()); - stmt.setInt(7, tenantId); + stmt.setInt(6, deviceGroup.getParentGroupId()); + stmt.setInt(7, deviceGroup.getGroupId()); + stmt.setInt(8, tenantId); stmt.addBatch(); } stmt.executeBatch(); @@ -1198,7 +1266,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } - @Override + @Override public List getAllDevicesOfGroup(String groupName, int tenantId) throws GroupManagementDAOException { Connection conn; List devices; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 7c8f64768d..9b5ab0e5ae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -312,6 +312,13 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid newParentPath = DeviceGroupConstants.HierarchicalGroup.SEPERATOR; } childrenGroup.setParentPath(newParentPath); + if (!newParentPath.equals(DeviceGroupConstants.HierarchicalGroup.SEPERATOR)) { + String[] groupIds = newParentPath.split(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); + int latestGroupId = Integer.parseInt(groupIds[groupIds.length - 1]); + childrenGroup.setParentGroupId(latestGroupId); + } else { + childrenGroup.setParentGroupId(0); + } } } } @@ -518,7 +525,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public PaginationResult getGroupsWithHierarchy(String username, GroupPaginationRequest request, - boolean requireGroupProps) throws GroupManagementException { + boolean requireGroupProps) throws GroupManagementException { if (request == null) { String msg = "Received incomplete data for retrieve groups with hierarchy"; log.error(msg); @@ -527,6 +534,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid if (log.isDebugEnabled()) { log.debug("Get groups with hierarchy " + request.toString()); } + boolean isWithParentPath = false; DeviceManagerUtil.validateGroupListPageSize(request); List rootGroups; try { @@ -538,7 +546,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } else { List allDeviceGroupIdsOfUser = getGroupIds(username); GroupManagementDAOFactory.openConnection(); - rootGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId); + rootGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId, isWithParentPath); } String parentPath; List childrenGroups; @@ -1359,7 +1367,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid * @throws GroupManagementDAOException on error during population of group properties. */ private void createGroupWithChildren(DeviceGroup parentGroup, List childrenGroups, - boolean requireGroupProps, int tenantId, int depth, int counter) throws GroupManagementDAOException { + boolean requireGroupProps, int tenantId, int depth, int counter) throws GroupManagementDAOException { if (childrenGroups.isEmpty() || depth == counter) { return; } From da6f7158cfbd16e0172473e49b385253c0c2f972 Mon Sep 17 00:00:00 2001 From: nishan Date: Thu, 15 Jun 2023 14:12:56 +0530 Subject: [PATCH 099/343] add api for get visible roles --- .../service/api/RoleManagementService.java | 98 +++++++++++++++++++ .../impl/RoleManagementServiceImpl.java | 93 +++++++++++++++++- 2 files changed, 190 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java index f7eb730a8b..5031f1598d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java @@ -187,6 +187,104 @@ public interface RoleManagementService { defaultValue = "5") @QueryParam("limit") int limit); + @GET + @Path("/visible/{metaKey}") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Getting the List of Visible Roles", + notes = "WSO2 IoTS supports role-based access control (RBAC) and role management. Using this API you can the list of roles that are in WSO2 IoTS.\n" + + "Note: Internal roles, roles created for service-providers, and application related roles will not be given in the output.", + tags = "Role Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:view") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully fetched the list of roles in WSO2 IoTS.", + response = RoleList.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 304, + message = "Not Modified. \n Empty body because the client already has the latest version of the " + + "requested resource."), + @ApiResponse( + code = 404, + message = "Not Found. \n The specified resource does not exist.\n", + response = ErrorResponse.class), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while fetching the list of roles" + + " assigned to the specified user.", + response = ErrorResponse.class) + }) + Response getVisibleRole( + @ApiParam( + name = "filter", + value = "Provide a character or a few characters in the role name.", + required = false) + @QueryParam("filter") String filter, + @ApiParam( + name = "user-store", + value = "The name of the UserStore you wish to get the list of roles.", + required = false) + @QueryParam("user-store") String userStoreName, + @ApiParam( + name = "If-Modified-Since", + value = "Checks if the requested variant was modified, since the specified date-time." + + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + + "Example: Mon, 05 Jan 2014 15:10:00 +0200", + required = false) + @HeaderParam("If-Modified-Since") String ifModifiedSince, + @ApiParam( + name = "offset", + value = "The starting pagination index for the complete list of qualified items.", + required = false, + defaultValue = "0") + @QueryParam("offset") int offset, + @ApiParam( + name = "limit", + value = "Provide how many role details you require from the starting pagination index/offset.", + required = false, + defaultValue = "5") + @QueryParam("limit") int limit, + @ApiParam( + name = "username", + value = "The username of the user.", + required = true, + defaultValue = "admin") + @QueryParam("username") String username, + @ApiParam( + name = "domain", + value = "The domain name of the user store.", + required = false) + @QueryParam("domain") String domain, + @ApiParam( + name = "metaKey", + value = "Key of the metadata", + required = true) + @PathParam("metaKey") String metaKey); + @GET @Path("/filter/{prefix}") @ApiOperation( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index c8df51825e..7f5078d8a6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -17,6 +17,12 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import org.apache.axis2.databinding.types.xsd._boolean; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleInfo; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; @@ -97,6 +103,91 @@ public class RoleManagementServiceImpl implements RoleManagementService { } } + @GET + @Path("/visible/{metaKey}") + @Override + public Response getVisibleRole( + @QueryParam("filter") String filter, + @QueryParam("user-store") String userStore, + @HeaderParam("If-Modified-Since") String ifModifiedSince, + @QueryParam("offset") int offset, @QueryParam("limit") int limit, + @QueryParam("username") String username, @QueryParam("domain") String domain, + @PathParam("metaKey") String metaKey) { + RequestValidationUtil.validatePaginationParameters(offset, limit); + if (limit == 0){ + limit = Constants.DEFAULT_PAGE_LIMIT; + } + if (domain != null && !domain.isEmpty()) { + username = domain + '/' + username; + } + Metadata metadata; + List visibleRoles; + RoleList visibleRoleList = new RoleList(); + try { + metadata = DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey); + String metaValue = metadata.getMetaValue(); + JSONParser parser = new JSONParser(); + JSONObject jsonObject = (JSONObject) parser.parse(metaValue); + boolean decision = (boolean) jsonObject.get("isUserAbleToViewAllRoles"); + if (decision) { + if(userStore == null || "".equals(userStore)){ + userStore = PRIMARY_USER_STORE; + } + try{ + visibleRoles =getRolesFromUserStore(filter, userStore); + visibleRoleList.setList(visibleRoles); + + visibleRoles = FilteringUtil.getFilteredList(getRolesFromUserStore(filter, userStore), offset, limit); + visibleRoleList.setList(visibleRoles); + + return Response.status(Response.Status.OK).entity(visibleRoleList).build(); + } catch (UserStoreException e) { + String msg = "Error occurred while retrieving roles from the underlying user stores"; + log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } + } else { + try{UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); + if (!userStoreManager.isExistingUser(username)) { + if (log.isDebugEnabled()) { + log.debug("User by username: " + username + " does not exist for role retrieval."); + } + String msg = "User by username: " + username + " does not exist for role retrieval."; + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } + visibleRoleList.setList(getFilteredVisibleRoles(userStoreManager, username)); + + return Response.status(Response.Status.OK).entity(visibleRoleList).build(); + }catch (UserStoreException e) { + String msg = "Error occurred while trying to retrieve roles of the user '" + username + "'"; + log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } + } + } catch (MetadataManagementException e) { + String msg = "Error occurred while getting the metadata entry for metaKey:" + metaKey; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + private List getFilteredVisibleRoles(UserStoreManager userStoreManager, String username) + throws UserStoreException { + String[] roleListOfUser; + roleListOfUser = userStoreManager.getRoleListOfUser(username); + List filteredRoles = new ArrayList<>(); + for (String role : roleListOfUser) { + if (!(role.startsWith("Internal/") || role.startsWith("Authentication/"))) { + filteredRoles.add(role); + } + } + return filteredRoles; + } + @GET @Path("/filter/{prefix}") @Override @@ -597,7 +688,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { userStoreManager.updateUserListOfRole(roleName, usersToDelete, usersToAdd); return Response.status(Response.Status.OK).entity("Role '" + roleName + "' has " + - "successfully been updated with the user list") + "successfully been updated with the user list") .build(); } catch (UserStoreException e) { String msg = "Error occurred while updating the users of the role '" + roleName + "'"; From 50beae1bf87d8dfea57bb5f23f7b83db7dbd103f Mon Sep 17 00:00:00 2001 From: nishan Date: Mon, 26 Jun 2023 07:28:53 +0530 Subject: [PATCH 100/343] Remove the user has role validation --- .../application/mgt/core/impl/ApplicationManagerImpl.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index 6bb2edc88e..e2bfb9902c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -3614,13 +3614,6 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ApplicationManagementException(msg); } - if (!hasUserRole(unrestrictedRoles, userName)) { - String msg = "You are trying to restrict the visibility of the application for a role set, but " - + "in order to perform the action at least one role should be assigned to user: " - + userName; - log.error(msg); - throw new BadRequestException(msg); - } } Filter filter = new Filter(); From 1844db87d8ab85dafc75cc3a046d6c1af255b108 Mon Sep 17 00:00:00 2001 From: Nishan Sangeeth Date: Wed, 28 Jun 2023 16:00:53 +0000 Subject: [PATCH 101/343] Improve app visibility restricting functionality Co-authored-by: Nishan Sangeeth Co-committed-by: Nishan Sangeeth --- .../common/services/ApplicationManager.java | 5 ++ .../mgt/core/impl/ApplicationManagerImpl.java | 52 ++++++++++++++++++- .../application/mgt/core/util/APIUtil.java | 18 +++++++ .../application/mgt/core/util/Constants.java | 3 +- .../impl/RoleManagementServiceImpl.java | 23 ++++---- .../device/mgt/api/jaxrs/util/Constants.java | 1 + 6 files changed, 91 insertions(+), 11 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java index f7655b566b..f0e2d040ff 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java @@ -29,6 +29,11 @@ import io.entgra.device.mgt.core.application.mgt.common.response.Category; import io.entgra.device.mgt.core.application.mgt.common.response.Tag; import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; import io.entgra.device.mgt.core.device.mgt.common.Base64File; +<<<<<<< HEAD +======= +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +>>>>>>> 3616245ae6 (Improve app visibility restricting functionality) import org.apache.cxf.jaxrs.ext.multipart.Attachment; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index e2bfb9902c..fba517f148 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -19,6 +19,16 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import io.entgra.device.mgt.core.application.mgt.common.*; +import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; +import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import org.json.JSONObject; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstaller; +import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; +import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger; +import io.entgra.device.mgt.core.application.mgt.common.Pagination; import io.entgra.device.mgt.core.application.mgt.common.config.RatingConfiguration; import io.entgra.device.mgt.core.application.mgt.common.dto.*; import io.entgra.device.mgt.core.application.mgt.common.exception.*; @@ -57,6 +67,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; +import javax.ws.rs.core.Response; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -1669,6 +1680,31 @@ public class ApplicationManagerImpl implements ApplicationManager { } } + /** + * Check whether valid metaData value or not + * + * @return true or false + * @throws MetadataManagementException If it is unable to load metaData + */ + private boolean isUserAbleToViewAllRoles() throws MetadataManagementException { + List allMetadata; + allMetadata = APIUtil.getMetadataManagementService().retrieveAllMetadata(); + if (allMetadata != null && !allMetadata.isEmpty()) { + for(Metadata metadata : allMetadata){ + if(Constants.SHOW_ALL_ROLES.equals(metadata.getMetaKey())){ + String metaValue = metadata.getMetaValue(); + if (metaValue != null) { + JSONObject jsonObject; + jsonObject = new JSONObject(metaValue); + boolean isUserAbleToViewAllRoles = jsonObject.getBoolean(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); + return isUserAbleToViewAllRoles; + } + } + } + } + return false; + } + /** * Get assigned role list of the given user. * @@ -3442,7 +3478,8 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public void validateAppCreatingRequest(T param) throws ApplicationManagementException, RequestValidatingException { + public void validateAppCreatingRequest(T param) + throws ApplicationManagementException, RequestValidatingException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); int deviceTypeId = -1; @@ -3614,6 +3651,15 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ApplicationManagementException(msg); } + if (!isUserAbleToViewAllRoles()) { + if (!hasUserRole(unrestrictedRoles, userName)) { + String msg = "You are trying to restrict the visibility of the application for a role set, but " + + "in order to perform the action at least one role should be assigned to user: " + + userName; + log.error(msg); + throw new BadRequestException(msg); + } + } } Filter filter = new Filter(); @@ -3665,6 +3711,10 @@ public class ApplicationManagerImpl implements ApplicationManager { String msg = "Error occurred when validating the unrestricted roles given for the web clip"; log.error(msg, e); throw new ApplicationManagementException(msg, e); + } catch (MetadataManagementException e) { + String msg = "Error occurred while retrieving metadata list"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java index 40b0762380..8c3ccbc8bf 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java @@ -40,6 +40,7 @@ import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.application.mgt.core.serviceprovider.ISServiceProviderApplicationService; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -64,6 +65,7 @@ public class APIUtil { private static volatile SubscriptionManager subscriptionManager; private static volatile ReviewManager reviewManager; private static volatile AppmDataHandler appmDataHandler; + private static volatile MetadataManagementService metadataManagementService; public static SPApplicationManager getSPApplicationManager() { if (SPApplicationManager == null) { @@ -516,4 +518,20 @@ public class APIUtil { .getAppHashValue() + Constants.FORWARD_SLASH; return basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); } + + public static MetadataManagementService getMetadataManagementService() { + if (metadataManagementService == null) { + synchronized (APIUtil.class) { + if (metadataManagementService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + metadataManagementService = (MetadataManagementService) ctx.getOSGiService( + MetadataManagementService.class, null); + if (metadataManagementService == null) { + throw new IllegalStateException("Metadata Management service not initialized."); + } + } + } + } + return metadataManagementService; + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java index 5864242acf..efd848cdb1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java @@ -70,7 +70,8 @@ public class Constants { public static final String ANY = "ANY"; public static final String DEFAULT_PCK_NAME = "default.app.com"; public static final String ALL = "ALL"; - + public static final String SHOW_ALL_ROLES = "SHOW_ALL_ROLES"; + public static final String IS_USER_ABLE_TO_VIEW_ALL_ROLES = "isUserAbleToViewAllRoles"; public static final String GOOGLE_PLAY_STORE_URL = "https://play.google.com/store/apps/details?id="; public static final String APPLE_STORE_URL = "https://itunes.apple.com/country/app/app-name/id"; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 7f5078d8a6..03a66c383e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -110,8 +110,10 @@ public class RoleManagementServiceImpl implements RoleManagementService { @QueryParam("filter") String filter, @QueryParam("user-store") String userStore, @HeaderParam("If-Modified-Since") String ifModifiedSince, - @QueryParam("offset") int offset, @QueryParam("limit") int limit, - @QueryParam("username") String username, @QueryParam("domain") String domain, + @QueryParam("offset") int offset, + @QueryParam("limit") int limit, + @QueryParam("username") String username, + @QueryParam("domain") String domain, @PathParam("metaKey") String metaKey) { RequestValidationUtil.validatePaginationParameters(offset, limit); if (limit == 0){ @@ -128,13 +130,13 @@ public class RoleManagementServiceImpl implements RoleManagementService { String metaValue = metadata.getMetaValue(); JSONParser parser = new JSONParser(); JSONObject jsonObject = (JSONObject) parser.parse(metaValue); - boolean decision = (boolean) jsonObject.get("isUserAbleToViewAllRoles"); + boolean decision = (boolean) jsonObject.get(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); if (decision) { - if(userStore == null || "".equals(userStore)){ + if (userStore == null || "".equals(userStore)){ userStore = PRIMARY_USER_STORE; } - try{ - visibleRoles =getRolesFromUserStore(filter, userStore); + try { + visibleRoles = getRolesFromUserStore(filter, userStore); visibleRoleList.setList(visibleRoles); visibleRoles = FilteringUtil.getFilteredList(getRolesFromUserStore(filter, userStore), offset, limit); @@ -148,7 +150,8 @@ public class RoleManagementServiceImpl implements RoleManagementService { new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } } else { - try{UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); + try { + UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); if (!userStoreManager.isExistingUser(username)) { if (log.isDebugEnabled()) { log.debug("User by username: " + username + " does not exist for role retrieval."); @@ -159,7 +162,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { visibleRoleList.setList(getFilteredVisibleRoles(userStoreManager, username)); return Response.status(Response.Status.OK).entity(visibleRoleList).build(); - }catch (UserStoreException e) { + } catch (UserStoreException e) { String msg = "Error occurred while trying to retrieve roles of the user '" + username + "'"; log.error(msg, e); return Response.serverError().entity( @@ -171,7 +174,9 @@ public class RoleManagementServiceImpl implements RoleManagementService { log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (ParseException e) { - throw new RuntimeException(e); + String msg = "Error occurred while parsing JSON metadata: " + e.getMessage(); + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java index c9ad2e182e..02d332baf2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java @@ -38,6 +38,7 @@ public class Constants { public static final int DEFAULT_PAGE_LIMIT = 50; public static final String FORWARD_SLASH = "/"; public static final String ANDROID = "android"; + public static final String IS_USER_ABLE_TO_VIEW_ALL_ROLES = "isUserAbleToViewAllRoles"; public static final String ANDROID_POLICY_VALIDATOR = "io.entgra.proprietary.uem.platform.android." + "core.polcy.AndroidPolicyPayloadValidator"; public static final String IOS = "ios"; From d90c5c459a35d8f7bae4366e19605d0ccb38fe02 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Thu, 29 Jun 2023 00:28:34 +0530 Subject: [PATCH 102/343] Remove reserved_user when fetching users --- .../api/jaxrs/service/impl/UserManagementServiceImpl.java | 5 +++-- .../device/mgt/core/device/mgt/api/jaxrs/util/Constants.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java index 286c0a47aa..d0f5239fa3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java @@ -424,7 +424,7 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(users.size()); BasicUserInfo user; for (String username : users) { - if (Constants.APIM_RESERVED_USER.equals(username)) { + if (Constants.APIM_RESERVED_USER.equals(username) || Constants.RESERVED_USER.equals(username)) { continue; } user = getBasicUserInfo(username); @@ -489,6 +489,7 @@ public class UserManagementServiceImpl implements UserManagementService { } if (commonUsers != null) { commonUsers.remove(Constants.APIM_RESERVED_USER); + commonUsers.remove(Constants.RESERVED_USER); } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(firstName)) { @@ -664,7 +665,7 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(); UserInfo user; for (String username : users) { - if (Constants.APIM_RESERVED_USER.equals(username)) { + if (Constants.APIM_RESERVED_USER.equals(username) || Constants.RESERVED_USER.equals(username)) { continue; } user = new UserInfo(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java index 02d332baf2..0a9b6efa26 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java @@ -31,7 +31,8 @@ public class Constants { public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices"; public static final String PRIMARY_USER_STORE = "PRIMARY"; public static final String APIM_RESERVED_USER = "apim_reserved_user"; - public static final String DEFAULT_STREAM_VERSION = "1.0.0"; + public static final String RESERVED_USER = "reserved_user"; + public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; public static final String DEFAULT_SIMPLE_DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; From 5d9938d7befa01f3d2fabf9ab07c6912eda15208 Mon Sep 17 00:00:00 2001 From: Kavin Prathaban Date: Fri, 30 Jun 2023 06:32:38 +0000 Subject: [PATCH 103/343] Add footer config template ## Purpose * Fixes https://roadmap.entgra.net/issues/10180 ## Description * cdm-config.xml.j2, cdm-config.xml templates are updated from hardcoded values to retrieve values from deployment.toml * server_name, server_version and current_year are added as variables * **Usage:** change deployment.toml values when a new version released. This will update the footer ## Related PRs * https://repository.entgra.net/proprietary/product-uem/pulls/15 Co-authored-by: prathabanKavin Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/160 Co-authored-by: Kavin Prathaban Co-committed-by: Kavin Prathaban --- .../src/main/resources/conf/cdm-config.xml | 2 +- .../templates/repository/conf/cdm-config.xml.j2 | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index 3ce48daefe..c40cefc413 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -189,7 +189,7 @@ <a href='https://entgra.io' target='_blank'> Entgra </a> - IoT Server 5.2.0 | © 2023 + UEM Server 5.3.0 | © 2023 , All Rights Reserved. Entgra diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index 262761caec..2152b1814f 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -325,12 +325,16 @@ - <a href='https://entgra.io' target='_blank'> - Entgra - </a> - IoT Server 5.2.0 | © 2023 - , All Rights Reserved. - + <a href='https://entgra.io' target='_blank'> + Entgra + </a> + {% if product_conf is defined %} + {{product_conf.server_name}} {{product_conf.server_version}} | © {{product_conf.current_year}} + {% else %} + Entgra UEM Server + {% endif %} + , All Rights Reserved. + Entgra repository/resources/whitelabel From fde6de94bb49ad986a4933b016611624800d0374 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Sat, 1 Jul 2023 21:06:29 +0530 Subject: [PATCH 104/343] fix: sub tenants grouping issue --- .../admin/GroupManagementAdminServiceImpl.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index cd53637812..5e4d0d4789 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -44,6 +44,7 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupMan import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.apache.commons.lang.StringUtils; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -106,13 +107,22 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ @DefaultValue("5") @QueryParam("limit") int limit) { try { RequestValidationUtil.validatePaginationParameters(offset, limit); + String currentUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); GroupPaginationRequest request = new GroupPaginationRequest(offset, limit); request.setGroupName(name); request.setOwner(owner); request.setStatus(status); request.setDepth(depth); - PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(null, request, requireGroupProps); + + PaginationResult deviceGroupsResult; + if (StringUtils.isBlank(currentUser)) { + deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(null, request, requireGroupProps); + } else { + deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(currentUser, request, requireGroupProps); + } + DeviceGroupList deviceGroupList = new DeviceGroupList(); deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); From 05811512482f6fb01884744d2b9922c598a8b663 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Sun, 2 Jul 2023 01:23:13 +0530 Subject: [PATCH 105/343] add: super-tenant admin check --- .../service/impl/admin/GroupManagementAdminServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 5e4d0d4789..636ed66062 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -113,9 +113,10 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ request.setOwner(owner); request.setStatus(status); request.setDepth(depth); + boolean isAdmin = DEFAULT_ADMIN_ROLE.equals(currentUser); PaginationResult deviceGroupsResult; - if (StringUtils.isBlank(currentUser)) { + if (StringUtils.isBlank(currentUser) || isAdmin) { deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() .getGroupsWithHierarchy(null, request, requireGroupProps); } else { From b682e77d346c9a9fbabae473aa5e93eaefc71a23 Mon Sep 17 00:00:00 2001 From: ThilinaPremachandra Date: Mon, 3 Jul 2023 18:53:34 +0530 Subject: [PATCH 106/343] fix: group assigned role issue --- .../impl/GroupManagementServiceImpl.java | 22 +++++++++++++++++-- .../GroupManagementAdminServiceImpl.java | 16 +++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index 262e51eb9f..b4fb899ba8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -29,6 +29,7 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistExc import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.CarbonConstants; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; @@ -58,6 +59,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.UserRealm; +import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.*; import javax.naming.InitialContext; @@ -70,6 +73,7 @@ import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class GroupManagementServiceImpl implements GroupManagementService { @@ -123,8 +127,18 @@ public class GroupManagementServiceImpl implements GroupManagementService { request.setGroupName(name); request.setOwner(owner); request.setDepth(depth); - PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(currentUser, request, requireGroupProps); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + UserRealm realmService = DeviceMgtAPIUtils.getRealmService().getTenantUserRealm(tenantId); + String[] roles = realmService.getUserStoreManager().getRoleListOfUser(currentUser); + boolean hasAdminRole = Arrays.asList(roles).contains(DEFAULT_ADMIN_ROLE); + PaginationResult deviceGroupsResult; + if (hasAdminRole) { + deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(null, request, requireGroupProps); + } else{ + deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(currentUser, request, requireGroupProps); + } DeviceGroupList deviceGroupList = new DeviceGroupList(); deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); @@ -133,6 +147,10 @@ public class GroupManagementServiceImpl implements GroupManagementService { String error = "Error occurred while retrieving groups with hierarchy."; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); + } catch (UserStoreException e) { + String msg = "Error occurred while getting user realm."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 636ed66062..35be14c7cb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -43,8 +43,11 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupManagementAdminService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.apache.commons.lang.StringUtils; +import org.wso2.carbon.user.api.UserRealm; +import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; @@ -53,6 +56,7 @@ import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.ArrayList; +import java.util.Arrays; public class GroupManagementAdminServiceImpl implements GroupManagementAdminService { @@ -113,17 +117,19 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ request.setOwner(owner); request.setStatus(status); request.setDepth(depth); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + UserRealm realmService = DeviceMgtAPIUtils.getRealmService().getTenantUserRealm(tenantId); + String[] roles = realmService.getUserStoreManager().getRoleListOfUser(currentUser); boolean isAdmin = DEFAULT_ADMIN_ROLE.equals(currentUser); - + boolean hasAdminRole = Arrays.asList(roles).contains(DEFAULT_ADMIN_ROLE); PaginationResult deviceGroupsResult; - if (StringUtils.isBlank(currentUser) || isAdmin) { + if (StringUtils.isBlank(currentUser) || isAdmin || hasAdminRole) { deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() .getGroupsWithHierarchy(null, request, requireGroupProps); } else { deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() .getGroupsWithHierarchy(currentUser, request, requireGroupProps); } - DeviceGroupList deviceGroupList = new DeviceGroupList(); deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); @@ -132,6 +138,10 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ String error = "Error occurred while retrieving groups with hierarchy."; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); + } catch (UserStoreException e) { + String msg = "Error occurred while getting user realm."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } From 3dc567fcfec09465f5746f9534a8f214c23d4148 Mon Sep 17 00:00:00 2001 From: rajitha Date: Tue, 4 Jul 2023 18:37:39 +0530 Subject: [PATCH 107/343] Fix transaction initiating issue --- .../device/mgt/core/operation/mgt/OperationManagerImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index 92cf1818a7..223eb95564 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -472,6 +472,7 @@ public class OperationManagerImpl implements OperationManager { int failAttempts = 0; while (true) { try { + OperationManagementDAOFactory.beginTransaction(); operationMappingDAO.updateOperationMapping(operation.getId(), device.getEnrolmentInfo().getId(), io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.PushNotificationStatus.SCHEDULED); OperationManagementDAOFactory.commitTransaction(); @@ -494,6 +495,11 @@ public class OperationManagerImpl implements OperationManager { } catch (InterruptedException ignore) { break; } + } catch (TransactionManagementException ex) { + log.error("Error occurred while initiating the transaction", ex); + break; + } finally { + OperationManagementDAOFactory.closeConnection(); } } } catch (Exception e) { From a1ae369fe5d92c460d272905c549e5480f49ee0a Mon Sep 17 00:00:00 2001 From: rajitha Date: Wed, 5 Jul 2023 20:01:06 +0530 Subject: [PATCH 108/343] Fix realm service unbinding issues --- .../APIApplicationManagerExtensionDataHolder.java | 13 +++++++------ .../publisher/internal/APIPublisherDataHolder.java | 13 +++++++------ .../internal/JWTClientExtensionDataHolder.java | 13 +++++++------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index d6a3bb2fc5..e3bbebc4d0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -68,17 +68,18 @@ public class APIApplicationManagerExtensionDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public TenantManager getTenantManager() { + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); + } return tenantManager; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java index baff1848ed..bc7b8af32c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java @@ -75,17 +75,18 @@ public class APIPublisherDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public TenantManager getTenantManager() { + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); + } return tenantManager; } diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java index 7d253b2333..cd3999c9bf 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java @@ -74,17 +74,18 @@ public class JWTClientExtensionDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public TenantManager getTenantManager() { + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); + } return tenantManager; } } From b765c8ded32dfe5e2e4e80b0bb8807d2f563e395 Mon Sep 17 00:00:00 2001 From: Thilina Sandaruwan Date: Mon, 10 Jul 2023 07:46:21 +0000 Subject: [PATCH 109/343] Grouping Improvements (#169) Purpose After deleting a role, delete relevant records from DM_ROLE_GROUP_MAP table Related tickets: https://roadmap.entgra.net/issues/9528 and https://roadmap.entgra.net/issues/9529 Co-authored-by: ThilinaPremachandra Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/169 Co-authored-by: Thilina Sandaruwan Co-committed-by: Thilina Sandaruwan --- .../impl/GroupManagementServiceImpl.java | 4 +- .../impl/RoleManagementServiceImpl.java | 13 ++++-- .../GroupManagementAdminServiceImpl.java | 4 +- .../core/device/mgt/core/dao/GroupDAO.java | 9 ++++ .../core/dao/impl/AbstractGroupDAOImpl.java | 17 ++++++++ .../GroupManagementProviderService.java | 16 ++++++- .../GroupManagementProviderServiceImpl.java | 42 +++++++++++++++++-- 7 files changed, 93 insertions(+), 12 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index b4fb899ba8..98ca6249d0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -489,8 +489,8 @@ public class GroupManagementServiceImpl implements GroupManagementService { log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupAlreadyExistException e) { - String msg = "Group already exists with name : " + groups.getName() + "."; - log.warn(msg); + String msg = "Group already exists with name : " + groups.getName() + " Try with another group name."; + log.error(msg, e); return Response.status(Response.Status.CONFLICT).entity(msg).build(); } catch (RoleDoesNotExistException e) { return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 03a66c383e..44150409ad 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import org.apache.axis2.databinding.types.xsd._boolean; import org.json.simple.JSONObject; @@ -638,6 +639,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { @Consumes(MediaType.WILDCARD) @Override public Response deleteRole(@PathParam("roleName") String roleName, @QueryParam("user-store") String userStoreName) { + String roleToDelete = roleName; if (userStoreName != null && !userStoreName.isEmpty()) { roleName = userStoreName + "/" + roleName; } @@ -645,6 +647,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { try { final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm(); final UserStoreManager userStoreManager = userRealm.getUserStoreManager(); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); if (!userStoreManager.isExistingRole(roleName)) { String msg = "No role exists with the name : " + roleName ; return Response.status(404).entity(msg).build(); @@ -654,16 +657,18 @@ public class RoleManagementServiceImpl implements RoleManagementService { if (log.isDebugEnabled()) { log.debug("Deleting the role in user store"); } - userStoreManager.deleteRole(roleName); - // Delete all authorizations for the current role before deleting - authorizationManager.clearRoleAuthorization(roleName); - + DeviceMgtAPIUtils.getGroupManagementProviderService().deleteRoleAndRoleGroupMapping(roleName, roleToDelete, tenantId, userStoreManager, authorizationManager); return Response.status(Response.Status.OK).build(); } catch (UserStoreException e) { String msg = "Error occurred while deleting the role '" + roleName + "'"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } catch (GroupManagementException e) { + String msg = "Error occurred while deleting group-role mapping records"; + log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index 35be14c7cb..d7bf236acf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -199,8 +199,8 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupAlreadyExistException e) { - String msg = "Group already exists with name : " + group.getName() + "."; - log.warn(msg); + String msg = "Group already exists with name : " + group.getName() + " Try with another group name."; + log.error(msg, e); return Response.status(Response.Status.CONFLICT).entity(msg).build(); } catch (RoleDoesNotExistException e) { return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 777cdb922f..ac91b7036f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -155,6 +155,15 @@ public interface GroupDAO { */ void deleteGroupsMapping(List groupIds, int tenantId) throws GroupManagementDAOException; + /** + * Delete mappings of Device Groups. + * + * @param role of Device Groups. + * @param tenantId of the role. + * @throws GroupManagementDAOException on error during deletion of mappings of groups + */ + void deleteGroupsMapping(String role, int tenantId) throws GroupManagementDAOException; + /** * Delete existing Device Groups. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 9705c5772c..e1fc26eb8e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -541,6 +541,23 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } + @Override + public void deleteGroupsMapping(String role, int tenantId) throws GroupManagementDAOException { + + try { + Connection conn = GroupManagementDAOFactory.getConnection(); + String sql = "DELETE FROM DM_ROLE_GROUP_MAP WHERE ROLE = ? AND TENANT_ID = ?"; + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, role); + stmt.setInt(2, tenantId); + stmt.executeUpdate(); + } + } catch (SQLException e) { + String msg = "Error occurred while removing record from group-role mapping."; + log.error(msg); + throw new GroupManagementDAOException(msg, e); + } + } @Override public void deleteGroups(List groupIds, int tenantId) throws GroupManagementDAOException { try { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index b263ea1234..ef2338688f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -31,6 +31,8 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistEx import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import org.wso2.carbon.user.api.AuthorizationManager; +import org.wso2.carbon.user.api.UserStoreManager; import java.util.List; @@ -58,7 +60,7 @@ public interface GroupManagementProviderService { * @param defaultPermissions of the default role * @throws GroupManagementException */ - void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException, RoleDoesNotExistException; + void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupAlreadyExistException,GroupManagementException, RoleDoesNotExistException; /** * Update existing device group. @@ -80,6 +82,18 @@ public interface GroupManagementProviderService { */ boolean deleteGroup(int groupId, boolean isDeleteChildren) throws GroupManagementException; + /** + * Delete existing device group. + * + * @param role to be deleted with the userStore name. + * @param roleToDelete to delete the role. + * @param tenantId to belongs to roles. + * @param userStoreManager with details. + * @param authorizationManager with details. + * @throws GroupManagementException + */ + void deleteRoleAndRoleGroupMapping(String role, String roleToDelete, int tenantId, UserStoreManager userStoreManager, AuthorizationManager authorizationManager) throws GroupManagementException; + /** * Get the device group provided the device group id. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 9b5ab0e5ae..3e03301769 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -49,10 +49,12 @@ import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.netbeans.lib.cvsclient.commandLine.command.status; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; +import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import org.wso2.carbon.user.api.AuthorizationManager; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; @@ -148,7 +150,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupManagementException { + public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupAlreadyExistException, GroupManagementException { if (groups == null) { String msg = "Received incomplete data for createGroup"; log.error(msg); @@ -181,7 +183,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } GroupManagementDAOFactory.commitTransaction(); } else { - throw new GroupManagementException("Group exist with name " + groups.getName()); + throw new GroupAlreadyExistException("Group already exists with name : " + groups.getName() + " Try with another group name."); } } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); @@ -359,6 +361,40 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } + /** + * {@inheritDoc} + */ + @Override + public void deleteRoleAndRoleGroupMapping(String roleName, String roleToDelete, int tenantId, UserStoreManager userStoreManager, AuthorizationManager authorizationManager) throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Delete roles"); + } + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.deleteGroupsMapping(roleToDelete, tenantId); + userStoreManager.deleteRole(roleName); + // Delete all authorizations for the current role before deleting + authorizationManager.clearRoleAuthorization(roleName); + GroupManagementDAOFactory.commitTransaction(); + } catch (UserStoreException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while deleting the role '" + roleName + "'"; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while deleting the role"; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + /** * {@inheritDoc} */ From 087a9fe72808fc57b138cdeb78a8d17ec523ae58 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 11 Jul 2023 11:43:26 +0530 Subject: [PATCH 110/343] Fix dependency importing issue --- .../pom.xml | 4 +++ .../service/api/GroupManagementService.java | 25 +++++++++++++------ .../pom.xml | 4 +++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index f9931aae6c..fde1c89087 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -411,6 +411,10 @@ org.wso2.carbon.ntask.core provided + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.notification.logger + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java index be792d22c1..33d46f139b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java @@ -33,6 +33,17 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Info; +import io.swagger.annotations.ResponseHeader; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Tag; import javax.validation.Valid; import javax.ws.rs.*; @@ -1286,11 +1297,11 @@ public interface GroupManagementService { "Server error occurred while creating the group or adding devices or sharing the group.", response = ErrorResponse.class) }) - Response createGroupWithRoles(@ApiParam( - name = "group", - value = "Define the group object with data.", - required = true) - @Valid DeviceGroupRoleWrapper group - ); - + Response createGroupWithRoles( + @ApiParam( + name = "group", + value = "Define the group object with data.", + required = true) + @Valid DeviceGroupRoleWrapper group + ); } diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index cd75cd10c5..f93f462924 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -283,6 +283,10 @@ org.wso2.orbit.javax.xml.bind jaxb-api + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.notification.logger + From ef2838414a1827ebea19f485561fb8dca9c33a7b Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 11 Jul 2023 12:13:53 +0530 Subject: [PATCH 111/343] Fix build failure --- .../device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 27617e89ae..0c2e5663fe 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -364,7 +364,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index b97dba2a91..26f6603912 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -473,7 +473,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 org.wso2.carbon.multitenancy diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 585aeafeaa..c12f494f37 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -78,7 +78,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test From dc6bbdd282d7653df302c570f45957be50f7c6ba Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 12 Jul 2023 00:05:02 +0530 Subject: [PATCH 112/343] Improve functionality and fix formatting issues --- .../mgt/core/impl/ApplicationManagerImpl.java | 6 +++--- .../mgt/core/impl/SubscriptionManagerImpl.java | 12 +++++++++++- .../core/application/mgt/core/util/Constants.java | 3 +++ .../service/impl/RoleManagementServiceImpl.java | 12 ++++++++++-- .../mgt/core/operation/mgt/OperationManagerImpl.java | 9 ++++++++- .../service/DeviceManagementProviderServiceImpl.java | 10 +++++++++- .../service/GroupManagementProviderServiceImpl.java | 2 +- 7 files changed, 45 insertions(+), 9 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index fba517f148..6b4d590fa8 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -1250,7 +1250,7 @@ public class ApplicationManagerImpl implements ApplicationManager { this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger); } } - if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { + if (Constants.ENTERPRISE_APP_TYPE.equals(applicationDTO.getType()) || Constants.PUBLIC_APP_TYPE.equals(applicationDTO.getType())) { persistAppIconInfo(applicationReleaseDTO); } applicationReleaseEntities.add(applicationReleaseDTO); @@ -1690,8 +1690,8 @@ public class ApplicationManagerImpl implements ApplicationManager { List allMetadata; allMetadata = APIUtil.getMetadataManagementService().retrieveAllMetadata(); if (allMetadata != null && !allMetadata.isEmpty()) { - for(Metadata metadata : allMetadata){ - if(Constants.SHOW_ALL_ROLES.equals(metadata.getMetaKey())){ + for (Metadata metadata : allMetadata) { + if (Constants.SHOW_ALL_ROLES.equals(metadata.getMetaKey())) { String metaValue = metadata.getMetaValue(); if (metaValue != null) { JSONObject jsonObject; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 92c1a93f18..5fdbbfaca1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -684,7 +684,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action, properties); activityList.add(activity); for (DeviceIdentifier identifier : deviceIdentifiers) { - log.info(String.format("App %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build()); + log.info(String.format("App %s triggered", action), appInstallLogContextBuilder + .setAppId(String.valueOf(applicationDTO.getId())) + .setAppName(applicationDTO.getName()) + .setAppType(applicationDTO.getType()) + .setSubType(subType) + .setTenantId(tenantId) + .setTenantDomain(tenantDomain) + .setDevice(String.valueOf(identifier)) + .setUserName(username) + .setAction(action) + .build()); } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java index efd848cdb1..c3e7c49160 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java @@ -94,6 +94,9 @@ public class Constants { public static final String MSI = "MSI"; public static final String APPX = "APPX"; + public static final String ENTERPRISE_APP_TYPE = "ENTERPRISE"; + public static final String PUBLIC_APP_TYPE = "ENTERPRISE"; + private static final Map AGENT_DATA = new HashMap<>(); static { AGENT_DATA.put("android", "android-agent.apk"); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 44150409ad..5c04516650 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import com.google.common.base.Strings; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; @@ -35,6 +36,7 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.SetReferenceTransformer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.util.StringUtils; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; @@ -57,6 +59,12 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URLEncoder; import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; import static io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants.PRIMARY_USER_STORE; @@ -120,7 +128,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { if (limit == 0){ limit = Constants.DEFAULT_PAGE_LIMIT; } - if (domain != null && !domain.isEmpty()) { + if (!Strings.isNullOrEmpty(domain)) { username = domain + '/' + username; } Metadata metadata; @@ -133,7 +141,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { JSONObject jsonObject = (JSONObject) parser.parse(metaValue); boolean decision = (boolean) jsonObject.get(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); if (decision) { - if (userStore == null || "".equals(userStore)){ + if (Strings.isNullOrEmpty(userStore)){ userStore = PRIMARY_USER_STORE; } try { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index 223eb95564..e752475939 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -721,7 +721,14 @@ public class OperationManagerImpl implements OperationManager { DeviceCacheManagerImpl.getInstance().removeDeviceFromCache(deviceId, tenantId); break; } - log.info("Device Connected", deviceConnectivityLogContextBuilder.setDeviceId(deviceId.getId()).setDeviceType(deviceId.getType()).setActionTag("PENDING_OPERATION").setTenantDomain(tenantDomain).setTenantId(String.valueOf(tenantId)).setUserName(userName).build()); + log.info("Device Connected", deviceConnectivityLogContextBuilder + .setDeviceId(deviceId.getId()) + .setDeviceType(deviceId.getType()) + .setActionTag("PENDING_OPERATION") + .setTenantDomain(tenantDomain) + .setTenantId(String.valueOf(tenantId)) + .setUserName(userName) + .build()); return getOperations(deviceId, Operation.Status.PENDING, enrolmentId); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 31b77ebef3..eb1a60c48c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -331,7 +331,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + "'"); } - log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(existingDevice.getId())).setDeviceType(String.valueOf(existingDevice.getType())).setOwner(newEnrolmentInfo.getOwner()).setOwnership(String.valueOf(newEnrolmentInfo.getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); + log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder + .setDeviceId(String.valueOf(existingDevice.getId())) + .setDeviceType(String.valueOf(existingDevice.getType())) + .setOwner(newEnrolmentInfo.getOwner()) + .setOwnership(String.valueOf(newEnrolmentInfo.getOwnership())) + .setTenantID(String.valueOf(tenantId)) + .setTenantDomain(tenantDomain) + .setUserName(userName) + .build()); status = true; } else { log.warn("Unable to update device enrollment for device : " + device.getDeviceIdentifier() + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 3e03301769..a35d4d74bb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -314,7 +314,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid newParentPath = DeviceGroupConstants.HierarchicalGroup.SEPERATOR; } childrenGroup.setParentPath(newParentPath); - if (!newParentPath.equals(DeviceGroupConstants.HierarchicalGroup.SEPERATOR)) { + if (!DeviceGroupConstants.HierarchicalGroup.SEPERATOR.equals(newParentPath)) { String[] groupIds = newParentPath.split(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); int latestGroupId = Integer.parseInt(groupIds[groupIds.length - 1]); childrenGroup.setParentGroupId(latestGroupId); From 8b967cee4c8709c8b2a287a940293ddf8d1f635d Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Tue, 11 Jul 2023 15:53:09 +0530 Subject: [PATCH 113/343] Add missing ios scopes in mdm-ui-config --- .../src/main/resources/conf/mdm-ui-config.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 809c856038..b16935562d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -227,6 +227,19 @@ perm:android:clear-application perm:android:suspend-package perm:android:alternate-install + perm:ios:lock + perm:ios:location + perm:ios:ring + perm:ios:clear-passcode + perm:ios:enterprise-wipe + perm:ios:notification + perm:ios:wipe-data + perm:ios:boolean-setting + perm:ios:wallpaper + perm:ios:app-attributes + perm:ios:app-configurations + perm:mac-os:restart + perm:mac-os:shut-down device-mgt From f72166895f47811352f333f7077fea050761d141 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Tue, 11 Jul 2023 23:08:33 +0530 Subject: [PATCH 114/343] Fix class not found error in analytics component --- .../api/impl/GrafanaAPIProxyServiceImpl.java | 5 +- .../api/impl/util/GrafanaMgtAPIUtils.java | 52 +++++++++++++++++++ .../pom.xml | 2 +- 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java index 6121f78ddd..23128fc527 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java @@ -22,6 +22,7 @@ import com.google.gson.JsonObject; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.GrafanaAPIProxyService; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.bean.ErrorResponse; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.exception.RefererNotValid; +import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util.GrafanaMgtAPIUtils; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util.GrafanaRequestHandlerUtil; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception.GrafanaManagementException; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean.GrafanaPanelIdentifier; @@ -49,8 +50,8 @@ public class GrafanaAPIProxyServiceImpl implements GrafanaAPIProxyService { public Response queryDatasource(JsonObject body, @Context HttpHeaders headers, @Context UriInfo requestUriInfo) { try { GrafanaPanelIdentifier panelIdentifier = GrafanaRequestHandlerUtil.getPanelIdentifier(headers); - GrafanaMgtDataHolder.getInstance().getGrafanaQueryService(). - buildSafeQuery(body, panelIdentifier.getDashboardId(), panelIdentifier.getPanelId(), requestUriInfo.getRequestUri()); + GrafanaMgtAPIUtils.getGrafanaQueryService().buildSafeQuery(body, panelIdentifier.getDashboardId(), + panelIdentifier.getPanelId(), requestUriInfo.getRequestUri()); return GrafanaRequestHandlerUtil.proxyPassPostRequest(body, requestUriInfo, panelIdentifier.getOrgId()); } catch (MaliciousQueryAttempt e) { return Response.status(Response.Status.BAD_REQUEST).entity( diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java new file mode 100644 index 0000000000..07a4293b49 --- /dev/null +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 - 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.analytics.mgt.grafana.proxy.api.impl.util; + +import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.service.GrafanaQueryService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +public class GrafanaMgtAPIUtils { + + private static final Log log = LogFactory.getLog(GrafanaMgtAPIUtils.class); + private static volatile GrafanaQueryService grafanaQueryService; + + /** + * Accessing GrafanaQueryService from OSGI service context + * @return GrafanaQueryService instance + */ + public static GrafanaQueryService getGrafanaQueryService() { + if (grafanaQueryService == null) { + synchronized (GrafanaMgtAPIUtils.class) { + if (grafanaQueryService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + grafanaQueryService = + (GrafanaQueryService) ctx.getOSGiService(GrafanaQueryService.class, null); + if (grafanaQueryService == null) { + String msg = "Grafana Query service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + } + } + return grafanaQueryService; + } +} diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index d16b2ad8c9..fcf8b4bf98 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -124,7 +124,7 @@ org.wso2.carbon.utils;version="[4.8,5)" - !io.entgra.device.mgt.core.transport.mgt.email.sender.core.internal, + !io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.internal, io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.* From f2243ebd0e9de22c5d8d6be2bcb50fc076168d0f Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 12 Jul 2023 00:39:31 +0530 Subject: [PATCH 115/343] Fix formatting issue --- .../mgt/core/impl/SubscriptionManagerImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 5fdbbfaca1..e4bfe93d46 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -677,7 +677,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager { entry.getKey(), action, properties); activityList.add(activity); for (DeviceIdentifier identifier : deviceIdentifiers) { - log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder.setAppId(String.valueOf(applicationDTO.getId())).setAppName(applicationDTO.getName()).setAppType(applicationDTO.getType()).setSubType(subType).setTenantId(tenantId).setTenantDomain(tenantDomain).setDevice(String.valueOf(identifier)).setUserName(username).setAction(action).build()); + log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder + .setAppId(String.valueOf(applicationDTO.getId())) + .setAppName(applicationDTO.getName()) + .setAppType(applicationDTO.getType()) + .setSubType(subType) + .setTenantId(tenantId) + .setTenantDomain(tenantDomain) + .setDevice(String.valueOf(identifier)) + .setUserName(username) + .setAction(action) + .build()); } } } else { From ac3e144437d76a12dedb4c81ba5bb019a854e5a2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 13 Jul 2023 07:54:34 +0530 Subject: [PATCH 116/343] Fix OSGI service unbinding issue --- .../internal/DeviceManagementDataHolder.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java index a901ffeddf..3fa8fdc453 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -118,18 +118,18 @@ public class DeviceManagementDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } public TenantManager getTenantManager() { - return tenantManager; - } - - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); } - this.tenantManager = realmService.getTenantManager(); + return tenantManager; } + + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public DeviceManagementProviderService getDeviceManagementProvider() { From b7f077e63983b2c0a88cab3e502dc18ddcd06e80 Mon Sep 17 00:00:00 2001 From: Pasindu Rupasinghe Date: Thu, 1 Jun 2023 09:50:58 +0000 Subject: [PATCH 117/343] Implement service for consumer rest APIs Co-authored-by: Pasindu Rupasinghe Co-committed-by: Pasindu Rupasinghe --- .../apimgt/extension/rest/api/ConsumerRESTAPIServices.java | 2 ++ .../extension/rest/api/ConsumerRESTAPIServicesImpl.java | 4 ++++ 2 files changed, 6 insertions(+) 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index 5ed98034e2..7fddca04f2 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -23,6 +23,8 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; 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.bean.APIMConsumer.Application; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; import java.util.List; import java.util.Map; 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index 293894ee71..a85c611f99 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -24,6 +24,10 @@ 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.dto.ApiApplicationInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; 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; From 958f4e43d6c73efd824a9ba562e7200eacb23278 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Thu, 1 Jun 2023 17:13:51 +0530 Subject: [PATCH 118/343] Add Consumer REST API integration --- .../pom.xml | 8 ++++++ ...ApplicationManagerExtensionDataHolder.java | 6 ++++ ...ationManagerExtensionServiceComponent.java | 28 +++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 9ace7f0c33..f62fd9c2ee 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -143,6 +143,14 @@ org.wso2.carbon.apimgt.impl;version="[9.28,10)", org.wso2.carbon.apimgt.impl.utils;version="[9.28,10)", org.wso2.carbon.context;version="[4.8,5)", + 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.context;version="${carbon.kernel.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension, + io.entgra.device.mgt.core.identity.jwt.client.extension.dto, + io.entgra.device.mgt.core.identity.jwt.client.extension.exception, + io.entgra.device.mgt.core.identity.jwt.client.extension.service, + io.entgra.device.mgt.core.apimgt.extension.rest.api, org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", org.wso2.carbon.registry.core.service;version="[1.0,2)", org.wso2.carbon.registry.indexing.service;version="[4.8,5)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index e3bbebc4d0..c8608b4fc8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -39,8 +39,11 @@ public class APIApplicationManagerExtensionDataHolder { private TenantIndexingLoader indexLoader; private JWTClientManagerService jwtClientManagerService; private ConsumerRESTAPIServices consumerRESTAPIServices; +<<<<<<< HEAD private APIApplicationServices apiApplicationServices; private MetadataManagementService metadataManagementService; +======= +>>>>>>> 9fc055cd4f (Add Consumer REST API integration) private APIApplicationManagerExtensionDataHolder() { } @@ -118,6 +121,7 @@ public class APIApplicationManagerExtensionDataHolder { public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { this.consumerRESTAPIServices = consumerRESTAPIServices; } +<<<<<<< HEAD public APIApplicationServices getApiApplicationServices() { return apiApplicationServices; @@ -134,4 +138,6 @@ public class APIApplicationManagerExtensionDataHolder { public void setMetadataManagementService(MetadataManagementService metadataManagementService) { this.metadataManagementService = metadataManagementService; } +======= +>>>>>>> 9fc055cd4f (Add Consumer REST API integration) } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index b3dc6dbd9d..78e0867d78 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -34,6 +34,34 @@ import org.wso2.carbon.user.core.service.RealmService; @Component( name = "io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionServiceComponent", immediate = true) +/** + * @scr.component name="io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionServiceComponent" + * @scr.reference name="tenant.registryloader" + * interface="org.wso2.carbon.registry.core.service.TenantRegistryLoader" + * cardinality="1..1" + * policy="dynamic" + * bind="setTenantRegistryLoader" + * unbind="unsetTenantRegistryLoader" + * @scr.reference name="tenant.indexloader" + * interface="org.wso2.carbon.registry.indexing.service.TenantIndexingLoader" + * cardinality="1..1" + * policy="dynamic" + * bind="setIndexLoader" + * unbind="unsetIndexLoader" + * @scr.reference name="realm.service" + * immediate="true" + * interface="org.wso2.carbon.user.core.service.RealmService" + * cardinality="1..1" + * policy="dynamic" + * bind="setRealmService" + * unbind="unsetRealmService" + * @scr.reference name="io.entgra.device.mgt.core.apimgt.extension.rest.api" + * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" + * cardinality="0..1" + * policy="dynamic" + * bind="setConsumerRESTAPIServices" + * unbind="unsetConsumerRESTAPIServices" + */ public class APIApplicationManagerExtensionServiceComponent { private static final Log log = LogFactory.getLog(APIApplicationManagerExtensionServiceComponent.class); From 29a8dd5fdee5f547a3c1e11e09f80de75b1d27d2 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 6 Jun 2023 11:17:29 +0530 Subject: [PATCH 119/343] Add API app registering refactored code --- .../APIManagementProviderServiceImpl.java | 35 +++++++++++++++++++ ...ApplicationManagerExtensionDataHolder.java | 7 ---- ...ationManagerExtensionServiceComponent.java | 8 ++++- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 0808f11963..67a6f21f16 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -41,6 +41,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.App import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.RegistrationProfile; 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; @@ -119,6 +120,40 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, isAllowedAllDomains, validityTime, tokenInfo); } + @Override + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], + String keyType, String username, + boolean isAllowedAllDomains, + String validityTime, String password) throws APIManagerException { + + + ConsumerRESTAPIServices consumerRESTAPIServices = + APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + + + /* + + */ + + try { + consumerRESTAPIServices.getAllApplications(null, null, null); + } catch (APIServicesException e) { + e.printStackTrace(); + } catch (BadRequestException e) { + e.printStackTrace(); + } catch (UnexpectedResponseException e) { + e.printStackTrace(); + } + + return null; + + + } + + + /** + * {@inheritDoc} + */ @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index c8608b4fc8..978a46c13a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -39,12 +39,8 @@ public class APIApplicationManagerExtensionDataHolder { private TenantIndexingLoader indexLoader; private JWTClientManagerService jwtClientManagerService; private ConsumerRESTAPIServices consumerRESTAPIServices; -<<<<<<< HEAD private APIApplicationServices apiApplicationServices; private MetadataManagementService metadataManagementService; -======= ->>>>>>> 9fc055cd4f (Add Consumer REST API integration) - private APIApplicationManagerExtensionDataHolder() { } @@ -121,7 +117,6 @@ public class APIApplicationManagerExtensionDataHolder { public void setConsumerRESTAPIServices(ConsumerRESTAPIServices consumerRESTAPIServices) { this.consumerRESTAPIServices = consumerRESTAPIServices; } -<<<<<<< HEAD public APIApplicationServices getApiApplicationServices() { return apiApplicationServices; @@ -138,6 +133,4 @@ public class APIApplicationManagerExtensionDataHolder { public void setMetadataManagementService(MetadataManagementService metadataManagementService) { this.metadataManagementService = metadataManagementService; } -======= ->>>>>>> 9fc055cd4f (Add Consumer REST API integration) } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index 78e0867d78..ffb576295d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -55,12 +55,18 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setRealmService" * unbind="unsetRealmService" - * @scr.reference name="io.entgra.device.mgt.core.apimgt.extension.rest.api" + * @scr.reference name="apimgt.extension.ConsumerRESTAPIServices" * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" * cardinality="0..1" * policy="dynamic" * bind="setConsumerRESTAPIServices" * unbind="unsetConsumerRESTAPIServices" + * @scr.reference name="apimgt.extension.APIApplicationService" + * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices" + * cardinality="0..1" + * policy="dynamic" + * bind="setAPIApplicationServices" + * unbind="unsetAPIApplicationServices" */ public class APIApplicationManagerExtensionServiceComponent { From 52fd8c4b893beb686573130124c524b0f2ce63a1 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 6 Jun 2023 17:03:33 +0530 Subject: [PATCH 120/343] Add Application key generating logic --- .../APIManagementProviderServiceImpl.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 67a6f21f16..238042dc24 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -126,17 +126,36 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isAllowedAllDomains, String validityTime, String password) throws APIManagerException { + APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance().getApiApplicationServices(); ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - - /* - - */ - try { - consumerRESTAPIServices.getAllApplications(null, null, null); + consumerRESTAPIServices.getAllApplications(null, null, applicationName); + + List uniqueApiList = new ArrayList(); + + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); + + for (String tag: tags) { + Map queryParams = new HashMap<>(); + queryParams.put("tag", tag); + if ("carbon.super".equals(tenantDomain)) { + consumerRESTAPIServices.getAllApis(null, null, queryParams); + } else { + //call All API getting call with carbon super header param + } + + uniqueApiList.add("Test"); + Set taggedAPISet = new HashSet<>(uniqueApiList); + uniqueApiList.clear(); + uniqueApiList.addAll(taggedAPISet); + } + + consumerRESTAPIServices.getAllSubscriptions(null, null, "1"); + + } catch (APIServicesException e) { e.printStackTrace(); } catch (BadRequestException e) { From da4f3f14563768fc75a27e9c7ac8e463e5cda21a Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 7 Jun 2023 20:58:48 +0530 Subject: [PATCH 121/343] Add API integration --- .../APIManagementProviderServiceImpl.java | 61 +++++++++++++++++-- .../api/bean/APIMConsumer/Subscription.java | 2 - 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 238042dc24..f57c2fadc6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -132,28 +132,77 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); try { - consumerRESTAPIServices.getAllApplications(null, null, applicationName); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = + consumerRESTAPIServices.getAllApplications(null, null, applicationName); - List uniqueApiList = new ArrayList(); + List uniqueApiList = new ArrayList<>(); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); - for (String tag: tags) { + for (String tag : tags) { Map queryParams = new HashMap<>(); queryParams.put("tag", tag); if ("carbon.super".equals(tenantDomain)) { consumerRESTAPIServices.getAllApis(null, null, queryParams); } else { //call All API getting call with carbon super header param + APIInfo[] apiInfos; + if (!"carbon.super".equals(tenantDomain)) { + headerParams.put("X-WSO2-Tenant", "carbon.super"); } + apiInfos = consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); - uniqueApiList.add("Test"); - Set taggedAPISet = new HashSet<>(uniqueApiList); + uniqueApiList.addAll(List.of(apiInfos)); + Set taggedAPISet = new HashSet<>(uniqueApiList); uniqueApiList.clear(); uniqueApiList.addAll(taggedAPISet); } - consumerRESTAPIServices.getAllSubscriptions(null, null, "1"); + if (applications.length == 0) { + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = + new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); + + application.setName(applicationName); + application = consumerRESTAPIServices.createApplication(null, null, application); + List subscriptions = new ArrayList<>(); + for (APIInfo apiInfo : uniqueApiList) { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.getApplicationId()); + subscriptions.add(subscription); + } + consumerRESTAPIServices.createSubscriptions(null, null, subscriptions); + } else { + if (applications.length == 1) { + Optional application = + Arrays.stream(applications).findFirst(); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, null, + application.get().getApplicationId()); + for (Subscription subscription : subscriptions) { + if (uniqueApiList.contains(subscription.getApiInfo())) { + uniqueApiList.remove(subscription.getApiInfo()); + } else { + uniqueApiList.add(subscription.getApiInfo()); + } + } + + + //duplicate code block + List subscriptionList = new ArrayList<>(); + for (APIInfo apiInfo : uniqueApiList) { + Subscription subscription = new Subscription(); + subscription.setApiId(apiInfo.getId()); + subscription.setApplicationId(application.get().getApplicationId()); + subscriptionList.add(subscription); + } + consumerRESTAPIServices.createSubscriptions(null, null, subscriptionList); + } else { + String msg = "Found more than one application for application name: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + + } } catch (APIServicesException e) { 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java index 2ff525f5dc..11fc881c1b 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java @@ -18,8 +18,6 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; -import org.json.JSONObject; - public class Subscription { private String subscriptionId; From 2125519aa6c7e69009f3102953872b15815a5670 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Sat, 10 Jun 2023 11:43:27 +0530 Subject: [PATCH 122/343] Add todo Comments --- .../extension/APIManagementProviderServiceImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index f57c2fadc6..5df0e841d8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -242,9 +242,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isAllowedAllDomains, String validityTime, TokenInfo tokenInfo) throws APIManagerException { + ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); + ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); try { List uniqueApiList = new ArrayList<>(); @@ -311,6 +313,16 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } } + + if (isNewApplication) { + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); + apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); + apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); + return apiApplicationKey; + } else { + return null; + } } catch (APIServicesException e) { String msg = "Error occurred while processing the response of APIM REST endpoints."; log.error(msg, e); From 8880ef99db4851afb466e878b5b20470a507663a Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Mon, 12 Jun 2023 16:27:38 +0530 Subject: [PATCH 123/343] Improve APIM application key generate method --- .../APIManagementProviderServiceImpl.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 5df0e841d8..3f509b4c36 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -48,6 +48,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.Unexpected import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.eclipse.jetty.http.MetaData; import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; @@ -314,13 +315,47 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } } + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (isNewApplication) { ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - return apiApplicationKey; + + Metadata metaData = new Metadata(); + metaData.setMetaKey(applicationName); + String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); + metaData.setMetaValue(metaValue); + try { + metadataManagementService.createMetadata(metaData); + return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } catch (MetadataKeyAlreadyExistsException e) { + String msg = "Found duplicate meta value entry for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } } else { + try { + Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); + if (metaData == null) { + String msg = + "Couldn't find application key data from meta data mgt service. Meta key: " + applicationName; + log.error(msg); + throw new APIManagerException(msg); + } + String[] metaValues = metaData.getMetaValue().split(":"); + String applicationId = metaValues[0]; + String keyMappingId = metaValues[1]; + //todo call the API key retrieving call, return apiApplicationKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while getting meta data for meta key: " + applicationName; + log.error(msg, e); + throw new APIManagerException(msg, e); + } return null; } } catch (APIServicesException e) { From 83780c6a0c1075a3b26ba862de58c825a1b4e0b9 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 20 Jun 2023 09:39:49 +0530 Subject: [PATCH 124/343] Add improvements to APIM application creating logic --- .../application/extension/APIManagementProviderServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3f509b4c36..f57d7db079 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -53,6 +53,7 @@ import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; +import org.wso2.carbon.apimgt.api.model.*; import org.wso2.carbon.apimgt.api.model.API; import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; From 8ea49320196101f01af045abde085b63267404e4 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 13 Jul 2023 12:20:48 +0530 Subject: [PATCH 125/343] Fixes in JWT token generation --- .../APIManagementProviderServiceImpl.java | 9 +++++-- .../rest/api/APIApplicationServices.java | 5 ++-- .../rest/api/APIApplicationServicesImpl.java | 12 ++++----- .../rest/api/constants/Constants.java | 2 -- .../extension/service/KeyMgtServiceImpl.java | 2 +- .../publisher/APIPublisherServiceImpl.java | 10 +++++-- .../impl/DeviceManagementServiceImpl.java | 27 ++++++++++++------- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 21 +++++++++++++++ 8 files changed, 64 insertions(+), 24 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index f57d7db079..b4a1f11e14 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -800,9 +800,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; try { if (username == null || password == null) { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForConsumerRestCalls", + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); } else { - apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); + apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys( + "ClientForConsumerRestCalls", + username, password, + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); } accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); 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/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 index 1cdceff56a..f5cc8b3ec1 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/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 @@ -24,9 +24,10 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIService public interface APIApplicationServices { - APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; + APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) + throws APIServicesException; - APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) + APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; 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 9dbd5f52cc..a03f81d086 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 @@ -44,7 +44,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { getAPIManagerConfigurationService().getAPIManagerConfiguration(); @Override - public APIApplicationKey createAndRetrieveApplicationCredentials() + public APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); @@ -53,8 +53,8 @@ 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("clientName", clientName); + jsonObject.put("grantType", grantType); jsonObject.put("owner", serverUser); jsonObject.put("saasApp", true); @@ -75,15 +75,15 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) + public APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName", username); - jsonObject.put("grantType", Constants.GRANT_TYPE); + jsonObject.put("clientName", clientName); + jsonObject.put("grantType", grantType); jsonObject.put("owner", username); jsonObject.put("saasApp", true); 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 6c3cf21c89..6ca26f74f0 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 @@ -27,10 +27,8 @@ public final class Constants { public static final String AMPERSAND = "&"; public static final String SLASH = "/"; public static final String EQUAL = "="; - public static final String CLIENT_NAME = "rest_api_publisher_code"; public static final String SERVER_USER = "WorkflowConfigurations.ServerUser"; 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"; public static final String OAUTH_TOKEN_SCOPE = "scope"; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 69f51fff56..63e42132f0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -344,7 +344,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { Response response = client.newCall(request).execute(); return gson.fromJson(response.body().string(), OAuthApplication.class); } catch (IOException e) { - msg = "Error occurred while processing the response"; + msg = "Error occurred while processing the response" + e; throw new KeyMgtException(msg); } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index fe98a8cef8..e188ae799b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -90,7 +90,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForPublisherRestCalls", + "client_credentials password refresh_token" + ); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { @@ -403,7 +406,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForPublisherRestCalls", + "client_credentials password refresh_token" + ); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 09be7963fd..67042ede8b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -23,6 +23,11 @@ import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProvi import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; +import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; +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.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; @@ -804,11 +809,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { //todo - lasantha - can't get password from here ApiApplicationKey apiApplicationKey; try { - DCRResponse adminDCRResponse = keyMgtService.dynamicClientRegistration(applicationName, - PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName(), - "client_credentials", null, new String[] {"device_management"}, false, validityTime, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword()); + + APIApplicationServices apiApplicationServices = DeviceMgtAPIUtils.getApiApplicationServices(); + APIApplicationKey adminDCRResponse = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForJWTTokenGeneration", + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer" + ); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); JWTClientManagerService jwtClientManagerService = (JWTClientManagerService) ctx. @@ -816,11 +822,14 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { JWTClient jwtClient = jwtClientManagerService.getJWTClient(); AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(adminDCRResponse.getClientId(), adminDCRResponse.getClientSecret(), - username, "appm:subscribe"); + username, "appm:subscribe apim:admin apim:api_key apim:app_import_export apim:app_manage" + + " apim:store_settings apim:sub_alert_manage apim:sub_manage apim:subscribe openid perm:device:enroll " + + "perm:devices:details perm:devices:features perm:devices:search perm:devices:view perm:groups:groups " + + "perm:users:send-invitation"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, - new String[] {"device_management"}, null, false, String.valueOf(validityTime), + new String[] {"device_management"}, "PRODUCTION", false, String.valueOf(validityTime), accessTokenInfo.getAccessToken()); } catch (JWTClientException e) { @@ -828,8 +837,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } catch (UserStoreException e) { - String msg = "Error while getting user credentials."; + } catch (APIServicesException e) { + String msg = "Error while generating api Application"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index a297bffd48..f1a5db1156 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; @@ -157,6 +158,7 @@ public class DeviceMgtAPIUtils { private static volatile SubscriptionManager subscriptionManager; private static volatile ApplicationManager applicationManager; private static volatile ConsumerRESTAPIServices consumerRESTAPIServices; + private static volatile APIApplicationServices apiApplicationServices; private static volatile APIManagementProviderService apiManagementProviderService; static { @@ -410,6 +412,25 @@ public class DeviceMgtAPIUtils { return consumerRESTAPIServices; } + /** + * Initializing and accessing method for APIM API application REST API. + * + * @return APIApplicationServices instance + * @throws IllegalStateException if APIApplicationServices cannot be initialized + */ + public static synchronized APIApplicationServices getApiApplicationServices() { + if (apiApplicationServices == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + apiApplicationServices = (APIApplicationServices) ctx.getOSGiService(APIApplicationServices.class, null); + if (apiApplicationServices == null) { + String msg = "API application service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + return apiApplicationServices; + } + /** * Initializing and accessing method for API management Provider Service. * From 8215186061bf218455696af408152092ec43cc94 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 26 Jul 2023 07:29:08 +0530 Subject: [PATCH 126/343] Revert "Fixes in JWT token generation and sync with upstream apim420 branch" This reverts commit d567209c11918bb6f2762629da78a50dcb335ee0, reversing changes made to 437c0e642d7e6dc009310640c68813d5c58679da. --- .../pom.xml | 4 +- .../api/impl/GrafanaAPIProxyServiceImpl.java | 5 +- .../api/impl/util/GrafanaMgtAPIUtils.java | 52 -- .../pom.xml | 2 +- .../pom.xml | 4 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 10 +- .../APIManagementProviderServiceImpl.java | 160 +---- ...ApplicationManagerExtensionDataHolder.java | 14 +- ...ationManagerExtensionServiceComponent.java | 34 - .../pom.xml | 2 +- .../rest/api/APIApplicationServices.java | 5 +- .../rest/api/APIApplicationServicesImpl.java | 12 +- .../rest/api/ConsumerRESTAPIServices.java | 2 - .../rest/api/ConsumerRESTAPIServicesImpl.java | 4 - .../api/bean/APIMConsumer/Subscription.java | 2 + .../rest/api/constants/Constants.java | 2 + .../pom.xml | 2 +- .../pom.xml | 2 +- .../extension/service/KeyMgtServiceImpl.java | 2 +- .../pom.xml | 4 +- .../publisher/APIPublisherServiceImpl.java | 10 +- .../internal/APIPublisherDataHolder.java | 13 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../common/services/ApplicationManager.java | 5 - .../pom.xml | 13 +- .../mgt/core/impl/ApplicationManagerImpl.java | 63 +- .../core/impl/SubscriptionManagerImpl.java | 38 +- .../application/mgt/core/util/APIUtil.java | 21 +- .../application/mgt/core/util/Constants.java | 6 +- .../user-test/user-mgt-registry-test.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 11 +- .../mgt/core/bean/Certificate.java | 9 - .../mgt/core/dao/CertificateDAO.java | 21 - .../dao/impl/AbstractCertificateDAOImpl.java | 70 -- .../mgt/core/impl/CertificateGenerator.java | 106 +-- .../mgt/core/impl/KeyStoreReader.java | 37 - .../src/test/resources/data-source-config.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 22 +- .../pom.xml | 36 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 31 +- .../src/test/resources/conf/carbon.xml | 658 ++++++++++++++++++ .../test/resources/repository/conf/carbon.xml | 0 .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 4 +- .../service/api/GroupManagementService.java | 98 --- .../service/api/RoleManagementService.java | 98 --- .../admin/GroupManagementAdminService.java | 85 +-- .../impl/DeviceManagementServiceImpl.java | 27 +- .../impl/GroupManagementServiceImpl.java | 85 +-- .../impl/RoleManagementServiceImpl.java | 119 +--- .../impl/UserManagementServiceImpl.java | 10 - .../GroupManagementAdminServiceImpl.java | 67 +- .../device/mgt/api/jaxrs/util/Constants.java | 5 +- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 21 - .../pom.xml | 2 +- .../mgt/common/DeviceManagementConstants.java | 2 - .../common/general/QREnrollmentDetails.java | 20 - .../group/mgt/DeviceGroupRoleWrapper.java | 151 ---- .../mgt/common/otp/mgt/OTPEmailTypes.java | 2 +- .../mgt/common/spi/OTPManagementService.java | 6 +- .../pom.xml | 18 +- .../DeviceManagementConfigService.java | 7 +- .../DeviceManagementConfigServiceImpl.java | 61 +- .../config/api/util/DeviceMgtAPIUtils.java | 17 - .../pom.xml | 4 +- .../core/device/mgt/core/dao/GroupDAO.java | 49 +- .../core/dao/impl/AbstractGroupDAOImpl.java | 193 +---- .../impl/group/PostgreSQLGroupDAOImpl.java | 46 +- .../core/dao/util/GroupManagementDAOUtil.java | 1 - .../internal/DeviceManagementDataHolder.java | 16 +- .../operation/mgt/OperationManagerImpl.java | 51 +- .../dao/impl/GenericOTPManagementDAOImpl.java | 13 +- .../mgt/service/OTPManagementServiceImpl.java | 54 +- .../DeviceManagementProviderServiceImpl.java | 84 +-- .../GroupManagementProviderService.java | 31 - .../GroupManagementProviderServiceImpl.java | 126 +--- .../src/test/resources/sql/h2.sql | 1 - .../pom.xml | 4 +- .../pom.xml | 2 +- .../exception/StorageManagementException.java | 32 - components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 16 +- .../JWTClientExtensionDataHolder.java | 13 +- .../extension/service/JWTClientTest.java | 3 +- .../user-test/user-mgt-registry-test.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../logger/AppInstallLogContext.java | 181 ----- .../logger/DeviceConnectivityLogContext.java | 150 ---- .../logger/DeviceEnrolmentLogContext.java | 149 ---- .../notification/logger/PolicyLogContext.java | 133 ---- .../impl/EntgraAppInstallLoggerImpl.java | 318 --------- .../EntgraDeviceConnectivityLoggerImpl.java | 318 --------- .../impl/EntgraDeviceEnrolmentLoggerImpl.java | 318 --------- .../logger/impl/EntgraDeviceLoggerImpl.java | 7 + .../logger/impl/EntgraPolicyLoggerImpl.java | 318 --------- .../logger/impl/EntgraUserLoggerImpl.java | 2 + .../logger/util/MDCContextUtil.java | 102 +-- components/logger/pom.xml | 2 +- .../pom.xml | 9 +- .../mock/BaseOperationTemplatePluginTest.java | 1 - .../carbon-home/dbscripts/dm-db-h2.sql | 199 ++---- .../carbon-home/dbscripts/insert-subtypes.sql | 3 - .../repository/conf/cdm-config.xml | 92 +-- .../conf/datasources/data-source-config.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 15 +- .../impl/PolicyAdministratorPointImpl.java | 10 +- .../mgt/core/mgt/impl/PolicyManagerImpl.java | 39 +- .../src/test/resources/sql/CreateH2TestDB.sql | 248 +++---- .../user-test/user-mgt-registry-test.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../pom.xml | 11 +- .../carbon-home/dbscripts/dm-db-h2.sql | 169 ++--- .../conf/datasources/data-source-config.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- .../interceptor/DefaultTokenHandler.java | 99 ++- .../ui/request/interceptor/UserHandler.java | 1 - .../interceptor/util/HandlerConstants.java | 1 - .../request/interceptor/util/HandlerUtil.java | 13 - components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 4 +- .../authenticator/BasicAuthAuthenticator.java | 31 +- .../CertificateAuthenticator.java | 9 +- .../OneTimeTokenAuthenticator.java | 14 +- .../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 +- .../pom.xml | 6 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../src/main/resources/conf/cdm-config.xml | 2 +- .../src/main/resources/conf/mdm-ui-config.xml | 15 +- .../repository/conf/cdm-config.xml.j2 | 16 +- .../src/main/resources/dbscripts/cdm/h2.sql | 1 - .../main/resources/dbscripts/cdm/mssql.sql | 1 - .../main/resources/dbscripts/cdm/mysql.sql | 1 - .../main/resources/dbscripts/cdm/oracle.sql | 1 - .../resources/dbscripts/cdm/postgresql.sql | 1 - .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 5 +- .../pom.xml | 5 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../email/templates/user-enrollment.vm | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- .../conf/webapp-authenticator-config.xml | 4 +- .../etc/webapp-authenticator-config.xml.j2 | 4 +- .../webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 27 +- 234 files changed, 1377 insertions(+), 5036 deletions(-) delete mode 100644 components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml delete mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml delete mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java delete mode 100644 components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java delete mode 100644 components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index c198c72364..82f30811ab 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -295,7 +295,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java index 23128fc527..6121f78ddd 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java @@ -22,7 +22,6 @@ import com.google.gson.JsonObject; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.GrafanaAPIProxyService; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.bean.ErrorResponse; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.exception.RefererNotValid; -import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util.GrafanaMgtAPIUtils; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util.GrafanaRequestHandlerUtil; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception.GrafanaManagementException; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean.GrafanaPanelIdentifier; @@ -50,8 +49,8 @@ public class GrafanaAPIProxyServiceImpl implements GrafanaAPIProxyService { public Response queryDatasource(JsonObject body, @Context HttpHeaders headers, @Context UriInfo requestUriInfo) { try { GrafanaPanelIdentifier panelIdentifier = GrafanaRequestHandlerUtil.getPanelIdentifier(headers); - GrafanaMgtAPIUtils.getGrafanaQueryService().buildSafeQuery(body, panelIdentifier.getDashboardId(), - panelIdentifier.getPanelId(), requestUriInfo.getRequestUri()); + GrafanaMgtDataHolder.getInstance().getGrafanaQueryService(). + buildSafeQuery(body, panelIdentifier.getDashboardId(), panelIdentifier.getPanelId(), requestUriInfo.getRequestUri()); return GrafanaRequestHandlerUtil.proxyPassPostRequest(body, requestUriInfo, panelIdentifier.getOrgId()); } catch (MaliciousQueryAttempt e) { return Response.status(Response.Status.BAD_REQUEST).entity( diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java deleted file mode 100644 index 07a4293b49..0000000000 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaMgtAPIUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018 - 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.analytics.mgt.grafana.proxy.api.impl.util; - -import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.service.GrafanaQueryService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; - -public class GrafanaMgtAPIUtils { - - private static final Log log = LogFactory.getLog(GrafanaMgtAPIUtils.class); - private static volatile GrafanaQueryService grafanaQueryService; - - /** - * Accessing GrafanaQueryService from OSGI service context - * @return GrafanaQueryService instance - */ - public static GrafanaQueryService getGrafanaQueryService() { - if (grafanaQueryService == null) { - synchronized (GrafanaMgtAPIUtils.class) { - if (grafanaQueryService == null) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - grafanaQueryService = - (GrafanaQueryService) ctx.getOSGiService(GrafanaQueryService.class, null); - if (grafanaQueryService == null) { - String msg = "Grafana Query service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - } - } - } - return grafanaQueryService; - } -} diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 3cbdb071e5..a05f1959a3 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index fcf8b4bf98..2e2888b88a 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -211,7 +211,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito org.wso2.carbon diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 110c64f553..0b495a83a8 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 6482bc57da..abf6339213 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 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 d2e2ca34c7..e647b5f2dc 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 io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 5dc407ca23..1732b47585 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 022d3a8a51..37082c6fc6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index f62fd9c2ee..7434c58e54 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -143,14 +143,6 @@ org.wso2.carbon.apimgt.impl;version="[9.28,10)", org.wso2.carbon.apimgt.impl.utils;version="[9.28,10)", org.wso2.carbon.context;version="[4.8,5)", - 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.context;version="${carbon.kernel.version.range}", - io.entgra.device.mgt.core.identity.jwt.client.extension, - io.entgra.device.mgt.core.identity.jwt.client.extension.dto, - io.entgra.device.mgt.core.identity.jwt.client.extension.exception, - io.entgra.device.mgt.core.identity.jwt.client.extension.service, - io.entgra.device.mgt.core.apimgt.extension.rest.api, org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", org.wso2.carbon.registry.core.service;version="[1.0,2)", org.wso2.carbon.registry.indexing.service;version="[4.8,5)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index b4a1f11e14..0808f11963 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -41,19 +41,16 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.App import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.RegistrationProfile; 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; -import org.eclipse.jetty.http.MetaData; import org.wso2.carbon.apimgt.api.APIAdmin; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; -import org.wso2.carbon.apimgt.api.model.*; import org.wso2.carbon.apimgt.api.model.API; import org.wso2.carbon.apimgt.api.model.APIKey; import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; @@ -122,108 +119,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, isAllowedAllDomains, validityTime, tokenInfo); } - @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], - String keyType, String username, - boolean isAllowedAllDomains, - String validityTime, String password) throws APIManagerException { - - APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance().getApiApplicationServices(); - - ConsumerRESTAPIServices consumerRESTAPIServices = - APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - - try { - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(null, null, applicationName); - - List uniqueApiList = new ArrayList<>(); - - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); - - for (String tag : tags) { - Map queryParams = new HashMap<>(); - queryParams.put("tag", tag); - if ("carbon.super".equals(tenantDomain)) { - consumerRESTAPIServices.getAllApis(null, null, queryParams); - } else { - //call All API getting call with carbon super header param - APIInfo[] apiInfos; - if (!"carbon.super".equals(tenantDomain)) { - headerParams.put("X-WSO2-Tenant", "carbon.super"); - } - apiInfos = consumerRESTAPIServices.getAllApis(null, null, queryParams, headerParams); - - uniqueApiList.addAll(List.of(apiInfos)); - Set taggedAPISet = new HashSet<>(uniqueApiList); - uniqueApiList.clear(); - uniqueApiList.addAll(taggedAPISet); - } - - if (applications.length == 0) { - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = - new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); - - application.setName(applicationName); - application = consumerRESTAPIServices.createApplication(null, null, application); - List subscriptions = new ArrayList<>(); - for (APIInfo apiInfo : uniqueApiList) { - Subscription subscription = new Subscription(); - subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.getApplicationId()); - subscriptions.add(subscription); - } - consumerRESTAPIServices.createSubscriptions(null, null, subscriptions); - } else { - if (applications.length == 1) { - Optional application = - Arrays.stream(applications).findFirst(); - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(null, null, - application.get().getApplicationId()); - for (Subscription subscription : subscriptions) { - if (uniqueApiList.contains(subscription.getApiInfo())) { - uniqueApiList.remove(subscription.getApiInfo()); - } else { - uniqueApiList.add(subscription.getApiInfo()); - } - } - - - //duplicate code block - List subscriptionList = new ArrayList<>(); - for (APIInfo apiInfo : uniqueApiList) { - Subscription subscription = new Subscription(); - subscription.setApiId(apiInfo.getId()); - subscription.setApplicationId(application.get().getApplicationId()); - subscriptionList.add(subscription); - } - consumerRESTAPIServices.createSubscriptions(null, null, subscriptionList); - } else { - String msg = "Found more than one application for application name: " + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - - } - - - } catch (APIServicesException e) { - e.printStackTrace(); - } catch (BadRequestException e) { - e.printStackTrace(); - } catch (UnexpectedResponseException e) { - e.printStackTrace(); - } - - return null; - - - } - - - /** - * {@inheritDoc} - */ @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, @@ -244,11 +139,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isAllowedAllDomains, String validityTime, TokenInfo tokenInfo) throws APIManagerException { - ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); - ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); try { List uniqueApiList = new ArrayList<>(); @@ -315,50 +208,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } } - - MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); - if (isNewApplication) { - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(applicationInfo, application); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); - apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); - apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); - - Metadata metaData = new Metadata(); - metaData.setMetaKey(applicationName); - String metaValue = application.getApplicationId() + ":" + applicationKey.getKeyMappingId(); - metaData.setMetaValue(metaValue); - try { - metadataManagementService.createMetadata(metaData); - return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while creating the meta data entry for mata key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } catch (MetadataKeyAlreadyExistsException e) { - String msg = "Found duplicate meta value entry for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - } else { - try { - Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); - if (metaData == null) { - String msg = - "Couldn't find application key data from meta data mgt service. Meta key: " + applicationName; - log.error(msg); - throw new APIManagerException(msg); - } - String[] metaValues = metaData.getMetaValue().split(":"); - String applicationId = metaValues[0]; - String keyMappingId = metaValues[1]; - //todo call the API key retrieving call, return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while getting meta data for meta key: " + applicationName; - log.error(msg, e); - throw new APIManagerException(msg, e); - } - return null; - } } catch (APIServicesException e) { String msg = "Error occurred while processing the response of APIM REST endpoints."; log.error(msg, e); @@ -800,14 +649,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; try { if (username == null || password == null) { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( - "ClientForConsumerRestCalls", - "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); } else { - apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys( - "ClientForConsumerRestCalls", - username, password, - "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); + apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); } accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 978a46c13a..d6a3bb2fc5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -41,6 +41,7 @@ public class APIApplicationManagerExtensionDataHolder { private ConsumerRESTAPIServices consumerRESTAPIServices; private APIApplicationServices apiApplicationServices; private MetadataManagementService metadataManagementService; + private APIApplicationManagerExtensionDataHolder() { } @@ -67,18 +68,17 @@ public class APIApplicationManagerExtensionDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - setTenantManager(realmService != null ? - realmService.getTenantManager() : null); + this.setTenantManager(realmService); } - private void setTenantManager(TenantManager tenantManager) { - this.tenantManager = tenantManager; + private void setTenantManager(RealmService realmService) { + if (realmService == null) { + throw new IllegalStateException("Realm service is not initialized properly"); + } + this.tenantManager = realmService.getTenantManager(); } public TenantManager getTenantManager() { - if (tenantManager == null) { - throw new IllegalStateException("Tenant manager is not initialized properly"); - } return tenantManager; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java index ffb576295d..b3dc6dbd9d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionServiceComponent.java @@ -34,40 +34,6 @@ import org.wso2.carbon.user.core.service.RealmService; @Component( name = "io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionServiceComponent", immediate = true) -/** - * @scr.component name="io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionServiceComponent" - * @scr.reference name="tenant.registryloader" - * interface="org.wso2.carbon.registry.core.service.TenantRegistryLoader" - * cardinality="1..1" - * policy="dynamic" - * bind="setTenantRegistryLoader" - * unbind="unsetTenantRegistryLoader" - * @scr.reference name="tenant.indexloader" - * interface="org.wso2.carbon.registry.indexing.service.TenantIndexingLoader" - * cardinality="1..1" - * policy="dynamic" - * bind="setIndexLoader" - * unbind="unsetIndexLoader" - * @scr.reference name="realm.service" - * immediate="true" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="apimgt.extension.ConsumerRESTAPIServices" - * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices" - * cardinality="0..1" - * policy="dynamic" - * bind="setConsumerRESTAPIServices" - * unbind="unsetConsumerRESTAPIServices" - * @scr.reference name="apimgt.extension.APIApplicationService" - * interface="io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices" - * cardinality="0..1" - * policy="dynamic" - * bind="setAPIApplicationServices" - * unbind="unsetAPIApplicationServices" - */ public class APIApplicationManagerExtensionServiceComponent { private static final Log log = LogFactory.getLog(APIApplicationManagerExtensionServiceComponent.class); 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 45c9ab231f..7d4ef0501d 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 io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml 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/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 index f5cc8b3ec1..1cdceff56a 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/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 @@ -24,10 +24,9 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIService public interface APIApplicationServices { - APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) - throws APIServicesException; + APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; - APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) + APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; 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 a03f81d086..9dbd5f52cc 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 @@ -44,7 +44,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { getAPIManagerConfigurationService().getAPIManagerConfiguration(); @Override - public APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) + public APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); @@ -53,8 +53,8 @@ public class APIApplicationServicesImpl implements APIApplicationServices { JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName", clientName); - jsonObject.put("grantType", grantType); + jsonObject.put("clientName", Constants.CLIENT_NAME); + jsonObject.put("grantType", Constants.GRANT_TYPE); jsonObject.put("owner", serverUser); jsonObject.put("saasApp", true); @@ -75,15 +75,15 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) + public APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName", clientName); - jsonObject.put("grantType", grantType); + jsonObject.put("clientName", username); + jsonObject.put("grantType", Constants.GRANT_TYPE); jsonObject.put("owner", username); jsonObject.put("saasApp", true); 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index 7fddca04f2..5ed98034e2 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -23,8 +23,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; 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.bean.APIMConsumer.Application; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; import java.util.List; import java.util.Map; 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index a85c611f99..293894ee71 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -24,10 +24,6 @@ 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.dto.ApiApplicationInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; 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; 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java index 11fc881c1b..2ff525f5dc 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/bean/APIMConsumer/Subscription.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/APIMConsumer/Subscription.java @@ -18,6 +18,8 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; +import org.json.JSONObject; + public class Subscription { private String subscriptionId; 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 6ca26f74f0..6c3cf21c89 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 @@ -27,8 +27,10 @@ public final class Constants { public static final String AMPERSAND = "&"; public static final String SLASH = "/"; public static final String EQUAL = "="; + public static final String CLIENT_NAME = "rest_api_publisher_code"; public static final String SERVER_USER = "WorkflowConfigurations.ServerUser"; 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"; public static final String OAUTH_TOKEN_SCOPE = "scope"; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 82957d2b0d..2392078c2e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 201515986f..53374f48c6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 63e42132f0..69f51fff56 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -344,7 +344,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { Response response = client.newCall(request).execute(); return gson.fromJson(response.body().string(), OAuthApplication.class); } catch (IOException e) { - msg = "Error occurred while processing the response" + e; + msg = "Error occurred while processing the response"; throw new KeyMgtException(msg); } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 7e3ef60c38..c0c72a2f65 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -41,7 +41,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index e188ae799b..fe98a8cef8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -90,10 +90,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( - "ClientForPublisherRestCalls", - "client_credentials password refresh_token" - ); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { @@ -406,10 +403,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( - "ClientForPublisherRestCalls", - "client_credentials password refresh_token" - ); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java index bc7b8af32c..baff1848ed 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java @@ -75,18 +75,17 @@ public class APIPublisherDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - setTenantManager(realmService != null ? - realmService.getTenantManager() : null); + this.setTenantManager(realmService); } - private void setTenantManager(TenantManager tenantManager) { - this.tenantManager = tenantManager; + private void setTenantManager(RealmService realmService) { + if (realmService == null) { + throw new IllegalStateException("Realm service is not initialized properly"); + } + this.tenantManager = realmService.getTenantManager(); } public TenantManager getTenantManager() { - if (tenantManager == null) { - throw new IllegalStateException("Tenant manager is not initialized properly"); - } return tenantManager; } diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 2094510334..bee1ec2744 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 6a8a238623..c9eafdb800 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java index f0e2d040ff..f7655b566b 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java @@ -29,11 +29,6 @@ import io.entgra.device.mgt.core.application.mgt.common.response.Category; import io.entgra.device.mgt.core.application.mgt.common.response.Tag; import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; import io.entgra.device.mgt.core.device.mgt.common.Base64File; -<<<<<<< HEAD -======= -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; ->>>>>>> 3616245ae6 (Improve app visibility restricting functionality) import org.apache.cxf.jaxrs.ext.multipart.Attachment; import java.util.List; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index fde1c89087..9c3ab8ff85 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -153,10 +153,6 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - src/test/resources/testng.xml @@ -164,9 +160,6 @@ ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties - - org.ops4j.pax.logging - @@ -411,10 +404,6 @@ org.wso2.carbon.ntask.core provided - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.notification.logger - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index 6b4d590fa8..9a50d0d00a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -19,16 +19,6 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import io.entgra.device.mgt.core.application.mgt.common.*; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; -import org.json.JSONObject; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstaller; -import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; -import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger; -import io.entgra.device.mgt.core.application.mgt.common.Pagination; import io.entgra.device.mgt.core.application.mgt.common.config.RatingConfiguration; import io.entgra.device.mgt.core.application.mgt.common.dto.*; import io.entgra.device.mgt.core.application.mgt.common.exception.*; @@ -67,7 +57,6 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; -import javax.ws.rs.core.Response; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -1250,13 +1239,13 @@ public class ApplicationManagerImpl implements ApplicationManager { this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger); } } - if (Constants.ENTERPRISE_APP_TYPE.equals(applicationDTO.getType()) || Constants.PUBLIC_APP_TYPE.equals(applicationDTO.getType())) { - persistAppIconInfo(applicationReleaseDTO); - } applicationReleaseEntities.add(applicationReleaseDTO); } applicationDTO.setId(appId); applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities); + if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { + persistAppIconInfo(applicationReleaseDTO); + } return APIUtil.appDtoToAppResponse(applicationDTO); } } catch (LifeCycleManagementDAOException e) { @@ -1680,31 +1669,6 @@ public class ApplicationManagerImpl implements ApplicationManager { } } - /** - * Check whether valid metaData value or not - * - * @return true or false - * @throws MetadataManagementException If it is unable to load metaData - */ - private boolean isUserAbleToViewAllRoles() throws MetadataManagementException { - List allMetadata; - allMetadata = APIUtil.getMetadataManagementService().retrieveAllMetadata(); - if (allMetadata != null && !allMetadata.isEmpty()) { - for (Metadata metadata : allMetadata) { - if (Constants.SHOW_ALL_ROLES.equals(metadata.getMetaKey())) { - String metaValue = metadata.getMetaValue(); - if (metaValue != null) { - JSONObject jsonObject; - jsonObject = new JSONObject(metaValue); - boolean isUserAbleToViewAllRoles = jsonObject.getBoolean(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); - return isUserAbleToViewAllRoles; - } - } - } - } - return false; - } - /** * Get assigned role list of the given user. * @@ -3478,8 +3442,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public void validateAppCreatingRequest(T param) - throws ApplicationManagementException, RequestValidatingException { + public void validateAppCreatingRequest(T param) throws ApplicationManagementException, RequestValidatingException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); int deviceTypeId = -1; @@ -3651,14 +3614,12 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ApplicationManagementException(msg); } - if (!isUserAbleToViewAllRoles()) { - if (!hasUserRole(unrestrictedRoles, userName)) { - String msg = "You are trying to restrict the visibility of the application for a role set, but " - + "in order to perform the action at least one role should be assigned to user: " - + userName; - log.error(msg); - throw new BadRequestException(msg); - } + if (!hasUserRole(unrestrictedRoles, userName)) { + String msg = "You are trying to restrict the visibility of the application for a role set, but " + + "in order to perform the action at least one role should be assigned to user: " + + userName; + log.error(msg); + throw new BadRequestException(msg); } } @@ -3711,10 +3672,6 @@ public class ApplicationManagerImpl implements ApplicationManager { String msg = "Error occurred when validating the unrestricted roles given for the web clip"; log.error(msg, e); throw new ApplicationManagementException(msg, e); - } catch (MetadataManagementException e) { - String msg = "Error occurred while retrieving metadata list"; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index e4bfe93d46..cae569bbd3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -19,10 +19,6 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import com.google.gson.Gson; -import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraAppInstallLoggerImpl; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.application.mgt.common.*; @@ -91,8 +87,8 @@ import java.util.stream.Collectors; * This is the default implementation for the Subscription Manager. */ public class SubscriptionManagerImpl implements SubscriptionManager { - AppInstallLogContext.Builder appInstallLogContextBuilder = new AppInstallLogContext.Builder(); - private static final EntgraLogger log = new EntgraAppInstallLoggerImpl(SubscriptionManagerImpl.class); + + private static final Log log = LogFactory.getLog(SubscriptionManagerImpl.class); private SubscriptionDAO subscriptionDAO; private ApplicationDAO applicationDAO; private LifecycleStateManager lifecycleStateManager; @@ -624,9 +620,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Properties properties, boolean isOperationReExecutingDisabled) throws ApplicationManagementException { - String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + //Get app subscribing info of each device SubscribingDeviceIdHolder subscribingDeviceIdHolder = getSubscribingDeviceIdHolder(devices, applicationDTO.getApplicationReleaseDTOs().get(0).getId()); @@ -676,36 +670,10 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Activity activity = addAppOperationOnDevices(applicationDTO, new ArrayList<>(entry.getValue()), entry.getKey(), action, properties); activityList.add(activity); - for (DeviceIdentifier identifier : deviceIdentifiers) { - log.info(String.format("Web app %s triggered", action), appInstallLogContextBuilder - .setAppId(String.valueOf(applicationDTO.getId())) - .setAppName(applicationDTO.getName()) - .setAppType(applicationDTO.getType()) - .setSubType(subType) - .setTenantId(tenantId) - .setTenantDomain(tenantDomain) - .setDevice(String.valueOf(identifier)) - .setUserName(username) - .setAction(action) - .build()); - } } } else { Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action, properties); activityList.add(activity); - for (DeviceIdentifier identifier : deviceIdentifiers) { - log.info(String.format("App %s triggered", action), appInstallLogContextBuilder - .setAppId(String.valueOf(applicationDTO.getId())) - .setAppName(applicationDTO.getName()) - .setAppType(applicationDTO.getType()) - .setSubType(subType) - .setTenantId(tenantId) - .setTenantDomain(tenantDomain) - .setDevice(String.valueOf(identifier)) - .setUserName(username) - .setAction(action) - .build()); - } } ApplicationInstallResponse applicationInstallResponse = new ApplicationInstallResponse(); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java index 8c3ccbc8bf..4b78b9e1c2 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java @@ -40,7 +40,6 @@ import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.application.mgt.core.serviceprovider.ISServiceProviderApplicationService; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -65,7 +64,6 @@ public class APIUtil { private static volatile SubscriptionManager subscriptionManager; private static volatile ReviewManager reviewManager; private static volatile AppmDataHandler appmDataHandler; - private static volatile MetadataManagementService metadataManagementService; public static SPApplicationManager getSPApplicationManager() { if (SPApplicationManager == null) { @@ -516,22 +514,7 @@ public class APIUtil { public static String createAppIconPath(ApplicationReleaseDTO applicationReleaseDTO, int tenantId) throws ApplicationManagementException { String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + applicationReleaseDTO .getAppHashValue() + Constants.FORWARD_SLASH; - return basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); - } - - public static MetadataManagementService getMetadataManagementService() { - if (metadataManagementService == null) { - synchronized (APIUtil.class) { - if (metadataManagementService == null) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - metadataManagementService = (MetadataManagementService) ctx.getOSGiService( - MetadataManagementService.class, null); - if (metadataManagementService == null) { - throw new IllegalStateException("Metadata Management service not initialized."); - } - } - } - } - return metadataManagementService; + String iconPath = basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); + return iconPath; } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java index c3e7c49160..5864242acf 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java @@ -70,8 +70,7 @@ public class Constants { public static final String ANY = "ANY"; public static final String DEFAULT_PCK_NAME = "default.app.com"; public static final String ALL = "ALL"; - public static final String SHOW_ALL_ROLES = "SHOW_ALL_ROLES"; - public static final String IS_USER_ABLE_TO_VIEW_ALL_ROLES = "isUserAbleToViewAllRoles"; + public static final String GOOGLE_PLAY_STORE_URL = "https://play.google.com/store/apps/details?id="; public static final String APPLE_STORE_URL = "https://itunes.apple.com/country/app/app-name/id"; @@ -94,9 +93,6 @@ public class Constants { public static final String MSI = "MSI"; public static final String APPX = "APPX"; - public static final String ENTERPRISE_APP_TYPE = "ENTERPRISE"; - public static final String PUBLIC_APP_TYPE = "ENTERPRISE"; - private static final Map AGENT_DATA = new HashMap<>(); static { AGENT_DATA.put("android", "android-agent.apk"); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index 96fd6acfff..fc32a2698d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:./target/databasetest/CARBON_TEST + jdbc:h2:target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 2e2e67a22f..512aef9700 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index b67ccf20ef..82a035ace6 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 3a7526f408..0691f0648c 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index d24319a34f..d23f1863cd 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -111,10 +111,6 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - src/test/resources/testng.xml @@ -122,9 +118,6 @@ ${basedir}/target/coverage-reports/jacoco-unit.exec file:src/test/resources/log4j.properties - - org.ops4j.pax.logging - @@ -182,7 +175,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java index acf63daa07..e3e55c330f 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/bean/Certificate.java @@ -25,15 +25,6 @@ public class Certificate { X509Certificate certificate; int tenantId; String tenantDomain; - String deviceIdentifier; - - public String getDeviceIdentifier() { - return deviceIdentifier; - } - - public void setDeviceIdentifier(String deviceIdentifier) { - this.deviceIdentifier = deviceIdentifier; - } public int getTenantId() { return tenantId; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java index 779251761e..de3be1856a 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/CertificateDAO.java @@ -41,17 +41,6 @@ public interface CertificateDAO { void addCertificate(List certificate) throws CertificateManagementDAOException; - /** - * This can be used to store a certificate in the database, where it will be stored against the serial number - * of the certificate. - * - * @param certificate Holds the certificate and relevant details. - * @throws CertificateManagementDAOException - * - */ - void addCertificate(Certificate certificate) - throws CertificateManagementDAOException; - /** * Usage is to obtain a certificate stored in the database by providing the common name. * @@ -62,16 +51,6 @@ public interface CertificateDAO { */ CertificateResponse retrieveCertificate(String serialNumber) throws CertificateManagementDAOException; - /** - * Obtain a certificated stored in the database by providing the common name and the tenant ID - * - * @param serialNumber Serial number (Common name) of the certificate - * @param tenantId ID of the certificate owning tenant - * @return representation of the certificate. - * @throws CertificateManagementDAOException if fails to read the certificate from the database - */ - CertificateResponse retrieveCertificate(String serialNumber, int tenantId) throws CertificateManagementDAOException; - /** * Get all the certificates in a paginated manner. * diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java index 0a8e9e3066..45a7e7c56f 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/AbstractCertificateDAOImpl.java @@ -81,40 +81,6 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ } } - @Override - public void addCertificate(Certificate certificate) - throws CertificateManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - stmt = conn.prepareStatement( - "INSERT INTO DM_DEVICE_CERTIFICATE (SERIAL_NUMBER, CERTIFICATE, TENANT_ID," + - " USERNAME, DEVICE_IDENTIFIER) VALUES (?,?,?,?,?)"); - PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext. - getThreadLocalCarbonContext(); - String username = threadLocalCarbonContext.getUsername(); - // the serial number of the certificate used for its creation is set as its alias. - String serialNumber = certificate.getSerial(); - if (serialNumber == null || serialNumber.isEmpty()) { - serialNumber = String.valueOf(certificate.getCertificate().getSerialNumber()); - } - byte[] bytes = Serializer.serialize(certificate.getCertificate()); - - stmt.setString(1, serialNumber); - stmt.setBytes(2, bytes); - stmt.setInt(3, certificate.getTenantId()); - stmt.setString(4, username); - stmt.setString(5, certificate.getDeviceIdentifier()); - stmt.executeUpdate(); - } catch (SQLException | IOException e) { - throw new CertificateManagementDAOException("Error occurred while saving the " + - "certificate. ", e); - } finally { - CertificateManagementDAOUtil.cleanupResources(stmt, null); - } - } - @Override public CertificateResponse retrieveCertificate(String serialNumber) throws CertificateManagementDAOException { @@ -153,42 +119,6 @@ public abstract class AbstractCertificateDAOImpl implements CertificateDAO{ return certificateResponse; } - @Override - public CertificateResponse retrieveCertificate(String serialNumber, int tenantId) throws CertificateManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet resultSet = null; - CertificateResponse certificateResponse = null; - try { - conn = this.getConnection(); - String query = - "SELECT CERTIFICATE, SERIAL_NUMBER, TENANT_ID, USERNAME FROM" - + " DM_DEVICE_CERTIFICATE WHERE SERIAL_NUMBER = ? AND TENANT_ID = ? "; - stmt = conn.prepareStatement(query); - stmt.setString(1, serialNumber); - stmt.setInt(2, tenantId); - resultSet = stmt.executeQuery(); - - if (resultSet.next()) { - certificateResponse = new CertificateResponse(); - byte[] certificateBytes = resultSet.getBytes("CERTIFICATE"); - certificateResponse.setCertificate(certificateBytes); - certificateResponse.setSerialNumber(resultSet.getString("SERIAL_NUMBER")); - certificateResponse.setTenantId(resultSet.getInt("TENANT_ID")); - certificateResponse.setUsername(resultSet.getString("USERNAME")); - CertificateGenerator.extractCertificateDetails(certificateBytes, certificateResponse); - } - } catch (SQLException e) { - String errorMsg = - "Unable to get the read the certificate with serial" + serialNumber; - log.error(errorMsg, e); - throw new CertificateManagementDAOException(errorMsg, e); - } finally { - CertificateManagementDAOUtil.cleanupResources(stmt, resultSet); - } - return certificateResponse; - } - @Override public List searchCertificate(String serialNumber) throws CertificateManagementDAOException { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index b8109e74fc..bc98fae4a5 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -55,28 +55,10 @@ import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; import org.bouncycastle.pkcs.PKCS10CertificationRequest; import org.bouncycastle.util.Store; -import org.jscep.message.CertRep; -import org.jscep.message.MessageDecodingException; -import org.jscep.message.MessageEncodingException; -import org.jscep.message.PkcsPkiEnvelopeDecoder; -import org.jscep.message.PkcsPkiEnvelopeEncoder; -import org.jscep.message.PkiMessage; -import org.jscep.message.PkiMessageDecoder; -import org.jscep.message.PkiMessageEncoder; +import org.jscep.message.*; import org.jscep.transaction.FailInfo; import org.jscep.transaction.Nonce; import org.jscep.transaction.TransactionId; -import org.wso2.carbon.certificate.mgt.core.dao.CertificateDAO; -import org.wso2.carbon.certificate.mgt.core.dao.CertificateManagementDAOException; -import org.wso2.carbon.certificate.mgt.core.dao.CertificateManagementDAOFactory; -import org.wso2.carbon.certificate.mgt.core.dto.CAStatus; -import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse; -import org.wso2.carbon.certificate.mgt.core.dto.SCEPResponse; -import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException; -import org.wso2.carbon.certificate.mgt.core.exception.TransactionManagementException; -import org.wso2.carbon.certificate.mgt.core.util.CertificateManagementConstants; -import org.wso2.carbon.certificate.mgt.core.util.CommonUtil; -import org.wso2.carbon.certificate.mgt.core.util.Serializer; import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.naming.InvalidNameException; @@ -88,34 +70,12 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; -import java.security.InvalidKeyException; -import java.security.KeyFactory; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.SecureRandom; -import java.security.Security; -import java.security.SignatureException; +import java.security.*; import java.security.cert.Certificate; import java.security.cert.*; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; import java.util.*; -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateExpiredException; -import java.security.cert.CertificateFactory; -import java.security.cert.CertificateNotYetValidException; -import java.security.cert.X509Certificate; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.X509EncodedKeySpec; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; import java.util.concurrent.TimeUnit; public class CertificateGenerator { @@ -376,31 +336,15 @@ public class CertificateGenerator { CertificateResponse lookUpCertificate = null; KeyStoreReader keyStoreReader = new KeyStoreReader(); if (distinguishedName != null && !distinguishedName.isEmpty()) { - if (distinguishedName.contains("CN=")) { - String[] dnSplits = null; - if (distinguishedName.contains("/")) { - dnSplits = distinguishedName.split("/"); - } else if (distinguishedName.contains(",")) { - //some older versions of nginx will forward the client certificate subject dn separated with commas - dnSplits = distinguishedName.split(","); - } - String commonNameExtracted = null; - int tenantId = 0; - if (dnSplits != null && dnSplits.length >= 1) { - for (String dnPart : dnSplits) { - if (dnPart.contains("CN=")) { - commonNameExtracted = dnPart.replace("CN=", ""); - } else if (dnPart.contains("OU=")) { - //the OU of the certificate will be like OU=tenant_ ex: OU=tenant_-1234 - //splitting by underscore to extract the tenant domain - String[] orgUnitSplits = dnPart.split("_"); - tenantId = Integer.parseInt(orgUnitSplits[1]); - } + if (distinguishedName.contains("/CN=")) { + String[] dnSplits = distinguishedName.split("/"); + for (String dnPart : dnSplits) { + if (dnPart.contains("CN=")) { + String commonNameExtracted = dnPart.replace("CN=", ""); + lookUpCertificate = keyStoreReader.getCertificateBySerial(commonNameExtracted); + break; } } - - lookUpCertificate = keyStoreReader.getCertificateBySerial(commonNameExtracted, tenantId); - } else { LdapName ldapName; try { @@ -727,29 +671,6 @@ public class CertificateGenerator { throw new KeystoreException(errorMsg, e); } } - public void saveCertificate(org.wso2.carbon.certificate.mgt.core.bean.Certificate - certificate) throws KeystoreException { - - if (certificate == null) { - return; - } - - try { - CertificateDAO certificateDAO = CertificateManagementDAOFactory.getCertificateDAO(); - CertificateManagementDAOFactory.beginTransaction(); - certificateDAO.addCertificate(certificate); - CertificateManagementDAOFactory.commitTransaction(); - } catch (CertificateManagementDAOException e) { - String errorMsg = "Error occurred when saving the generated certificate in database"; - log.error(errorMsg); - CertificateManagementDAOFactory.rollbackTransaction(); - throw new KeystoreException(errorMsg, e); - } catch (TransactionManagementException e) { - String errorMsg = "Error occurred when saving the generated certificate in database"; - log.error(errorMsg); - throw new KeystoreException(errorMsg, e); - } - } public void saveCertInKeyStore(List certificate) throws KeystoreException { @@ -864,9 +785,8 @@ public class CertificateGenerator { X500Name issuerName = new X500Name(subjectDn); String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst() .getValue().toString(); - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - X500Name subjectName = new X500Name("O=" + commonName + ",CN=" + - serialNumber + ", OU=tenant_"+tenantId); + X500Name subjectName = new X500Name("O=" + commonName + "O=AndroidDevice,CN=" + + serialNumber); Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(365 * 100)); @@ -889,8 +809,8 @@ public class CertificateGenerator { List certificates = new ArrayList<>(); certificate.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); certificate.setCertificate(issuedCert); - certificate.setDeviceIdentifier(commonName); - saveCertificate(certificate); + certificates.add(certificate); + saveCertInKeyStore(certificates); } catch (OperatorCreationException e) { String errorMsg = "Error creating the content signer"; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java index 94cab378bf..56ec2bb6f5 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/KeyStoreReader.java @@ -271,43 +271,6 @@ public class KeyStoreReader { return raPrivateKey; } - public CertificateResponse getCertificateBySerial(String serialNumber, int tenantId) throws KeystoreException { - CertificateResponse certificateResponse = null; - try { - CertificateCacheManager cacheManager = CertificateCacheManagerImpl.getInstance(); - certificateResponse = cacheManager.getCertificateBySerial(serialNumber); - if (certificateResponse == null) { - try { - CertificateManagementDAOFactory.openConnection(); - certificateResponse = certDao.retrieveCertificate(serialNumber, tenantId); - } catch (SQLException e) { - String errorMsg = "Error when making a connection to the database."; - throw new KeystoreException(errorMsg, e); - } finally { - CertificateManagementDAOFactory.closeConnection(); - } - if (certificateResponse != null && certificateResponse.getCertificate() != null) { - Certificate certificate = (Certificate) Serializer.deserialize(certificateResponse.getCertificate()); - if (certificate instanceof X509Certificate) { - X509Certificate x509cert = (X509Certificate) certificate; - String commonName = CertificateGenerator.getCommonName(x509cert); - certificateResponse.setCommonName(commonName); - cacheManager.addCertificateBySerial(serialNumber, certificateResponse); - } - } - } - } catch (CertificateManagementDAOException e) { - String errorMsg = "Error when retrieving certificate from the the database for the serial number: " + - serialNumber; - throw new KeystoreException(errorMsg, e); - - } catch (ClassNotFoundException | IOException e) { - String errorMsg = "Error when de-serializing saved certificate."; - throw new KeystoreException(errorMsg, e); - } - return certificateResponse; - } - public CertificateResponse getCertificateBySerial(String serialNumber) throws KeystoreException { CertificateResponse certificateResponse = null; try { diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml index 533fd82959..27b6dfeaeb 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/test/resources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true org.h2.Driver wso2carbon wso2carbon diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 7833296e8a..98c20d369b 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index d8a79858c6..38ba36543d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -106,19 +106,13 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - - file:src/test/resources/log4j.properties + file:src/test/resources/carbon-home/repository/conf/log4j.properties + src/test/resources/testng.xml - - org.ops4j.pax.logging - @@ -213,15 +207,5 @@ org.wso2.orbit.javax.xml.bind jaxb-api - - com.sun.xml.bind - jaxb-core - test - - - com.sun.xml.bind - jaxb-impl - test - diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 610f4f6cda..8b1dc93e22 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -104,21 +104,6 @@ io.entgra.device.mgt.core.device.mgt.core test - - org.mockito - mockito-core - test - - - com.sun.xml.bind - jaxb-core - test - - - com.sun.xml.bind - jaxb-impl - test - @@ -172,25 +157,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - - - file:src/test/resources/log4j.properties - - - src/test/resources/testng.xml - - - org.ops4j.pax.logging - - - org.jacoco jacoco-maven-plugin diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index da2c459069..f984260692 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index f238d4d5d4..a50c455f80 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 1608581ec7..c357cd7566 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index c2899b36e3..17a7c4b6ff 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index aeaed8655c..ed434c7873 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -122,16 +122,6 @@ powermock-module-testng test - - org.wso2.carbon - org.wso2.carbon.securevault - test - - - org.mockito - mockito-core - test - @@ -199,25 +189,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - - - file:src/test/resources/log4j.properties - - - src/test/resources/testng.xml - - - org.ops4j.pax.logging - - - diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml new file mode 100644 index 0000000000..a5518cb720 --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/conf/carbon.xml @@ -0,0 +1,658 @@ + + + + + + + + + ${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/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/src/test/resources/repository/conf/carbon.xml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index d1c6c2206c..6291d849a5 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index e18d86ef10..cab0ec4896 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 1223822167..c6914f5733 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 0c2e5663fe..09ac87fdb8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -364,7 +364,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java index 33d46f139b..cfe12bc3f8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/GroupManagementService.java @@ -26,24 +26,6 @@ import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.swagger.annotations.*; import org.apache.axis2.transport.http.HTTPConstants; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; import javax.validation.Valid; import javax.ws.rs.*; @@ -177,13 +159,6 @@ import java.util.List; key = "perm:groups:devices-types", roles = {"Internal/devicemgt-user"}, permissions = {"/device-mgt/groups/devices/types"} - ), - @Scope( - name = "View whether the groups has relevant device types", - description = "View whether the groups has relevant device types", - key = "perm:groups:add", - roles = {"Internal/devicemgt-user"}, - permissions = {"/device-mgt/groups/device-types"} ) } ) @@ -1231,77 +1206,4 @@ public interface GroupManagementService { required = true) List identifiers); - - @POST - @Path("/roles/share") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = HTTPConstants.HEADER_POST, - value = "Consolidated API for Creating a Device Group, Adding Devices, and Sharing", - notes = "This API can be used to create a new device group, add devices to the group, and share the group with user roles.", - tags = "Device Group Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:add") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "Created. \n Device group has successfully been created.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The URL of the created group."), - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body."), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource has been modified the last time.\n" + - "Used by caches, or in conditional requests.") - } - ), - @ApiResponse( - code = 303, - message = "See Other. \n Source can be retrieved from the URL specified at the Location " + - "header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error.", - response = ErrorResponse.class), - @ApiResponse( - code = 401, - message = "Unauthorized. \n Current logged in user is not authorized to perform the operation.", - response = ErrorResponse.class), - @ApiResponse( - code = 404, - message = "Group not found.", - response = ErrorResponse.class), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while creating the group or adding devices or sharing the group.", - response = ErrorResponse.class) - }) - Response createGroupWithRoles( - @ApiParam( - name = "group", - value = "Define the group object with data.", - required = true) - @Valid DeviceGroupRoleWrapper group - ); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java index 5031f1598d..f7eb730a8b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/RoleManagementService.java @@ -187,104 +187,6 @@ public interface RoleManagementService { defaultValue = "5") @QueryParam("limit") int limit); - @GET - @Path("/visible/{metaKey}") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Getting the List of Visible Roles", - notes = "WSO2 IoTS supports role-based access control (RBAC) and role management. Using this API you can the list of roles that are in WSO2 IoTS.\n" + - "Note: Internal roles, roles created for service-providers, and application related roles will not be given in the output.", - tags = "Role Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:roles:view") - }) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully fetched the list of roles in WSO2 IoTS.", - response = RoleList.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource has been modified the last time.\n" + - "Used by caches, or in conditional requests."), - }), - @ApiResponse( - code = 304, - message = "Not Modified. \n Empty body because the client already has the latest version of the " + - "requested resource."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist.\n", - response = ErrorResponse.class), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the list of roles" + - " assigned to the specified user.", - response = ErrorResponse.class) - }) - Response getVisibleRole( - @ApiParam( - name = "filter", - value = "Provide a character or a few characters in the role name.", - required = false) - @QueryParam("filter") String filter, - @ApiParam( - name = "user-store", - value = "The name of the UserStore you wish to get the list of roles.", - required = false) - @QueryParam("user-store") String userStoreName, - @ApiParam( - name = "If-Modified-Since", - value = "Checks if the requested variant was modified, since the specified date-time." + - "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + - "Example: Mon, 05 Jan 2014 15:10:00 +0200", - required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince, - @ApiParam( - name = "offset", - value = "The starting pagination index for the complete list of qualified items.", - required = false, - defaultValue = "0") - @QueryParam("offset") int offset, - @ApiParam( - name = "limit", - value = "Provide how many role details you require from the starting pagination index/offset.", - required = false, - defaultValue = "5") - @QueryParam("limit") int limit, - @ApiParam( - name = "username", - value = "The username of the user.", - required = true, - defaultValue = "admin") - @QueryParam("username") String username, - @ApiParam( - name = "domain", - value = "The domain name of the user store.", - required = false) - @QueryParam("domain") String domain, - @ApiParam( - name = "metaKey", - value = "Key of the metadata", - required = true) - @PathParam("metaKey") String metaKey); - @GET @Path("/filter/{prefix}") @ApiOperation( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java index eb5f791ab6..393389340f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/GroupManagementAdminService.java @@ -27,16 +27,8 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.swagger.annotations.*; import org.apache.axis2.transport.http.HTTPConstants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import javax.validation.Valid; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -366,79 +358,4 @@ public interface GroupManagementAdminService { required = true) @Valid DeviceGroup group); - - - @POST - @Path("/roles/share") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = HTTPConstants.HEADER_POST, - value = "Consolidated API for Creating a Device Group, Adding Devices, and Sharing", - notes = "This API can be used to create a new device group, add devices to the group, and share the group with user roles.", - tags = "Device Group Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:groups:add") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 201, - message = "Created. \n Device group has successfully been created.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The URL of the created group."), - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body."), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource has been modified the last time.\n" + - "Used by caches, or in conditional requests.") - } - ), - @ApiResponse( - code = 303, - message = "See Other. \n Source can be retrieved from the URL specified at the Location " + - "header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error.", - response = ErrorResponse.class), - @ApiResponse( - code = 401, - message = "Unauthorized. \n Current logged in user is not authorized to perform the operation.", - response = ErrorResponse.class), - @ApiResponse( - code = 404, - message = "Group not found.", - response = ErrorResponse.class), - @ApiResponse( - code = 406, - message = "Not Acceptable.\n The requested media type is not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while creating the group or adding devices or sharing the group.", - response = ErrorResponse.class) - }) - Response createGroupWithRoles(@ApiParam( - name = "group", - value = "Define the group object with data.", - required = true) - @Valid DeviceGroupRoleWrapper group - - ); - } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 67042ede8b..09be7963fd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -23,11 +23,6 @@ import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProvi import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; -import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; -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.dto.APIApplicationKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; @@ -809,12 +804,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { //todo - lasantha - can't get password from here ApiApplicationKey apiApplicationKey; try { - - APIApplicationServices apiApplicationServices = DeviceMgtAPIUtils.getApiApplicationServices(); - APIApplicationKey adminDCRResponse = apiApplicationServices.createAndRetrieveApplicationCredentials( - "ClientForJWTTokenGeneration", - "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer" - ); + DCRResponse adminDCRResponse = keyMgtService.dynamicClientRegistration(applicationName, + PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminUserName(), + "client_credentials", null, new String[] {"device_management"}, false, validityTime, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() + .getRealmConfiguration().getAdminPassword()); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); JWTClientManagerService jwtClientManagerService = (JWTClientManagerService) ctx. @@ -822,14 +816,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { JWTClient jwtClient = jwtClientManagerService.getJWTClient(); AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(adminDCRResponse.getClientId(), adminDCRResponse.getClientSecret(), - username, "appm:subscribe apim:admin apim:api_key apim:app_import_export apim:app_manage" + - " apim:store_settings apim:sub_alert_manage apim:sub_manage apim:subscribe openid perm:device:enroll " + - "perm:devices:details perm:devices:features perm:devices:search perm:devices:view perm:groups:groups " + - "perm:users:send-invitation"); + username, "appm:subscribe"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, - new String[] {"device_management"}, "PRODUCTION", false, String.valueOf(validityTime), + new String[] {"device_management"}, null, false, String.valueOf(validityTime), accessTokenInfo.getAccessToken()); } catch (JWTClientException e) { @@ -837,8 +828,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } catch (APIServicesException e) { - String msg = "Error while generating api Application"; + } catch (UserStoreException e) { + String msg = "Error while getting user credentials."; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index 98ca6249d0..f0122835e1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -18,28 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; -import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceToGroupsAssignment; @@ -59,21 +37,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.user.api.UserRealm; -import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.*; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.transaction.UserTransaction; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class GroupManagementServiceImpl implements GroupManagementService { @@ -127,18 +94,8 @@ public class GroupManagementServiceImpl implements GroupManagementService { request.setGroupName(name); request.setOwner(owner); request.setDepth(depth); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - UserRealm realmService = DeviceMgtAPIUtils.getRealmService().getTenantUserRealm(tenantId); - String[] roles = realmService.getUserStoreManager().getRoleListOfUser(currentUser); - boolean hasAdminRole = Arrays.asList(roles).contains(DEFAULT_ADMIN_ROLE); - PaginationResult deviceGroupsResult; - if (hasAdminRole) { - deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(null, request, requireGroupProps); - } else{ - deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(currentUser, request, requireGroupProps); - } + PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(currentUser, request, requireGroupProps); DeviceGroupList deviceGroupList = new DeviceGroupList(); deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); @@ -147,10 +104,6 @@ public class GroupManagementServiceImpl implements GroupManagementService { String error = "Error occurred while retrieving groups with hierarchy."; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); - } catch (UserStoreException e) { - String msg = "Error occurred while getting user realm."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } @@ -463,38 +416,4 @@ public class GroupManagementServiceImpl implements GroupManagementService { } } - @POST - @Path("/roles/share") - @Override - public Response createGroupWithRoles(DeviceGroupRoleWrapper groups) { - if (groups == null) { - return Response.status(Response.Status.BAD_REQUEST).build(); - } - groups.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); - groups.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); - try { - DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(groups, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); - DeviceGroup group = DeviceMgtAPIUtils.getGroupManagementProviderService().getGroup(groups.getName(), - PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername().isEmpty()); - if (group != null) { - DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), groups.getUserRoles()); - return Response.status(Response.Status.CREATED).entity(group.getGroupId()).build(); - } else { - String msg = "Error occurred while retrieving newly created group."; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } catch (GroupManagementException e) { - String msg = "Error occurred while adding " + groups.getName() + " group"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (GroupAlreadyExistException e) { - String msg = "Group already exists with name : " + groups.getName() + " Try with another group name."; - log.error(msg, e); - return Response.status(Response.Status.CONFLICT).entity(msg).build(); - } catch (RoleDoesNotExistException e) { - return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); - } - } - } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index 5c04516650..c8df51825e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -17,14 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; -import com.google.common.base.Strings; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; -import org.apache.axis2.databinding.types.xsd._boolean; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleInfo; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.RoleList; @@ -36,7 +28,6 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.SetReferenceTransformer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.util.StringUtils; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; @@ -59,12 +50,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URLEncoder; import java.util.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; import static io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants.PRIMARY_USER_STORE; @@ -112,96 +97,6 @@ public class RoleManagementServiceImpl implements RoleManagementService { } } - @GET - @Path("/visible/{metaKey}") - @Override - public Response getVisibleRole( - @QueryParam("filter") String filter, - @QueryParam("user-store") String userStore, - @HeaderParam("If-Modified-Since") String ifModifiedSince, - @QueryParam("offset") int offset, - @QueryParam("limit") int limit, - @QueryParam("username") String username, - @QueryParam("domain") String domain, - @PathParam("metaKey") String metaKey) { - RequestValidationUtil.validatePaginationParameters(offset, limit); - if (limit == 0){ - limit = Constants.DEFAULT_PAGE_LIMIT; - } - if (!Strings.isNullOrEmpty(domain)) { - username = domain + '/' + username; - } - Metadata metadata; - List visibleRoles; - RoleList visibleRoleList = new RoleList(); - try { - metadata = DeviceMgtAPIUtils.getMetadataManagementService().retrieveMetadata(metaKey); - String metaValue = metadata.getMetaValue(); - JSONParser parser = new JSONParser(); - JSONObject jsonObject = (JSONObject) parser.parse(metaValue); - boolean decision = (boolean) jsonObject.get(Constants.IS_USER_ABLE_TO_VIEW_ALL_ROLES); - if (decision) { - if (Strings.isNullOrEmpty(userStore)){ - userStore = PRIMARY_USER_STORE; - } - try { - visibleRoles = getRolesFromUserStore(filter, userStore); - visibleRoleList.setList(visibleRoles); - - visibleRoles = FilteringUtil.getFilteredList(getRolesFromUserStore(filter, userStore), offset, limit); - visibleRoleList.setList(visibleRoles); - - return Response.status(Response.Status.OK).entity(visibleRoleList).build(); - } catch (UserStoreException e) { - String msg = "Error occurred while retrieving roles from the underlying user stores"; - log.error(msg, e); - return Response.serverError().entity( - new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } - } else { - try { - UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); - if (!userStoreManager.isExistingUser(username)) { - if (log.isDebugEnabled()) { - log.debug("User by username: " + username + " does not exist for role retrieval."); - } - String msg = "User by username: " + username + " does not exist for role retrieval."; - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } - visibleRoleList.setList(getFilteredVisibleRoles(userStoreManager, username)); - - return Response.status(Response.Status.OK).entity(visibleRoleList).build(); - } catch (UserStoreException e) { - String msg = "Error occurred while trying to retrieve roles of the user '" + username + "'"; - log.error(msg, e); - return Response.serverError().entity( - new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } - } - } catch (MetadataManagementException e) { - String msg = "Error occurred while getting the metadata entry for metaKey:" + metaKey; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ParseException e) { - String msg = "Error occurred while parsing JSON metadata: " + e.getMessage(); - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); - } - } - - private List getFilteredVisibleRoles(UserStoreManager userStoreManager, String username) - throws UserStoreException { - String[] roleListOfUser; - roleListOfUser = userStoreManager.getRoleListOfUser(username); - List filteredRoles = new ArrayList<>(); - for (String role : roleListOfUser) { - if (!(role.startsWith("Internal/") || role.startsWith("Authentication/"))) { - filteredRoles.add(role); - } - } - return filteredRoles; - } - @GET @Path("/filter/{prefix}") @Override @@ -647,7 +542,6 @@ public class RoleManagementServiceImpl implements RoleManagementService { @Consumes(MediaType.WILDCARD) @Override public Response deleteRole(@PathParam("roleName") String roleName, @QueryParam("user-store") String userStoreName) { - String roleToDelete = roleName; if (userStoreName != null && !userStoreName.isEmpty()) { roleName = userStoreName + "/" + roleName; } @@ -655,7 +549,6 @@ public class RoleManagementServiceImpl implements RoleManagementService { try { final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm(); final UserStoreManager userStoreManager = userRealm.getUserStoreManager(); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); if (!userStoreManager.isExistingRole(roleName)) { String msg = "No role exists with the name : " + roleName ; return Response.status(404).entity(msg).build(); @@ -665,18 +558,16 @@ public class RoleManagementServiceImpl implements RoleManagementService { if (log.isDebugEnabled()) { log.debug("Deleting the role in user store"); } - DeviceMgtAPIUtils.getGroupManagementProviderService().deleteRoleAndRoleGroupMapping(roleName, roleToDelete, tenantId, userStoreManager, authorizationManager); + userStoreManager.deleteRole(roleName); + // Delete all authorizations for the current role before deleting + authorizationManager.clearRoleAuthorization(roleName); + return Response.status(Response.Status.OK).build(); } catch (UserStoreException e) { String msg = "Error occurred while deleting the role '" + roleName + "'"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } catch (GroupManagementException e) { - String msg = "Error occurred while deleting group-role mapping records"; - log.error(msg, e); - return Response.serverError().entity( - new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } } @@ -706,7 +597,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { userStoreManager.updateUserListOfRole(roleName, usersToDelete, usersToAdd); return Response.status(Response.Status.OK).entity("Role '" + roleName + "' has " + - "successfully been updated with the user list") + "successfully been updated with the user list") .build(); } catch (UserStoreException e) { String msg = "Error occurred while updating the users of the role '" + roleName + "'"; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java index d0f5239fa3..5209ace472 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java @@ -424,9 +424,6 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(users.size()); BasicUserInfo user; for (String username : users) { - if (Constants.APIM_RESERVED_USER.equals(username) || Constants.RESERVED_USER.equals(username)) { - continue; - } user = getBasicUserInfo(username); userList.add(user); } @@ -487,10 +484,6 @@ public class UserManagementServiceImpl implements UserManagementService { if (StringUtils.isNotEmpty(username)) { commonUsers = getUserList(null, username); } - if (commonUsers != null) { - commonUsers.remove(Constants.APIM_RESERVED_USER); - commonUsers.remove(Constants.RESERVED_USER); - } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(firstName)) { tempList = getUserList(Constants.USER_CLAIM_FIRST_NAME, firstName); @@ -665,9 +658,6 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(); UserInfo user; for (String username : users) { - if (Constants.APIM_RESERVED_USER.equals(username) || Constants.RESERVED_USER.equals(username)) { - continue; - } user = new UserInfo(); user.setUsername(username); user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS)); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java index d7bf236acf..5f6d8a7bae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java @@ -29,34 +29,13 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistEx import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceGroupList; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.GroupManagementAdminService; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.apache.commons.lang.StringUtils; -import org.wso2.carbon.user.api.UserRealm; -import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import java.util.ArrayList; -import java.util.Arrays; public class GroupManagementAdminServiceImpl implements GroupManagementAdminService { @@ -111,25 +90,13 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ @DefaultValue("5") @QueryParam("limit") int limit) { try { RequestValidationUtil.validatePaginationParameters(offset, limit); - String currentUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); GroupPaginationRequest request = new GroupPaginationRequest(offset, limit); request.setGroupName(name); request.setOwner(owner); request.setStatus(status); request.setDepth(depth); - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - UserRealm realmService = DeviceMgtAPIUtils.getRealmService().getTenantUserRealm(tenantId); - String[] roles = realmService.getUserStoreManager().getRoleListOfUser(currentUser); - boolean isAdmin = DEFAULT_ADMIN_ROLE.equals(currentUser); - boolean hasAdminRole = Arrays.asList(roles).contains(DEFAULT_ADMIN_ROLE); - PaginationResult deviceGroupsResult; - if (StringUtils.isBlank(currentUser) || isAdmin || hasAdminRole) { - deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(null, request, requireGroupProps); - } else { - deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() - .getGroupsWithHierarchy(currentUser, request, requireGroupProps); - } + PaginationResult deviceGroupsResult = DeviceMgtAPIUtils.getGroupManagementProviderService() + .getGroupsWithHierarchy(null, request, requireGroupProps); DeviceGroupList deviceGroupList = new DeviceGroupList(); deviceGroupList.setList(deviceGroupsResult.getData()); deviceGroupList.setCount(deviceGroupsResult.getRecordsTotal()); @@ -138,10 +105,6 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ String error = "Error occurred while retrieving groups with hierarchy."; log.error(error, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); - } catch (UserStoreException e) { - String msg = "Error occurred while getting user realm."; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } @@ -181,30 +144,4 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ return Response.status(Response.Status.CONFLICT).entity(msg).build(); } } - @POST - @Path("/roles/share") - @Override - public Response createGroupWithRoles(DeviceGroupRoleWrapper group) { - if (group == null) { - return Response.status(Response.Status.BAD_REQUEST).build(); - } - group.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); - group.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE); - try { - DeviceMgtAPIUtils.getGroupManagementProviderService().createGroupWithRoles(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS); - DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), group.getUserRoles()); - return Response.status(Response.Status.CREATED).build(); - } catch (GroupManagementException e) { - String msg = "Error occurred while adding " + group.getName() + " group"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (GroupAlreadyExistException e) { - String msg = "Group already exists with name : " + group.getName() + " Try with another group name."; - log.error(msg, e); - return Response.status(Response.Status.CONFLICT).entity(msg).build(); - } catch (RoleDoesNotExistException e) { - return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); - } - } - } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java index 0a9b6efa26..300e47b147 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java @@ -30,16 +30,13 @@ public class Constants { public static final String USER_CLAIM_MODIFIED = "http://wso2.org/claims/modified"; public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices"; public static final String PRIMARY_USER_STORE = "PRIMARY"; - public static final String APIM_RESERVED_USER = "apim_reserved_user"; - public static final String RESERVED_USER = "reserved_user"; - public static final String DEFAULT_STREAM_VERSION = "1.0.0"; + public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; public static final String DEFAULT_SIMPLE_DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z"; public static final int DEFAULT_PAGE_LIMIT = 50; public static final String FORWARD_SLASH = "/"; public static final String ANDROID = "android"; - public static final String IS_USER_ABLE_TO_VIEW_ALL_ROLES = "isUserAbleToViewAllRoles"; public static final String ANDROID_POLICY_VALIDATOR = "io.entgra.proprietary.uem.platform.android." + "core.polcy.AndroidPolicyPayloadValidator"; public static final String IOS = "ios"; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index f1a5db1156..a297bffd48 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; @@ -158,7 +157,6 @@ public class DeviceMgtAPIUtils { private static volatile SubscriptionManager subscriptionManager; private static volatile ApplicationManager applicationManager; private static volatile ConsumerRESTAPIServices consumerRESTAPIServices; - private static volatile APIApplicationServices apiApplicationServices; private static volatile APIManagementProviderService apiManagementProviderService; static { @@ -412,25 +410,6 @@ public class DeviceMgtAPIUtils { return consumerRESTAPIServices; } - /** - * Initializing and accessing method for APIM API application REST API. - * - * @return APIApplicationServices instance - * @throws IllegalStateException if APIApplicationServices cannot be initialized - */ - public static synchronized APIApplicationServices getApiApplicationServices() { - if (apiApplicationServices == null) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - apiApplicationServices = (APIApplicationServices) ctx.getOSGiService(APIApplicationServices.class, null); - if (apiApplicationServices == null) { - String msg = "API application service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - } - return apiApplicationServices; - } - /** * Initializing and accessing method for API management Provider Service. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index bec50d0782..d8323a431c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java index 6fd2fedde9..fb4c749b82 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceManagementConstants.java @@ -134,8 +134,6 @@ public final class DeviceManagementConstants { public static final String LAST_NAME = "last-name"; public static final String TENANT_ADMIN_USERNAME = "tenant-admin-username"; public static final String TENANT_ADMIN_PASSWORD = "tenant-admin-password"; - - public static final int OTP_DEFAULT_EXPIRY_SECONDS = 3600; } public static final class EventServices { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java index 08a334bf2f..df0719d152 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java @@ -18,22 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.common.general; -import java.util.Map; - public class QREnrollmentDetails { String ownershipType; String username; String enrollmentMode; - Map customValues; - - public Map getCustomValues() { - return customValues; - } - - public void setCustomValues(Map customValues) { - this.customValues = customValues; - } - int tokenExpiry; public String getOwnershipType() { return ownershipType; } @@ -46,12 +34,4 @@ public class QREnrollmentDetails { public String getEnrollmentMode() { return enrollmentMode; } public void setEnrollmentMode(String enrollmentMode) { this.enrollmentMode = enrollmentMode; } - - public int getTokenExpiry() { - return tokenExpiry; - } - - public void setTokenExpiry(int tokenExpiry) { - this.tokenExpiry = tokenExpiry; - } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java deleted file mode 100644 index 768fe55524..0000000000 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/group/mgt/DeviceGroupRoleWrapper.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2018 - 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.device.mgt.common.group.mgt; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -/** - * Holds Device Group details and expose to external access - */ -@ApiModel(value = "DeviceGroupRoleWrapper", description = "This class carries all information related to a managed device group.") -public class DeviceGroupRoleWrapper implements Serializable { - - private static final long serialVersionUID = 1998121711L; - - @ApiModelProperty(name = "id", value = "ID of the device group in the device group information database.") - private int id; - - @ApiModelProperty(name = "description", value = "The device group description that can be set on the device group by the user.", required = true) - private String description; - - @ApiModelProperty(name = "name", value = "The device group name that can be set on the device group by the user.", required = true) - private String name; - - private String owner; - - @ApiModelProperty(name = "status", value = "The status of group that needs updating/retrieval.") - private String status; - - @ApiModelProperty(name = "parentGroupId", value = "Group ID of parent group") - private int parentGroupId; - - @ApiModelProperty(name = "parentPath", value = "Path of parent group") - private String parentPath; - - @ApiModelProperty(name = "childrenGroups", value = "Children groups") - private List childrenGroups; - - @ApiModelProperty(name = "userRoles", value = "User roles") - private List userRoles; - - public DeviceGroupRoleWrapper() { - } - - public DeviceGroupRoleWrapper(String name) { - this.name = name; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - private Map groupProperties; - - public int getGroupId() { - return id; - } - - public void setGroupId(int id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public Map getGroupProperties() { - return groupProperties; - } - - public void setGroupProperties(Map groupProperties) { - this.groupProperties = groupProperties; - } - - public int getParentGroupId() { - return parentGroupId; - } - - public void setParentGroupId(int parentGroupId) { - this.parentGroupId = parentGroupId; - } - - public String getParentPath() { - return parentPath; - } - - public void setParentPath(String parentPath) { - this.parentPath = parentPath; - } - - public List getChildrenGroups() { - return childrenGroups; - } - - public void setChildrenGroups(List childrenGroups) { - this.childrenGroups = childrenGroups; - } - - public List getUserRoles() { - return userRoles; - } - - public void setUserRoles(List userRoles) { - this.userRoles = userRoles; - } -} \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java index 53113c5b75..afb1d6b0fa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/otp/mgt/OTPEmailTypes.java @@ -19,5 +19,5 @@ package io.entgra.device.mgt.core.device.mgt.common.otp.mgt; public enum OTPEmailTypes { - USER_VERIFY, DEVICE_ENROLLMENT, USER_INVITE, REMOTE_SESSION + USER_VERIFY, DEVICE_ENROLLMENT } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java index e4cfa042b6..c89d311cda 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/OTPManagementService.java @@ -35,8 +35,7 @@ public interface OTPManagementService { * @throws OTPManagementException if error occurred whle verifying validity of the OPT * @throws BadRequestException if found an null value for OTP */ - OneTimePinDTO isValidOTP(String oneTimeToken, boolean requireRenewal) throws - OTPManagementException, BadRequestException; + OneTimePinDTO isValidOTP(String oneTimeToken) throws OTPManagementException, BadRequestException; /** * Invalidate the OTP and send welcome mail @@ -60,7 +59,8 @@ public interface OTPManagementService { boolean hasEmailRegistered(String email, String emailDomain) throws OTPManagementException, DeviceManagementException; - OneTimePinDTO generateOneTimePin(OneTimePinDTO oneTimePinData, boolean persistPin) throws OTPManagementException; + OneTimePinDTO generateOneTimePin(String email, String emailType, String userName, Object metaDataObj, + int tenantId, boolean persistPin) throws OTPManagementException; OneTimePinDTO getRenewedOtpByEmailAndMailType(String email, String emailType) throws OTPManagementException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index c00dc59b3b..a4673c3e6e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -76,20 +76,12 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - + + file:src/test/resources/log4j.properties + src/test/resources/testng.xml - - ${basedir}/target/coverage-reports/jacoco-unit.exec - file:src/test/resources/log4j.properties - - - org.ops4j.pax.logging - @@ -263,7 +255,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java index 729e477c00..eac30a6de6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java @@ -139,12 +139,7 @@ public interface DeviceManagementConfigService { value = "The properties list using for query a device", required = true) @QueryParam("properties") - String properties, - @ApiParam( - name = "withAccessToken", - value = "Whether to use access token or otp token for device configuration") - @QueryParam("withAccessToken") - boolean withAccessToken); + String properties); @PUT @Path("/device/transfer") diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java index de80a541d2..f387dfea32 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java @@ -21,10 +21,6 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.OTPManagementException; -import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.OTPEmailTypes; -import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto.OneTimePinDTO; -import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; import io.entgra.device.mgt.core.device.mgt.common.AppRegistrationCredentials; import io.entgra.device.mgt.core.device.mgt.common.ApplicationRegistrationException; import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; @@ -52,30 +48,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.AppRegistrationCredentials; -import org.wso2.carbon.device.mgt.common.ApplicationRegistrationException; -import org.wso2.carbon.device.mgt.common.DeviceTransferRequest; -import org.wso2.carbon.device.mgt.common.configuration.mgt.AmbiguousConfigurationException; -import org.wso2.carbon.device.mgt.common.configuration.mgt.DeviceConfiguration; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException; -import org.wso2.carbon.device.mgt.common.exceptions.OTPManagementException; -import org.wso2.carbon.device.mgt.common.general.TenantDetail; -import org.wso2.carbon.device.mgt.common.otp.mgt.OTPEmailTypes; -import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; -import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagementException; -import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; -import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; -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.keymanager.KeyManagerConfigurations; -import org.wso2.carbon.device.mgt.core.config.ui.UIConfiguration; -import org.wso2.carbon.device.mgt.core.config.ui.UIConfigurationManager; -import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionUtils; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; -import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; -import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.user.api.Tenant; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; @@ -98,8 +70,7 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig @Path("/configurations") @Produces(MediaType.APPLICATION_JSON) public Response getConfiguration(@HeaderParam("token") String token, - @QueryParam("properties") String properties, - @QueryParam("withAccessToken") boolean withAccessToken) { + @QueryParam("properties") String properties) { DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService(); try { if (token == null || token.isEmpty()) { @@ -124,8 +95,7 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig deviceProps.put("token", token); DeviceConfiguration devicesConfiguration = dms.getDeviceConfiguration(deviceProps); - if (withAccessToken) setAccessTokenToDeviceConfigurations(devicesConfiguration); - else setOTPTokenToDeviceConfigurations(devicesConfiguration); + setAccessTokenToDeviceConfigurations(devicesConfiguration); return Response.status(Response.Status.OK).entity(devicesConfiguration).build(); } catch (DeviceManagementException e) { String msg = "Error occurred while retrieving configurations"; @@ -237,33 +207,6 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig } } - private void setOTPTokenToDeviceConfigurations(DeviceConfiguration deviceConfiguration) - throws DeviceManagementException { - OneTimePinDTO oneTimePinData = new OneTimePinDTO(); - oneTimePinData.setEmail(OTPEmailTypes.DEVICE_ENROLLMENT.toString()); - oneTimePinData.setEmailType(OTPEmailTypes.DEVICE_ENROLLMENT.toString()); - oneTimePinData.setUsername(deviceConfiguration.getDeviceOwner()); - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( - deviceConfiguration.getTenantDomain(), true); - oneTimePinData.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - PrivilegedCarbonContext.endTenantFlow(); - OTPManagementService otpManagementService = DeviceMgtAPIUtils.getOtpManagementService(); - try { - OneTimePinDTO oneTimePinDTO = otpManagementService.generateOneTimePin(oneTimePinData, true); - if (oneTimePinDTO == null) { - String msg = "Null value returned when generating OTP token for " + oneTimePinData.getOtpToken(); - log.error(msg); - throw new DeviceManagementException(msg); - } - deviceConfiguration.setAccessToken(oneTimePinDTO.getOtpToken()); - } catch (OTPManagementException ex) { - String msg = "Error occurred while generating one time pin: " + ex.getMessage(); - log.error(msg, ex); - throw new DeviceManagementException(msg, ex); - } - } - @Override @Path("/tenants") @GET diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java index fbe57c8928..1dd6052def 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/util/DeviceMgtAPIUtils.java @@ -22,8 +22,6 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.user.core.service.RealmService; /** @@ -36,8 +34,6 @@ public class DeviceMgtAPIUtils { private static DeviceManagementProviderService deviceManagementProviderService = null; private static RealmService realmService = null; - private static OTPManagementService otpManagementService = null; - public static DeviceManagementProviderService getDeviceManagementService() { if (deviceManagementProviderService == null) { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -52,19 +48,6 @@ public class DeviceMgtAPIUtils { return deviceManagementProviderService; } - public static OTPManagementService getOtpManagementService() { - if (otpManagementService == null) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - otpManagementService = (OTPManagementService) ctx.getOSGiService(OTPManagementService.class, null); - if (otpManagementService == null) { - String msg = "OTP Management Service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - } - return otpManagementService; - } - public static RealmService getRealmService() { if (realmService == null) { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 26f6603912..521ff65c5c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -473,7 +473,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito org.wso2.carbon.multitenancy diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index ac91b7036f..16ac6f62be 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -22,7 +22,6 @@ import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import java.util.List; import java.util.Map; @@ -41,18 +40,6 @@ public interface GroupDAO { */ int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException; - /** - * Add properties for device group. - * Note that groupId parameter is considered seperately due to the groupId parameter passed with - * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. - * - * @param groups to be added. - * @param tenantId of the group. - * @return sql execution result. - * @throws GroupManagementDAOException - */ - int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException; - /** * Add properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with @@ -65,18 +52,6 @@ public interface GroupDAO { */ boolean addGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException; - /** - * Update properties for device group. - * Note that groupId parameter is considered seperately due to the groupId parameter passed with - * device group Payload is ignored in the add/update logic instead the internal groupId reference is used. - * - * @param groups to be updated. - * @param tenantId of the group. - * @return sql execution result. - * @throws GroupManagementDAOException - */ - boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) throws GroupManagementDAOException; - /** * Update properties for device group. * Note that groupId parameter is considered seperately due to the groupId parameter passed with @@ -155,15 +130,6 @@ public interface GroupDAO { */ void deleteGroupsMapping(List groupIds, int tenantId) throws GroupManagementDAOException; - /** - * Delete mappings of Device Groups. - * - * @param role of Device Groups. - * @param tenantId of the role. - * @throws GroupManagementDAOException on error during deletion of mappings of groups - */ - void deleteGroupsMapping(String role, int tenantId) throws GroupManagementDAOException; - /** * Delete existing Device Groups. * @@ -220,19 +186,6 @@ public interface GroupDAO { */ List getGroups(GroupPaginationRequest paginationRequest, int tenantId) throws GroupManagementDAOException; - /** - * Get paginated list of Device Groups in tenant with specified device group ids. - * - * @param paginationRequest to filter results. - * @param deviceGroupIds of groups required. - * @param tenantId of user's tenant. - * @param isWithParentPath of user's ParentPath. - * @return List of all Device Groups in tenant. - * @throws GroupManagementDAOException - */ - List getGroups(GroupPaginationRequest paginationRequest, List deviceGroupIds, - int tenantId, boolean isWithParentPath) throws GroupManagementDAOException; - /** * Get paginated list of Device Groups in tenant with specified device group ids. * @@ -459,4 +412,4 @@ public interface GroupDAO { List groupNames) throws GroupManagementDAOException; -} \ No newline at end of file +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index e1fc26eb8e..803526e593 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -18,7 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; @@ -50,7 +49,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "WHERE TENANT_ID = ?"; if (StringUtils.isNotBlank(request.getGroupName())) { sql += " AND GROUP_NAME LIKE ?"; @@ -104,7 +103,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { @Override public List getGroups(GroupPaginationRequest request, List deviceGroupIds, - int tenantId) throws GroupManagementDAOException { + int tenantId) throws GroupManagementDAOException { int deviceGroupIdsCount = deviceGroupIds.size(); if (deviceGroupIdsCount == 0) { return new ArrayList<>(); @@ -112,7 +111,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE TENANT_ID = ?"; + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP WHERE TENANT_ID = ?"; if (StringUtils.isNotBlank(request.getGroupName())) { sql += " AND GROUP_NAME LIKE ?"; } @@ -165,73 +164,6 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throw new GroupManagementDAOException(msg, e); } } - @Override - public List getGroups(GroupPaginationRequest request, List deviceGroupIds, - int tenantId, boolean isWithParentPath) throws GroupManagementDAOException { - int deviceGroupIdsCount = deviceGroupIds.size(); - if (deviceGroupIdsCount == 0) { - return new ArrayList<>(); - } - - try { - Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE TENANT_ID = ?"; - if (StringUtils.isNotBlank(request.getGroupName())) { - sql += " AND GROUP_NAME LIKE ?"; - } - if (StringUtils.isNotBlank(request.getOwner())) { - sql += " AND OWNER LIKE ?"; - } - if (StringUtils.isNotBlank(request.getParentPath())) { - if(isWithParentPath){ - sql += " AND PARENT_PATH LIKE ?"; - } - } - sql += " AND ID IN ("; - for (int i = 0; i < deviceGroupIdsCount; i++) { - sql += (deviceGroupIdsCount - 1 != i) ? "?," : "?"; - } - sql += ")"; - if (request.getRowCount() != 0) { - sql += " LIMIT ? OFFSET ?"; - } - - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - int paramIndex = 1; - stmt.setInt(paramIndex++, tenantId); - if (StringUtils.isNotBlank(request.getGroupName())) { - stmt.setString(paramIndex++, request.getGroupName() + "%"); - } - if (StringUtils.isNotBlank(request.getOwner())) { - stmt.setString(paramIndex++, request.getOwner() + "%"); - } - if (StringUtils.isNotBlank(request.getParentPath())) { - if(isWithParentPath){ - stmt.setString(paramIndex++, request.getParentPath()); - } - } - for (Integer deviceGroupId : deviceGroupIds) { - stmt.setInt(paramIndex++, deviceGroupId); - } - if (request.getRowCount() != 0) { - stmt.setInt(paramIndex++, request.getRowCount()); - stmt.setInt(paramIndex, request.getStartIndex()); - } - List deviceGroupList = new ArrayList<>(); - try (ResultSet resultSet = stmt.executeQuery()) { - while (resultSet.next()) { - deviceGroupList.add(GroupManagementDAOUtil.loadGroup(resultSet)); - } - } - return deviceGroupList; - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving groups of groups IDs " + deviceGroupIds.toString() - + " in tenant: " + tenantId; - log.error(msg); - throw new GroupManagementDAOException(msg, e); - } - } @Override public int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException { @@ -243,11 +175,11 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { Connection conn = GroupManagementDAOFactory.getConnection(); String sql; if (deviceGroup.getStatus() == null || deviceGroup.getStatus().isEmpty()) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " - + "VALUES (?, ?, ?, ?, ?, ?)"; + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + + "VALUES (?, ?, ?, ?, ?)"; } else { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID, STATUS) " - + "VALUES (?, ?, ?, ?, ?, ?, ?)"; + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + + "VALUES (?, ?, ?, ?, ?, ?)"; hasStatus = true; } stmt = conn.prepareStatement(sql, new String[]{"ID"}); @@ -256,9 +188,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(3, deviceGroup.getOwner()); stmt.setInt(4, tenantId); stmt.setString(5, deviceGroup.getParentPath()); - stmt.setInt(6, deviceGroup.getParentGroupId()); if (hasStatus) { - stmt.setString(7, deviceGroup.getStatus()); + stmt.setString(6, deviceGroup.getStatus()); } stmt.executeUpdate(); @@ -275,47 +206,6 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } - @Override - public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { - int groupId = -1; - boolean hasStatus = false; - try { - Connection conn = GroupManagementDAOFactory.getConnection(); - String sql; - if (groups.getStatus() == null || groups.getStatus().isEmpty()) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " - + "VALUES (?, ?, ?, ?, ?, ?)"; - } else { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID, STATUS) " - + "VALUES (?, ?, ?, ?, ?, ?, ?)"; - hasStatus = true; - } - try (PreparedStatement stmt = conn.prepareStatement(sql, new String[]{"ID"})) { - stmt.setString(1, groups.getDescription()); - stmt.setString(2, groups.getName()); - stmt.setString(3, groups.getOwner()); - stmt.setInt(4, tenantId); - stmt.setString(5, groups.getParentPath()); - stmt.setInt(6, groups.getParentGroupId()); - if (hasStatus) { - stmt.setString(7, groups.getStatus()); - } - stmt.executeUpdate(); - try (ResultSet rs = stmt.getGeneratedKeys();) { - if (rs.next()) { - groupId = rs.getInt(1); - } - return groupId; - } - } - } catch (SQLException e) { - String msg = "Error occurred while adding deviceGroup '" + - groups.getName() + "'"; - log.error(msg); - throw new GroupManagementDAOException(msg, e); - } - } - public boolean addGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException { boolean status; @@ -344,33 +234,6 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { return status; } - public boolean addGroupPropertiesWithRoles(DeviceGroupRoleWrapper groups, int groupId, int tenantId) - throws GroupManagementDAOException { - boolean status; - try { - Connection conn = GroupManagementDAOFactory.getConnection(); - try (PreparedStatement stmt = conn.prepareStatement( - "INSERT INTO GROUP_PROPERTIES(GROUP_ID, PROPERTY_NAME, " + - "PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?)")) { - for (Map.Entry entry : groups.getGroupProperties().entrySet()) { - stmt.setInt(1, groupId); - stmt.setString(2, entry.getKey()); - stmt.setString(3, entry.getValue()); - stmt.setInt(4, tenantId); - stmt.addBatch(); - } - stmt.executeBatch(); - status = true; - } - } catch (SQLException e) { - String msg = "Error occurred while adding properties for group '" + - groups.getName() + "' values : " + groups.getGroupProperties(); - log.error(msg); - throw new GroupManagementDAOException(msg, e); - } - return status; - } - public boolean updateGroupProperties(DeviceGroup deviceGroup, int groupId, int tenantId) throws GroupManagementDAOException { boolean status; @@ -440,7 +303,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = "UPDATE DM_GROUP SET DESCRIPTION = ?, GROUP_NAME = ?, OWNER = ?, STATUS = ?, " - + "PARENT_PATH = ?, PARENT_GROUP_ID = ? WHERE ID = ? AND TENANT_ID = ?"; + + "PARENT_PATH = ? WHERE ID = ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)){ for (DeviceGroup deviceGroup : deviceGroups) { stmt.setString(1, deviceGroup.getDescription()); @@ -448,9 +311,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(3, deviceGroup.getOwner()); stmt.setString(4, deviceGroup.getStatus()); stmt.setString(5, deviceGroup.getParentPath()); - stmt.setInt(6, deviceGroup.getParentGroupId()); - stmt.setInt(7, deviceGroup.getGroupId()); - stmt.setInt(8, tenantId); + stmt.setInt(6, deviceGroup.getGroupId()); + stmt.setInt(7, tenantId); stmt.addBatch(); } stmt.executeBatch(); @@ -541,23 +403,6 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } - @Override - public void deleteGroupsMapping(String role, int tenantId) throws GroupManagementDAOException { - - try { - Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "DELETE FROM DM_ROLE_GROUP_MAP WHERE ROLE = ? AND TENANT_ID = ?"; - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, role); - stmt.setInt(2, tenantId); - stmt.executeUpdate(); - } - } catch (SQLException e) { - String msg = "Error occurred while removing record from group-role mapping."; - log.error(msg); - throw new GroupManagementDAOException(msg, e); - } - } @Override public void deleteGroups(List groupIds, int tenantId) throws GroupManagementDAOException { try { @@ -646,7 +491,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { ResultSet resultSet = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP WHERE ID = ? " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP WHERE ID = ? " + "AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, groupId); @@ -669,7 +514,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { public List getChildrenGroups(String parentPath, int tenantId) throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "WHERE PARENT_PATH LIKE ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, parentPath + "%"); @@ -694,7 +539,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { public List getRootGroups(int tenantId) throws GroupManagementDAOException { try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "WHERE PARENT_PATH LIKE ? AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, "/"); @@ -722,7 +567,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupBuilders = new ArrayList<>(); try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT G.ID, G.GROUP_NAME, G.DESCRIPTION, G.OWNER, G.STATUS, G.PARENT_PATH, G.PARENT_GROUP_ID FROM DM_GROUP G " + + String sql = "SELECT G.ID, G.GROUP_NAME, G.DESCRIPTION, G.OWNER, G.STATUS, G.PARENT_PATH FROM DM_GROUP G " + "INNER JOIN DM_DEVICE_GROUP_MAP GM ON G.ID = GM.GROUP_ID " + "WHERE GM.DEVICE_ID = ? AND GM.TENANT_ID = ?"; stmt = conn.prepareStatement(sql); @@ -860,7 +705,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { try { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = - "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "WHERE LOWER(GROUP_NAME) = LOWER(?) AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, groupName); @@ -1031,7 +876,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupList = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID P FROM DM_GROUP g, " + + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP g, " + "(SELECT GROUP_ID FROM DM_ROLE_GROUP_MAP WHERE ROLE IN ("; int index = 0; @@ -1145,7 +990,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { List deviceGroupList = null; try { Connection conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH, PARENT_GROUP_ID FROM DM_GROUP " + String sql = "SELECT ID, DESCRIPTION, GROUP_NAME, OWNER, STATUS, PARENT_PATH FROM DM_GROUP " + "WHERE OWNER = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, username); @@ -1283,7 +1128,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } - @Override + @Override public List getAllDevicesOfGroup(String groupName, int tenantId) throws GroupManagementDAOException { Connection conn; List devices; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java index 6a786a0bfd..f2aeaed327 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java @@ -18,9 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.group; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; @@ -42,7 +39,6 @@ import java.util.List; */ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { - private static final Log log = LogFactory.getLog(PostgreSQLGroupDAOImpl.class); @Override public int addGroup(DeviceGroup deviceGroup, int tenantId) throws GroupManagementDAOException { PreparedStatement stmt = null; @@ -53,7 +49,7 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { Connection conn = GroupManagementDAOFactory.getConnection(); String sql; if(StringUtils.isEmpty(deviceGroup.getStatus())) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, PARENT_GROUP_ID) " + + sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + "VALUES (?, ?, ?, ?) RETURNING ID"; } else { sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + @@ -83,46 +79,6 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { } } - @Override - public int addGroupWithRoles(DeviceGroupRoleWrapper groups, int tenantId) throws GroupManagementDAOException { - int groupId = -1; - boolean hasStatus = false; - try { - Connection conn = GroupManagementDAOFactory.getConnection(); - String sql; - if (StringUtils.isEmpty(groups.getStatus())) { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH) " + - "VALUES (?, ?, ?, ?) RETURNING ID"; - } else { - sql = "INSERT INTO DM_GROUP(DESCRIPTION, GROUP_NAME, OWNER, TENANT_ID, PARENT_PATH, STATUS) " + - "VALUES (?, ?, ?, ?, ?) RETURNING ID"; - hasStatus = true; - } - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, groups.getDescription()); - stmt.setString(2, groups.getName()); - stmt.setString(3, groups.getOwner()); - stmt.setInt(4, tenantId); - stmt.setString(5, groups.getParentPath()); - if (hasStatus) { - stmt.setString(6, groups.getStatus()); - } - stmt.execute(); - try (ResultSet rs = stmt.getGeneratedKeys()) { - if (rs.next()) { - groupId = rs.getInt(1); - } - return groupId; - } - } - } catch (SQLException e) { - String msg = "Error occurred while adding deviceGroup '" + - groups.getName() + "'"; - log.error(msg); - throw new GroupManagementDAOException(msg, e); - } - } - @Override public List getDevices(int groupId, int startIndex, int rowCount, int tenantId) throws GroupManagementDAOException { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java index 42307e6b74..acf8d4c614 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/GroupManagementDAOUtil.java @@ -87,7 +87,6 @@ public final class GroupManagementDAOUtil { group.setOwner(resultSet.getString("OWNER")); group.setStatus(resultSet.getString("STATUS")); group.setParentPath(resultSet.getString("PARENT_PATH")); - group.setParentGroupId(resultSet.getInt("PARENT_GROUP_ID")); return group; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java index 3fa8fdc453..a901ffeddf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -118,18 +118,18 @@ public class DeviceManagementDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - setTenantManager(realmService != null ? - realmService.getTenantManager() : null); + this.setTenantManager(realmService); } public TenantManager getTenantManager() { - if (tenantManager == null) { - throw new IllegalStateException("Tenant manager is not initialized properly"); - } - return tenantManager; } + return tenantManager; + } - private void setTenantManager(TenantManager tenantManager) { - this.tenantManager = tenantManager; + private void setTenantManager(RealmService realmService) { + if (realmService == null) { + throw new IllegalStateException("Realm service is not initialized properly"); + } + this.tenantManager = realmService.getTenantManager(); } public DeviceManagementProviderService getDeviceManagementProvider() { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index e752475939..5e5ca5c13d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -19,23 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt; import io.entgra.device.mgt.core.device.mgt.common.*; -import com.google.gson.Gson; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceConnectivityLoggerImpl; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; -import org.apache.commons.lang.StringUtils; -import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; -import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException; @@ -85,8 +68,7 @@ import java.util.concurrent.ThreadPoolExecutor; */ public class OperationManagerImpl implements OperationManager { - DeviceConnectivityLogContext.Builder deviceConnectivityLogContextBuilder = new DeviceConnectivityLogContext.Builder(); - private static final EntgraLogger log = new EntgraDeviceConnectivityLoggerImpl(OperationManagerImpl.class); + private static final Log log = LogFactory.getLog(OperationManagerImpl.class); private static final int CACHE_VALIDITY_PERIOD = 5 * 60 * 1000; private static final String NOTIFIER_TYPE_LOCAL = "LOCAL"; private static final String SYSTEM = "system"; @@ -169,8 +151,6 @@ public class OperationManagerImpl implements OperationManager { } } - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); DeviceIDHolder deviceValidationResult = DeviceManagerUtil.validateDeviceIdentifiers(deviceIds); List validDeviceIds = deviceValidationResult.getValidDeviceIDList(); if (!validDeviceIds.isEmpty()) { @@ -247,10 +227,6 @@ public class OperationManagerImpl implements OperationManager { activity.setActivityStatus( this.getActivityStatus(deviceValidationResult, deviceAuthorizationResult)); } - for (DeviceIdentifier deviceId : authorizedDeviceIds) { - device = getDevice(deviceId); - log.info("Operation added", deviceConnectivityLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(deviceType).setActionTag("ADD_OPERATION").setTenantDomain(tenantDomain).setTenantId(tenantId).setUserName(initiatedBy).setOperationCode(operationCode).build()); - } return activity; } catch (OperationManagementDAOException e) { OperationManagementDAOFactory.rollbackTransaction(); @@ -472,7 +448,6 @@ public class OperationManagerImpl implements OperationManager { int failAttempts = 0; while (true) { try { - OperationManagementDAOFactory.beginTransaction(); operationMappingDAO.updateOperationMapping(operation.getId(), device.getEnrolmentInfo().getId(), io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.PushNotificationStatus.SCHEDULED); OperationManagementDAOFactory.commitTransaction(); @@ -495,11 +470,6 @@ public class OperationManagerImpl implements OperationManager { } catch (InterruptedException ignore) { break; } - } catch (TransactionManagementException ex) { - log.error("Error occurred while initiating the transaction", ex); - break; - } finally { - OperationManagementDAOFactory.closeConnection(); } } } catch (Exception e) { @@ -703,9 +673,7 @@ public class OperationManagerImpl implements OperationManager { if (log.isDebugEnabled()) { log.debug("Device identifier id:[" + deviceId.getId() + "] type:[" + deviceId.getType() + "]"); } - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + EnrolmentInfo enrolmentInfo = this.getActiveEnrolmentInfo(deviceId); if (enrolmentInfo == null) { throw new OperationManagementException("Device not found for the given device Identifier:" + @@ -718,25 +686,16 @@ public class OperationManagerImpl implements OperationManager { case INACTIVE: case UNREACHABLE: this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceCacheManagerImpl.getInstance().removeDeviceFromCache(deviceId, tenantId); break; } - log.info("Device Connected", deviceConnectivityLogContextBuilder - .setDeviceId(deviceId.getId()) - .setDeviceType(deviceId.getType()) - .setActionTag("PENDING_OPERATION") - .setTenantDomain(tenantDomain) - .setTenantId(String.valueOf(tenantId)) - .setUserName(userName) - .build()); + return getOperations(deviceId, Operation.Status.PENDING, enrolmentId); } @Override public List getPendingOperations(Device device) throws OperationManagementException { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo(); if (enrolmentInfo == null) { throw new OperationManagementException("Device not found for the given device Identifier:" + @@ -754,10 +713,10 @@ public class OperationManagerImpl implements OperationManager { this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE); device.setEnrolmentInfo(enrolmentInfo); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceCacheManagerImpl.getInstance().addDeviceToCache(deviceIdentifier, device, tenantId); break; } - log.info("Device Connected", deviceConnectivityLogContextBuilder.setDeviceId(device.getDeviceIdentifier()).setDeviceType(device.getType()).setActionTag("PENDING_OPERATION").setTenantDomain(tenantDomain).setTenantId(String.valueOf(tenantId)).setUserName(userName).build()); return getOperations(deviceIdentifier, Operation.Status.PENDING, enrolmentId); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java index 02373de936..eaac0bf827 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/dao/impl/GenericOTPManagementDAOImpl.java @@ -18,7 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DBConnectionException; import io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto.OneTimePinDTO; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.AbstractDAOImpl; @@ -26,12 +25,7 @@ import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.OTPManagementDAO; import io.entgra.device.mgt.core.device.mgt.core.otp.mgt.exception.OTPManagementDAOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.exceptions.DBConnectionException; -import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; -import org.wso2.carbon.device.mgt.core.otp.mgt.dao.AbstractDAOImpl; -import org.wso2.carbon.device.mgt.core.otp.mgt.dao.OTPManagementDAO; -import org.wso2.carbon.device.mgt.core.otp.mgt.exception.OTPManagementDAOException; + import java.sql.*; import java.util.Calendar; import java.util.List; @@ -57,8 +51,7 @@ public class GenericOTPManagementDAOImpl extends AbstractDAOImpl implements OTPM + "META_INFO, " + "CREATED_AT," + "TENANT_ID," - + "USERNAME, " - + "EXPIRY_TIME) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; + + "USERNAME) VALUES (?, ?, ?, ?, ?, ?, ?)"; try { Connection conn = this.getDBConnection(); Calendar calendar = Calendar.getInstance(); @@ -72,8 +65,6 @@ public class GenericOTPManagementDAOImpl extends AbstractDAOImpl implements OTPM stmt.setTimestamp(5, timestamp); stmt.setInt(6, oneTimePinDTO.getTenantId()); stmt.setString(7, oneTimePinDTO.getUsername()); - stmt.setInt(8, oneTimePinDTO.getExpiryTime() == 0 - ? DeviceManagementConstants.OTPProperties.OTP_DEFAULT_EXPIRY_SECONDS : oneTimePinDTO.getExpiryTime()); stmt.addBatch(); } stmt.executeBatch(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java index 074eb8eed7..087cf3851f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/otp/mgt/service/OTPManagementServiceImpl.java @@ -117,8 +117,7 @@ public class OTPManagementServiceImpl implements OTPManagementService { } @Override - public OneTimePinDTO isValidOTP(String oneTimeToken, boolean requireRenewal) throws OTPManagementException, - BadRequestException { + public OneTimePinDTO isValidOTP(String oneTimeToken) throws OTPManagementException, BadRequestException { if (StringUtils.isBlank(oneTimeToken)){ String msg = "Received blank OTP to verify. OTP: " + oneTimeToken; log.error(msg); @@ -142,19 +141,17 @@ public class OTPManagementServiceImpl implements OTPManagementService { oneTimePinDTO.getCreatedAt().getTime() + oneTimePinDTO.getExpiryTime() * 1000L); if (currentTimestamp.after(expiredTimestamp)) { - if (requireRenewal) { - String renewedOTP = UUID.randomUUID().toString(); - renewOTP(oneTimePinDTO, renewedOTP); - Gson gson = new Gson(); - Tenant tenant = gson.fromJson(oneTimePinDTO.getMetaInfo(), Tenant.class); + String renewedOTP = UUID.randomUUID().toString(); + renewOTP(oneTimePinDTO, renewedOTP); + Gson gson = new Gson(); + Tenant tenant = gson.fromJson(oneTimePinDTO.getMetaInfo(), Tenant.class); - Properties props = new Properties(); - props.setProperty("first-name", tenant.getAdminFirstName()); - props.setProperty("otp-token", renewedOTP); - props.setProperty("email", oneTimePinDTO.getEmail()); - props.setProperty("type", oneTimePinDTO.getEmailType()); - sendMail(props, oneTimePinDTO.getEmail(), DeviceManagementConstants.EmailAttributes.USER_VERIFY_TEMPLATE); - } + Properties props = new Properties(); + props.setProperty("first-name", tenant.getAdminFirstName()); + props.setProperty("otp-token", renewedOTP); + props.setProperty("email", oneTimePinDTO.getEmail()); + props.setProperty("type", oneTimePinDTO.getEmailType()); + sendMail(props, oneTimePinDTO.getEmail(), DeviceManagementConstants.EmailAttributes.USER_VERIFY_TEMPLATE); return null; } return oneTimePinDTO; @@ -227,6 +224,9 @@ public class OTPManagementServiceImpl implements OTPManagementService { } } } + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + OneTimePinDTO oneTimePinDTO; + List oneTimePinDTOList = new ArrayList<>(); Properties props = new Properties(); props.setProperty("enrollment-steps", enrollmentSteps.toString()); try { @@ -234,11 +234,16 @@ public class OTPManagementServiceImpl implements OTPManagementService { for (String username : deviceEnrollmentInvitation.getUsernames()) { String emailAddress = DeviceManagerUtil.getUserClaimValue( username, DeviceManagementConstants.User.CLAIM_EMAIL_ADDRESS); + oneTimePinDTO = generateOneTimePin(emailAddress, OTPEmailTypes.DEVICE_ENROLLMENT.toString(), username, + null, tenantId, false); + oneTimePinDTOList.add(oneTimePinDTO); props.setProperty("first-name", DeviceManagerUtil. getUserClaimValue(username, DeviceManagementConstants.User.CLAIM_FIRST_NAME)); props.setProperty("username", username); + props.setProperty("otp-token", oneTimePinDTO.getOtpToken()); sendMail(props, emailAddress, DeviceManagementConstants.EmailAttributes.USER_ENROLLMENT_TEMPLATE); } + this.otpManagementDAO.addOTPData(oneTimePinDTOList); ConnectionManagerUtil.commitDBTransaction(); } catch (UserStoreException e) { String msg = "Error occurred while getting claim values to invite user"; @@ -252,6 +257,11 @@ public class OTPManagementServiceImpl implements OTPManagementService { String msg = "SQL Error occurred when adding OPT data to send device enrollment Invitation."; log.error(msg, e); throw new OTPManagementException(msg, e); + } catch (OTPManagementDAOException e) { + ConnectionManagerUtil.rollbackDBTransaction(); + String msg = "Error occurred while saving the OTP data."; + log.error(msg, e); + throw new OTPManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -259,17 +269,27 @@ public class OTPManagementServiceImpl implements OTPManagementService { /** * Create One Time Token - * @param oneTimePinDTO Data related to the one time pin + * @param email email + * @param emailType email type + * @param userName username + * @param metaDataObj meta data object + * @param tenantId tenant Id * @return {@link OneTimePinDTO} */ @Override - public OneTimePinDTO generateOneTimePin(OneTimePinDTO oneTimePinDTO, boolean persistPin) throws OTPManagementException { + public OneTimePinDTO generateOneTimePin(String email, String emailType, String userName, Object metaDataObj, + int tenantId, boolean persistPin) throws OTPManagementException { String otpValue = UUID.randomUUID().toString(); Gson gson = new Gson(); - String metaInfo = gson.toJson(oneTimePinDTO.getMetaInfo()); + String metaInfo = gson.toJson(metaDataObj); + OneTimePinDTO oneTimePinDTO = new OneTimePinDTO(); + oneTimePinDTO.setEmail(email); + oneTimePinDTO.setTenantId(tenantId); + oneTimePinDTO.setUsername(userName); + oneTimePinDTO.setEmailType(emailType); oneTimePinDTO.setMetaInfo(metaInfo); oneTimePinDTO.setOtpToken(otpValue); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index eb1a60c48c..02d6b010eb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -21,30 +21,6 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import io.entgra.device.mgt.core.device.mgt.common.*; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceEnrolmentLoggerImpl; -import org.apache.commons.collections.map.SingletonMap; -import org.apache.commons.lang.StringUtils; -import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.Billing; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceEnrollmentInfoNotification; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManager; -import io.entgra.device.mgt.core.device.mgt.common.DeviceNotification; -import io.entgra.device.mgt.core.device.mgt.common.DevicePropertyNotification; -import io.entgra.device.mgt.core.device.mgt.common.DeviceTransferRequest; -import io.entgra.device.mgt.core.device.mgt.common.DynamicTaskContext; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.FeatureManager; -import io.entgra.device.mgt.core.device.mgt.common.InitialOperationConfig; -import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; -import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.common.StartupOperationConfig; -import io.entgra.device.mgt.core.device.mgt.common.BillingResponse; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.*; @@ -135,27 +111,13 @@ import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.*; -import java.time.LocalTime; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService, PluginInitializationListener { - DeviceEnrolmentLogContext.Builder deviceEnrolmentLogContextBuilder = new DeviceEnrolmentLogContext.Builder(); - - private static final EntgraLogger log = new EntgraDeviceEnrolmentLoggerImpl(DeviceManagementProviderServiceImpl.class); + private static final Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class); private static final String OPERATION_RESPONSE_EVENT_STREAM_DEFINITION = "org.wso2.iot.OperationResponseStream"; private final DeviceManagementPluginRepository pluginRepository; @@ -243,8 +205,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } return false; } - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); EnrollmentConfiguration enrollmentConfiguration = DeviceManagerUtil.getEnrollmentConfigurationEntry(); String deviceSerialNumber = null; if (enrollmentConfiguration != null) { @@ -331,15 +291,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + "'"); } - log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder - .setDeviceId(String.valueOf(existingDevice.getId())) - .setDeviceType(String.valueOf(existingDevice.getType())) - .setOwner(newEnrolmentInfo.getOwner()) - .setOwnership(String.valueOf(newEnrolmentInfo.getOwnership())) - .setTenantID(String.valueOf(tenantId)) - .setTenantDomain(tenantDomain) - .setUserName(userName) - .build()); status = true; } else { log.warn("Unable to update device enrollment for device : " + device.getDeviceIdentifier() + @@ -376,7 +327,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } device.setEnrolmentInfo(enrollment); DeviceManagementDAOFactory.commitTransaction(); - log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(String.valueOf(device.getType())).setOwner(enrollment.getOwner()).setOwnership(String.valueOf(enrollment.getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); } else { DeviceManagementDAOFactory.rollbackTransaction(); throw new DeviceManagementException("No device type registered with name - " + device.getType() @@ -454,8 +404,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (log.isDebugEnabled()) { log.debug("Modifying enrollment for device: " + device.getId() + " of type '" + device.getType() + "'"); } - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); DeviceManager deviceManager = this.getDeviceManager(device.getType()); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); if (deviceManager == null) { @@ -484,7 +432,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId); DeviceManagementDAOFactory.commitTransaction(); - log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(currentDevice.getId())).setDeviceType(String.valueOf(currentDevice.getType())).setOwner(currentDevice.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(currentDevice.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); this.removeDeviceFromCache(deviceIdentifier); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); @@ -568,8 +515,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } int tenantId = this.getTenantId(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + Device device = this.getDevice(deviceId, false); if (device == null) { if (log.isDebugEnabled()) { @@ -603,7 +549,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } } //procees to dis-enroll a device from traccar ends - log.info("Device disenrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(String.valueOf(device.getType())).setOwner(device.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(device.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); + } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while dis-enrolling '" + deviceId.getType() + @@ -1060,15 +1006,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv dateDiff = endDate.getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); } } - - // Convert dateDiff to days as a decimal value - double dateDiffInDays = (double) dateDiff / (24 * 60 * 60 * 1000); - - if (dateDiffInDays % 1 >= 0.9) { - dateDiffInDays = Math.ceil(dateDiffInDays); - } - - long dateInDays = (long) dateDiffInDays; + long dateInDays = TimeUnit.DAYS.convert(dateDiff, TimeUnit.MILLISECONDS); double cost = (tenantCost.getCost() / 365) * dateInDays; totalCost += cost; device.setCost(Math.round(cost * 100.0) / 100.0); @@ -1135,13 +1073,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv long difference_In_Days = (difference_In_Time / (1000 * 60 * 60 * 24)) % 365; - if (difference_In_Time % (1000 * 60 * 60 * 24) >= 0.9 * (1000 * 60 * 60 * 24)) { - difference_In_Days++; - } - for (int i = 1; i <= difference_In_Years; i++) { List allDevicesPerYear = new ArrayList<>(); - LocalDateTime oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; + LocalDateTime oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); Timestamp newStartDate; Timestamp newEndDate; @@ -1150,12 +1084,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv remainingDaysConsidered = true; oneYearAfterStart = startDate.toLocalDateTime(); newEndDate = endDate; + } else if (Timestamp.valueOf(oneYearAfterStart).getTime() >= endDate.getTime()) { + newEndDate = Timestamp.valueOf(oneYearAfterStart); } else { - oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; + oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); newEndDate = Timestamp.valueOf(oneYearAfterStart); } } else { - oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; + oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); newEndDate = Timestamp.valueOf(oneYearAfterStart); } @@ -1178,7 +1114,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv allDevices.addAll(billingResponse.getDevice()); totalCost = totalCost + billingResponse.getTotalCostPerYear(); deviceCount = deviceCount + billingResponse.getDeviceCount(); - LocalDateTime nextStartDate = oneYearAfterStart.plusDays(1).with(LocalTime.of(00, 00, 00)); + LocalDateTime nextStartDate = oneYearAfterStart.plusDays(1); startDate = Timestamp.valueOf(nextStartDate); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index ef2338688f..1bae5b30ce 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -24,15 +24,6 @@ import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.*; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; -import org.wso2.carbon.user.api.AuthorizationManager; -import org.wso2.carbon.user.api.UserStoreManager; import java.util.List; @@ -52,16 +43,6 @@ public interface GroupManagementProviderService { void createGroup(DeviceGroup deviceGroup, String defaultRole, String[] defaultPermissions) throws GroupManagementException, GroupAlreadyExistException; - /** - * Add new device group and create default role with default permissions. - * - * @param groups to add - * @param defaultRole of the deviceGroup - * @param defaultPermissions of the default role - * @throws GroupManagementException - */ - void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupAlreadyExistException,GroupManagementException, RoleDoesNotExistException; - /** * Update existing device group. * @@ -82,18 +63,6 @@ public interface GroupManagementProviderService { */ boolean deleteGroup(int groupId, boolean isDeleteChildren) throws GroupManagementException; - /** - * Delete existing device group. - * - * @param role to be deleted with the userStore name. - * @param roleToDelete to delete the role. - * @param tenantId to belongs to roles. - * @param userStoreManager with details. - * @param authorizationManager with details. - * @throws GroupManagementException - */ - void deleteRoleAndRoleGroupMapping(String role, String roleToDelete, int tenantId, UserStoreManager userStoreManager, AuthorizationManager authorizationManager) throws GroupManagementException; - /** * Get the device group provided the device group id. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index a35d4d74bb..c605a8ebe7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -19,23 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import io.entgra.device.mgt.core.device.mgt.common.*; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceTypesOfGroups; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; -import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.GroupDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; @@ -52,20 +35,12 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import org.wso2.carbon.user.api.AuthorizationManager; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import java.sql.SQLException; import java.util.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; @@ -150,59 +125,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - public void createGroupWithRoles(DeviceGroupRoleWrapper groups, String defaultRole, String[] defaultPermissions) throws GroupAlreadyExistException, GroupManagementException { - if (groups == null) { - String msg = "Received incomplete data for createGroup"; - log.error(msg); - throw new GroupManagementException(msg); - } - if (log.isDebugEnabled()) { - log.debug("Creating group '" + groups.getName() + "'"); - } - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - try { - GroupManagementDAOFactory.beginTransaction(); - DeviceGroup existingGroup = this.groupDAO.getGroup(groups.getName(), tenantId); - if (existingGroup == null) { - if (groups.getParentGroupId() == 0) { - groups.setParentPath(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); - } else { - DeviceGroup immediateParentGroup = groupDAO.getGroup(groups.getParentGroupId(), tenantId); - if (immediateParentGroup == null) { - GroupManagementDAOFactory.rollbackTransaction(); - String msg = "Parent group with group ID '" + groups.getParentGroupId() + "' does not exist. Hence creating of group '" + groups.getName() + "' was not success"; - log.error(msg); - throw new GroupManagementException(msg); - } - String parentPath = DeviceManagerUtil.createParentPath(immediateParentGroup); - groups.setParentPath(parentPath); - } - int updatedGroupID = this.groupDAO.addGroupWithRoles(groups, tenantId); - if (groups.getGroupProperties() != null && groups.getGroupProperties().size() > 0) { - this.groupDAO.addGroupPropertiesWithRoles(groups, updatedGroupID, tenantId); - } - GroupManagementDAOFactory.commitTransaction(); - } else { - throw new GroupAlreadyExistException("Group already exists with name : " + groups.getName() + " Try with another group name."); - } - } catch (GroupManagementDAOException e) { - GroupManagementDAOFactory.rollbackTransaction(); - String msg = e.getMessage(); - log.error(msg, e); - throw new GroupManagementException(msg, e); - } catch (TransactionManagementException e) { - String msg = "Error occurred while initiating transaction."; - log.error(msg, e); - throw new GroupManagementException(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); - } - - if (log.isDebugEnabled()) { - log.debug("DeviceGroup added: " + groups.getName()); - } - } - /** * {@inheritDoc} */ @@ -314,13 +236,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid newParentPath = DeviceGroupConstants.HierarchicalGroup.SEPERATOR; } childrenGroup.setParentPath(newParentPath); - if (!DeviceGroupConstants.HierarchicalGroup.SEPERATOR.equals(newParentPath)) { - String[] groupIds = newParentPath.split(DeviceGroupConstants.HierarchicalGroup.SEPERATOR); - int latestGroupId = Integer.parseInt(groupIds[groupIds.length - 1]); - childrenGroup.setParentGroupId(latestGroupId); - } else { - childrenGroup.setParentGroupId(0); - } } } } @@ -361,40 +276,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } } - /** - * {@inheritDoc} - */ - @Override - public void deleteRoleAndRoleGroupMapping(String roleName, String roleToDelete, int tenantId, UserStoreManager userStoreManager, AuthorizationManager authorizationManager) throws GroupManagementException { - if (log.isDebugEnabled()) { - log.debug("Delete roles"); - } - try { - GroupManagementDAOFactory.beginTransaction(); - groupDAO.deleteGroupsMapping(roleToDelete, tenantId); - userStoreManager.deleteRole(roleName); - // Delete all authorizations for the current role before deleting - authorizationManager.clearRoleAuthorization(roleName); - GroupManagementDAOFactory.commitTransaction(); - } catch (UserStoreException e) { - GroupManagementDAOFactory.rollbackTransaction(); - String msg = "Error occurred while deleting the role '" + roleName + "'"; - log.error(msg, e); - throw new GroupManagementException(msg, e); - } catch (TransactionManagementException e) { - String msg = "Error occurred while initiating transaction."; - log.error(msg, e); - throw new GroupManagementException(msg, e); - } catch (GroupManagementDAOException e) { - GroupManagementDAOFactory.rollbackTransaction(); - String msg = "Error occurred while deleting the role"; - log.error(msg, e); - throw new GroupManagementException(msg, e); - } finally { - GroupManagementDAOFactory.closeConnection(); - } - } - /** * {@inheritDoc} */ @@ -561,7 +442,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid @Override public PaginationResult getGroupsWithHierarchy(String username, GroupPaginationRequest request, - boolean requireGroupProps) throws GroupManagementException { + boolean requireGroupProps) throws GroupManagementException { if (request == null) { String msg = "Received incomplete data for retrieve groups with hierarchy"; log.error(msg); @@ -570,7 +451,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid if (log.isDebugEnabled()) { log.debug("Get groups with hierarchy " + request.toString()); } - boolean isWithParentPath = false; DeviceManagerUtil.validateGroupListPageSize(request); List rootGroups; try { @@ -582,7 +462,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } else { List allDeviceGroupIdsOfUser = getGroupIds(username); GroupManagementDAOFactory.openConnection(); - rootGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId, isWithParentPath); + rootGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId); } String parentPath; List childrenGroups; @@ -1403,7 +1283,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid * @throws GroupManagementDAOException on error during population of group properties. */ private void createGroupWithChildren(DeviceGroup parentGroup, List childrenGroups, - boolean requireGroupProps, int tenantId, int depth, int counter) throws GroupManagementDAOException { + boolean requireGroupProps, int tenantId, int depth, int counter) throws GroupManagementDAOException { if (childrenGroups.isEmpty() || depth == counter) { return; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index 4f83fa5b5e..d22d8f312f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -16,7 +16,6 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(45) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index c12f494f37..a9814241de 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -78,7 +78,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index d0ecba2064..57ff12e288 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java deleted file mode 100644 index 38985716de..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* 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 org.wso2.carbon.device.mgt.core.common.exception; - -/** - * Represents the exception thrown during storing and retrieving the artifacts. - */ -public class StorageManagementException extends Exception { - public StorageManagementException(String message, Throwable ex) { - super(message, ex); - } - - public StorageManagementException(String message) { - super(message); - } -} - diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 7e01efb324..cb1c9dba67 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index e6848b89c8..9971311788 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 7bf1a8fbdb..819685280b 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 8bf81024df..fa60f27f1e 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index e5157d6a82..8b646fa964 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -155,12 +155,7 @@ org.powermock - powermock-api-mockito2 - test - - - org.mockito - mockito-core + powermock-api-mockito test @@ -258,19 +253,12 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - file:src/test/resources/log4j.properties src/test/resources/testng.xml - - org.ops4j.pax.logging - diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java index cd3999c9bf..7d253b2333 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java @@ -74,18 +74,17 @@ public class JWTClientExtensionDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - setTenantManager(realmService != null ? - realmService.getTenantManager() : null); + this.setTenantManager(realmService); } - private void setTenantManager(TenantManager tenantManager) { - this.tenantManager = tenantManager; + private void setTenantManager(RealmService realmService) { + if (realmService == null) { + throw new IllegalStateException("Realm service is not initialized properly"); + } + this.tenantManager = realmService.getTenantManager(); } public TenantManager getTenantManager() { - if (tenantManager == null) { - throw new IllegalStateException("Tenant manager is not initialized properly"); - } return tenantManager; } } diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java index beb7db9962..d497d5e108 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/java/io/entgra/device/mgt/core/identity/jwt/client/extension/service/JWTClientTest.java @@ -43,10 +43,9 @@ import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; import java.util.Properties; -import org.powermock.modules.testng.PowerMockTestCase; @PrepareForTest(JWTClientUtil.class) -public class JWTClientTest extends PowerMockTestCase{ +public class JWTClientTest { private static final Log log = LogFactory.getLog(JWTClientTest.class); @ObjectFactory diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml index 96fd6acfff..fc32a2698d 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:./target/databasetest/CARBON_TEST + jdbc:h2:target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index bc0478f310..216bfb4d71 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 70ca947ed2..324934a4dd 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java deleted file mode 100644 index 33cffac366..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/AppInstallLogContext.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2018 - 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.notification.logger; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; - -public class AppInstallLogContext extends LogContext { - private final String appId; - private final String appName; - private final String appType; - private final String subType; - private final String tenantId; - private final String tenantDomain; - private final String device; - private final String userName; - private final String action; - - private AppInstallLogContext(Builder builder) { - this.appId = builder.appId; - this.appName = builder.appName; - this.appType = builder.appType; - this.subType = builder.subType; - this.tenantId = builder.tenantId; - this.tenantDomain = builder.tenantDomain; - this.device = builder.device; - this.userName = builder.userName; - this.action = builder.action; - } - - public String getAppId() { - return appId; - } - - public String getAppName() { - return appName; - } - - public String getAppType() { - return appType; - } - - public String getSubType() { - return subType; - } - - public String getTenantId() { - return tenantId; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public String getDevice() { - return device; - } - - public String getUserName() { - return userName; - } - - public String getAction() { - return action; - } - - public static class Builder { - private String appId; - private String appName; - private String appType; - private String subType; - private String tenantId; - private String tenantDomain; - private String device; - private String userName; - private String action; - - public Builder() { - } - - public String getUserName() { - return userName; - } - - public Builder setUserName(String userName) { - this.userName = userName; - return this; - } - - public String getAppId() { - return appId; - } - - public Builder setAppId(String appId) { - this.appId = appId; - return this; - } - - public String getAppName() { - return appName; - } - - public Builder setAppName(String appName) { - this.appName = appName; - return this; - } - - public String getAppType() { - return appType; - } - - public Builder setAppType(String appType) { - this.appType = appType; - return this; - } - - public String getSubType() { - return subType; - } - - public Builder setSubType(String subType) { - this.subType = subType; - return this; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public Builder setTenantDomain(String tenantDomain) { - this.tenantDomain = tenantDomain; - return this; - } - - public String getTenantId() { - return tenantId; - } - - public Builder setTenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - public String getDevice() { - return device; - } - - public Builder setDevice(String device) { - this.device = device; - return this; - } - - public String getAction() { - return action; - } - - public Builder setAction(String action) { - this.action = action; - return this; - } - - public AppInstallLogContext build() { - return new AppInstallLogContext(this); - } - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java deleted file mode 100644 index d110e84a43..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceConnectivityLogContext.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2018 - 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.notification.logger; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; - -public class DeviceConnectivityLogContext extends LogContext { - - private final String deviceId; - private final String deviceType; - private final String actionTag; - private final String operationCode; - private final String tenantId; - private final String tenantDomain; - private final String userName; - - private DeviceConnectivityLogContext(Builder builder) { - this.deviceId = builder.deviceId; - this.deviceType = builder.deviceType; - this.actionTag = builder.actionTag; - this.operationCode = builder.operationCode; - this.tenantId = builder.tenantId; - this.tenantDomain = builder.tenantDomain; - this.userName = builder.userName; - } - - public String getDeviceId() { - return deviceId; - } - - public String getDeviceType() { - return deviceType; - } - - public String getActionTag() { - return actionTag; - } - - public String getOperationCode() { - return operationCode; - } - - public String getTenantId() { - return tenantId; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public String getUserName() { - return userName; - } - - public static class Builder { - private String deviceId; - private String deviceType; - private String operationCode; - private String actionTag; - private String tenantId; - private String tenantDomain; - private String userName; - - public Builder() { - } - - public String getDeviceId() { - return deviceId; - } - - public Builder setDeviceId(String deviceId) { - this.deviceId = deviceId; - return this; - } - - public String getDeviceType() { - return deviceType; - } - - public Builder setDeviceType(String deviceType) { - this.deviceType = deviceType; - return this; - } - - public String getOperationCode() { - return operationCode; - } - - public Builder setOperationCode(String operationCode) { - this.operationCode = operationCode; - return this; - } - - public String getTenantId() { - return tenantId; - } - - public Builder setTenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public Builder setTenantDomain(String tenantDomain) { - this.tenantDomain = tenantDomain; - return this; - } - - public String getUserName() { - return userName; - } - - public Builder setUserName(String userName) { - this.userName = userName; - return this; - } - - public String getActionTag() { - return actionTag; - } - - public Builder setActionTag(String actionTag) { - this.actionTag = actionTag; - return this; - } - - public DeviceConnectivityLogContext build() { - return new DeviceConnectivityLogContext(this); - } - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java deleted file mode 100644 index b355b29671..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/DeviceEnrolmentLogContext.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2018 - 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.notification.logger; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; - -public class DeviceEnrolmentLogContext extends LogContext { - private final String deviceId; - private final String deviceType; - private final String owner; - private final String ownership; - private final String tenantID; - private final String tenantDomain; - private final String userName; - - private DeviceEnrolmentLogContext(Builder builder) { - this.deviceId = builder.deviceId; - this.deviceType = builder.deviceType; - this.owner = builder.owner; - this.ownership = builder.ownership; - this.tenantID = builder.tenantID; - this.tenantDomain = builder.tenantDomain; - this.userName = builder.userName; - } - - public String getTenantID() { - return tenantID; - } - - public String getDeviceId() { - return deviceId; - } - - public String getOwner() { - return owner; - } - - public String getDeviceType() { - return deviceType; - } - - public String getOwnership() { - return ownership; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public String getUserName() { - return userName; - } - public static class Builder { - private String deviceId; - private String deviceType; - private String owner; - private String ownership; - private String tenantID; - private String tenantDomain; - private String userName; - - public Builder() { - } - - public String getDeviceType() { - return deviceType; - } - - public Builder setDeviceType(String deviceType) { - this.deviceType = deviceType; - return this; - } - - public String getTenantID() { - return tenantID; - } - - public Builder setTenantID(String tenantID) { - this.tenantID = tenantID; - return this; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public Builder setTenantDomain(String tenantDomain) { - this.tenantDomain = tenantDomain; - return this; - } - - public String getUserName() { - return userName; - } - - public Builder setUserName(String userName) { - this.userName = userName; - return this; - } - - public String getDeviceId() { - return deviceId; - } - - public Builder setDeviceId(String deviceId) { - this.deviceId = deviceId; - return this; - } - - public String getOwner() { - return owner; - } - - public Builder setOwner(String owner) { - this.owner = owner; - return this; - } - - public String getOwnership() { - return ownership; - } - - public Builder setOwnership(String ownership) { - this.ownership = ownership; - return this; - } - - public DeviceEnrolmentLogContext build() { - return new DeviceEnrolmentLogContext(this); - } - - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java deleted file mode 100644 index 9dbd10a059..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/PolicyLogContext.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2018 - 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.notification.logger; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; - -public class PolicyLogContext extends LogContext { - private final String policyName; - private final String payload; - private final String actionTag; - private final String userName; - private final String tenantID; - private final String tenantDomain; - - private PolicyLogContext(Builder builder) { - this.policyName = builder.policyName; - this.payload = builder.payload; - this.actionTag = builder.actionTag; - this.userName = builder.userName; - this.tenantID = builder.tenantID; - this.tenantDomain = builder.tenantDomain; - } - - public String getPolicyName() { - return policyName; - } - - public String getPayload() { - return payload; - } - - public String getActionTag() { - return actionTag; - } - - public String getUserName() { - return userName; - } - - public String getTenantID() { - return tenantID; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public static class Builder { - private String policyName; - private String payload; - private String actionTag; - private String userName; - private String tenantID; - private String tenantDomain; - - public Builder() { - } - - public String getPolicyName() { - return policyName; - } - - public Builder setPolicyName(String policyName) { - this.policyName = policyName; - return this; - } - - public String getPayload() { - return payload; - } - - public Builder setPayload(String payload) { - this.payload = payload; - return this; - } - - public String getActionTag() { - return actionTag; - } - - public Builder setActionTag(String actionTag) { - this.actionTag = actionTag; - return this; - } - - public String getUserName() { - return userName; - } - - public Builder setUserName(String userName) { - this.userName = userName; - return this; - } - - public String getTenantID() { - return tenantID; - } - - public Builder setTenantID(String tenantID) { - this.tenantID = tenantID; - return this; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public Builder setTenantDomain(String tenantDomain) { - this.tenantDomain = tenantDomain; - return this; - } - - public PolicyLogContext build() { - return new PolicyLogContext(this); - } - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java deleted file mode 100644 index 81f071c2af..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2018 - 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.notification.logger.impl; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; -import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; - -public class EntgraAppInstallLoggerImpl implements EntgraLogger { - - private static Log log = null; - - public EntgraAppInstallLoggerImpl(Class clazz) { - log = LogFactory.getLog(clazz); - } - - public void info(String message) { - log.info(message); - } - - public void info(String message, Throwable t) { - log.info(message, t); - } - - @Override - public void info(Object o) { - log.info(o); - } - - @Override - public void info(Object o, Throwable throwable) { - log.info(o, throwable); - } - - @Override - public void info(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.info(message); - } - - @Override - public void info(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.info(object); - } - - @Override - public void info(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.info(object, t); - } - - public void debug(String message) { - log.debug(message); - } - - public void debug(String message, Throwable t) { - log.debug(message, t); - } - - @Override - public void debug(Object o) { - log.debug(o); - } - - @Override - public void debug(Object o, Throwable throwable) { - log.debug(o, throwable); - } - - @Override - public void debug(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.debug(message); - } - - @Override - public void debug(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.debug(object); - } - - @Override - public void debug(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.debug(object, t); - } - - public void error(String message) { - log.error(message); - } - - public void error(String message, Throwable t) { - log.error(message, t); - } - - @Override - public void error(Object o) { - log.error(o); - } - - @Override - public void error(Object o, Throwable throwable) { - log.error(o, throwable); - } - - @Override - public void error(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.error(message); - } - - @Override - public void error(String message, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.error(message, t); - } - - @Override - public void error(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.error(object); - } - - @Override - public void error(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.error(object, t); - } - - public void warn(String message) { - log.warn(message); - } - - public void warn(String message, Throwable t) { - log.warn(message, t); - } - - @Override - public void warn(Object o) { - log.warn(o); - } - - @Override - public void warn(Object o, Throwable throwable) { - log.warn(o, throwable); - } - - @Override - public void warn(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.warn(message); - } - - @Override - public void warn(String message, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.warn(message, t); - } - - @Override - public void warn(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.warn(object); - } - - @Override - public void warn(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.warn(object, t); - } - - public void trace(String message) { - log.trace(message); - } - - public void trace(String message, Throwable t) { - log.trace(message, t); - } - - @Override - public void trace(Object o) { - log.trace(o); - } - - @Override - public void trace(Object o, Throwable throwable) { - log.trace(o, throwable); - } - - @Override - public void trace(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.trace(message); - } - - @Override - public void trace(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.trace(object); - } - - @Override - public void trace(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.trace(object, t); - } - - public void fatal(String message) { - log.fatal(message); - } - - public void fatal(String message, Throwable t) { - log.fatal(message, t); - } - - @Override - public void fatal(Object o) { - log.fatal(0); - } - - @Override - public void fatal(Object o, Throwable throwable) { - log.fatal(0, throwable); - } - - @Override - public void fatal(String message, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.fatal(message); - } - - @Override - public void fatal(Object object, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.fatal(object); - } - - @Override - public void fatal(Object object, Throwable t, LogContext logContext) { - AppInstallLogContext appInstallLogContext = (AppInstallLogContext) logContext; - MDCContextUtil.populateAppInstallMDCContext(appInstallLogContext); - log.fatal(object, t); - } - - @Override - public boolean isDebugEnabled() { - return log.isDebugEnabled(); - } - - @Override - public boolean isErrorEnabled() { - return log.isErrorEnabled(); - } - - @Override - public boolean isFatalEnabled() { - return log.isFatalEnabled(); - } - - @Override - public boolean isInfoEnabled() { - return log.isInfoEnabled(); - } - - @Override - public boolean isTraceEnabled() { - return log.isTraceEnabled(); - } - - @Override - public boolean isWarnEnabled() { - return log.isWarnEnabled(); - } - - @Override - public void clearLogContext() { - MDC.clear(); - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java deleted file mode 100644 index aaa62bf488..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2018 - 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.notification.logger.impl; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContext; -import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; - -public class EntgraDeviceConnectivityLoggerImpl implements EntgraLogger { - - private static Log log = null; - - public EntgraDeviceConnectivityLoggerImpl(Class clazz) { - log = LogFactory.getLog(clazz); - } - - public void info(String message) { - log.info(message); - } - - public void info(String message, Throwable t) { - log.info(message, t); - } - - @Override - public void info(Object o) { - log.info(o); - } - - @Override - public void info(Object o, Throwable throwable) { - log.info(o, throwable); - } - - @Override - public void info(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.info(message); - } - - @Override - public void info(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.info(object); - } - - @Override - public void info(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.info(object, t); - } - - public void debug(String message) { - log.debug(message); - } - - public void debug(String message, Throwable t) { - log.debug(message, t); - } - - @Override - public void debug(Object o) { - log.debug(o); - } - - @Override - public void debug(Object o, Throwable throwable) { - log.debug(o, throwable); - } - - @Override - public void debug(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.debug(message); - } - - @Override - public void debug(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.debug(object); - } - - @Override - public void debug(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.debug(object, t); - } - - public void error(String message) { - log.error(message); - } - - public void error(String message, Throwable t) { - log.error(message, t); - } - - @Override - public void error(Object o) { - log.error(o); - } - - @Override - public void error(Object o, Throwable throwable) { - log.error(o, throwable); - } - - @Override - public void error(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.error(message); - } - - @Override - public void error(String message, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.error(message, t); - } - - @Override - public void error(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.error(object); - } - - @Override - public void error(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.error(object, t); - } - - public void warn(String message) { - log.warn(message); - } - - public void warn(String message, Throwable t) { - log.warn(message, t); - } - - @Override - public void warn(Object o) { - log.warn(o); - } - - @Override - public void warn(Object o, Throwable throwable) { - log.warn(o, throwable); - } - - @Override - public void warn(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.warn(message); - } - - @Override - public void warn(String message, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.warn(message, t); - } - - @Override - public void warn(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.warn(object); - } - - @Override - public void warn(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.warn(object, t); - } - - public void trace(String message) { - log.trace(message); - } - - public void trace(String message, Throwable t) { - log.trace(message, t); - } - - @Override - public void trace(Object o) { - log.trace(o); - } - - @Override - public void trace(Object o, Throwable throwable) { - log.trace(o, throwable); - } - - @Override - public void trace(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.trace(message); - } - - @Override - public void trace(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.trace(object); - } - - @Override - public void trace(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.trace(object, t); - } - - public void fatal(String message) { - log.fatal(message); - } - - public void fatal(String message, Throwable t) { - log.fatal(message, t); - } - - @Override - public void fatal(Object o) { - log.fatal(0); - } - - @Override - public void fatal(Object o, Throwable throwable) { - log.fatal(0, throwable); - } - - @Override - public void fatal(String message, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.fatal(message); - } - - @Override - public void fatal(Object object, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.fatal(object); - } - - @Override - public void fatal(Object object, Throwable t, LogContext logContext) { - DeviceConnectivityLogContext deviceConnectivityLogContext = (DeviceConnectivityLogContext) logContext; - MDCContextUtil.populateDeviceConnectivityMDCContext(deviceConnectivityLogContext); - log.fatal(object, t); - } - - @Override - public boolean isDebugEnabled() { - return log.isDebugEnabled(); - } - - @Override - public boolean isErrorEnabled() { - return log.isErrorEnabled(); - } - - @Override - public boolean isFatalEnabled() { - return log.isFatalEnabled(); - } - - @Override - public boolean isInfoEnabled() { - return log.isInfoEnabled(); - } - - @Override - public boolean isTraceEnabled() { - return log.isTraceEnabled(); - } - - @Override - public boolean isWarnEnabled() { - return log.isWarnEnabled(); - } - - @Override - public void clearLogContext() { - MDC.clear(); - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java deleted file mode 100644 index db0b7dd265..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2018 - 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.notification.logger.impl; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext; -import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; - -public class EntgraDeviceEnrolmentLoggerImpl implements EntgraLogger { - - private static Log log = null; - - public EntgraDeviceEnrolmentLoggerImpl(Class clazz) { - log = LogFactory.getLog(clazz); - } - - public void info(String message) { - log.info(message); - } - - public void info(String message, Throwable t) { - log.info(message, t); - } - - @Override - public void info(Object o) { - log.info(o); - } - - @Override - public void info(Object o, Throwable throwable) { - log.info(o, throwable); - } - - @Override - public void info(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.info(message); - } - - @Override - public void info(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.info(object); - } - - @Override - public void info(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.info(object, t); - } - - public void debug(String message) { - log.debug(message); - } - - public void debug(String message, Throwable t) { - log.debug(message, t); - } - - @Override - public void debug(Object o) { - log.debug(o); - } - - @Override - public void debug(Object o, Throwable throwable) { - log.debug(o, throwable); - } - - @Override - public void debug(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.debug(message); - } - - @Override - public void debug(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.debug(object); - } - - @Override - public void debug(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.debug(object, t); - } - - public void error(String message) { - log.error(message); - } - - public void error(String message, Throwable t) { - log.error(message, t); - } - - @Override - public void error(Object o) { - log.error(o); - } - - @Override - public void error(Object o, Throwable throwable) { - log.error(o, throwable); - } - - @Override - public void error(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.error(message); - } - - @Override - public void error(String message, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.error(message, t); - } - - @Override - public void error(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.error(object); - } - - @Override - public void error(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.error(object, t); - } - - public void warn(String message) { - log.warn(message); - } - - public void warn(String message, Throwable t) { - log.warn(message, t); - } - - @Override - public void warn(Object o) { - log.warn(o); - } - - @Override - public void warn(Object o, Throwable throwable) { - log.warn(o, throwable); - } - - @Override - public void warn(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.warn(message); - } - - @Override - public void warn(String message, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.warn(message, t); - } - - @Override - public void warn(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.warn(object); - } - - @Override - public void warn(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.warn(object, t); - } - - public void trace(String message) { - log.trace(message); - } - - public void trace(String message, Throwable t) { - log.trace(message, t); - } - - @Override - public void trace(Object o) { - log.trace(o); - } - - @Override - public void trace(Object o, Throwable throwable) { - log.trace(o, throwable); - } - - @Override - public void trace(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.trace(message); - } - - @Override - public void trace(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.trace(object); - } - - @Override - public void trace(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.trace(object, t); - } - - public void fatal(String message) { - log.fatal(message); - } - - public void fatal(String message, Throwable t) { - log.fatal(message, t); - } - - @Override - public void fatal(Object o) { - log.fatal(0); - } - - @Override - public void fatal(Object o, Throwable throwable) { - log.fatal(0, throwable); - } - - @Override - public void fatal(String message, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.fatal(message); - } - - @Override - public void fatal(Object object, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.fatal(object); - } - - @Override - public void fatal(Object object, Throwable t, LogContext logContext) { - DeviceEnrolmentLogContext deviceEnrolmentLogContext = (DeviceEnrolmentLogContext) logContext; - MDCContextUtil.populateDeviceEnrolmentMDCContext(deviceEnrolmentLogContext); - log.fatal(object, t); - } - - @Override - public boolean isDebugEnabled() { - return log.isDebugEnabled(); - } - - @Override - public boolean isErrorEnabled() { - return log.isErrorEnabled(); - } - - @Override - public boolean isFatalEnabled() { - return log.isFatalEnabled(); - } - - @Override - public boolean isInfoEnabled() { - return log.isInfoEnabled(); - } - - @Override - public boolean isTraceEnabled() { - return log.isTraceEnabled(); - } - - @Override - public boolean isWarnEnabled() { - return log.isWarnEnabled(); - } - - @Override - public void clearLogContext() { - MDC.clear(); - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java index a51987463f..ae10ae87c2 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.notification.logger.impl; + import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; @@ -25,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.MDC; + public class EntgraDeviceLoggerImpl implements EntgraLogger { private static Log log = null; @@ -72,6 +74,7 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.info(object, t); } + public void debug(String message) { log.debug(message); } @@ -111,6 +114,7 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.debug(object, t); } + public void error(String message) { log.error(message); } @@ -157,6 +161,7 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.error(object, t); } + public void warn(String message) { log.warn(message); } @@ -203,6 +208,7 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.warn(object, t); } + public void trace(String message) { log.trace(message); } @@ -242,6 +248,7 @@ public class EntgraDeviceLoggerImpl implements EntgraLogger { log.trace(object, t); } + public void fatal(String message) { log.fatal(message); } diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java deleted file mode 100644 index 218252f260..0000000000 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2018 - 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.notification.logger.impl; - -import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; -import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; - -public class EntgraPolicyLoggerImpl implements EntgraLogger { - - private static Log log = null; - - public EntgraPolicyLoggerImpl(Class clazz) { - log = LogFactory.getLog(clazz); - } - - public void info(String message) { - log.info(message); - } - - public void info(String message, Throwable t) { - log.info(message, t); - } - - @Override - public void info(Object o) { - log.info(o); - } - - @Override - public void info(Object o, Throwable throwable) { - log.info(o, throwable); - } - - @Override - public void info(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.info(message); - } - - @Override - public void info(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.info(object); - } - - @Override - public void info(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.info(object, t); - } - - public void debug(String message) { - log.debug(message); - } - - public void debug(String message, Throwable t) { - log.debug(message, t); - } - - @Override - public void debug(Object o) { - log.debug(o); - } - - @Override - public void debug(Object o, Throwable throwable) { - log.debug(o, throwable); - } - - @Override - public void debug(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.debug(message); - } - - @Override - public void debug(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.debug(object); - } - - @Override - public void debug(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.debug(object, t); - } - - public void error(String message) { - log.error(message); - } - - public void error(String message, Throwable t) { - log.error(message, t); - } - - @Override - public void error(Object o) { - log.error(o); - } - - @Override - public void error(Object o, Throwable throwable) { - log.error(o, throwable); - } - - @Override - public void error(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.error(message); - } - - @Override - public void error(String message, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.error(message, t); - } - - @Override - public void error(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.error(object); - } - - @Override - public void error(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.error(object, t); - } - - public void warn(String message) { - log.warn(message); - } - - public void warn(String message, Throwable t) { - log.warn(message, t); - } - - @Override - public void warn(Object o) { - log.warn(o); - } - - @Override - public void warn(Object o, Throwable throwable) { - log.warn(o, throwable); - } - - @Override - public void warn(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.warn(message); - } - - @Override - public void warn(String message, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.warn(message, t); - } - - @Override - public void warn(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.warn(object); - } - - @Override - public void warn(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.warn(object, t); - } - - public void trace(String message) { - log.trace(message); - } - - public void trace(String message, Throwable t) { - log.trace(message, t); - } - - @Override - public void trace(Object o) { - log.trace(o); - } - - @Override - public void trace(Object o, Throwable throwable) { - log.trace(o, throwable); - } - - @Override - public void trace(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.trace(message); - } - - @Override - public void trace(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.trace(object); - } - - @Override - public void trace(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.trace(object, t); - } - - public void fatal(String message) { - log.fatal(message); - } - - public void fatal(String message, Throwable t) { - log.fatal(message, t); - } - - @Override - public void fatal(Object o) { - log.fatal(0); - } - - @Override - public void fatal(Object o, Throwable throwable) { - log.fatal(0, throwable); - } - - @Override - public void fatal(String message, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.fatal(message); - } - - @Override - public void fatal(Object object, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.fatal(object); - } - - @Override - public void fatal(Object object, Throwable t, LogContext logContext) { - PolicyLogContext policyLogContext = (PolicyLogContext) logContext; - MDCContextUtil.populatePolicyMDCContext(policyLogContext); - log.fatal(object, t); - } - - @Override - public boolean isDebugEnabled() { - return log.isDebugEnabled(); - } - - @Override - public boolean isErrorEnabled() { - return log.isErrorEnabled(); - } - - @Override - public boolean isFatalEnabled() { - return log.isFatalEnabled(); - } - - @Override - public boolean isInfoEnabled() { - return log.isInfoEnabled(); - } - - @Override - public boolean isTraceEnabled() { - return log.isTraceEnabled(); - } - - @Override - public boolean isWarnEnabled() { - return log.isWarnEnabled(); - } - - @Override - public void clearLogContext() { - MDC.clear(); - } -} diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java index fa482605f6..6a082b013d 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.notification.logger.impl; + import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.UserLogContext; @@ -25,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.MDC; + public class EntgraUserLoggerImpl implements EntgraLogger { private static Log log = null; diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java index dc046e8eeb..09f903188a 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java @@ -17,7 +17,8 @@ */ package io.entgra.device.mgt.core.notification.logger.util; -import io.entgra.device.mgt.core.notification.logger.*; +import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; +import io.entgra.device.mgt.core.notification.logger.UserLogContext; import org.apache.log4j.MDC; public final class MDCContextUtil { @@ -61,105 +62,6 @@ public final class MDCContextUtil { } } - - public static void populatePolicyMDCContext(final PolicyLogContext mdcContext) { - if (mdcContext.getPolicyName() != null) { - MDC.put("PolicyName", mdcContext.getPolicyName()); - } - if (mdcContext.getPayload() != null) { - MDC.put("Payload", mdcContext.getPayload()); - } - if (mdcContext.getActionTag() != null) { - MDC.put("ActionTag", mdcContext.getActionTag()); - } - if (mdcContext.getUserName() != null) { - MDC.put("UserName", mdcContext.getUserName()); - } - if (mdcContext.getTenantDomain() != null) { - MDC.put("TenantDomain", mdcContext.getTenantDomain()); - } - if (mdcContext.getTenantID() != null) { - MDC.put("TenantId", mdcContext.getTenantID()); - } - } - - public static void populateAppInstallMDCContext(final AppInstallLogContext mdcContext) { - if (mdcContext.getAppId() != null) { - MDC.put("AppId", mdcContext.getAppId()); - } - if (mdcContext.getAppName() != null) { - MDC.put("AppName", mdcContext.getAppName()); - } - if (mdcContext.getAppType() != null) { - MDC.put("AppType", mdcContext.getAppType()); - } - if (mdcContext.getSubType() != null) { - MDC.put("SubType", mdcContext.getSubType()); - } - if (mdcContext.getDevice() != null) { - MDC.put("Device", mdcContext.getDevice()); - } - if (mdcContext.getTenantDomain() != null) { - MDC.put("TenantDomain", mdcContext.getTenantDomain()); - } - if (mdcContext.getTenantId() != null) { - MDC.put("TenantId", mdcContext.getTenantId()); - } - if (mdcContext.getUserName() != null) { - MDC.put("UserName", mdcContext.getUserName()); - } - if (mdcContext.getAction() != null) { - MDC.put("Action", mdcContext.getAction()); - } - } - - public static void populateDeviceConnectivityMDCContext(final DeviceConnectivityLogContext mdcContext) { - if (mdcContext.getDeviceId() != null) { - MDC.put("DeviceId", mdcContext.getDeviceId()); - } - if (mdcContext.getDeviceType() != null) { - MDC.put("DeviceType", mdcContext.getDeviceType()); - } - if (mdcContext.getOperationCode() != null) { - MDC.put("OperationCode", mdcContext.getOperationCode()); - } - if (mdcContext.getTenantDomain() != null) { - MDC.put("TenantDomain", mdcContext.getTenantDomain()); - } - if (mdcContext.getTenantId() != null) { - MDC.put("TenantId", mdcContext.getTenantId()); - } - if (mdcContext.getUserName() != null) { - MDC.put("UserName", mdcContext.getUserName()); - } - if (mdcContext.getActionTag() != null) { - MDC.put("ActionTag", mdcContext.getActionTag()); - } - } - - public static void populateDeviceEnrolmentMDCContext(final DeviceEnrolmentLogContext mdcContext) { - if (mdcContext.getDeviceId() != null) { - MDC.put("DeviceId", mdcContext.getDeviceId()); - } - if (mdcContext.getDeviceType() != null) { - MDC.put("DeviceType", mdcContext.getDeviceType()); - } - if (mdcContext.getOwner() != null) { - MDC.put("Owner", mdcContext.getOwner()); - } - if (mdcContext.getOwnership() != null) { - MDC.put("Ownership", mdcContext.getOwnership()); - } - if (mdcContext.getTenantID() != null) { - MDC.put("TenantId", mdcContext.getTenantID()); - } - if (mdcContext.getTenantDomain() != null) { - MDC.put("TenantDomain", mdcContext.getTenantDomain()); - } - if (mdcContext.getUserName() != null) { - MDC.put("UserName", mdcContext.getUserName()); - } - } } diff --git a/components/logger/pom.xml b/components/logger/pom.xml index c4dfdd014b..cb85a7f88c 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index c8af2e9003..c71669f41e 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -119,10 +119,6 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - file:src/test/resources/carbon-home/repository/conf/log4j.properties @@ -130,9 +126,6 @@ src/test/resources/testng.xml - - org.ops4j.pax.logging - diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java index 58c7e8b65f..c563311602 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/mock/BaseOperationTemplatePluginTest.java @@ -144,7 +144,6 @@ public abstract class BaseOperationTemplatePluginTest { conn = ConnectionManagerUtils.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/insert-subtypes.sql'"); } finally { TestUtils.cleanupResources(conn, stmt, null); } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index df3277920d..6052156588 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, OWNER VARCHAR(255) DEFAULT NULL, - PARENT_PATH VARCHAR(255) DEFAULT NULL, + PARENT_PATH VARCHAR(255) DEFAULT '/', TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); @@ -42,7 +42,7 @@ 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 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, @@ -84,8 +84,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( CREATE TABLE IF NOT EXISTS DM_OPERATION ( ID INTEGER AUTO_INCREMENT NOT NULL, TYPE VARCHAR(50) NOT NULL, - CREATED_TIMESTAMP BIGINT NOT NULL, - RECEIVED_TIMESTAMP BIGINT 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, @@ -108,19 +108,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( 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_DEVICE_STATUS ( - ID INTEGER AUTO_INCREMENT NOT NULL, - ENROLMENT_ID INTEGER NOT NULL, - DEVICE_ID INTEGER NOT NULL, - STATUS VARCHAR(50) DEFAULT NULL, - UPDATE_TIME TIMESTAMP DEFAULT NULL, - CHANGED_BY VARCHAR(255) NOT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES - DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE -); + CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -188,17 +176,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, PAYLOAD_VERSION VARCHAR (45) NULL, - TENANT_ID INT NOT NULL , - PROFILE_ID INT NOT 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 NOT NULL, - UPDATED INT NULL, + ACTIVE INT(2) NOT NULL, + UPDATED INT(1) NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -209,11 +197,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , - DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT NOT NULL, + 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 NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,9 +216,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT NOT NULL , + ID INT(11) NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -240,11 +228,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT NOT NULL AUTO_INCREMENT, - PROFILE_ID INT NOT NULL, + 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 NOT NULL , + TENANT_ID INT(11) NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -255,11 +243,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT NOT NULL AUTO_INCREMENT, + ID INT(11) NOT NULL AUTO_INCREMENT, ACTION_TYPE VARCHAR(45) NOT NULL, - CORRECTIVE_POLICY_ID INT DEFAULT NULL, - POLICY_ID INT NOT NULL, - FEATURE_ID INT DEFAULT 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 @@ -270,9 +258,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -296,11 +284,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_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 NULL , + APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -353,7 +341,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT NOT NULL, + ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -368,7 +356,7 @@ 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 NOT NULL, + TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) ); @@ -397,7 +385,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER NULL, + MEMORY_USAGE INTEGER(10) NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -417,16 +405,6 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- -CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( - ID INTEGER AUTO_INCREMENT NOT NULL, - ICON_PATH VARCHAR(150) DEFAULT NULL, - PACKAGE_NAME VARCHAR(150) NOT NULL, - VERSION VARCHAR(50) DEFAULT '1.1.0', - CREATED_TIMESTAMP TIMESTAMP NOT NULL, - TENANT_ID INTEGER NOT NULL, - PRIMARY KEY (ID) -); - -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, @@ -447,7 +425,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( DEVICE_ID INT NULL, ENROLMENT_ID INT NOT NULL, KEY_FIELD VARCHAR(45) NULL, - VALUE_FIELD VARCHAR(1500) NULL, + VALUE_FIELD VARCHAR(1000) NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) @@ -476,7 +454,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT NOT NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -513,8 +491,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT NULL, - UPDATE_TIMESTAMP BIGINT NOT 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) @@ -541,7 +519,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT NOT NULL, + TIMESTAMP BIGINT(15) NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -610,7 +588,8 @@ 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) + PRIMARY KEY (ID), + CONSTRAINT email_type_uk UNIQUE (EMAIL, EMAIL_TYPE) ); -- END OF DM_OTP_DATA TABLE -- @@ -746,94 +725,52 @@ 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, - SUB_TYPE_ID VARCHAR(45) NOT NULL, + 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-- --- DM_TRACCAR_UNSYNCED_DEVICES TABLE -- -CREATE TABLE IF NOT EXISTS DM_TRACCAR_UNSYNCED_DEVICES ( - ID INT NOT NULL AUTO_INCREMENT, - DEVICE_NAME VARCHAR(100) NOT NULL, - IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, - TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, - TRACCAR_USENAME VARCHAR(100) NULL, - STATUS VARCHAR(100) NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (ID) -); --- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- - -- SUB_OPERATION_TEMPLATE TABLE-- -CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( - SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, +CREATE TABLE SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID int NOT NULL AUTO_INCREMENT, OPERATION_DEFINITION TEXT NOT NULL, - OPERATION_CODE VARCHAR(100) NOT NULL, - SUB_TYPE_ID INT NOT NULL, + OPERATION_CODE varchar(100) NOT NULL, + SUB_TYPE_ID int NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL, - CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, - UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + CREATE_TIMESTAMP timestamp NULL DEFAULT NULL, + UPDATE_TIMESTAMP timestamp NULL DEFAULT NULL, PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), - CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), --- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), + UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID,OPERATION_CODE, DEVICE_TYPE), CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) ); +/* + * Copyright (c) 2018 - 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. + */ + -- END OF SUB_OPERATION_TEMPLATE TABLE-- + +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/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql deleted file mode 100644 index ffa001a086..0000000000 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/insert-subtypes.sql +++ /dev/null @@ -1,3 +0,0 @@ -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}'); \ No newline at end of file diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml index 3ce48daefe..b6c2900db7 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -31,10 +31,18 @@ 60000 true - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider - io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider + + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider + + + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider + + + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider + + + io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider + @@ -42,16 +50,16 @@ https://localhost:9443 - ${admin.username} - ${admin.username} + admin + admin https://localhost:9443 - ${admin.username} - ${admin.username} + admin + admin - io.entgra.device.mgt.core.policy.mgt + org.wso2.carbon.policy.mgt true 60000 5 @@ -82,7 +90,7 @@ device caching for upto configured expiry-time in seconds. In clustered setup all worker nodes can enable the device-cache to improve performance. --> - true + false 600 10000 - - true - 600 - 10000 - true - true + false 86400 @@ -114,11 +120,6 @@ false - false - - DM_DB - ARCHIVAL_DB - io.entgra.device.mgt.core.device.mgt.core.task.impl.ArchivalTask 0 0 0 1/1 * ? * @@ -158,7 +159,7 @@ true - ws://localhost:9763 + wss://localhost:9443 2 100 20 @@ -166,50 +167,5 @@ 640 BYOD,COPE - - false - false - io.entgra.device.mgt.core.device.mgt.common.enrollment.notification.EnrollmentNotifier - http://localhost:8280 - - - false - - - test_role - - /permission/admin/Login - - - - - - - - <a href='https://entgra.io' target='_blank'> - Entgra - </a> - IoT Server 5.2.0 | © 2023 - , All Rights Reserved. - - Entgra - - repository/resources/whitelabel - favicon.png - logo.png - icon.png - default - - - - - - - - - - false - Replace with mail - diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index 2e591b07c9..ad8165fc67 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true org.h2.Driver wso2carbon wso2carbon diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 94c29533fe..d83ea2e190 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 0439397aff..0eff71e8f9 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index eac063769d..10fa65047d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index fbfb70849b..52d3c6c045 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index f93f462924..6887a4f3e5 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -116,19 +116,12 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - file:src/test/resources/log4j.properties src/test/resources/testng.xml - - org.ops4j.pax.logging - @@ -261,7 +254,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test @@ -283,10 +276,6 @@ org.wso2.orbit.javax.xml.bind jaxb-api - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.notification.logger - diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java index c5d661c567..b07f311ce1 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/impl/PolicyAdministratorPointImpl.java @@ -19,9 +19,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.impl; import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -57,8 +54,7 @@ import java.util.Set; public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { - PolicyLogContext.Builder policyLogContextBuilder = new PolicyLogContext.Builder(); - private static final EntgraLogger log = new EntgraPolicyLoggerImpl(PolicyAdministratorPointImpl.class); + private static final Log log = LogFactory.getLog(PolicyAdministratorPointImpl.class); private PolicyManager policyManager; private ProfileManager profileManager; @@ -139,8 +135,6 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { try { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService(); if (log.isDebugEnabled()) { @@ -174,13 +168,11 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { properties, triggerInfo); taskManager.registerTask(taskInfo); taskManager.scheduleTask(taskInfo.getName()); - log.info("Apply changes to device", policyLogContextBuilder.setActionTag("PUBLISH_CHANGES").setUserName(userName).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).build()); } else { if (!taskManager.isTaskScheduled(taskName)) { TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ, properties, triggerInfo); taskManager.scheduleTask(taskInfo.getName()); - log.info("Apply changes to device", policyLogContextBuilder.setActionTag("PUBLISH_CHANGES").setUserName(userName).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).build()); } else { throw new PolicyManagementException("There is a task already running for policy changes. Please try " + "to apply " + diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index d0534e28ac..5cc0dc35b8 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -18,10 +18,6 @@ package io.entgra.device.mgt.core.policy.mgt.core.mgt.impl; -import com.google.gson.Gson; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraPolicyLoggerImpl; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest; @@ -52,7 +48,6 @@ import io.entgra.device.mgt.core.policy.mgt.core.util.PolicyManagerUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import java.sql.SQLException; import java.sql.Timestamp; @@ -60,13 +55,12 @@ import java.util.*; public class PolicyManagerImpl implements PolicyManager { - PolicyLogContext.Builder policyLogContextBuilder = new PolicyLogContext.Builder(); private final PolicyDAO policyDAO; private final ProfileDAO profileDAO; private final FeatureDAO featureDAO; private final ProfileManager profileManager; private final PolicyConfiguration policyConfiguration; - private static final EntgraLogger log = new EntgraPolicyLoggerImpl(PolicyManagerImpl.class); + private static final Log log = LogFactory.getLog(PolicyManagerImpl.class); public PolicyManagerImpl() { this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO(); @@ -78,9 +72,6 @@ public class PolicyManagerImpl implements PolicyManager { @Override public Policy addPolicy(Policy policy) throws PolicyManagementException { - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); try { PolicyManagementDAOFactory.beginTransaction(); if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) { @@ -162,16 +153,11 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } - String stringPayload = new Gson().toJson(policy); - log.info("Policy created", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("ADD_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return policy; } @Override public Policy updatePolicy(Policy policy) throws PolicyManagementException { - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); try { // Previous policy needs to be obtained before beginning the transaction Policy previousPolicy = this.getPolicy(policy.getId()); @@ -313,8 +299,6 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } - String stringPayload = new Gson().toJson(policy); - log.info("Policy updated", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("UPDATE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return policy; } @@ -504,10 +488,6 @@ public class PolicyManagerImpl implements PolicyManager { @Override public boolean updatePolicyPriorities(List policies) throws PolicyManagementException { - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); - String stringPayload = new Gson().toJson(policies); boolean bool; try { List existingPolicies; @@ -536,24 +516,18 @@ public class PolicyManagerImpl implements PolicyManager { } finally { PolicyManagementDAOFactory.closeConnection(); } - log.info("Policy priorities updated", policyLogContextBuilder.setPayload(stringPayload).setActionTag("UPDATE_POLICY_PRIORITIES").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return bool; } @Override public boolean deletePolicy(Policy policy) throws PolicyManagementException { try { - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); PolicyManagementDAOFactory.beginTransaction(); policyDAO.deleteAllPolicyRelatedConfigs(policy.getId()); policyDAO.deletePolicy(policy.getId()); featureDAO.deleteFeaturesOfProfile(policy.getProfileId()); profileDAO.deleteProfile(policy.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); - String stringPayload = new Gson().toJson(policy); - log.info("Policy deleted", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("DELETE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return true; } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); @@ -574,9 +548,6 @@ public class PolicyManagerImpl implements PolicyManager { @Override public boolean deletePolicy(int policyId) throws PolicyManagementException { - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); boolean bool; List policies = this.getPolicies(); Policy pol = null; @@ -607,8 +578,6 @@ public class PolicyManagerImpl implements PolicyManager { featureDAO.deleteFeaturesOfProfile(policy.getProfileId()); profileDAO.deleteProfile(policy.getProfileId()); PolicyManagementDAOFactory.commitTransaction(); - String stringPayload = new Gson().toJson(policy); - log.info("Policy deleted", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(stringPayload).setActionTag("DELETE_POLICY").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); return bool; } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); @@ -667,9 +636,6 @@ public class PolicyManagerImpl implements PolicyManager { List deviceList = new ArrayList<>(); DeviceManagementProviderService deviceManagementService = PolicyManagementDataHolder .getInstance().getDeviceManagementService(); - String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); - String userName = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername()); for (DeviceIdentifier deviceIdentifier : deviceIdentifierList) { try { Device device = deviceManagementService.getDevice(deviceIdentifier, false); @@ -698,9 +664,6 @@ public class PolicyManagerImpl implements PolicyManager { } policy.setDevices(deviceList); } - String policyPayload = new Gson().toJson(policy); - String deviceListPayload = new Gson().toJson(deviceList); - log.info("Policy added to devices", policyLogContextBuilder.setPolicyName(policy.getPolicyName()).setPayload(" Policy: " + policyPayload + " DeviceList: " + deviceListPayload).setActionTag("ADD_POLICY_TO_DEVICE").setUserName(userName).setTenantID(tenantId).setTenantDomain(tenantDomain).build()); } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); throw new PolicyManagementException("Error occurred while adding the policy (" diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index e3ed0cd6ec..defd753f33 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -1,51 +1,3 @@ - DROP VIEW IF EXISTS FEATURE_NON_COMPLIANCE_INFO; - ALTER TABLE IF EXISTS DM_DEVICE DROP CONSTRAINT IF EXISTS fk_DM_DEVICE_DM_DEVICE_TYPE2; --- ALTER TABLE IF EXISTS DM_DEVICE_TYPE_PLATFORM DROP CONSTRAINT IF EXISTS DM_DEVICE_TYPE_DM_DEVICE_TYPE_PLATFORM_MAPPING; - ALTER TABLE IF EXISTS DM_ROLE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_ROLE_GROUP_MAP_DM_GROUP2; - ALTER TABLE IF EXISTS DM_DEVICE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_MAP_DM_GROUP2; - ALTER TABLE IF EXISTS DM_DEVICE_GROUP_POLICY DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_POLICY; --- ALTER TABLE IF EXISTS DM_GEOFENCE_GROUP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_GEOFENCE_GROUP_MAPPING_GROUP; --- ALTER TABLE IF EXISTS DM_DEVICE_EVENT_GROUP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_EVENT_GROUP_MAPPING_GROUP; - - ALTER TABLE IF EXISTS DM_DEVICE_GROUP_MAP DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_MAP_DM_DEVICE2; - ALTER TABLE IF EXISTS DM_ENROLMENT DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_ENROLMENT; - ALTER TABLE IF EXISTS DM_DEVICE_STATUS DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_STATUS_DEVICE; - ALTER TABLE IF EXISTS DM_DEVICE_POLICY DROP CONSTRAINT IF EXISTS FK_DEVICE_DEVICE_POLICY; - ALTER TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED DROP CONSTRAINT IF EXISTS FK_DM_POLICY_DEVCIE_APPLIED; - ALTER TABLE IF EXISTS DM_APPLICATION DROP CONSTRAINT IF EXISTS FK_DM_DEVICE; - ALTER TABLE IF EXISTS DM_NOTIFICATION DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_NOTIFICATION; - ALTER TABLE IF EXISTS DM_DEVICE_INFO DROP CONSTRAINT IF EXISTS DM_DEVICE_INFO_DEVICE; - ALTER TABLE IF EXISTS DM_DEVICE_LOCATION DROP CONSTRAINT IF EXISTS DM_DEVICE_LOCATION_DEVICE; - ALTER TABLE IF EXISTS DM_DEVICE_DETAIL DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_DETAILS_DEVICE; - - ALTER TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_MAPPING_OPERATION; - ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_OPERATION; - - ALTER TABLE IF EXISTS DM_DEVICE_STATUS DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_STATUS_ENROLMENT; - ALTER TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_MAPPING_DEVICE; - ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_ENROLLMENT; - ALTER TABLE IF EXISTS DM_APPLICATION DROP CONSTRAINT IF EXISTS FK_DM_ENROLEMENT; - ALTER TABLE IF EXISTS DM_DEVICE_INFO DROP CONSTRAINT IF EXISTS DM_DEVICE_INFO_DEVICE_ENROLLMENT; - ALTER TABLE IF EXISTS DM_DEVICE_LOCATION DROP CONSTRAINT IF EXISTS DM_DEVICE_LOCATION_DM_ENROLLMENT; - ALTER TABLE IF EXISTS DM_DEVICE_DETAIL DROP CONSTRAINT IF EXISTS FK_DM_ENROLMENT_DEVICE_DETAILS; - ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE DROP CONSTRAINT IF EXISTS FK_DM_EN_OP_MAP_RESPONSE; - ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE_LARGE DROP CONSTRAINT IF EXISTS FK_DM_EN_OP_MAP_RESPONSE_LARGE; - ALTER TABLE IF EXISTS DM_DEVICE_OPERATION_RESPONSE_LARGE DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_OPERATION_RESPONSE_LARGE_MAPPING; --- - ALTER TABLE IF EXISTS DM_POLICY DROP CONSTRAINT IF EXISTS FK_DM_PROFILE_DM_POLICY; - ALTER TABLE IF EXISTS DM_PROFILE_FEATURES DROP CONSTRAINT IF EXISTS FK_DM_PROFILE_DM_POLICY_FEATURES; --- - ALTER TABLE IF EXISTS DM_DEVICE_POLICY DROP CONSTRAINT IF EXISTS FK_POLICY_DEVICE_POLICY; - ALTER TABLE IF EXISTS DM_DEVICE_TYPE_POLICY DROP CONSTRAINT IF EXISTS FK_DEVICE_TYPE_POLICY; - ALTER TABLE IF EXISTS DM_POLICY_CORRECTIVE_ACTION DROP CONSTRAINT IF EXISTS FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION; - ALTER TABLE IF EXISTS DM_ROLE_POLICY DROP CONSTRAINT IF EXISTS FK_ROLE_POLICY_POLICY; - ALTER TABLE IF EXISTS DM_USER_POLICY DROP CONSTRAINT IF EXISTS DM_POLICY_USER_POLICY; - ALTER TABLE IF EXISTS DM_POLICY_CRITERIA DROP CONSTRAINT IF EXISTS FK_POLICY_POLICY_CRITERIA; - ALTER TABLE IF EXISTS DM_DEVICE_GROUP_POLICY DROP CONSTRAINT IF EXISTS FK_DM_DEVICE_GROUP_DM_POLICY; - ALTER TABLE IF EXISTS DM_POLICY_CRITERIA DROP CONSTRAINT IF EXISTS FK_CRITERIA_POLICY_CRITERIA; - ALTER TABLE IF EXISTS DM_POLICY_CRITERIA_PROPERTIES DROP CONSTRAINT IF EXISTS FK_POLICY_CRITERIA_PROPERTIES; - ALTER TABLE IF EXISTS DM_POLICY_COMPLIANCE_FEATURES DROP CONSTRAINT IF EXISTS FK_COMPLIANCE_FEATURES_STATUS; - DROP TABLE IF EXISTS DM_DEVICE_TYPE; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( ID INT AUTO_INCREMENT NOT NULL, @@ -61,23 +13,24 @@ DROP TABLE IF EXISTS DM_GROUP; 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, + STATUS VARCHAR(50) DEFAULT NULL, + DATE_OF_CREATE BIGINT DEFAULT NULL, + DATE_OF_LAST_UPDATE BIGINT DEFAULT NULL, + OWNER VARCHAR(45) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); -DROP TABLE IF EXISTS DM_ROLE_GROUP_MAP; -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 + +DROP TABLE IF EXISTS DM_DEVICE_CERTIFICATE; +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) ); DROP TABLE IF EXISTS DM_DEVICE; @@ -85,14 +38,13 @@ 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 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) + 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 ); DROP TABLE IF EXISTS DM_DEVICE_PROPERTIES; @@ -101,8 +53,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES ( 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) + TENANT_ID VARCHAR(100) DEFAULT NULL, + PRIMARY KEY (DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME) ); DROP TABLE IF EXISTS GROUP_PROPERTIES; @@ -122,9 +74,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( 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, + REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID) - REFERENCES DM_GROUP (ID) ON DELETE CASCADE ON UPDATE CASCADE + REFERENCES DM_GROUP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_OPERATION; @@ -144,7 +96,7 @@ DROP TABLE IF EXISTS DM_ENROLMENT; CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OWNER VARCHAR(255) NOT NULL, + OWNER VARCHAR(50) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, IS_TRANSFERRED BOOLEAN NOT NULL DEFAULT FALSE, @@ -153,8 +105,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( 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) + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_DEVICE_STATUS; CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( @@ -168,7 +119,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES - DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE + DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_ENROLMENT_OP_MAPPING; CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( @@ -216,14 +167,10 @@ 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 ); @@ -234,25 +181,30 @@ 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 , + DEVICE_TYPE VARCHAR(20) NOT NULL , CREATED_TIME DATETIME NOT NULL , UPDATED_TIME DATETIME NOT NULL , - PRIMARY KEY (ID) + PRIMARY KEY (ID) , + CONSTRAINT DM_PROFILE_DEVICE_TYPE + FOREIGN KEY (DEVICE_TYPE ) + REFERENCES DM_DEVICE_TYPE (NAME ) + ON DELETE NO ACTION + ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_POLICY; CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , + PAYLOAD_VERSION VARCHAR (45) DEFAULT NULL, DESCRIPTION VARCHAR(1000) NULL, - PAYLOAD_VERSION VARCHAR (45) NULL, - TENANT_ID INT NOT NULL , - PROFILE_ID INT NOT 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 NOT NULL, - UPDATED INT NULL, + ACTIVE INT(2) NOT NULL, + UPDATED INT(1) NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -261,13 +213,31 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); + +DROP TABLE IF EXISTS DM_POLICY_CORRECTIVE_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 +); + + DROP TABLE IF EXISTS DM_DEVICE_POLICY; CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , - DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT NOT NULL, + 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 NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -283,24 +253,29 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( DROP TABLE IF EXISTS DM_DEVICE_TYPE_POLICY; CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT NOT NULL , - DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT NOT NULL , + ID INT(11) NOT NULL , + DEVICE_TYPE VARCHAR(20) 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, + CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE + FOREIGN KEY (DEVICE_TYPE ) + REFERENCES DM_DEVICE_TYPE (NAME) + ON DELETE NO ACTION ON UPDATE NO ACTION ); DROP TABLE IF EXISTS DM_PROFILE_FEATURES; CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT NOT NULL AUTO_INCREMENT, - PROFILE_ID INT NOT NULL, + 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 NOT NULL , + DEVICE_TYPE VARCHAR(20) NOT NULL, + TENANT_ID INT(11) NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -310,26 +285,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ON UPDATE NO ACTION ); -CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT NOT NULL AUTO_INCREMENT, - ACTION_TYPE VARCHAR(45) NOT NULL, - CORRECTIVE_POLICY_ID INT DEFAULT NULL, - POLICY_ID INT NOT NULL, - FEATURE_ID INT 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 -); - DROP TABLE IF EXISTS DM_ROLE_POLICY; CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -355,11 +315,11 @@ DROP TABLE IF EXISTS DM_DEVICE_POLICY_APPLIED; CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_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 NULL , + APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -403,7 +363,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( POLICY_CRITERION_ID INT NOT NULL, PROP_KEY VARCHAR(45) NULL, PROP_VALUE VARCHAR(100) NULL, - CONTENT BLOB NULL, + CONTENT BLOB NULL COMMENT 'This is used to ', PRIMARY KEY (ID), CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES FOREIGN KEY (POLICY_CRITERION_ID) @@ -416,7 +376,7 @@ DROP TABLE IF EXISTS DM_POLICY_COMPLIANCE_STATUS; CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT NOT NULL, + ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -431,8 +391,8 @@ DROP TABLE IF EXISTS DM_POLICY_CHANGE_MGT; 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 NOT NULL, + DEVICE_TYPE VARCHAR(20) NOT NULL, + TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) ); @@ -463,7 +423,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER NULL, + MEMORY_USAGE INTEGER(10) NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -474,7 +434,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_enrolement + CONSTRAINT FK_DM_APP_MAP_DM_ENROL FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION @@ -488,14 +448,15 @@ DROP TABLE IF EXISTS DM_NOTIFICATION; CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, - OPERATION_ID INTEGER NULL, + OPERATION_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL, STATUS VARCHAR(10) NULL, - DESCRIPTION VARCHAR(1000) NULL, - LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, + DESCRIPTION VARCHAR(100) 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 + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES + DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -- NOTIFICATION TABLE END -- @@ -533,11 +494,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT NOT NULL, - ALTITUDE DOUBLE NULL, - SPEED FLOAT NULL, - BEARING FLOAT NULL, - DISTANCE DOUBLE NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_LOCATION_DEVICE FOREIGN KEY (DEVICE_ID) @@ -550,8 +507,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ON DELETE NO ACTION ON UPDATE NO ACTION ); -DROP INDEX IF EXISTS DM_DEVICE_LOCATION_GEO_hashx; -CREATE INDEX DM_DEVICE_LOCATION_GEO_hashx ON DM_DEVICE_LOCATION(GEO_HASH ASC); DROP TABLE IF EXISTS DM_DEVICE_DETAIL; CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( @@ -572,8 +527,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT NULL, - UPDATE_TIMESTAMP BIGINT NOT 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) @@ -598,14 +553,15 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( CONSTRAINT FK_DM_DEVICE_GROUP_POLICY FOREIGN KEY (DEVICE_GROUP_ID) REFERENCES DM_GROUP (ID) - ON DELETE CASCADE - ON UPDATE CASCADE , + ON DELETE NO ACTION + ON UPDATE NO ACTION, CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY FOREIGN KEY (POLICY_ID) REFERENCES DM_POLICY (ID) - ON DELETE CASCADE - ON UPDATE CASCADE + ON DELETE NO ACTION + ON UPDATE NO ACTION ); + -- END OF POLICY AND DEVICE GROUP MAPPING -- -- DASHBOARD RELATED VIEWS -- @@ -665,4 +621,22 @@ DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID ORDER BY TENANT_ID, DEVICE_ID; +/* + * Copyright (c) 2018 - 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. + */ + -- END OF DASHBOARD RELATED VIEWS -- diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index 96fd6acfff..fc32a2698d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:./target/databasetest/CARBON_TEST + jdbc:h2:target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 0d6b866dea..2daade26a6 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 8c1e357da7..45b7fd07c9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -114,10 +114,6 @@ org.apache.maven.plugins maven-surefire-plugin - - --add-opens=java.xml/jdk.xml.internal=ALL-UNNAMED - --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED - file:src/test/resources/carbon-home/repository/conf/log4j.properties @@ -125,9 +121,6 @@ src/test/resources/testng.xml - - org.ops4j.pax.logging - @@ -349,7 +342,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index df3277920d..40ad63072f 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( STATUS VARCHAR(50) DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL, OWNER VARCHAR(255) DEFAULT NULL, - PARENT_PATH VARCHAR(255) DEFAULT NULL, + PARENT_PATH VARCHAR(255) DEFAULT '/', TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); @@ -42,7 +42,7 @@ 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 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, @@ -84,8 +84,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_MAP ( CREATE TABLE IF NOT EXISTS DM_OPERATION ( ID INTEGER AUTO_INCREMENT NOT NULL, TYPE VARCHAR(50) NOT NULL, - CREATED_TIMESTAMP BIGINT NOT NULL, - RECEIVED_TIMESTAMP BIGINT 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, @@ -108,19 +108,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( 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_DEVICE_STATUS ( - ID INTEGER AUTO_INCREMENT NOT NULL, - ENROLMENT_ID INTEGER NOT NULL, - DEVICE_ID INTEGER NOT NULL, - STATUS VARCHAR(50) DEFAULT NULL, - UPDATE_TIME TIMESTAMP DEFAULT NULL, - CHANGED_BY VARCHAR(255) NOT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device_status_device FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT fk_dm_device_status_enrolment FOREIGN KEY (ENROLMENT_ID) REFERENCES - DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE -); + CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -188,17 +176,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, PAYLOAD_VERSION VARCHAR (45) NULL, - TENANT_ID INT NOT NULL , - PROFILE_ID INT NOT 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 NOT NULL, - UPDATED INT NULL, + ACTIVE INT(2) NOT NULL, + UPDATED INT(1) NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -209,11 +197,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , - DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT NOT NULL, + 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 NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -228,9 +216,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT NOT NULL , + ID INT(11) NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -240,11 +228,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT NOT NULL AUTO_INCREMENT, - PROFILE_ID INT NOT NULL, + 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 NOT NULL , + TENANT_ID INT(11) NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -255,11 +243,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT NOT NULL AUTO_INCREMENT, + ID INT(11) NOT NULL AUTO_INCREMENT, ACTION_TYPE VARCHAR(45) NOT NULL, - CORRECTIVE_POLICY_ID INT DEFAULT NULL, - POLICY_ID INT NOT NULL, - FEATURE_ID INT DEFAULT 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 @@ -270,9 +258,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT NOT NULL AUTO_INCREMENT , + ID INT(11) NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT NOT NULL , + POLICY_ID INT(11) NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -296,11 +284,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_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 NULL , + APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -353,7 +341,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT NOT NULL, + ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -368,7 +356,7 @@ 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 NOT NULL, + TENANT_ID INT(11) NOT NULL, PRIMARY KEY (ID) ); @@ -397,7 +385,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER NULL, + MEMORY_USAGE INTEGER(10) NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -417,16 +405,6 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( -- POLICY RELATED TABLES FINISHED -- -CREATE TABLE IF NOT EXISTS DM_APP_ICONS ( - ID INTEGER AUTO_INCREMENT NOT NULL, - ICON_PATH VARCHAR(150) DEFAULT NULL, - PACKAGE_NAME VARCHAR(150) NOT NULL, - VERSION VARCHAR(50) DEFAULT '1.1.0', - CREATED_TIMESTAMP TIMESTAMP NOT NULL, - TENANT_ID INTEGER NOT NULL, - PRIMARY KEY (ID) -); - -- NOTIFICATION TABLE -- CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( NOTIFICATION_ID INTEGER AUTO_INCREMENT NOT NULL, @@ -447,7 +425,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( DEVICE_ID INT NULL, ENROLMENT_ID INT NOT NULL, KEY_FIELD VARCHAR(45) NULL, - VALUE_FIELD VARCHAR(1500) NULL, + VALUE_FIELD VARCHAR(1000) NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) @@ -476,7 +454,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT NOT NULL, + UPDATE_TIMESTAMP BIGINT(15) NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -513,8 +491,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT NULL, - UPDATE_TIMESTAMP BIGINT NOT 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) @@ -541,7 +519,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT NOT NULL, + TIMESTAMP BIGINT(15) NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -766,6 +744,24 @@ CREATE TABLE IF NOT EXISTS DM_EXT_DEVICE_MAPPING ( STATUS INT DEFAULT 0, PRIMARY KEY (ID) ); +/* + * Copyright (c) 2018 - 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. + */ + -- END OF DM_EXT_DEVICE_MAPPING TABLE-- -- END OF DM_EXT_PERMISSION_MAPPING TABLE-- @@ -777,23 +773,23 @@ CREATE TABLE IF NOT EXISTS DM_EXT_PERMISSION_MAPPING ( -- 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) + 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 + 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-- @@ -806,34 +802,5 @@ 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, - DEVICE_NAME VARCHAR(100) NOT NULL, - IOTS_DEVICE_IDENTIFIER VARCHAR(300) DEFAULT NULL UNIQUE, - TRACCAR_DEVICE_UNIQUE_ID INT NOT NULL, - TRACCAR_USENAME VARCHAR(100) NULL, - STATUS VARCHAR(100) NULL, - TENANT_ID INTEGER DEFAULT 0, - PRIMARY KEY (ID) -); --- END OF DM_TRACCAR_UNSYNCED_DEVICES TABLE -- - --- SUB_OPERATION_TEMPLATE TABLE-- -CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( - SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, - OPERATION_DEFINITION TEXT NOT NULL, - OPERATION_CODE VARCHAR(100) NOT NULL, - SUB_TYPE_ID INT NOT NULL, - DEVICE_TYPE VARCHAR(25) NOT NULL, - CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, - UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, - PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), - CONSTRAINT uk_sub_operation_template UNIQUE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), --- UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID, OPERATION_CODE, DEVICE_TYPE), - CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) -); - --- END OF SUB_OPERATION_TEMPLATE TABLE-- +-- END OF DM_DEVICE_SUB_TYPE TABLE-- \ No newline at end of file diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index 2e591b07c9..ad8165fc67 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE + 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/pom.xml b/components/subtype-mgt/pom.xml index 91d04c4c33..0f4e0f5f5a 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 26e51edae7..0913807c9c 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 06997c8f17..daf623b335 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 20edac784a..802b4fc403 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.27-SNAPSHOT + 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 f0eb908782..9ea2215ea7 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 7c15343e73..e6c32be204 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.27-SNAPSHOT + 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 d14ddd7d18..456c573204 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index b4ba0d60bf..1d07439a11 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 8163f936a3..5ed3918990 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index bdc00ce03d..ce01e21a9c 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 6550c0c17b..2b70f9001d 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.27-SNAPSHOT + 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 06b561b237..77c2cf12cb 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 7c275e0a25..a2140712f7 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 9abdfa3735..2e0dd266f5 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 60dcfdbe95..fceb5e77d1 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index a23d2d922d..e91b0ed983 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.27-SNAPSHOT + 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 18baf3dd9d..6eda7374a9 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 685e75809d..a58b6b40ae 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java index a40dcafefd..1d757b421e 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import com.google.gson.Gson; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; @@ -26,22 +27,13 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.StringUtils; -import io.entgra.ui.request.interceptor.util.HandlerConstants; -import io.entgra.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; +import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; import org.apache.http.entity.ContentType; -import io.entgra.ui.request.interceptor.beans.ProxyResponse; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.common.exceptions.OTPManagementException; -import org.wso2.carbon.device.mgt.common.otp.mgt.OTPEmailTypes; -import org.wso2.carbon.device.mgt.common.otp.mgt.dto.OneTimePinDTO; -import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.core.service.RealmService; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -63,28 +55,71 @@ public class DefaultTokenHandler extends HttpServlet { HttpSession httpSession = req.getSession(false); if (httpSession != null) { - String userWithDomain = (String) httpSession.getAttribute(HandlerConstants.USERNAME_WITH_DOMAIN); - String[] userNameParts = userWithDomain.split("@"); - - OneTimePinDTO oneTimePinData = new OneTimePinDTO(); - oneTimePinData.setEmail(OTPEmailTypes.REMOTE_SESSION.toString()); - oneTimePinData.setEmailType(OTPEmailTypes.REMOTE_SESSION.toString()); - oneTimePinData.setUsername(userNameParts[0]); - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); - try { - oneTimePinData.setTenantId(realmService.getTenantManager().getTenantId(userNameParts[1])); - } catch (UserStoreException e) { - throw new RuntimeException(e); + AuthData authData = (AuthData) httpSession.getAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY); + if (authData == null) { + HandlerUtil.sendUnAuthorizeResponse(resp); + return; } - oneTimePinData.setExpiryTime(DeviceManagementConstants.OTPProperties.OTP_DEFAULT_EXPIRY_SECONDS); - OTPManagementService otpManagementService = HandlerUtil.getOTPManagementService(); - try { - oneTimePinData = otpManagementService.generateOneTimePin(oneTimePinData, true); - HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(oneTimePinData.getOtpToken())); - } catch (OTPManagementException e) { - log.error("Failed while generating remote session OTP for user " + userWithDomain, e); - HandlerUtil.handleError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR); + + AuthData defaultAuthData = (AuthData) httpSession + .getAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY); + if (defaultAuthData != null) { + HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultAuthData.getAccessToken())); + return; + } + + String clientId = authData.getClientId(); + String clientSecret = authData.getClientSecret(); + + String queryString = req.getQueryString(); + String scopeString = ""; + if (StringUtils.isNotEmpty(queryString)) { + scopeString = req.getParameter("scopes"); + if (scopeString != null) { + scopeString = "?scopes=" + scopeString; + } + } + + String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); + String tokenUrl = iotsCoreUrl + "/api/device-mgt/v1.0/devices/" + clientId + + "/" + clientSecret + "/default-token" + scopeString; + + HttpGet defaultTokenRequest = new HttpGet(tokenUrl); + defaultTokenRequest + .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); + defaultTokenRequest + .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); + ProxyResponse tokenResultResponse = HandlerUtil.execute(defaultTokenRequest); + + if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { + log.error("Error occurred while invoking the API to get default token data."); + HandlerUtil.handleError(resp, tokenResultResponse); + return; + } + String tokenResult = tokenResultResponse.getData(); + if (tokenResult == null) { + log.error("Invalid default token response is received."); + HandlerUtil.handleError(resp, tokenResultResponse); + return; + } + + JsonParser jsonParser = new JsonParser(); + JsonElement jTokenResult = jsonParser.parse(tokenResult); + if (jTokenResult.isJsonObject()) { + JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); + AuthData newDefaultAuthData = new AuthData(); + newDefaultAuthData.setClientId(clientId); + newDefaultAuthData.setClientSecret(clientSecret); + + String defaultToken = jTokenResultAsJsonObject.get("accessToken").getAsString(); + newDefaultAuthData.setAccessToken(defaultToken); + newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refreshToken").getAsString()); + newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scopes").getAsString()); + httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); + + HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken)); } } else { HandlerUtil.sendUnAuthorizeResponse(resp); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index c0f6c7f6ee..d5e8d2bf4d 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -120,7 +120,6 @@ public class UserHandler extends HttpServlet { proxyResponse.setData( jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", "")); HandlerUtil.handleSuccess(resp, proxyResponse); - httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); } } catch (IOException e) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java index 9aa9cb9fe6..239cf1c944 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java @@ -106,5 +106,4 @@ public class HandlerConstants { public static final String IOT_REPORTING_WEBAPP_HOST_ENV_VAR = "iot.reporting.webapp.host"; public static final String USER_SCOPES = "userScopes"; public static final String HUBSPOT_CHAT_URL = "api.hubapi.com"; - public static final String USERNAME_WITH_DOMAIN = "usernameWithDomain"; } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index f15215067e..5a05a19425 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -51,9 +51,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.w3c.dom.Document; -import io.entgra.ui.request.interceptor.beans.ProxyResponse; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.spi.OTPManagementService; import org.xml.sax.SAXException; import javax.servlet.http.HttpServletRequest; @@ -73,8 +70,6 @@ public class HandlerUtil { private static boolean isLoginCacheInitialized = false; private static AuthData authData; - private static OTPManagementService otpManagementService; - /*** * * @param httpRequest - httpMethod e.g:- HttpPost, HttpGet @@ -747,12 +742,4 @@ public class HandlerUtil { public static boolean isPropertyDefined(String property) { return StringUtils.isEmpty(System.getProperty(property)); } - - public static OTPManagementService getOTPManagementService() { - if (otpManagementService == null) { - otpManagementService = (OTPManagementService) PrivilegedCarbonContext - .getThreadLocalCarbonContext().getOSGiService(OTPManagementService.class, null); - } - return otpManagementService; - } } diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 0faab0c2fa..47912a8465 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 44862e66e7..6476fc0aa6 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml @@ -273,7 +273,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito test diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java index 11395eef60..6545b7bbab 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BasicAuthAuthenticator.java @@ -35,7 +35,6 @@ import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.nio.charset.Charset; import java.util.Base64; import java.util.Properties; -import java.util.StringTokenizer; public class BasicAuthAuthenticator implements WebappAuthenticator { @@ -51,23 +50,15 @@ public class BasicAuthAuthenticator implements WebappAuthenticator { @Override public boolean canHandle(Request request) { /* - This is done to avoid every web app being able to use basic auth. Add the following to - the required web.xml of the web app. This is a global config for a web app to allow all - contexts of the web app to use basic auth + This is done to avoid every endpoint being able to use basic auth. Add the following to + the required web.xml of the web app. basicAuth true - - Adding the basicAuthAllowList parameter allows to selectively allow some context paths in a - web app to use basic auth while all the other context remain unavailable with basic auth. - If this parameter is present, any context that requires basic auth must be specially - added as comma separated list to the param-value of basicAuthAllowList. */ - if (!isAllowListedForBasicAuth(request)) { - if (!isAuthenticationSupported(request)) { - return false; - } + if (!isAuthenticationSupported(request)) { + return false; } if (request.getCoyoteRequest() == null || request.getCoyoteRequest().getMimeHeaders() == null) { return false; @@ -84,20 +75,6 @@ public class BasicAuthAuthenticator implements WebappAuthenticator { return false; } - private boolean isAllowListedForBasicAuth(Request request) { - String param = request.getContext().findParameter("basicAuthAllowList"); - if (param != null && !param.isEmpty()) { - //Add the nonSecured end-points to cache - String[] basicAuthAllowList = param.split(","); - for (String contexPath : basicAuthAllowList) { - if (request.getRequestURI().toString().endsWith(contexPath.trim())) { - return true; - } - } - } - return false; - } - @Override public AuthenticationInfo authenticate(Request request, Response response) { AuthenticationInfo authenticationInfo = new AuthenticationInfo(); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java index cb9bf50215..5238828dd0 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java @@ -74,17 +74,9 @@ public class CertificateAuthenticator implements WebappAuthenticator { // When there is a load balancer terminating mutual SSL, it should pass this header along and // as the value of this header, the client certificate subject dn should be passed. if (request.getHeader(PROXY_MUTUAL_AUTH_HEADER) != null) { - if (log.isDebugEnabled()) { - log.debug("PROXY_MUTUAL_AUTH_HEADER " + request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); - } CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifySubjectDN(request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); authenticationInfo = checkCertificateResponse(certificateResponse); - if (log.isDebugEnabled()) { - log.debug("Certificate Serial : " + certificateResponse.getSerialNumber() - + ", CN : " + certificateResponse.getCommonName() - + " , username" + authenticationInfo.getUsername()); - } } else if (request.getHeader(MUTUAL_AUTH_HEADER) != null) { Object object = request.getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); @@ -97,6 +89,7 @@ public class CertificateAuthenticator implements WebappAuthenticator { CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). getCertificateManagementService().verifyPEMSignature(clientCertificate[0]); authenticationInfo = checkCertificateResponse(certificateResponse); + } else { authenticationInfo.setStatus(Status.FAILURE); authenticationInfo.setMessage("No client certificate is present"); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java index 29392b63f5..82e592524b 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OneTimeTokenAuthenticator.java @@ -49,18 +49,8 @@ public class OneTimeTokenAuthenticator implements WebappAuthenticator { try { OTPManagementService otpManagementService = AuthenticatorFrameworkDataHolder.getInstance() .getOtpManagementService(); - OneTimePinDTO validOTP; - if (request.getRequestURI().toString().endsWith("cloud/download-url") - || request.getRequestURI().toString().endsWith("cloud/tenant")) { - validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders - .ONE_TIME_TOKEN_HEADER), true); - } else { - log.info("Validating OTP for enrollments PIN: " + request.getHeader(Constants - .HTTPHeaders.ONE_TIME_TOKEN_HEADER)); - validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders - .ONE_TIME_TOKEN_HEADER), false); - } - + OneTimePinDTO validOTP = otpManagementService.isValidOTP(request.getHeader(Constants.HTTPHeaders + .ONE_TIME_TOKEN_HEADER)); if (validOTP != null) { authenticationInfo.setStatus(Status.CONTINUE); authenticationInfo.setTenantId(validOTP.getTenantId()); diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 252b96df53..f5f2d2c1f3 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index c087fc0b4a..e7d57bd4b7 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 570f87276f..01debfaf07 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.27-SNAPSHOT + 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 7dd4d6fb94..2087a82870 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 2ebf097dd7..168b828243 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 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 c0456a9c1c..73abea954f 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index b157b5afa6..f13b9e3927 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 98ac163d22..b0f3a595a5 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -17,12 +17,14 @@ ~ under the License. --> - + io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 696558150f..636cc8c34e 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 6ed2466109..1a2cb3b77e 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 7e04260393..9c37daadae 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 2841167689..eaa8ffa5c7 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 499e95ba46..4877de4bbe 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index da7eeda702..5617820cf5 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index b434483af3..c21ff6fb19 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index ad2d1c068c..3867d0806e 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 366cffe69e..3acaabfd9d 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 7a33d7ebef..ee3a2da42a 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index bd44c707b0..5d58fe1956 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 0798f33b74..6ba482a99f 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index dfbd7c1aa5..89babbcd7a 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 3e3e688d59..9dacdae6ba 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 844427fea5..e37e6fbd26 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 8648168dca..f74312e6a3 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 1c2f9f450a..810e45e3b7 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 84e33b2daf..e02dcb8012 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 8f8ec91fba..845e0f69d7 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 406388f422..2a2c6468b1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index c40cefc413..3ce48daefe 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -189,7 +189,7 @@ <a href='https://entgra.io' target='_blank'> Entgra </a> - UEM Server 5.3.0 | © 2023 + IoT Server 5.2.0 | © 2023 , All Rights Reserved. Entgra diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index b16935562d..46114821a2 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -224,22 +224,9 @@ perm:admin:tenant:view perm:admin:metadata:view perm:admin:usage:view - perm:android:clear-application + perm:android:clear-applicatio perm:android:suspend-package perm:android:alternate-install - perm:ios:lock - perm:ios:location - perm:ios:ring - perm:ios:clear-passcode - perm:ios:enterprise-wipe - perm:ios:notification - perm:ios:wipe-data - perm:ios:boolean-setting - perm:ios:wallpaper - perm:ios:app-attributes - perm:ios:app-configurations - perm:mac-os:restart - perm:mac-os:shut-down device-mgt diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index 2152b1814f..262761caec 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -325,16 +325,12 @@ - <a href='https://entgra.io' target='_blank'> - Entgra - </a> - {% if product_conf is defined %} - {{product_conf.server_name}} {{product_conf.server_version}} | © {{product_conf.current_year}} - {% else %} - Entgra UEM Server - {% endif %} - , All Rights Reserved. - + <a href='https://entgra.io' target='_blank'> + Entgra + </a> + IoT Server 5.2.0 | © 2023 + , All Rights Reserved. + Entgra repository/resources/whitelabel diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 15ffa69605..df3277920d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -25,7 +25,6 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 5b6b3b93f1..c162d41e06 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -41,7 +41,6 @@ IF NOT EXISTS(SELECT * OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 86da197b12..6dcc7bec44 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -29,7 +29,6 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(255) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ) ENGINE = InnoDB; diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 6cc55f7e74..a6f87c9cb6 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -52,7 +52,6 @@ CREATE TABLE DM_GROUP ( OWNER VARCHAR2(255) DEFAULT NULL, PARENT_PATH VARCHAR2(255) DEFAULT NULL, TENANT_ID NUMBER(10) DEFAULT 0, - PARENT_GROUP_ID NUMBER(10) DEFAULT 0, CONSTRAINT PK_DM_GROUP PRIMARY KEY (ID) ) / diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index b1fc128cf9..8c601111b7 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -23,7 +23,6 @@ CREATE TABLE IF NOT EXISTS DM_GROUP ( OWNER VARCHAR(45) DEFAULT NULL, PARENT_PATH VARCHAR(255) DEFAULT NULL, TENANT_ID INTEGER DEFAULT 0, - PARENT_GROUP_ID INTEGER DEFAULT 0, PRIMARY KEY (ID) ) ; diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 062cc6df3e..904012948e 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 9ef814e62f..6455ab6f05 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 80ed932a53..cb5841a715 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 96c5194c45..230fa3700f 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 096683db82..e1b4db491a 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index a2d4bed8ba..f551b3e518 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 13e974fbdb..57b1438027 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index c3e2fafa70..3220ebb7da 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index fd4fb89fd9..1bfe57fa69 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index 34a5aa4ccf..f4b3d3e41a 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 3eb94e0b04..f9f8ce9f41 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -17,12 +17,13 @@ ~ under the License. --> - + io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 8351d50946..a16c219134 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -17,12 +17,13 @@ ~ under the License. --> - + io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 02b8f172a5..7f96d0da93 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 5eaac22ad1..97a7746320 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 30094f7686..cf0e00a0b5 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 3cccf87ad1..f37cf1d8f3 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 3243b26827..7984cd5521 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index d7e84d2782..a70cbbc67a 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 002b18f48f..001cc0dd34 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 8f87de9b1f..a19947d332 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index ee105d34b8..73986be63f 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm index ef5307de33..7765bcdda2 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/src/main/resources/email/templates/user-enrollment.vm @@ -37,7 +37,7 @@

You have been invited to enrol your device in Entgra IoT Server. - Click here to begin device enrolment.

+ Click here to begin device enrolment.

Enrollment Steps are as below, diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 53fcfbaee9..a75c167bfa 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index 23513d7ed8..ee58261e6c 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index b6dd0dcc5c..5dcab5c654 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index c7f0a53f58..d9b3cb564c 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.27-SNAPSHOT + 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 8350d1b2d2..d60cefe7be 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 53903a27e5..90ba4c04cc 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index a3ead6185d..45b132211d 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index f8aa63d70f..ce0141f915 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml index c3bb4569b8..bf5d2e00e2 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf/webapp-authenticator-config.xml @@ -24,8 +24,8 @@ false https://${iot.keymanager.host}:${iot.keymanager.https.port} - {{super_admin.username}} - {{super_admin.password}} + ${admin.username} + ${admin.password} 100 100 diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 index 6c51e0f2b6..7c3ce35486 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/src/main/resources/conf_templates/templates/repository/conf/etc/webapp-authenticator-config.xml.j2 @@ -14,8 +14,8 @@ false https://${iot.keymanager.host}:${iot.keymanager.https.port} - {{super_admin.username}} - {{super_admin.password}} + ${admin.username} + ${admin.password} 100 100 diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index adbbd92316..5aaec7c6b5 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 1a0eab8a0f..28dfc7301b 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT WSO2 Carbon - Device Management - Parent https://entgra.io WSO2 Connected Device Manager Components @@ -833,16 +833,6 @@ jaxb-api ${version.org.wso2.orbit.javax.xml.bind} - - com.sun.xml.bind - jaxb-core - 2.3.0.1 - - - com.sun.xml.bind - jaxb-impl - 2.3.1 - org.apache.axis2.transport @@ -1664,7 +1654,7 @@ org.powermock - powermock-api-mockito2 + powermock-api-mockito ${power.mock.version} test @@ -1751,11 +1741,6 @@ mockito-inline ${mokito.version} - - org.mockito - mockito-core - ${mokito.version} - org.ops4j.pax.logging pax-logging-api @@ -1903,7 +1888,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 2.22.0 ${basedir}/target/coverage-reports/jacoco-ut.exec @@ -1997,7 +1982,7 @@ 1.2.11-wso2v25 - 5.0.27-SNAPSHOT + 5.0.26-SNAPSHOT 4.9.2 @@ -2128,7 +2113,7 @@ 0.7.8 0.7.5.201505241946 1.0b3 - 2.0.2 + 1.7.4 1.4.0.wso2v1 1.7.25 @@ -2151,7 +2136,7 @@ [1.6.0, 2.0.0) [1.2.0,1.3.0) - 2.23.4 + 4.2.0 2.8.1.wso2v2 4.3.1.wso2v1 2.1.210.wso2v1 From 7dfcb418f4828cf1e7f260f9a1c7304b38574556 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 26 Jul 2023 08:35:23 +0530 Subject: [PATCH 127/343] Fix jwt token generation --- .../APIManagementProviderServiceImpl.java | 9 +++++-- .../rest/api/APIApplicationServices.java | 5 ++-- .../rest/api/APIApplicationServicesImpl.java | 12 ++++----- .../rest/api/constants/Constants.java | 2 -- .../extension/service/KeyMgtServiceImpl.java | 2 +- .../publisher/APIPublisherServiceImpl.java | 10 +++++-- .../impl/DeviceManagementServiceImpl.java | 26 ++++++++++++------- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 21 +++++++++++++++ .../jwt/client/extension/JWTClient.java | 4 ++- 9 files changed, 66 insertions(+), 25 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 0808f11963..8c12ac45ec 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -649,9 +649,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.AccessTokenInfo accessTokenInfo; try { if (username == null || password == null) { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForConsumerRestCalls", + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); } else { - apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys(username, password); + apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys( + "ClientForConsumerRestCalls", + username, password, + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); } accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); 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/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 index 1cdceff56a..f5cc8b3ec1 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/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 @@ -24,9 +24,10 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIService public interface APIApplicationServices { - APIApplicationKey createAndRetrieveApplicationCredentials() throws APIServicesException; + APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) + throws APIServicesException; - APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) + APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; 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 9dbd5f52cc..a03f81d086 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 @@ -44,7 +44,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { getAPIManagerConfigurationService().getAPIManagerConfiguration(); @Override - public APIApplicationKey createAndRetrieveApplicationCredentials() + public APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); @@ -53,8 +53,8 @@ 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("clientName", clientName); + jsonObject.put("grantType", grantType); jsonObject.put("owner", serverUser); jsonObject.put("saasApp", true); @@ -75,15 +75,15 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey generateAndRetrieveApplicationKeys(String username, String password) + public APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); JSONObject jsonObject = new JSONObject(); jsonObject.put("callbackUrl", Constants.EMPTY_STRING); - jsonObject.put("clientName", username); - jsonObject.put("grantType", Constants.GRANT_TYPE); + jsonObject.put("clientName", clientName); + jsonObject.put("grantType", grantType); jsonObject.put("owner", username); jsonObject.put("saasApp", true); 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 6c3cf21c89..6ca26f74f0 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 @@ -27,10 +27,8 @@ public final class Constants { public static final String AMPERSAND = "&"; public static final String SLASH = "/"; public static final String EQUAL = "="; - public static final String CLIENT_NAME = "rest_api_publisher_code"; public static final String SERVER_USER = "WorkflowConfigurations.ServerUser"; 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"; public static final String OAUTH_TOKEN_SCOPE = "scope"; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 69f51fff56..63e42132f0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -344,7 +344,7 @@ public class KeyMgtServiceImpl implements KeyMgtService { Response response = client.newCall(request).execute(); return gson.fromJson(response.body().string(), OAuthApplication.class); } catch (IOException e) { - msg = "Error occurred while processing the response"; + msg = "Error occurred while processing the response" + e; throw new KeyMgtException(msg); } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index fe98a8cef8..e188ae799b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -90,7 +90,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForPublisherRestCalls", + "client_credentials password refresh_token" + ); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { @@ -403,7 +406,10 @@ public class APIPublisherServiceImpl implements APIPublisherService { APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; try { - apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials(); + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForPublisherRestCalls", + "client_credentials password refresh_token" + ); accessTokenInfo = apiApplicationServices.generateAccessTokenFromRegisteredApplication( apiApplicationKey.getClientId(), apiApplicationKey.getClientSecret()); } catch (APIServicesException e) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 09be7963fd..6f84458c44 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -23,6 +23,11 @@ import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProvi import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderServiceImpl; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; +import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; +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.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; @@ -804,11 +809,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { //todo - lasantha - can't get password from here ApiApplicationKey apiApplicationKey; try { - DCRResponse adminDCRResponse = keyMgtService.dynamicClientRegistration(applicationName, - PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminUserName(), - "client_credentials", null, new String[] {"device_management"}, false, validityTime, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword()); + APIApplicationServices apiApplicationServices = DeviceMgtAPIUtils.getApiApplicationServices(); + APIApplicationKey adminDCRResponse = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForJWTTokenGeneration", + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer" + ); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); JWTClientManagerService jwtClientManagerService = (JWTClientManagerService) ctx. @@ -816,11 +821,14 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { JWTClient jwtClient = jwtClientManagerService.getJWTClient(); AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(adminDCRResponse.getClientId(), adminDCRResponse.getClientSecret(), - username, "appm:subscribe"); + username, "appm:subscribe apim:admin apim:api_key apim:app_import_export apim:app_manage" + + " apim:store_settings apim:sub_alert_manage apim:sub_manage apim:subscribe openid perm:device:enroll " + + "perm:devices:details perm:devices:features perm:devices:search perm:devices:view perm:groups:groups " + + "perm:users:send-invitation"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, - new String[] {"device_management"}, null, false, String.valueOf(validityTime), + new String[] {"device_management"}, "PRODUCTION", false, String.valueOf(validityTime), accessTokenInfo.getAccessToken()); } catch (JWTClientException e) { @@ -828,8 +836,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } catch (UserStoreException e) { - String msg = "Error while getting user credentials."; + } catch (APIServicesException e) { + String msg = "Error while generating api Application"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index a297bffd48..db613f8a28 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; import io.entgra.device.mgt.core.apimgt.application.extension.APIManagementProviderService; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; @@ -156,6 +157,7 @@ public class DeviceMgtAPIUtils { private static volatile SubscriptionManager subscriptionManager; private static volatile ApplicationManager applicationManager; + private static volatile APIApplicationServices apiApplicationServices; private static volatile ConsumerRESTAPIServices consumerRESTAPIServices; private static volatile APIManagementProviderService apiManagementProviderService; @@ -410,6 +412,25 @@ public class DeviceMgtAPIUtils { return consumerRESTAPIServices; } + /** + * Initializing and accessing method for APIM API application REST API. + * + * @return APIApplicationServices instance + * @throws IllegalStateException if APIApplicationServices cannot be initialized + */ + public static synchronized APIApplicationServices getApiApplicationServices() { + if (apiApplicationServices == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + apiApplicationServices = (APIApplicationServices) ctx.getOSGiService(APIApplicationServices.class, null); + if (apiApplicationServices == null) { + String msg = "API application service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + } + return apiApplicationServices; + } + /** * Initializing and accessing method for API management Provider Service. * diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java index a2ae303414..2675314524 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/JWTClient.java @@ -138,7 +138,9 @@ public class JWTClient { if (jwtConfig == null) { return null; } - URL tokenEndpoint = new URL(jwtConfig.getTokenEndpoint()); +// todo: +// URL tokenEndpoint = new URL(jwtConfig.getTokenEndpoint()); + URL tokenEndpoint = new URL("https://localhost:9443/oauth2/token"); HttpClient httpClient = JWTClientUtil.getHttpClient(tokenEndpoint.getProtocol()); HttpPost postMethod = new HttpPost(tokenEndpoint.toString()); postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs)); From 2d296a3453f9317e5f432450f651b0062f753875 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 26 Jul 2023 12:44:40 +0530 Subject: [PATCH 128/343] Implement map application keys using dcr response --- .../APIManagementProviderServiceImpl.java | 9 ++- .../rest/api/ConsumerRESTAPIServices.java | 3 + .../rest/api/ConsumerRESTAPIServicesImpl.java | 67 ++++++++++++++++++- 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 8c12ac45ec..3c62275186 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -250,8 +250,13 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe log.error(msg); throw new APIManagerException(msg); } - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), - keyManager.getName(), validityTime, keyType); + + ApiApplicationInfo applicationInfo = getApplicationInfo(null, null); + tokenInfo.setApiApplicationInfo(applicationInfo); + + ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, + keyManager.getName(), keyType); + ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index 5ed98034e2..8ab2c1f0ad 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -55,6 +55,9 @@ public interface ConsumerRESTAPIServices { ApplicationKey generateApplicationKeys(TokenInfo tokenInfo, String applicationId, String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException; + ApplicationKey mapApplicationKeys(TokenInfo tokenInfo, Application application, String keyManager, String keyType) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index 293894ee71..572756dff7 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -606,6 +606,71 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public ApplicationKey mapApplicationKeys(TokenInfo tokenInfo, Application application, String keyManager, String keyType) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); + String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + + application.getApplicationId() + "/map-keys"; + + String payload = "{\n" + + " \"consumerKey\": \"" + apiApplicationInfo.getClientId() + "\",\n" + + " \"consumerSecret\": \"" + apiApplicationInfo.getClientSecret() + "\",\n" + + " \"keyManager\": \"" + keyManager + "\",\n" + + " \"keyType\": \"" + keyType + "\"\n" + + "}"; + RequestBody requestBody = RequestBody.create(JSON, payload); + + Request.Builder builder = new Request.Builder(); + builder.url(getAllScopesUrl); + if (!token) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + tokenInfo.getAccessToken()); + } + builder.post(requestBody); + Request request = builder.build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), ApplicationKey.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + if (!token) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return mapApplicationKeys(refreshedTokenInfo, application, keyManager, keyType); + } else { + String msg = "Invalid access token. Unauthorized request"; + log.error(msg); + throw new APIServicesException(msg); + } + } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { + String msg = "Bad Request, Invalid request body"; + 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(msg, e); + } + } + @Override public ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException { @@ -733,7 +798,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { private boolean isTokenNull(ApiApplicationInfo apiApplicationInfo, String accessToken) throws BadRequestException { boolean token; - if ((!(accessToken == null) && apiApplicationInfo == null)) { + if ((!(accessToken == null))) { token = true; } else if (!(apiApplicationInfo == null) && accessToken == null) { token = false; From a17c5c27abba5c62aef747ffa4ab34c129a4f367 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Wed, 2 Aug 2023 07:56:01 +0530 Subject: [PATCH 129/343] Fix test case failure --- .../device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index bf43ea4cde..38fe9896c3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -507,7 +507,6 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.notification.logger - provided org.wso2.orbit.javax.xml.bind From f117e40fc908be937c0ef8ecc6321bfc861a3209 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Sun, 6 Aug 2023 23:38:02 +0530 Subject: [PATCH 130/343] Fix SSO related issues --- .../APIManagementProviderServiceImpl.java | 15 +++++++-------- .../ui/request/interceptor/SsoLoginHandler.java | 2 +- .../interceptor/util/HandlerConstants.java | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3c62275186..3a3bf5f941 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -65,6 +65,7 @@ import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.util.*; +import java.util.stream.Collectors; /** * This class represents an implementation of APIManagementProviderService. @@ -143,31 +144,29 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); try { - List uniqueApiList = new ArrayList<>(); - Map headerParams = new HashMap<>(); if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) { headerParams.put("X-WSO2-Tenant", "carbon.super"); } + Map uniqueApiSet = new HashMap<>(); for (String tag : tags) { Map queryParams = new HashMap<>(); queryParams.put("tag", tag); APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(tokenInfo, queryParams, headerParams); - - uniqueApiList.addAll(List.of(apiInfos)); - Set taggedAPISet = new HashSet<>(uniqueApiList); - uniqueApiList.clear(); - uniqueApiList.addAll(taggedAPISet); + Arrays.stream(apiInfos).forEach(apiInfo -> uniqueApiSet.putIfAbsent(apiInfo.getName(), apiInfo)); } + List uniqueApiList = new ArrayList<>(uniqueApiSet.values()); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (applications.length == 0) { - return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); + return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, + validityTime); } else { if (applications.length == 1) { Optional applicationOpt = diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index de037d8bc1..52dc03b79c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -222,7 +222,7 @@ public class SsoLoginHandler extends HttpServlet { } // Update the grant types of the application - String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + applicationId + "/keys/" + + String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + "/" + applicationId + "/keys/" + HandlerConstants.PRODUCTION_KEY; HttpPut updateApplicationGrantTypesEndpoint = new HttpPut(url); updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java index 9aa9cb9fe6..c6058102b6 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java @@ -26,7 +26,7 @@ public class HandlerConstants { public static final String INTERNAL_TOKEN_ENDPOINT = "/token"; public static final String INTROSPECT_ENDPOINT = "/oauth2/introspect"; public static final String AUTHORIZATION_ENDPOINT = "/oauth2/authorize"; - public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/devportal/v2/applications/"; + public static final String APIM_APPLICATIONS_ENDPOINT = "/api/am/devportal/v3/applications"; public static final String IDENTITY_APP_MGT_ENDPOINT = "/services/IdentityApplicationManagementService.IdentityApplicationManagementServiceHttpsSoap11Endpoint"; public static final String LOGIN_PAGE = "/login"; public static final String SSO_LOGIN_CALLBACK = "/ssoLoginCallback"; @@ -77,7 +77,7 @@ public class HandlerConstants { public static final String OTP_HEADER = "one-time-token"; - public static final String AX_PREFIX = "ax2251:"; + public static final String AX_PREFIX = "ax2245:"; public static final String PAYLOADS_DIR = "repository/resources/payloads"; public static final String SOAP_ACTION_HEADER = "SOAPAction"; public static final String REFERER_HEADER = "Referer"; From da1f9d2437b160b95953577ce8c395b2a93e7efa Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 9 Aug 2023 07:34:00 +0530 Subject: [PATCH 131/343] Fix admin user details getting issue --- .../io.entgra.device.mgt.core.ui.request.interceptor/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 3fcfeea3b9..b9fe8f9195 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -335,10 +335,6 @@ javax.websocket javax.websocket-api - - xerces.wso2 - xercesImpl - org.json.wso2 json From 7e65d9f9801dd792bfcc08437747ecd53c6c1868 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 12 Sep 2023 00:02:07 +0530 Subject: [PATCH 132/343] Fix access token validating issue --- .../APIManagementProviderServiceImpl.java | 61 ++++--- .../request/interceptor/SsoLoginHandler.java | 153 +++++++++++------- .../ui/request/interceptor/UserHandler.java | 4 +- .../authenticator/OAuthAuthenticator.java | 2 +- 4 files changed, 124 insertions(+), 96 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3a3bf5f941..f4bd1cb588 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -111,13 +111,13 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, - boolean isAllowedAllDomains, - String validityTime, String accessToken) throws APIManagerException { + String keyType, + boolean isAllowedAllDomains, + String validityTime, String accessToken) throws APIManagerException { TokenInfo tokenInfo = new TokenInfo(); tokenInfo.setApiApplicationInfo(null); tokenInfo.setAccessToken(accessToken); - return generateAndRetrieveApplicationKeys(applicationName, tags ,keyType, isAllowedAllDomains, validityTime, tokenInfo); + return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, tokenInfo); } @Override @@ -127,12 +127,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe String validityTime, String password) throws APIManagerException { - ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); TokenInfo tokenInfo = new TokenInfo(); tokenInfo.setApiApplicationInfo(applicationInfo); tokenInfo.setAccessToken(null); - return generateAndRetrieveApplicationKeys(applicationName, tags, keyType,isAllowedAllDomains, validityTime, tokenInfo); + return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, tokenInfo); } private ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, @@ -149,7 +148,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe headerParams.put("X-WSO2-Tenant", "carbon.super"); } - Map uniqueApiSet = new HashMap<>(); + Map uniqueApiSet = new HashMap<>(); for (String tag : tags) { Map queryParams = new HashMap<>(); queryParams.put("tag", tag); @@ -162,8 +161,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application; - MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); if (applications.length == 0) { return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); @@ -171,8 +168,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (applications.length == 1) { Optional applicationOpt = Arrays.stream(applications).findFirst(); - application = applicationOpt.get(); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = + applicationOpt.get(); + MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); if (metaData == null) { // Todo add a comment @@ -183,7 +182,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe for (Subscription subscription : subscriptions) { uniqueApiList.removeIf(apiInfo -> Objects.equals(apiInfo.getId(), subscription.getApiInfo().getId())); } - addSubscriptions(application, uniqueApiList, tokenInfo); + + if (!uniqueApiList.isEmpty()) { + addSubscriptions(application, uniqueApiList, tokenInfo); + } String[] metaValues = metaData.getMetaValue().split(":"); if (metaValues.length != 2) { @@ -200,7 +202,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); return apiApplicationKey; } - } else { String msg = "Found more than one application for application name: " + applicationName; log.error(msg); @@ -250,11 +251,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } - ApiApplicationInfo applicationInfo = getApplicationInfo(null, null); - tokenInfo.setApiApplicationInfo(applicationInfo); - - ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, - keyManager.getName(), keyType); + tokenInfo.setApiApplicationInfo(getApplicationInfo(null, null)); +// ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, +// keyManager.getName(), keyType); + ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), + keyManager.getName(), validityTime, keyType); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); @@ -294,16 +295,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } /** - * * This method can be used to add a new subscriptions providing the ids of the APIs and the applications. * * @param application {@link io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application} - * @param apiInfos {@link List} - * @param tokenInfo {@link TokenInfo} - * - * @throws BadRequestException if incorrect data provided to call subscribing REST API. + * @param apiInfos {@link List} + * @param tokenInfo {@link TokenInfo} + * @throws BadRequestException if incorrect data provided to call subscribing REST API. * @throws UnexpectedResponseException if error occurred while processing the subscribing REST API. - * @throws APIServicesException if error occurred while invoking the subscribing REST API. + * @throws APIServicesException if error occurred while invoking the subscribing REST API. */ private void addSubscriptions( io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, @@ -323,7 +322,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscriptionList.add(subscription); }); - consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); + consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); } // /** @@ -557,7 +556,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe @Override public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType, - String validityPeriod, String username) throws APIManagerException { + String validityPeriod, String username) throws APIManagerException { try { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); ApiApplicationKey clientCredentials = getClientCredentials(tenantDomain, tags, applicationName, tokenType, @@ -605,17 +604,17 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe /** * Get Client credentials of application belongs to tenant admin * - * @param tenantDomain Tenant Domain - * @param tags Tags + * @param tenantDomain Tenant Domain + * @param tags Tags * @param applicationName Application Name - * @param tokenType Token Type - * @param validityPeriod Validity Period + * @param tokenType Token Type + * @param validityPeriod Validity Period * @return {@link ApiApplicationKey} * @throws APIManagerException if error occurred while generating access token - * @throws UserStoreException if error occurred while getting admin username. + * @throws UserStoreException if error occurred while getting admin username. */ private ApiApplicationKey getClientCredentials(String tenantDomain, String[] tags, String applicationName, - String tokenType, String validityPeriod) throws APIManagerException, UserStoreException { + String tokenType, String validityPeriod) throws APIManagerException, UserStoreException { APIRegistrationProfile registrationProfile = new APIRegistrationProfile(); registrationProfile.setAllowedToAllDomains(false); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index 52dc03b79c..78a95c019f 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.cache.LoginCache; import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthApp; import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthAppCacheKey; +import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.LoginException; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.text.StrSubstitutor; @@ -139,6 +140,8 @@ public class SsoLoginHandler extends HttpServlet { log.error("Error while creating the document builder."); } catch (SAXException e) { log.error("Error while parsing xml file.", e); + } catch (LoginException e) { + log.error("SSO Login is failed. Application: " + applicationName, e); } } @@ -149,7 +152,7 @@ public class SsoLoginHandler extends HttpServlet { * @param req {@link HttpServletRequest} * @param resp {@link HttpServletResponse} */ - private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) { + private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) throws LoginException { try { JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); @@ -166,10 +169,6 @@ public class SsoLoginHandler extends HttpServlet { ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); - if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { - HandlerUtil.handleError(resp, clientAppResponse); - } - if (clientAppResponse.getCode() == HttpStatus.SC_CREATED) { JsonParser jsonParser = new JsonParser(); JsonElement jClientAppResult = jsonParser.parse(clientAppResponse.getData()); @@ -188,71 +187,101 @@ public class SsoLoginHandler extends HttpServlet { // cache the oauth app credentials oAuthApp = new OAuthApp(applicationName, adminUsername, clientId, clientSecret, encodedClientApp); loginCache.addOAuthAppToCache(oAuthAppCacheKey, oAuthApp); + } else if (clientAppResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { + String msg = "Unauthorized attempt to register the client application. " + + "Application Name: " + applicationName + ". Response message: " + clientAppResponse.getData(); + log.error(msg); + HandlerUtil.handleError(resp, clientAppResponse); + throw new LoginException(msg); + } else { + String msg = "Failed the process while registering the client application. " + + "Application Name: " + applicationName + ". Response Code: " + + clientAppResponse.getCode() + ", Response message: " + clientAppResponse.getData(); + log.error(msg); + HandlerUtil.handleError(resp, null); + throw new LoginException(msg); } // Get the details of the registered application - String getApplicationEndpointUrl = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + - "?query=" + applicationName; - HttpGet getApplicationEndpoint = new HttpGet(getApplicationEndpointUrl); - getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + - getAccessToken(resp, encodedClientApp)); - - ProxyResponse getApplicationResponse = HandlerUtil.execute(getApplicationEndpoint); - - if (getApplicationResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { - HandlerUtil.handleError(resp, getApplicationResponse); - return; - } - - if (getApplicationResponse.getCode() == HttpStatus.SC_OK) { - JsonParser jsonParser = new JsonParser(); - JsonElement jAppResult = jsonParser.parse(getApplicationResponse.getData()); - if (jAppResult.isJsonObject()) { - JsonObject jClientAppResultAsJsonObject = jAppResult.getAsJsonObject(); - JsonArray appList = jClientAppResultAsJsonObject.getAsJsonArray("list"); - JsonObject app; - for (JsonElement appJson : appList) { - app = appJson.getAsJsonObject(); - if (app.get("name").getAsString().equals(applicationName)) { - applicationId = app.get("applicationId").getAsString(); - break; - } - } - } - } +// String getApplicationEndpointUrl = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + +// "?query=" + applicationName; +// HttpGet getApplicationEndpoint = new HttpGet(getApplicationEndpointUrl); +// getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + +// getAccessToken(resp, encodedClientApp)); +// +// ProxyResponse getApplicationResponse = HandlerUtil.execute(getApplicationEndpoint); +// +// if (getApplicationResponse.getCode() == HttpStatus.SC_OK) { +// JsonParser jsonParser = new JsonParser(); +// JsonElement jAppResult = jsonParser.parse(getApplicationResponse.getData()); +// if (jAppResult.isJsonObject()) { +// JsonObject jClientAppResultAsJsonObject = jAppResult.getAsJsonObject(); +// JsonArray appList = jClientAppResultAsJsonObject.getAsJsonArray("list"); +// JsonObject app; +// for (JsonElement appJson : appList) { +// app = appJson.getAsJsonObject(); +// if (app.get("name").getAsString().equals(applicationName)) { +// applicationId = app.get("applicationId").getAsString(); +// break; +// } +// } +// } +// } else if (getApplicationResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { +// String msg = "Unauthorized attempt to get registered application data. " + +// "Application Name: " + applicationName + ". Response message: " + clientAppResponse.getData(); +// log.error(msg); +// HandlerUtil.handleError(resp, getApplicationResponse); +// throw new LoginException(msg); +// } else { +// String msg = "Failed the process while getting the data of registered application. " + +// "Application Name: " + applicationName + ". Response Code: " +// + clientAppResponse.getCode() + ", Response message: " + clientAppResponse.getData(); +// log.error(msg); +// HandlerUtil.handleError(resp, null); +// throw new LoginException(msg); +// } // Update the grant types of the application - String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + "/" + applicationId + "/keys/" + - HandlerConstants.PRODUCTION_KEY; - HttpPut updateApplicationGrantTypesEndpoint = new HttpPut(url); - updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + - getAccessToken(resp, encodedClientApp)); - updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - updateApplicationGrantTypesEndpoint.setEntity(constructAppGrantTypeUpdatePayload()); - - ProxyResponse updateApplicationGrantTypesEndpointResponse = HandlerUtil.execute(updateApplicationGrantTypesEndpoint); - - // Update app as a SaaS app - this.updateSaasApp(applicationId); - - if (updateApplicationGrantTypesEndpointResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { - HandlerUtil.handleError(resp, updateApplicationGrantTypesEndpointResponse); - return; - } - - if (updateApplicationGrantTypesEndpointResponse.getCode() == HttpStatus.SC_OK) { - return; - } - HandlerUtil.handleError(resp, null); +// String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + "/" + applicationId + "/keys/" + +// HandlerConstants.PRODUCTION_KEY; +// HttpPut updateApplicationGrantTypesEndpoint = new HttpPut(url); +// updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + +// getAccessToken(resp, encodedClientApp)); +// updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); +// updateApplicationGrantTypesEndpoint.setEntity(constructAppGrantTypeUpdatePayload()); +// +// ProxyResponse updateApplicationGrantTypesEndpointResponse = HandlerUtil.execute(updateApplicationGrantTypesEndpoint); +// +// // Update app as a SaaS app +// this.updateSaasApp(applicationId); +// +// if (updateApplicationGrantTypesEndpointResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { +// String msg = "Unauthorized attempt to update the grant types of the application. " + +// "Application ID: " + applicationId + ". Response message: " +// + updateApplicationGrantTypesEndpointResponse.getData(); +// log.error(msg); +// HandlerUtil.handleError(resp, updateApplicationGrantTypesEndpointResponse); +// throw new LoginException(msg); +// } else if (updateApplicationGrantTypesEndpointResponse.getCode() != HttpStatus.SC_OK) { +// String msg = "Failed the process while updating the grant types of the application. " + +// "Application ID: " + applicationId + ". Response Code: " +// + updateApplicationGrantTypesEndpointResponse.getCode() + ", Response message: " +// + updateApplicationGrantTypesEndpointResponse.getData(); +// log.error(msg); +// HandlerUtil.handleError(resp, null); +// throw new LoginException(msg); +// } } catch (IOException e) { - log.error("Error occurred while sending the response into the socket. ", e); + throw new LoginException("Error occurred while sending the response into the socket.", e); } catch (JsonSyntaxException e) { - log.error("Error occurred while parsing the response. ", e); - } catch (ParserConfigurationException e) { - log.error("Error while creating the document builder."); - } catch (SAXException e) { - log.error("Error while parsing xml file.", e); + throw new LoginException("Error occurred while parsing the response.", e); } +// catch (ParserConfigurationException e) { +// throw new LoginException("Error while creating the document builder.", e); +// } +// catch (SAXException e) { +// throw new LoginException("Error while parsing xml file.", e); +// } } /** diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index c0f6c7f6ee..ac423d215c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -73,7 +73,7 @@ public class UserHandler extends HttpServlet { } String accessToken = authData.getAccessToken(); - String accessTokenWithoutPrefix = accessToken.substring(accessToken.indexOf("_") + 1); +// String accessTokenWithoutPrefix = accessToken.substring(accessToken.indexOf("_") + 1); HttpPost tokenEndpoint = new HttpPost(keymanagerUrl + HandlerConstants.INTROSPECT_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); @@ -82,7 +82,7 @@ public class UserHandler extends HttpServlet { String adminPassword = dmc.getKeyManagerConfigurations().getAdminPassword(); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() .encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes())); - StringEntity tokenEPPayload = new StringEntity("token=" + accessTokenWithoutPrefix, + StringEntity tokenEPPayload = new StringEntity("token=" + accessToken, ContentType.APPLICATION_FORM_URLENCODED); tokenEndpoint.setEntity(tokenEPPayload); ProxyResponse tokenStatus = HandlerUtil.execute(tokenEndpoint); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java index f973ae7dae..9678bff1eb 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/OAuthAuthenticator.java @@ -74,7 +74,7 @@ public class OAuthAuthenticator implements WebappAuthenticator { } try { String bearerToken = getBearerToken(request); - bearerToken = bearerToken.substring(bearerToken.indexOf("_")+1); +// bearerToken = bearerToken.substring(bearerToken.indexOf("_")+1); String resource = requestUri + ":" + requestMethod; OAuthValidationResponse oAuthValidationResponse = this.tokenValidator.validateToken(bearerToken, resource); authenticationInfo = Utils.setAuthenticationInfo(oAuthValidationResponse, authenticationInfo); From 907d4b03161f2421bab546494240fab3dd5ce351 Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 13 Sep 2023 12:20:37 +0530 Subject: [PATCH 133/343] Implement method for updateGrantType rest call --- .../rest/api/ConsumerRESTAPIServices.java | 4 ++ .../rest/api/ConsumerRESTAPIServicesImpl.java | 69 +++++++++++++++++++ 2 files changed, 73 insertions(+) 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index 8ab2c1f0ad..957fcfdaa7 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -61,6 +61,10 @@ public interface ConsumerRESTAPIServices { ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; + ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, + String supportedGrantTypes, String callbackUrl) + throws APIServicesException, BadRequestException, UnexpectedResponseException; + KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index 572756dff7..55f3c7003f 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -727,6 +727,75 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } + @Override + public ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, + String supportedGrantTypes, String callbackUrl) + throws APIServicesException, BadRequestException, UnexpectedResponseException { + + ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); + boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); + String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; + + Request.Builder builder = new Request.Builder(); + builder.url(getKeyDetails); + if (!token) { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + } else { + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + tokenInfo.getAccessToken()); + } + + String payload = "{\n" + + " \"keyMappingId\": \"" + keyMapId + "\",\n" + + " \"keyManager\": \"" + keyManager + "\",\n" + + " \"supportedGrantTypes\": [\n" + + " \"" + supportedGrantTypes + "\"\n" + + " ],\n" + + " \"callbackUrl\": \"" + callbackUrl + "\",\n" + + " \"additionalProperties\": {}\n" + + "}"; + RequestBody requestBody = RequestBody.create(JSON, payload); + + builder.put(requestBody); + Request request = builder.build(); + + try { + Response response = client.newCall(request).execute(); + if (HttpStatus.SC_OK == response.code()) { + return gson.fromJson(response.body().string(), ApplicationKey.class); + } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { + if (!token) { + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + //TODO: max attempt count + TokenInfo refreshedTokenInfo = new TokenInfo(); + refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); + refreshedTokenInfo.setAccessToken(null); + return updateGrantType(refreshedTokenInfo, applicationId, keyMapId, keyManager, supportedGrantTypes, callbackUrl); + } else { + String msg = "Invalid access token. Unauthorized request"; + log.error(msg); + throw new APIServicesException(msg); + } + } 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(msg, e); + } + } + @Override public KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { From 5848d68c63abe5bae39fd8f313c4f978da5278fa Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 14 Sep 2023 11:23:29 +0530 Subject: [PATCH 134/343] Add app updating intial changes --- .../APIManagementProviderServiceImpl.java | 29 ++++++++++++++----- .../ApplicationGrantTypeUpdater.java | 26 +++++++++++++++++ .../extension/exception/KeyMgtException.java | 4 +++ .../extension/service/KeyMgtServiceImpl.java | 12 ++++---- 4 files changed, 58 insertions(+), 13 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/bean/APIMConsumer/ApplicationGrantTypeUpdater.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index f4bd1cb588..3cf328e6b1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -24,7 +24,7 @@ import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplication import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; import io.entgra.device.mgt.core.apimgt.application.extension.util.APIManagerUtil; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; @@ -36,9 +36,6 @@ import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClie import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; @@ -229,7 +226,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe private ApiApplicationKey handleNewAPIApplication(String applicationName, List uniqueApiList, - TokenInfo tokenInfo, String keyType, String validityTime) throws APIManagerException { + TokenInfo tokenInfo, String keyType, String validityTime, + ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + boolean isMappingRequired) throws APIManagerException { ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); @@ -252,10 +251,26 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } tokenInfo.setApiApplicationInfo(getApplicationInfo(null, null)); + ApplicationKey applicationKey; + if (isMappingRequired) { + + } + + if (isMappingRequired) { + // If we need to get opaque token instead of the JWT token, we have to do the mapping. Therefore,, if + // it is a requirement then we have to call the method with enabling the flag. + applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, + keyManager.getName(), keyType); + } else { + applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), + keyManager.getName(), validityTime, keyType); + } + + // ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, // keyManager.getName(), keyType); - ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), - keyManager.getName(), validityTime, keyType); +// ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), +// keyManager.getName(), validityTime, keyType); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); 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/bean/APIMConsumer/ApplicationGrantTypeUpdater.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/APIMConsumer/ApplicationGrantTypeUpdater.java new file mode 100644 index 0000000000..b7d5e2e8b9 --- /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/bean/APIMConsumer/ApplicationGrantTypeUpdater.java @@ -0,0 +1,26 @@ +package io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer; + +import java.util.ArrayList; + +public class ApplicationGrantTypeUpdater { + + private String callbackUrl; + + private ArrayList supportedGrantTypes; + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public ArrayList getSupportedGrantTypes() { + return supportedGrantTypes; + } + + public void setSupportedGrantTypes(ArrayList supportedGrantTypes) { + this.supportedGrantTypes = supportedGrantTypes; + } +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/exception/KeyMgtException.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/exception/KeyMgtException.java index 5aa4d6e6aa..0faf78683c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/exception/KeyMgtException.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/exception/KeyMgtException.java @@ -28,5 +28,9 @@ public class KeyMgtException extends Exception { public KeyMgtException(String errorMessage) { super(errorMessage); } + + public KeyMgtException(String errorMessage, Exception e) { + super(errorMessage, e); + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 63e42132f0..11e472809a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -86,8 +86,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { .getTenantManager().getTenantId(tenantDomain); } catch (UserStoreException e) { msg = "Error while loading tenant configuration"; - log.error(msg); - throw new KeyMgtException(msg); + log.error(msg, e); + throw new KeyMgtException(msg, e); } kmConfig = getKeyManagerConfig(); @@ -116,8 +116,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { .getRealmProperty("reserved_tenant_user_password"); } catch (UserStoreException e) { msg = "Error while loading user realm configuration"; - log.error(msg); - throw new KeyMgtException(msg); + log.error(msg, e); + throw new KeyMgtException(msg, e); } createUserIfNotExists(subTenantUserUsername, subTenantUserPassword); @@ -415,8 +415,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { client.newCall(request).execute(); } catch (IOException e) { msg = "Error occurred while invoking create key manager endpoint"; - log.error(msg); - throw new KeyMgtException(msg); + log.error(msg, e); + throw new KeyMgtException(msg, e); } } From bb879f52cefd6ec4d62de9b11ed4739052a5b659 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 14 Sep 2023 13:30:36 +0530 Subject: [PATCH 135/343] Fix grant type update method --- .../rest/api/ConsumerRESTAPIServices.java | 2 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 12 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index 957fcfdaa7..e8342b18d5 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -62,7 +62,7 @@ public interface ConsumerRESTAPIServices { throws APIServicesException, BadRequestException, UnexpectedResponseException; ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, - String supportedGrantTypes, String callbackUrl) + List supportedGrantTypes, String callbackUrl) throws APIServicesException, BadRequestException, UnexpectedResponseException; KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index 55f3c7003f..e5608d5cbc 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -729,7 +729,7 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { @Override public ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, - String supportedGrantTypes, String callbackUrl) + List supportedGrantTypes, String callbackUrl) throws APIServicesException, BadRequestException, UnexpectedResponseException { ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); @@ -746,16 +746,19 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + tokenInfo.getAccessToken()); } - String payload = "{\n" + - " \"keyMappingId\": \"" + keyMapId + "\",\n" + - " \"keyManager\": \"" + keyManager + "\",\n" + - " \"supportedGrantTypes\": [\n" + - " \"" + supportedGrantTypes + "\"\n" + - " ],\n" + - " \"callbackUrl\": \"" + callbackUrl + "\",\n" + - " \"additionalProperties\": {}\n" + - "}"; - RequestBody requestBody = RequestBody.create(JSON, payload); + JSONArray supportedGrantTypeList = new JSONArray(); + for (String string : supportedGrantTypes) { + supportedGrantTypeList.put(string); + } + + JSONObject payload = new JSONObject(); + payload.put("keyMappingId", keyMapId); + payload.put("keyManager", keyManager); + payload.put("supportedGrantTypes", supportedGrantTypeList); + payload.put("callbackUrl", (callbackUrl != null ? callbackUrl : "")); + payload.put("additionalProperties", new JSONObject()); + + RequestBody requestBody = RequestBody.create(JSON, payload.toString()); builder.put(requestBody); Request request = builder.build(); From 088642e7ce9b9d3edd16d735b8743d97981a2bd4 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 19 Sep 2023 13:22:28 +0530 Subject: [PATCH 136/343] Improve API app registration --- ...ApiApplicationRegistrationServiceImpl.java | 21 ++++++- .../api/util/RegistrationProfile.java | 21 +++++++ .../APIManagementProviderService.java | 10 +++- .../APIManagementProviderServiceImpl.java | 56 +++++++++++++------ .../keymgt/extension/api/DCRRequest.java | 21 +++++++ .../extension/api/KeyManagerServiceImpl.java | 3 +- .../extension/service/KeyMgtService.java | 5 +- .../extension/service/KeyMgtServiceImpl.java | 23 +++++--- .../application/mgt/core/util/OAuthUtils.java | 2 +- .../impl/DeviceManagementServiceImpl.java | 5 +- 10 files changed, 133 insertions(+), 34 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index 133a5d1a9c..e3ce294a21 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -24,6 +24,7 @@ import io.entgra.device.mgt.core.apimgt.application.extension.api.util.Registrat import io.entgra.device.mgt.core.apimgt.application.extension.constants.ApiApplicationConstants; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -65,7 +66,7 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi applicationName, APIUtil.getDefaultTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false, ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword()); + .getRealmConfiguration().getAdminPassword(), null, false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } catch (APIManagerException e) { String msg = "Error occurred while registering an application '" + applicationName + "'"; @@ -108,10 +109,23 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { + ApplicationGrantTypeUpdater applicationGrantTypeUpdater = null; + if (registrationProfile.getSupportedGrantTypes() != null && !registrationProfile.getSupportedGrantTypes().isEmpty()) { + applicationGrantTypeUpdater = new ApplicationGrantTypeUpdater(); + applicationGrantTypeUpdater.setSupportedGrantTypes(registrationProfile.getSupportedGrantTypes()); + + } else if (StringUtils.isNotEmpty(registrationProfile.getCallbackUrl())) { + return Response.status(Response.Status.BAD_REQUEST).entity("Callback URL should be Empty when" + + " request does not contain supported grant types to update grant types of the " + + "application." + ).build(); + } + ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, - registrationProfile.isAllowedToAllDomains(), validityPeriod, registrationProfile.getPassword()); + registrationProfile.isAllowedToAllDomains(), validityPeriod, + registrationProfile.getPassword(), applicationGrantTypeUpdater, false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } @@ -123,7 +137,8 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, registrationProfile.getUsername(), - registrationProfile.isAllowedToAllDomains(), validityPeriod, registrationProfile.getPassword()); + registrationProfile.isAllowedToAllDomains(), validityPeriod, + registrationProfile.getPassword(), null, false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } catch (APIManagerException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/RegistrationProfile.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/RegistrationProfile.java index 3e3eb30a03..921b27f434 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/RegistrationProfile.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/RegistrationProfile.java @@ -22,6 +22,7 @@ import org.codehaus.jackson.annotate.JsonIgnoreProperties; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; /** * DTO class to be used when registering an ApiM application. @@ -43,6 +44,10 @@ public class RegistrationProfile { @XmlElement(required = false) private String validityPeriod; + private String callbackUrl; + + private ArrayList supportedGrantTypes; + public String getApplicationName() { return applicationName; } @@ -90,4 +95,20 @@ public class RegistrationProfile { public void setPassword(String password) { this.password = password; } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public ArrayList getSupportedGrantTypes() { + return supportedGrantTypes; + } + + public void setSupportedGrantTypes(ArrayList supportedGrantTypes) { + this.supportedGrantTypes = supportedGrantTypes; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index 14449cdf09..1b81b29ce3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -20,6 +20,8 @@ package io.entgra.device.mgt.core.apimgt.application.extension; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; /** @@ -53,12 +55,16 @@ public interface APIManagementProviderService { ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, - String validityTime, String password) throws APIManagerException; + String validityTime, String password, + ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + boolean isMappingRequired) throws APIManagerException; ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, boolean isAllowedAllDomains, - String validityTime, String accessToken) throws APIManagerException; + String validityTime, TokenInfo tokenInfo, + ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + boolean isMappingRequired) throws APIManagerException; // /** // * Remove APIM Application. diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 3cf328e6b1..6b5ecc63ca 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -24,7 +24,11 @@ import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplication import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; import io.entgra.device.mgt.core.apimgt.application.extension.util.APIManagerUtil; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; @@ -106,35 +110,42 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe // // } - @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, - boolean isAllowedAllDomains, - String validityTime, String accessToken) throws APIManagerException { - TokenInfo tokenInfo = new TokenInfo(); - tokenInfo.setApiApplicationInfo(null); - tokenInfo.setAccessToken(accessToken); - return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, tokenInfo); - } +// @Override +// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, +// String keyType, +// boolean isAllowedAllDomains, +// String validityTime, String accessToken) throws APIManagerException { +// TokenInfo tokenInfo = new TokenInfo(); +// tokenInfo.setApiApplicationInfo(null); +// tokenInfo.setAccessToken(accessToken); +// return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, +// tokenInfo, null, false); +// } @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, - String validityTime, String password) + String validityTime, String password, + ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + boolean isMappingRequired) throws APIManagerException { ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); TokenInfo tokenInfo = new TokenInfo(); tokenInfo.setApiApplicationInfo(applicationInfo); tokenInfo.setAccessToken(null); - return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, tokenInfo); + return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, + tokenInfo, applicationGrantTypeUpdater, isMappingRequired); } - private ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, + @Override + public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, boolean isAllowedAllDomains, - String validityTime, TokenInfo tokenInfo) throws APIManagerException { + String validityTime, TokenInfo tokenInfo, + ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + boolean isMappingRequired) throws APIManagerException { ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -160,7 +171,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); if (applications.length == 0) { return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, - validityTime); + validityTime, applicationGrantTypeUpdater, isMappingRequired); } else { if (applications.length == 1) { Optional applicationOpt = @@ -173,7 +184,8 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe if (metaData == null) { // Todo add a comment consumerRESTAPIServices.deleteApplication(tokenInfo, application.getApplicationId()); - return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime); + return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, + validityTime, applicationGrantTypeUpdater, isMappingRequired); } else { Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); for (Subscription subscription : subscriptions) { @@ -265,6 +277,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), keyManager.getName(), validityTime, keyType); } +// ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, +// String supportedGrantTypes, String callbackUrl) + if (applicationGrantTypeUpdater != null) { + applicationKey = consumerRESTAPIServices.updateGrantType(tokenInfo, application.getApplicationId(), + applicationKey.getKeyMappingId(), keyManager.getName(), + applicationGrantTypeUpdater.getSupportedGrantTypes(), + applicationGrantTypeUpdater.getCallbackUrl()); + } // ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, @@ -651,7 +671,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe registrationProfile.getTags(), tokenType, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() .getRealmConfiguration().getAdminUserName(), registrationProfile.isAllowedToAllDomains(), validityPeriod, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword()); + .getRealmConfiguration().getAdminPassword(), null, false); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java index 8f492c2234..9235087a77 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/DCRRequest.java @@ -22,6 +22,7 @@ import org.codehaus.jackson.annotate.JsonIgnoreProperties; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; @XmlRootElement @@ -45,6 +46,10 @@ public class DCRRequest { @XmlElement private int validityPeriod; + private String callbackUrl; + + private ArrayList supportedGrantTypes; + public String getApplicationName() { return applicationName; } @@ -104,4 +109,20 @@ public class DCRRequest { public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } + + public String getCallbackUrl() { + return callbackUrl; + } + + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public ArrayList getSupportedGrantTypes() { + return supportedGrantTypes; + } + + public void setSupportedGrantTypes(ArrayList supportedGrantTypes) { + this.supportedGrantTypes = supportedGrantTypes; + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java index 8a5c49e4d6..54cb0e98e1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java @@ -49,7 +49,8 @@ public class KeyManagerServiceImpl implements KeyManagerService { //todo lasantha - can pass password from here - modify DCRRequest object DCRResponse resp = keyMgtService.dynamicClientRegistration(dcrRequest.getApplicationName(), dcrRequest.getUsername(), dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), - dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod(), dcrRequest.getPassword()); + dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod(), dcrRequest.getPassword(), + dcrRequest.getSupportedGrantTypes(), dcrRequest.getCallbackUrl()); return Response.status(Response.Status.CREATED).entity(gson.toJson(resp)).build(); } catch (KeyMgtException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java index 92015842ba..b1ecb3c77b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtService.java @@ -24,6 +24,8 @@ import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.BadRequestException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.exception.KeyMgtException; +import java.util.List; + public interface KeyMgtService { /*** @@ -40,7 +42,8 @@ public interface KeyMgtService { * @throws KeyMgtException if any error occurs during DCR process */ DCRResponse dynamicClientRegistration(String clientName, String owner, String grantTypes, String callBackUrl, - String[] tags, boolean isSaasApp, int validityPeriod, String password) throws KeyMgtException; + String[] tags, boolean isSaasApp, int validityPeriod, String password, + List supportedGrantTypes, String callbackUrl) throws KeyMgtException; /*** * This method will handle the access token requests diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 11e472809a..f1d3c73641 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -65,7 +65,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { String subTenantUserUsername, subTenantUserPassword, keyManagerName, msg = null; public DCRResponse dynamicClientRegistration(String clientName, String owner, String grantTypes, String callBackUrl, - String[] tags, boolean isSaasApp, int validityPeriod, String password) throws KeyMgtException { + String[] tags, boolean isSaasApp, int validityPeriod, + String password, List supportedGrantTypes, String callbackUrl) throws KeyMgtException { if (owner == null) { PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -94,13 +95,14 @@ public class KeyMgtServiceImpl implements KeyMgtService { if (KeyMgtConstants.SUPER_TENANT.equals(tenantDomain)) { OAuthApplication dcrApplication = createOauthApplication(clientName, kmConfig.getAdminUsername(), tags, - validityPeriod, kmConfig.getAdminPassword()); + validityPeriod, kmConfig.getAdminPassword(), supportedGrantTypes, callbackUrl); return new DCRResponse(dcrApplication.getClientId(), dcrApplication.getClientSecret()); } else { // super-tenant admin dcr and token generation + //todo lasantha null passed in last two params OAuthApplication superTenantOauthApp = createOauthApplication( KeyMgtConstants.RESERVED_OAUTH_APP_NAME_PREFIX + KeyMgtConstants.SUPER_TENANT, - kmConfig.getAdminUsername(), null, validityPeriod, kmConfig.getAdminPassword()); + kmConfig.getAdminUsername(), null, validityPeriod, kmConfig.getAdminPassword(), null, null); String superAdminAccessToken = createAccessToken(superTenantOauthApp); // create new key manager for the tenant, under super-tenant space @@ -123,7 +125,10 @@ public class KeyMgtServiceImpl implements KeyMgtService { // DCR for the requesting user //todo lasantha -> need to pass password of user - OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod, password); + //todo lasantha null passed in last two params + + OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod, + password, null, null); String requestingUserAccessToken = createAccessToken(dcrApplication); // get application id @@ -317,9 +322,11 @@ public class KeyMgtServiceImpl implements KeyMgtService { * @throws KeyMgtException if any error occurs while creating response object */ private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags, - int validityPeriod, String ownerPassword) throws KeyMgtException { + int validityPeriod, String ownerPassword, + List supportedGrantTypes, String callbackUrl) throws KeyMgtException { //todo modify this to pass the password as well - String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod, ownerPassword); + String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod, + ownerPassword, supportedGrantTypes, callbackUrl); RequestBody oauthAppCreationPayload = RequestBody.Companion.create(oauthAppCreationPayloadStr, JSON); kmConfig = getKeyManagerConfig(); String dcrEndpoint = kmConfig.getServerUrl() + KeyMgtConstants.DCR_ENDPOINT; @@ -462,13 +469,15 @@ public class KeyMgtServiceImpl implements KeyMgtService { } private String createOauthAppCreationPayload(String clientName, String owner, String[] tags, int validityPeriod, - String password) { + String password, List supportedGrantTypes, String callbackUrl) { JSONObject jsonObject = new JSONObject(); jsonObject.put("applicationName", clientName); jsonObject.put("username", owner); jsonObject.put("tags", tags); jsonObject.put("validityPeriod", validityPeriod); jsonObject.put("password", password); + jsonObject.put("supportedGrantTypes", supportedGrantTypes); + jsonObject.put("callbackUrl", callbackUrl); return jsonObject.toString(); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java index c5975cb500..35dced984a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java @@ -66,7 +66,7 @@ public class OAuthUtils { registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE, username, registrationProfile.isAllowedToAllDomains(), Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword()); + .getRealmConfiguration().getAdminPassword(), null, false); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 0f5a000d17..5905831436 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplic 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.dto.APIApplicationKey; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; @@ -827,9 +828,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { "perm:users:send-invitation"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); + TokenInfo tokenInfo = new TokenInfo(); + tokenInfo.setAccessToken(accessTokenInfo.getAccessToken()); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, new String[] {"device_management"}, "PRODUCTION", false, String.valueOf(validityTime), - accessTokenInfo.getAccessToken()); + tokenInfo, null, true); } catch (JWTClientException e) { String msg = "Error while generating an application tokens for Tenant Admin."; From 500fa0df982fcafe04290ef0f3bfd7e596b379f3 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 20 Sep 2023 09:30:16 +0530 Subject: [PATCH 137/343] Add improvements to app registering logic --- ...ApiApplicationRegistrationServiceImpl.java | 30 +++++----- .../APIManagementProviderService.java | 23 ++++--- .../APIManagementProviderServiceImpl.java | 60 +++++++++++-------- .../application/mgt/core/util/OAuthUtils.java | 2 +- .../impl/DeviceManagementServiceImpl.java | 8 +-- 5 files changed, 69 insertions(+), 54 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index e3ce294a21..8b2562d656 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -66,7 +66,7 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi applicationName, APIUtil.getDefaultTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, false, ApiApplicationConstants.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword(), null, false); + .getRealmConfiguration().getAdminPassword(), null, null, null, false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } catch (APIManagerException e) { String msg = "Error occurred while registering an application '" + applicationName + "'"; @@ -109,23 +109,24 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { - ApplicationGrantTypeUpdater applicationGrantTypeUpdater = null; - if (registrationProfile.getSupportedGrantTypes() != null && !registrationProfile.getSupportedGrantTypes().isEmpty()) { - applicationGrantTypeUpdater = new ApplicationGrantTypeUpdater(); - applicationGrantTypeUpdater.setSupportedGrantTypes(registrationProfile.getSupportedGrantTypes()); - - } else if (StringUtils.isNotEmpty(registrationProfile.getCallbackUrl())) { - return Response.status(Response.Status.BAD_REQUEST).entity("Callback URL should be Empty when" + - " request does not contain supported grant types to update grant types of the " + - "application." - ).build(); - } +// ApplicationGrantTypeUpdater applicationGrantTypeUpdater = null; +// if (registrationProfile.getSupportedGrantTypes() != null && !registrationProfile.getSupportedGrantTypes().isEmpty()) { +// applicationGrantTypeUpdater = new ApplicationGrantTypeUpdater(); +// applicationGrantTypeUpdater.setSupportedGrantTypes(registrationProfile.getSupportedGrantTypes()); +// +// } else if (StringUtils.isNotEmpty(registrationProfile.getCallbackUrl())) { +// return Response.status(Response.Status.BAD_REQUEST).entity("Callback URL should be Empty when" + +// " request does not contain supported grant types to update grant types of the " + +// "application." +// ).build(); +// } ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, registrationProfile.isAllowedToAllDomains(), validityPeriod, - registrationProfile.getPassword(), applicationGrantTypeUpdater, false); + registrationProfile.getPassword(), null, registrationProfile.getSupportedGrantTypes(), + registrationProfile.getCallbackUrl(), false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } @@ -138,7 +139,8 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, registrationProfile.getUsername(), registrationProfile.isAllowedToAllDomains(), validityPeriod, - registrationProfile.getPassword(), null, false); + registrationProfile.getPassword(), null, registrationProfile.getSupportedGrantTypes(), + registrationProfile.getCallbackUrl(), false); return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); } } catch (APIManagerException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index 1b81b29ce3..3aa1835f78 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -24,6 +24,8 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.App import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; +import java.util.ArrayList; + /** * This comprise on operation that is been done with api manager from CDMF. This service needs to be implemented in APIM. */ @@ -52,18 +54,21 @@ public interface APIManagementProviderService { // String keyType, String username, boolean isAllowedAllDomains, // String validityTime) throws APIManagerException; +// ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, +// String keyType, String username, +// boolean isAllowedAllDomains, +// String validityTime, String password, +// ArrayList supportedGrantTypes, +// String callbackUrl, +// boolean isMappingRequired) throws APIManagerException; + ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, - String validityTime, String password, - ApplicationGrantTypeUpdater applicationGrantTypeUpdater, - boolean isMappingRequired) throws APIManagerException; - - ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, - boolean isAllowedAllDomains, - String validityTime, TokenInfo tokenInfo, - ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + String validityTime, + String password, String accessToken, + ArrayList supportedGrantTypes, + String callbackUrl, boolean isMappingRequired) throws APIManagerException; // /** diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 6b5ecc63ca..6d0d4b4f1d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -120,32 +120,44 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe // tokenInfo.setAccessToken(accessToken); // return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, // tokenInfo, null, false); +// } + +// @Override +// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, +// String keyType, String username, +// boolean isAllowedAllDomains, +// String validityTime, String password, +// ArrayList supportedGrantTypes, +// String callbackUrl, +// boolean isMappingRequired) +// throws APIManagerException { +// +// ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); +// TokenInfo tokenInfo = new TokenInfo(); +// tokenInfo.setApiApplicationInfo(applicationInfo); +// tokenInfo.setAccessToken(null); +// return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, +// tokenInfo, supportedGrantTypes, callbackUrl, isMappingRequired); // } @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, - String validityTime, String password, - ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + String validityTime, + String password, String accessToken, + ArrayList supportedGrantTypes, + String callbackUrl, boolean isMappingRequired) throws APIManagerException { - ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); TokenInfo tokenInfo = new TokenInfo(); - tokenInfo.setApiApplicationInfo(applicationInfo); - tokenInfo.setAccessToken(null); - return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, - tokenInfo, applicationGrantTypeUpdater, isMappingRequired); - } - - @Override - public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, - String keyType, - boolean isAllowedAllDomains, - String validityTime, TokenInfo tokenInfo, - ApplicationGrantTypeUpdater applicationGrantTypeUpdater, - boolean isMappingRequired) throws APIManagerException { + if (StringUtils.isEmpty(accessToken)) { + ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); + tokenInfo.setApiApplicationInfo(applicationInfo); + } else { + tokenInfo.setAccessToken(accessToken); + } ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -171,7 +183,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); if (applications.length == 0) { return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, - validityTime, applicationGrantTypeUpdater, isMappingRequired); + validityTime, supportedGrantTypes, callbackUrl, isMappingRequired); } else { if (applications.length == 1) { Optional applicationOpt = @@ -185,7 +197,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe // Todo add a comment consumerRESTAPIServices.deleteApplication(tokenInfo, application.getApplicationId()); return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, - validityTime, applicationGrantTypeUpdater, isMappingRequired); + validityTime, supportedGrantTypes, callbackUrl, isMappingRequired); } else { Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); for (Subscription subscription : subscriptions) { @@ -239,7 +251,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe private ApiApplicationKey handleNewAPIApplication(String applicationName, List uniqueApiList, TokenInfo tokenInfo, String keyType, String validityTime, - ApplicationGrantTypeUpdater applicationGrantTypeUpdater, + ArrayList supportedGrantTypes, String callbackUrl, boolean isMappingRequired) throws APIManagerException { ConsumerRESTAPIServices consumerRESTAPIServices = APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices(); @@ -264,9 +276,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe tokenInfo.setApiApplicationInfo(getApplicationInfo(null, null)); ApplicationKey applicationKey; - if (isMappingRequired) { - } if (isMappingRequired) { // If we need to get opaque token instead of the JWT token, we have to do the mapping. Therefore,, if @@ -279,11 +289,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } // ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, // String supportedGrantTypes, String callbackUrl) - if (applicationGrantTypeUpdater != null) { + if (supportedGrantTypes != null || StringUtils.isNotEmpty(callbackUrl)) { applicationKey = consumerRESTAPIServices.updateGrantType(tokenInfo, application.getApplicationId(), - applicationKey.getKeyMappingId(), keyManager.getName(), - applicationGrantTypeUpdater.getSupportedGrantTypes(), - applicationGrantTypeUpdater.getCallbackUrl()); + applicationKey.getKeyMappingId(), keyManager.getName(), supportedGrantTypes, callbackUrl); } @@ -671,7 +679,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe registrationProfile.getTags(), tokenType, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() .getRealmConfiguration().getAdminUserName(), registrationProfile.isAllowedToAllDomains(), validityPeriod, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword(), null, false); + .getRealmConfiguration().getAdminPassword(), null, null, null, false); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java index 35dced984a..96e4c40fd1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/OAuthUtils.java @@ -66,7 +66,7 @@ public class OAuthUtils { registrationProfile.getTags(), Constants.ApplicationInstall.DEFAULT_TOKEN_TYPE, username, registrationProfile.isAllowedToAllDomains(), Constants.ApplicationInstall.DEFAULT_VALIDITY_PERIOD, PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm() - .getRealmConfiguration().getAdminPassword(), null, false); + .getRealmConfiguration().getAdminPassword(), null, null, null, false); } finally { PrivilegedCarbonContext.endTenantFlow(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 5905831436..f7f46b7df1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -828,11 +828,11 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { "perm:users:send-invitation"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); - TokenInfo tokenInfo = new TokenInfo(); - tokenInfo.setAccessToken(accessTokenInfo.getAccessToken()); +// TokenInfo tokenInfo = new TokenInfo(); +// tokenInfo.setAccessToken(accessTokenInfo.getAccessToken()); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, - new String[] {"device_management"}, "PRODUCTION", false, String.valueOf(validityTime), - tokenInfo, null, true); + new String[] {"device_management"}, "PRODUCTION", null, false, String.valueOf(validityTime), + null, accessTokenInfo.getAccessToken(), null, null,true); } catch (JWTClientException e) { String msg = "Error while generating an application tokens for Tenant Admin."; From ac0ba0070789cef72c53d2f240551b0715b02f23 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 20 Sep 2023 09:37:58 +0530 Subject: [PATCH 138/343] Remove unnecessary sources --- ...ApiApplicationRegistrationServiceImpl.java | 13 - .../APIManagementProviderService.java | 32 -- .../APIManagementProviderServiceImpl.java | 306 +----------------- 3 files changed, 7 insertions(+), 344 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index 8b2562d656..2dd6e523f0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -24,7 +24,6 @@ import io.entgra.device.mgt.core.apimgt.application.extension.api.util.Registrat import io.entgra.device.mgt.core.apimgt.application.extension.constants.ApiApplicationConstants; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -109,18 +108,6 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi if (username.equals(registrationProfile.getUsername())) { synchronized (ApiApplicationRegistrationServiceImpl.class) { -// ApplicationGrantTypeUpdater applicationGrantTypeUpdater = null; -// if (registrationProfile.getSupportedGrantTypes() != null && !registrationProfile.getSupportedGrantTypes().isEmpty()) { -// applicationGrantTypeUpdater = new ApplicationGrantTypeUpdater(); -// applicationGrantTypeUpdater.setSupportedGrantTypes(registrationProfile.getSupportedGrantTypes()); -// -// } else if (StringUtils.isNotEmpty(registrationProfile.getCallbackUrl())) { -// return Response.status(Response.Status.BAD_REQUEST).entity("Callback URL should be Empty when" + -// " request does not contain supported grant types to update grant types of the " + -// "application." -// ).build(); -// } - ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( applicationName, registrationProfile.getTags(), ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java index 3aa1835f78..589923a920 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderService.java @@ -20,8 +20,6 @@ package io.entgra.device.mgt.core.apimgt.application.extension; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; import java.util.ArrayList; @@ -37,31 +35,6 @@ public interface APIManagementProviderService { */ boolean isTierLoaded(); -// /** -// * Generate and retreive application keys. if the application does exist then -// * create it and subscribe to apis that are grouped with the tags. -// * -// * @param apiApplicationName name of the application. -// * @param tags tags of the apis that application needs to be subscribed. -// * @param keyType of the application. -// * @param username to whom the application is created -// * @param isAllowedAllDomains application is allowed to all the tenants -// * @param validityTime validity period of the application -// * @return consumerkey and secrete of the created application. -// * @throws APIManagerException -// */ -// ApiApplicationKey generateAndRetrieveApplicationKeys(String apiApplicationName, String tags[], -// String keyType, String username, boolean isAllowedAllDomains, -// String validityTime) throws APIManagerException; - -// ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, -// String keyType, String username, -// boolean isAllowedAllDomains, -// String validityTime, String password, -// ArrayList supportedGrantTypes, -// String callbackUrl, -// boolean isMappingRequired) throws APIManagerException; - ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, boolean isAllowedAllDomains, @@ -71,11 +44,6 @@ public interface APIManagementProviderService { String callbackUrl, boolean isMappingRequired) throws APIManagerException; -// /** -// * Remove APIM Application. -// */ -// void removeAPIApplication(String applicationName, String username) throws APIManagerException; - /** * To get access token for given scopes and for the given validity period * @param scopes Scopes diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 6d0d4b4f1d..0f0791170b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -19,13 +19,10 @@ package io.entgra.device.mgt.core.apimgt.application.extension; import io.entgra.device.mgt.core.apimgt.application.extension.bean.APIRegistrationProfile; -import io.entgra.device.mgt.core.apimgt.application.extension.constants.ApiApplicationConstants; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplicationManagerExtensionDataHolder; -import io.entgra.device.mgt.core.apimgt.application.extension.util.APIManagerUtil; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.APIInfo; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationGrantTypeUpdater; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; @@ -48,16 +45,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.Unexpected import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.api.APIAdmin; -import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.dto.KeyManagerConfigurationDTO; -import org.wso2.carbon.apimgt.api.model.API; -import org.wso2.carbon.apimgt.api.model.APIKey; -import org.wso2.carbon.apimgt.api.model.ApiTypeWrapper; -import org.wso2.carbon.apimgt.api.model.SubscribedAPI; -import org.wso2.carbon.apimgt.api.model.Subscriber; -import org.wso2.carbon.apimgt.impl.APIAdminImpl; import org.wso2.carbon.apimgt.impl.APIConstants; import org.wso2.carbon.apimgt.impl.APIManagerFactory; import org.wso2.carbon.apimgt.impl.utils.APIUtil; @@ -65,8 +53,13 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; /** * This class represents an implementation of APIManagementProviderService. @@ -92,54 +85,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe return false; } -// @Override -// public void removeAPIApplication(String applicationName, String username) throws APIManagerException { -// -// try { -// APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); -// Application application = null; // todo:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -//// curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/am/devportal/v3/applications?query=CalculatorApp" -// if (application != null) { -// // todo:apim - apiConsumer.removeApplication(application, username); -// //curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X DELETE "https://localhost:9443/api/am/devportal/v3/applications/896658a0-b4ee-4535-bbfa-806c894a4015" -// } -// } catch (APIManagementException e) { -// throw new APIManagerException("Failed to remove api application : " + applicationName, e); -// } -// -// -// } - -// @Override -// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, -// String keyType, -// boolean isAllowedAllDomains, -// String validityTime, String accessToken) throws APIManagerException { -// TokenInfo tokenInfo = new TokenInfo(); -// tokenInfo.setApiApplicationInfo(null); -// tokenInfo.setAccessToken(accessToken); -// return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, -// tokenInfo, null, false); -// } - -// @Override -// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, -// String keyType, String username, -// boolean isAllowedAllDomains, -// String validityTime, String password, -// ArrayList supportedGrantTypes, -// String callbackUrl, -// boolean isMappingRequired) -// throws APIManagerException { -// -// ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); -// TokenInfo tokenInfo = new TokenInfo(); -// tokenInfo.setApiApplicationInfo(applicationInfo); -// tokenInfo.setAccessToken(null); -// return generateAndRetrieveApplicationKeys(applicationName, tags, keyType, isAllowedAllDomains, validityTime, -// tokenInfo, supportedGrantTypes, callbackUrl, isMappingRequired); -// } - @Override public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags, String keyType, String username, @@ -287,19 +232,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), keyManager.getName(), validityTime, keyType); } -// ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, -// String supportedGrantTypes, String callbackUrl) if (supportedGrantTypes != null || StringUtils.isNotEmpty(callbackUrl)) { applicationKey = consumerRESTAPIServices.updateGrantType(tokenInfo, application.getApplicationId(), applicationKey.getKeyMappingId(), keyManager.getName(), supportedGrantTypes, callbackUrl); } - -// ApplicationKey applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, -// keyManager.getName(), keyType); -// ApplicationKey applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), -// keyManager.getName(), validityTime, keyType); - ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -368,235 +305,6 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); } -// /** -// * {@inheritDoc} -// */ -// @Override -// public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], -// String keyType, String username, boolean isAllowedAllDomains, String validityTime) -// throws APIManagerException { -// -// -///* -// -//todo - Modify generateAndRetrieveApplicationKeys -// -//Check the existence of the API application. -// -//if Application is not exists -// Create the Application -// -//If super tenants -// Get set of tagged APIs -//If the tenant domain is not super tenant -// Get set of tagged APIs from super tenant space -// -//If new Application -// Subscribed to tagged APIs -//Else -// Get all subscribed APIs of application -// Filter out APIs and subscribed to APIs which can be subscribed -// Filter -> Use set of tagged APis -// Remove already subscribed APIs from the set -// Subscribed to remaining APIs -// -//Get Application keys from application -// If API keys are there return API keys -// -//Otherwise, Generate Application Keys and return them -// -// */ -// -// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); -// if (StringUtils.isEmpty(username)) { -// username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername() + "@" + tenantDomain; -// } -// try { -// APIConsumer apiConsumer = API_MANAGER_FACTORY.getAPIConsumer(username); -// Application application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -// int applicationId = 0; -// Subscriber subscriber = null; -// if (application == null) { -// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); -// if (subscriber == null) { -// // create subscriber -// // todo:resolve:apim - apiConsumer.addSubscriber(username, ""); -// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); -// } -// //create application -// application = new Application(applicationName, subscriber); -// application.setTier(ApiApplicationConstants.DEFAULT_TIER); -// application.setGroupId(""); -// application.setTokenType("OAUTH"); -// // todo:resolve:apim - apiConsumer.addApplication(application, username); -// application = null; // todo:resolve:apim - apiConsumer.getApplicationsByName(username, applicationName, ""); -// } else { -// subscriber = null; // todo:resolve:apim - apiConsumer.getSubscriber(username); -// } -// -// Set subscribedAPIs = -// null; // todo:resolve:apim - apiConsumer.getSubscribedAPIs(subscriber, applicationName, ""); -// -// log.info("Already subscribed API count: " + subscribedAPIs.size()); -// -// // subscribe to apis. -// APIConsumer apiConsumerAPIPublishedTenant = apiConsumer; -// if (tags != null && tags.length > 0) { -// for (String tag : tags) { -// boolean startedTenantFlow = false; -// Set apisWithTag = null; // todo:resolve:apim - apiConsumer.getAPIsWithTag(tag, tenantDomain); -// -// /** -// * From APIM 4.0.0, APIs published in the super tenant can only be listed by -// * APIConsumer, only if the APIConsumer belongs to the super tenant. So we -// * are starting tenant flow if we are not already in super tenant(child -// * tenant starting to create OAuth app). -// */ -// if (apisWithTag == null || apisWithTag.size() == 0) { -// PrivilegedCarbonContext.startTenantFlow(); -// PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, -// true); -// -// try { -// String superAdminUsername = PrivilegedCarbonContext -// .getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName(); -// apiConsumerAPIPublishedTenant = API_MANAGER_FACTORY.getAPIConsumer(superAdminUsername); -// } catch (UserStoreException e) { -// throw new APIManagerException("Failed to create api application for " + -// "tenant: " + tenantDomain + -// ". Caused by to inability to get super tenant username", e); -// } -// -// apisWithTag = null; // todo:resolve:apim - apiConsumerAPIPublishedTenant.getAPIsWithTag(tag, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); -// startedTenantFlow = true; -// } -// -// Set apiTypeWrapperList = new HashSet<>(); -// if (apisWithTag != null && apisWithTag.size() > 0) { -// Set tempApiIds = new HashSet<>(); -// for (API apiInfo : apisWithTag) { -// String id = apiInfo.getId().getProviderName().replace("@", "-AT-") -// + "-" + apiInfo.getId().getName() + "-" + apiInfo.getId().getVersion(); -// boolean subscriptionExist = false; -// if (subscribedAPIs.size() > 0) { -// for (SubscribedAPI subscribedAPI : subscribedAPIs) { -// // todo:resolve:apim -//// if (String.valueOf(subscribedAPI.getApiId().toString()).equals(id)) { -//// subscriptionExist = true; -//// break; -//// } -// } -// } -// if (!subscriptionExist && !tempApiIds.contains(id)) { -// ApiTypeWrapper apiTypeWrapper; -// if (startedTenantFlow) { -// /** -// * This mean APIs were not found in the child tenant, so all -// * calls to get info about APIs need to be to super tenant. -// */ -// apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( -// apiInfo.getUuid(), MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); -// } else { -// /** -// * Ideally, in all usecases of IoT server, tenant domain here -// * will be carbon.super. This block is kept to make sure in -// * the future, if there are some APIs published to a specific -// * tenant only. -// */ -// apiTypeWrapper = apiConsumerAPIPublishedTenant.getAPIorAPIProductByUUID( -// apiInfo.getUuid(), tenantDomain); -// } -// apiTypeWrapper.setTier(ApiApplicationConstants.DEFAULT_TIER); -// apiTypeWrapperList.add(apiTypeWrapper); -// tempApiIds.add(id); -// } -// } -// if (startedTenantFlow) { -// PrivilegedCarbonContext.endTenantFlow(); -// } -// -// /** This is done in a redundant loop instead of doing in the same loop -// * that populates apiTypeWrapperList because in a tenanted scenario, -// * apiConsumerAPIPublishedTenant will belong to super tenant. So super -// * tenant flow need to end before starting subscription to avoid adding -// * subscriptions inside super tenant when we are trying to create an -// * Oauth app for a child tenant. -// */ -// for (ApiTypeWrapper apiTypeWrapper : apiTypeWrapperList) { -// // todo:resolve:apim - apiConsumer.addSubscription(apiTypeWrapper, username, application); -// } -// } -// } -// } -// //end of subscription -// -// List applicationKeys = application.getKeys(); -// if (applicationKeys != null) { -// for (APIKey applicationKey : applicationKeys) { -// if (keyType.equals(applicationKey.getType())) { -// if (applicationKey.getConsumerKey() != null && !applicationKey.getConsumerKey().isEmpty()) { -// ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); -// apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); -// apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); -// return apiApplicationKey; -// } -// } -// } -// } -// -// List allowedDomains = new ArrayList<>(); -// if (isAllowedAllDomains) { -// allowedDomains.add(ApiApplicationConstants.ALLOWED_DOMAINS); -// } else { -// allowedDomains.add(APIManagerUtil.getTenantDomain()); -// } -// -// APIAdmin apiAdmin = new APIAdminImpl(); -// String keyManagerId = null; -// try { -// List keyManagerConfigurations = null; // todo:resolve:apim - -// // apiAdmin.getKeyManagerConfigurationsByTenant(tenantDomain); -// if (keyManagerConfigurations != null) { -// for (KeyManagerConfigurationDTO keyManagerConfigurationDTO : keyManagerConfigurations) { -// keyManagerId = keyManagerConfigurationDTO.getUuid(); -// } -// } -// String applicationAccessTokenExpiryTime = "N/A"; -// if (!StringUtils.isEmpty(validityTime)) { -// applicationAccessTokenExpiryTime = validityTime; -// } -// String jsonString = "{\"grant_types\":\"refresh_token,access_token," + -// "urn:ietf:params:oauth:grant-type:saml2-bearer," + -// "password,client_credentials,iwa:ntlm,urn:ietf:params:oauth:grant-type:jwt-bearer\"," + -// "\"additionalProperties\":\"{\\\"application_access_token_expiry_time\\\":\\\"" + applicationAccessTokenExpiryTime + "\\\"," + -// "\\\"user_access_token_expiry_time\\\":\\\"N\\/A\\\"," + -// "\\\"refresh_token_expiry_time\\\":\\\"N\\/A\\\"," + -// "\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," + -// "\"username\":\"" + username + "\"}"; -// -// Map keyDetails = null; // todo:resolve:apim - apiConsumer -//// .requestApprovalForApplicationRegistration(username, applicationName, keyType, "", -//// allowedDomains.toArray(new String[allowedDomains.size()]), validityTime, "default", "", -//// jsonString, keyManagerId, tenantDomain); -// -// if (keyDetails != null) { -// ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); -// apiApplicationKey.setConsumerKey((String) keyDetails.get("consumerKey")); -// apiApplicationKey.setConsumerSecret((String) keyDetails.get("consumerSecret")); -// return apiApplicationKey; -// } -// throw new APIManagerException("Failed to generate keys for tenant: " + tenantDomain); -//// todo:resolve:apim - commected as it says never throw since we commented apim calls above -//// cnt rm -//// } catch (APIManagementException e) { -// } catch (Exception e) { -// throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); -// } -// } catch (APIManagementException e) { -// throw new APIManagerException("Failed to create api application for tenant: " + tenantDomain, e); -// } -// } - @Override public AccessTokenInfo getAccessToken(String scopes, String[] tags, String applicationName, String tokenType, String validityPeriod, String username) throws APIManagerException { From cc6bbf1435de1db1d20c5bc5cc2313bb52e58630 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 21 Sep 2023 01:56:53 +0530 Subject: [PATCH 139/343] Improvements in App registration --- .../APIManagementProviderServiceImpl.java | 66 +- .../rest/api/APIApplicationServices.java | 2 +- .../rest/api/APIApplicationServicesImpl.java | 2 +- .../rest/api/ConsumerRESTAPIServices.java | 30 +- .../rest/api/ConsumerRESTAPIServicesImpl.java | 586 ++++++------------ .../extension/rest/api/dto/TokenInfo.java | 44 -- .../extension/service/KeyMgtServiceImpl.java | 9 +- .../impl/DeviceManagementServiceImpl.java | 3 - 8 files changed, 246 insertions(+), 496 deletions(-) delete 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/dto/TokenInfo.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 0f0791170b..837a1b902c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -26,7 +26,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.API import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.ApplicationKey; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.KeyManager; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Subscription; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; @@ -96,12 +95,11 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe boolean isMappingRequired) throws APIManagerException { - TokenInfo tokenInfo = new TokenInfo(); + ApiApplicationInfo apiApplicationInfo = new ApiApplicationInfo(); if (StringUtils.isEmpty(accessToken)) { - ApiApplicationInfo applicationInfo = getApplicationInfo(username, password); - tokenInfo.setApiApplicationInfo(applicationInfo); + apiApplicationInfo = getApplicationInfo(username, password); } else { - tokenInfo.setAccessToken(accessToken); + apiApplicationInfo.setAccess_token(accessToken); } ConsumerRESTAPIServices consumerRESTAPIServices = @@ -118,16 +116,16 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Map queryParams = new HashMap<>(); queryParams.put("tag", tag); - APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(tokenInfo, queryParams, headerParams); + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(apiApplicationInfo, queryParams, headerParams); Arrays.stream(apiInfos).forEach(apiInfo -> uniqueApiSet.putIfAbsent(apiInfo.getName(), apiInfo)); } List uniqueApiList = new ArrayList<>(uniqueApiSet.values()); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); + consumerRESTAPIServices.getAllApplications(apiApplicationInfo, applicationName); if (applications.length == 0) { - return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, + return handleNewAPIApplication(applicationName, uniqueApiList, apiApplicationInfo, keyType, validityTime, supportedGrantTypes, callbackUrl, isMappingRequired); } else { if (applications.length == 1) { @@ -140,17 +138,17 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe Metadata metaData = metadataManagementService.retrieveMetadata(applicationName); if (metaData == null) { // Todo add a comment - consumerRESTAPIServices.deleteApplication(tokenInfo, application.getApplicationId()); - return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, + consumerRESTAPIServices.deleteApplication(apiApplicationInfo, application.getApplicationId()); + return handleNewAPIApplication(applicationName, uniqueApiList, apiApplicationInfo, keyType, validityTime, supportedGrantTypes, callbackUrl, isMappingRequired); } else { - Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(tokenInfo, application.getApplicationId()); + Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(apiApplicationInfo, application.getApplicationId()); for (Subscription subscription : subscriptions) { uniqueApiList.removeIf(apiInfo -> Objects.equals(apiInfo.getId(), subscription.getApiInfo().getId())); } if (!uniqueApiList.isEmpty()) { - addSubscriptions(application, uniqueApiList, tokenInfo); + addSubscriptions(application, uniqueApiList, apiApplicationInfo); } String[] metaValues = metaData.getMetaValue().split(":"); @@ -162,7 +160,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } String applicationId = metaValues[0]; String keyMappingId = metaValues[1]; - ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(tokenInfo, applicationId, keyMappingId); + ApplicationKey applicationKey = consumerRESTAPIServices.getKeyDetails(apiApplicationInfo, applicationId, keyMappingId); ApiApplicationKey apiApplicationKey = new ApiApplicationKey(); apiApplicationKey.setConsumerKey(applicationKey.getConsumerKey()); apiApplicationKey.setConsumerSecret(applicationKey.getConsumerSecret()); @@ -195,7 +193,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe private ApiApplicationKey handleNewAPIApplication(String applicationName, List uniqueApiList, - TokenInfo tokenInfo, String keyType, String validityTime, + ApiApplicationInfo apiApplicationInfo, String keyType, String validityTime, ArrayList supportedGrantTypes, String callbackUrl, boolean isMappingRequired) throws APIManagerException { ConsumerRESTAPIServices consumerRESTAPIServices = @@ -205,10 +203,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe application.setThrottlingPolicy(UNLIMITED_TIER); try { - application = consumerRESTAPIServices.createApplication(tokenInfo, application); - addSubscriptions(application, uniqueApiList, tokenInfo); + application = consumerRESTAPIServices.createApplication(apiApplicationInfo, application); + addSubscriptions(application, uniqueApiList, apiApplicationInfo); - KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(tokenInfo); + KeyManager[] keyManagers = consumerRESTAPIServices.getAllKeyManagers(apiApplicationInfo); KeyManager keyManager; if (keyManagers.length == 1) { keyManager = keyManagers[0]; @@ -219,21 +217,29 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe throw new APIManagerException(msg); } - tokenInfo.setApiApplicationInfo(getApplicationInfo(null, null)); ApplicationKey applicationKey; - if (isMappingRequired) { - // If we need to get opaque token instead of the JWT token, we have to do the mapping. Therefore,, if + // If we need to get opaque token instead of the JWT token, we have to do the mapping. Therefore, if // it is a requirement then we have to call the method with enabling the flag. - applicationKey = consumerRESTAPIServices.mapApplicationKeys(tokenInfo, application, - keyManager.getName(), keyType); + APIApplicationServices apiApplicationServices = APIApplicationManagerExtensionDataHolder.getInstance() + .getApiApplicationServices(); + + APIApplicationKey apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentials( + "ClientForMapping", + "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); + + apiApplicationInfo.setClientId(apiApplicationKey.getClientId()); + apiApplicationInfo.setClientSecret(apiApplicationKey.getClientSecret()); + + applicationKey = consumerRESTAPIServices.mapApplicationKeys(apiApplicationInfo, application, + keyManager.getName(), keyType); } else { - applicationKey = consumerRESTAPIServices.generateApplicationKeys(tokenInfo, application.getApplicationId(), + applicationKey = consumerRESTAPIServices.generateApplicationKeys(apiApplicationInfo, application.getApplicationId(), keyManager.getName(), validityTime, keyType); } if (supportedGrantTypes != null || StringUtils.isNotEmpty(callbackUrl)) { - applicationKey = consumerRESTAPIServices.updateGrantType(tokenInfo, application.getApplicationId(), + applicationKey = consumerRESTAPIServices.updateGrantType(apiApplicationInfo, application.getApplicationId(), applicationKey.getKeyMappingId(), keyManager.getName(), supportedGrantTypes, callbackUrl); } @@ -277,16 +283,16 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe /** * This method can be used to add a new subscriptions providing the ids of the APIs and the applications. * - * @param application {@link io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application} - * @param apiInfos {@link List} - * @param tokenInfo {@link TokenInfo} + * @param application {@link io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application} + * @param apiInfos {@link List} + * @param apiApplicationInfo {@link ApiApplicationInfo} * @throws BadRequestException if incorrect data provided to call subscribing REST API. * @throws UnexpectedResponseException if error occurred while processing the subscribing REST API. * @throws APIServicesException if error occurred while invoking the subscribing REST API. */ private void addSubscriptions( io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application, - List apiInfos, TokenInfo tokenInfo) + List apiInfos, ApiApplicationInfo apiApplicationInfo) throws BadRequestException, UnexpectedResponseException, APIServicesException { ConsumerRESTAPIServices consumerRESTAPIServices = @@ -302,7 +308,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe subscriptionList.add(subscription); }); - consumerRESTAPIServices.createSubscriptions(tokenInfo, subscriptionList); + consumerRESTAPIServices.createSubscriptions(apiApplicationInfo, subscriptionList); } @Override @@ -407,7 +413,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe "ClientForConsumerRestCalls", "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); } else { - apiApplicationKey = apiApplicationServices.generateAndRetrieveApplicationKeys( + apiApplicationKey = apiApplicationServices.createAndRetrieveApplicationCredentialsWithUser( "ClientForConsumerRestCalls", username, password, "client_credentials password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"); 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/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 index f5cc8b3ec1..7b14f48800 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/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 @@ -27,7 +27,7 @@ public interface APIApplicationServices { APIApplicationKey createAndRetrieveApplicationCredentials(String clientName, String grantType) throws APIServicesException; - APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) + APIApplicationKey createAndRetrieveApplicationCredentialsWithUser(String clientName, String username, String password, String grantType) throws APIServicesException; AccessTokenInfo generateAccessTokenFromRegisteredApplication(String clientId, String clientSecret) throws APIServicesException; 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 a03f81d086..68ea575e02 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 @@ -75,7 +75,7 @@ public class APIApplicationServicesImpl implements APIApplicationServices { } @Override - public APIApplicationKey generateAndRetrieveApplicationKeys(String clientName, String username, String password, String grantType) + public APIApplicationKey createAndRetrieveApplicationCredentialsWithUser(String clientName, String username, String password, String grantType) throws APIServicesException { String applicationEndpoint = config.getFirstProperty(Constants.DCR_END_POINT); 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java index e8342b18d5..2cb3cf692c 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/ConsumerRESTAPIServices.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/ConsumerRESTAPIServices.java @@ -19,7 +19,7 @@ package io.entgra.device.mgt.core.apimgt.extension.rest.api; import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; 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; @@ -28,43 +28,45 @@ import java.util.List; import java.util.Map; public interface ConsumerRESTAPIServices { - Application[] getAllApplications(TokenInfo tokenInfo, String appName) + + Application[] getAllApplications(ApiApplicationInfo apiApplicationInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application getDetailsOfAnApplication(TokenInfo tokenInfo, String applicationId) + Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Application createApplication(TokenInfo tokenInfo, Application application) + Application createApplication(ApiApplicationInfo apiApplicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Boolean deleteApplication(TokenInfo tokenInfo, String applicationId) + Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] getAllSubscriptions(TokenInfo tokenInfo, String applicationId) + Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - APIInfo[] getAllApis(TokenInfo tokenInfo, Map queryParams, Map headerParams) + APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription createSubscription(TokenInfo tokenInfo, Subscription subscriptions) + Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - Subscription[] createSubscriptions(TokenInfo tokenInfo, List subscriptions) + Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey generateApplicationKeys(TokenInfo tokenInfo, String applicationId, String keyManager, String validityTime, String keyType) + ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyManager, + String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey mapApplicationKeys(TokenInfo tokenInfo, Application application, String keyManager, String keyType) + ApplicationKey mapApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application, String keyManager, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) + ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException; - ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, + ApplicationKey updateGrantType(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId, String keyManager, List supportedGrantTypes, String callbackUrl) throws APIServicesException, BadRequestException, UnexpectedResponseException; - KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) + KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java index e5608d5cbc..998331cc0d 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/ConsumerRESTAPIServicesImpl.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/ConsumerRESTAPIServicesImpl.java @@ -23,7 +23,6 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.*; 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.dto.ApiApplicationInfo; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; 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; @@ -51,22 +50,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { + Constants.COLON + port; @Override - public Application[] getAllApplications(TokenInfo tokenInfo, String appName) + public Application[] getAllApplications(ApiApplicationInfo apiApplicationInfo, String appName) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllApplicationsUrl = endPointPrefix + Constants.APPLICATIONS_API + "?query=" + appName; Request.Builder builder = new Request.Builder(); builder.url(getAllApplicationsUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.get(); Request request = builder.build(); @@ -76,21 +68,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray applicationList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(applicationList.toString(), Application[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - tokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - tokenInfo.setAccessToken(null); - return getAllApplications(tokenInfo, appName); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getAllApplications(refreshedApiApplicationInfo, appName); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -107,22 +91,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application getDetailsOfAnApplication(TokenInfo tokenInfo, String applicationId) + public Application getDetailsOfAnApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getDetailsOfAPPUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); builder.url(getDetailsOfAPPUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.get(); Request request = builder.build(); @@ -131,22 +108,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return getDetailsOfAnApplication(refreshedTokenInfo, applicationId); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getDetailsOfAnApplication(refreshedApiApplicationInfo, applicationId); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -163,33 +131,38 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Application createApplication(TokenInfo tokenInfo, Application application) + public Application createApplication(ApiApplicationInfo apiApplicationInfo, Application application) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API; - String applicationInfo = "{\n" + - " \"name\": \"" + application.getName() + "\",\n" + - " \"throttlingPolicy\": \"" + application.getThrottlingPolicy() + "\",\n" + - " \"description\": \"" + application.getDescription() + "\",\n" + - " \"tokenType\": \"" + application.getTokenType() + "\",\n" + - " \"groups\": " + gson.toJson(application.getGroups()) + ",\n" + - " \"attributes\": " + gson.toJson(application.getAttributes()) + ",\n" + - " \"subscriptionScopes\": " + gson.toJson(application.getSubscriptionScopes()) + "\n" + - "}"; - RequestBody requestBody = RequestBody.create(JSON, applicationInfo); + JSONArray groups = new JSONArray(); + JSONArray subscriptionScope = new JSONArray(); + + if (application.getGroups() != null && application.getSubscriptionScopes() != null) { + for (String string : application.getGroups()) { + groups.put(string); + } + for (Scopes string : application.getSubscriptionScopes()) { + subscriptionScope.put(string); + } + } + + JSONObject applicationInfo = new JSONObject(); + applicationInfo.put("name", application.getName()); + applicationInfo.put("throttlingPolicy", application.getThrottlingPolicy()); + applicationInfo.put("description", application.getDescription()); + applicationInfo.put("tokenType", application.getTokenType()); + applicationInfo.put("groups", groups); + applicationInfo.put("attributes", new JSONObject()); + applicationInfo.put("subscriptionScopes", subscriptionScope); + + RequestBody requestBody = RequestBody.create(JSON, applicationInfo.toString()); Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.post(requestBody); Request request = builder.build(); @@ -198,22 +171,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Application.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return createApplication(refreshedTokenInfo, application); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return createApplication(refreshedApiApplicationInfo, application); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -230,22 +194,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Boolean deleteApplication(TokenInfo tokenInfo, String applicationId) + public Boolean deleteApplication(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String deleteScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId; Request.Builder builder = new Request.Builder(); builder.url(deleteScopesUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.delete(); Request request = builder.build(); @@ -254,22 +211,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return true; } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return deleteApplication(refreshedTokenInfo, applicationId); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return deleteApplication(refreshedApiApplicationInfo, applicationId); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -286,22 +234,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] getAllSubscriptions(TokenInfo tokenInfo, String applicationId) + public Subscription[] getAllSubscriptions(ApiApplicationInfo apiApplicationInfo, String applicationId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllScopesUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "?applicationId=" + applicationId + "&limit=1000"; Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.get(); Request request = builder.build(); @@ -311,22 +252,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray subscriptionList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(subscriptionList.toString(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return getAllSubscriptions(refreshedTokenInfo, applicationId); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getAllSubscriptions(refreshedApiApplicationInfo, applicationId); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -343,11 +275,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public APIInfo[] getAllApis(TokenInfo tokenInfo, Map queryParams, Map headerParams) + public APIInfo[] getAllApis(ApiApplicationInfo apiApplicationInfo, Map queryParams, Map headerParams) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); StringBuilder getAPIsURL = new StringBuilder(endPointPrefix + Constants.DEV_PORTAL_API); for (Map.Entry query : queryParams.entrySet()) { @@ -356,13 +286,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(getAPIsURL.toString()); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + for (Map.Entry header : headerParams.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); } @@ -375,22 +301,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray apiList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(apiList.toString(), APIInfo[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return getAllApis(refreshedTokenInfo, queryParams, headerParams); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getAllApis(refreshedApiApplicationInfo, queryParams, headerParams); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -407,31 +324,24 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription createSubscription(TokenInfo tokenInfo, Subscription subscriptions) + public Subscription createSubscription(ApiApplicationInfo apiApplicationInfo, Subscription subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String createSubscriptionUrl = endPointPrefix + Constants.SUBSCRIPTION_API; - String subscriptionObject = "{\n" + - " \"applicationId\": \"" + subscriptions.getApplicationId() + "\",\n" + - " \"apiId\": \"" + subscriptions.getApiId() + "\",\n" + - " \"throttlingPolicy\": \"" + subscriptions.getThrottlingPolicy() + "\",\n" + - " \"requestedThrottlingPolicy\": \"" + subscriptions.getRequestedThrottlingPolicy() + "\"\n" + - "}"; + JSONObject subscriptionObject = new JSONObject(); + subscriptionObject.put("applicationId", subscriptions.getApplicationId()); + subscriptionObject.put("apiId", subscriptions.getApiId()); + subscriptionObject.put("throttlingPolicy", subscriptions.getThrottlingPolicy()); + subscriptionObject.put("requestedThrottlingPolicy", subscriptions.getRequestedThrottlingPolicy()); - RequestBody requestBody = RequestBody.create(JSON, subscriptionObject); + RequestBody requestBody = RequestBody.create(JSON, subscriptionObject.toString()); Request.Builder builder = new Request.Builder(); builder.url(createSubscriptionUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + builder.post(requestBody); Request request = builder.build(); @@ -440,22 +350,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_CREATED == response.code()) { return gson.fromJson(response.body().string(), Subscription.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return createSubscription(refreshedTokenInfo, subscriptions); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return createSubscription(refreshedApiApplicationInfo, subscriptions); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -472,11 +373,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public Subscription[] createSubscriptions(TokenInfo tokenInfo, List subscriptions) + public Subscription[] createSubscriptions(ApiApplicationInfo apiApplicationInfo, List subscriptions) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String createSubscriptionsUrl = endPointPrefix + Constants.SUBSCRIPTION_API + "/multiple"; String subscriptionsList = gson.toJson(subscriptions); @@ -484,13 +383,9 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { Request.Builder builder = new Request.Builder(); builder.url(createSubscriptionsUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); + builder.post(requestBody); Request request = builder.build(); @@ -499,22 +394,12 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), Subscription[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return createSubscriptions(refreshedTokenInfo, subscriptions); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return createSubscriptions(refreshedApiApplicationInfo, subscriptions); } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -531,42 +416,36 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey generateApplicationKeys(TokenInfo tokenInfo, String applicationId, String keyManager, + public ApplicationKey generateApplicationKeys(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyManager, String validityTime, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String generateApplicationKeysUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/generate-keys"; - String keyInfo = "{\n" + - " \"keyType\": \"" + keyType + "\",\n" + - " \"keyManager\": \"" + keyManager + "\",\n" + - " \"grantTypesToBeSupported\": [\n" + - " \"password\",\n" + - " \"client_credentials\"\n" + - " ],\n" + - " \"callbackUrl\": \"\",\n" + - " \"scopes\": [\n" + - " \"am_application_scope\",\n" + - " \"default\"\n" + - " ],\n" + - " \"validityTime\": " + validityTime + ",\n" + - " \"additionalProperties\": {}\n" + - "}"; + JSONArray grantTypesToBeSupported = new JSONArray(); + grantTypesToBeSupported.put("password"); + grantTypesToBeSupported.put("client_credentials"); - RequestBody requestBody = RequestBody.create(JSON, keyInfo); + JSONArray scopes = new JSONArray(); + scopes.put("am_application_scope"); + scopes.put("default"); + + JSONObject keyInfo = new JSONObject(); + keyInfo.put("keyType", keyType); + keyInfo.put("keyManager", keyManager); + keyInfo.put("grantTypesToBeSupported", grantTypesToBeSupported); + keyInfo.put("callbackUrl", ""); + keyInfo.put("scopes", scopes); + keyInfo.put("validityTime", 3600); + keyInfo.put("additionalProperties", new JSONObject()); + + RequestBody requestBody = RequestBody.create(JSON, keyInfo.toString()); Request.Builder builder = new Request.Builder(); builder.url(generateApplicationKeysUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.post(requestBody); Request request = builder.build(); @@ -575,22 +454,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return generateApplicationKeys(refreshedTokenInfo, applicationId, keyManager, validityTime, keyType); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return generateApplicationKeys(refreshedApiApplicationInfo, applicationId, keyManager, validityTime, keyType); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -607,31 +477,24 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey mapApplicationKeys(TokenInfo tokenInfo, Application application, String keyManager, String keyType) + public ApplicationKey mapApplicationKeys(ApiApplicationInfo apiApplicationInfo, Application application, String keyManager, String keyType) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllScopesUrl = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + application.getApplicationId() + "/map-keys"; - String payload = "{\n" + - " \"consumerKey\": \"" + apiApplicationInfo.getClientId() + "\",\n" + - " \"consumerSecret\": \"" + apiApplicationInfo.getClientSecret() + "\",\n" + - " \"keyManager\": \"" + keyManager + "\",\n" + - " \"keyType\": \"" + keyType + "\"\n" + - "}"; - RequestBody requestBody = RequestBody.create(JSON, payload); + JSONObject payload = new JSONObject(); + payload.put("consumerKey", apiApplicationInfo.getClientId()); + payload.put("consumerSecret", apiApplicationInfo.getClientSecret()); + payload.put("keyManager", keyManager); + payload.put("keyType", keyType); + + RequestBody requestBody = RequestBody.create(JSON, payload.toString()); Request.Builder builder = new Request.Builder(); builder.url(getAllScopesUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.post(requestBody); Request request = builder.build(); @@ -640,22 +503,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return mapApplicationKeys(refreshedTokenInfo, application, keyManager, keyType); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return mapApplicationKeys(refreshedApiApplicationInfo, application, keyManager, keyType); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request body"; log.error(msg); @@ -672,22 +526,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey getKeyDetails(TokenInfo tokenInfo, String applicationId, String keyMapId) + public ApplicationKey getKeyDetails(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; Request.Builder builder = new Request.Builder(); builder.url(getKeyDetails); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.get(); Request request = builder.build(); @@ -696,22 +543,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return getKeyDetails(refreshedTokenInfo, applicationId, keyMapId); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getKeyDetails(refreshedApiApplicationInfo, applicationId, keyMapId); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -728,23 +566,16 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public ApplicationKey updateGrantType(TokenInfo tokenInfo, String applicationId, String keyMapId, String keyManager, + public ApplicationKey updateGrantType(ApiApplicationInfo apiApplicationInfo, String applicationId, String keyMapId, String keyManager, List supportedGrantTypes, String callbackUrl) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getKeyDetails = endPointPrefix + Constants.APPLICATIONS_API + Constants.SLASH + applicationId + "/oauth-keys/" + keyMapId; Request.Builder builder = new Request.Builder(); builder.url(getKeyDetails); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); JSONArray supportedGrantTypeList = new JSONArray(); for (String string : supportedGrantTypes) { @@ -768,22 +599,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { if (HttpStatus.SC_OK == response.code()) { return gson.fromJson(response.body().string(), ApplicationKey.class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return updateGrantType(refreshedTokenInfo, applicationId, keyMapId, keyManager, supportedGrantTypes, callbackUrl); - } else { - String msg = "Invalid access token. Unauthorized request"; - log.error(msg); - throw new APIServicesException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return updateGrantType(refreshedApiApplicationInfo, applicationId, keyMapId, keyManager, supportedGrantTypes, callbackUrl); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -800,22 +622,15 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } @Override - public KeyManager[] getAllKeyManagers(TokenInfo tokenInfo) + public KeyManager[] getAllKeyManagers(ApiApplicationInfo apiApplicationInfo) throws APIServicesException, BadRequestException, UnexpectedResponseException { - ApiApplicationInfo apiApplicationInfo = tokenInfo.getApiApplicationInfo(); - boolean token = isTokenNull(apiApplicationInfo, tokenInfo.getAccessToken()); String getAllKeyManagersUrl = endPointPrefix + Constants.KEY_MANAGERS_API; Request.Builder builder = new Request.Builder(); builder.url(getAllKeyManagersUrl); - if (!token) { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + apiApplicationInfo.getAccess_token()); - } else { - builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER - + tokenInfo.getAccessToken()); - } + builder.addHeader(Constants.AUTHORIZATION_HEADER_NAME, Constants.AUTHORIZATION_HEADER_PREFIX_BEARER + + apiApplicationInfo.getAccess_token()); builder.get(); Request request = builder.build(); @@ -825,22 +640,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { JSONArray keyManagerList = (JSONArray) new JSONObject(response.body().string()).get("list"); return gson.fromJson(keyManagerList.toString(), KeyManager[].class); } else if (HttpStatus.SC_UNAUTHORIZED == response.code()) { - if (!token) { - APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); - AccessTokenInfo refreshedAccessToken = apiApplicationServices. - generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), - apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); - ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); - //TODO: max attempt count - TokenInfo refreshedTokenInfo = new TokenInfo(); - refreshedTokenInfo.setApiApplicationInfo(refreshedApiApplicationInfo); - refreshedTokenInfo.setAccessToken(null); - return getAllKeyManagers(refreshedTokenInfo); - } else { - String msg = "Invalid or null access token"; - log.error(msg); - throw new BadRequestException(msg); - } + APIApplicationServices apiApplicationServices = new APIApplicationServicesImpl(); + AccessTokenInfo refreshedAccessToken = apiApplicationServices. + generateAccessTokenFromRefreshToken(apiApplicationInfo.getRefresh_token(), + apiApplicationInfo.getClientId(), apiApplicationInfo.getClientSecret()); + ApiApplicationInfo refreshedApiApplicationInfo = returnApplicationInfo(apiApplicationInfo, refreshedAccessToken); + return getAllKeyManagers(refreshedApiApplicationInfo); + //TODO: max attempt count } else if (HttpStatus.SC_BAD_REQUEST == response.code()) { String msg = "Bad Request, Invalid request"; log.error(msg); @@ -856,29 +662,13 @@ public class ConsumerRESTAPIServicesImpl implements ConsumerRESTAPIServices { } } - private ApiApplicationInfo returnApplicationInfo(ApiApplicationInfo refreshedApplicationInfo, AccessTokenInfo refreshedToken) { + private ApiApplicationInfo returnApplicationInfo(ApiApplicationInfo apiApplicationInfo, AccessTokenInfo refreshedToken) { - ApiApplicationInfo applicationInfo = null; - applicationInfo.setClientId(refreshedApplicationInfo.getClientId()); - applicationInfo.setClientSecret(refreshedApplicationInfo.getClientSecret()); + ApiApplicationInfo applicationInfo = new ApiApplicationInfo(); + applicationInfo.setClientId(apiApplicationInfo.getClientId()); + applicationInfo.setClientSecret(apiApplicationInfo.getClientSecret()); applicationInfo.setAccess_token(refreshedToken.getAccess_token()); applicationInfo.setRefresh_token(refreshedToken.getRefresh_token()); - return applicationInfo; } - - private boolean isTokenNull(ApiApplicationInfo apiApplicationInfo, String accessToken) throws BadRequestException { - - boolean token; - if ((!(accessToken == null))) { - token = true; - } else if (!(apiApplicationInfo == null) && accessToken == null) { - token = false; - } else { - String msg = "Null access token or Rest Application info"; - log.error(msg); - throw new BadRequestException(msg); - } - return token; - } } 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/dto/TokenInfo.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/TokenInfo.java deleted file mode 100644 index 72100c982b..0000000000 --- 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/dto/TokenInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2018 - 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.dto; - -/** - * This holds the API application information and access token for REST APIS cals. - */ -public class TokenInfo { - - private ApiApplicationInfo apiApplicationInfo; - private String accessToken; - - public ApiApplicationInfo getApiApplicationInfo() { - return apiApplicationInfo; - } - - public void setApiApplicationInfo(ApiApplicationInfo apiApplicationInfo) { - this.apiApplicationInfo = apiApplicationInfo; - } - - public String getAccessToken() { - return accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } -} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index f1d3c73641..5afd9dbc65 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -20,7 +20,7 @@ package io.entgra.device.mgt.core.apimgt.keymgt.extension.service; import com.google.gson.Gson; import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.ApiApplicationInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.UnexpectedResponseException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.*; @@ -437,14 +437,13 @@ public class KeyMgtServiceImpl implements KeyMgtService { */ private io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application getApplication(String applicationName, String accessToken) throws KeyMgtException { - TokenInfo tokenInfo = new TokenInfo(); - tokenInfo.setApiApplicationInfo(null); - tokenInfo.setAccessToken(accessToken); + ApiApplicationInfo apiApplicationInfo = new ApiApplicationInfo(); + apiApplicationInfo.setAccess_token(accessToken); try { ConsumerRESTAPIServices consumerRESTAPIServices = KeyMgtDataHolder.getInstance().getConsumerRESTAPIServices(); io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications = - consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName); + consumerRESTAPIServices.getAllApplications(apiApplicationInfo, applicationName); if (applications.length == 1) { return applications[0]; } else { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index f7f46b7df1..3ba6e390f5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -27,7 +27,6 @@ import io.entgra.device.mgt.core.apimgt.application.extension.internal.APIApplic 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.dto.APIApplicationKey; -import io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.TokenInfo; import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException; import io.entgra.device.mgt.core.apimgt.keymgt.extension.DCRResponse; import io.entgra.device.mgt.core.apimgt.keymgt.extension.TokenRequest; @@ -828,8 +827,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { "perm:users:send-invitation"); APIManagementProviderService apiManagementProviderService = DeviceMgtAPIUtils.getAPIManagementService(); -// TokenInfo tokenInfo = new TokenInfo(); -// tokenInfo.setAccessToken(accessTokenInfo.getAccessToken()); apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(applicationName, new String[] {"device_management"}, "PRODUCTION", null, false, String.valueOf(validityTime), null, accessTokenInfo.getAccessToken(), null, null,true); From 144170c4c9a443b7982c1a5dbf959d0d65e736ee Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 27 Sep 2023 15:10:51 +0530 Subject: [PATCH 140/343] Fix sso loging app creation payload --- .../ui/request/interceptor/LoginHandler.java | 3 +- .../request/interceptor/SsoLoginHandler.java | 236 +++++++++--------- .../interceptor/util/HandlerConstants.java | 1 + .../request/interceptor/util/HandlerUtil.java | 12 +- 4 files changed, 131 insertions(+), 121 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index b058322933..9aa6eec0ad 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -86,7 +86,8 @@ public class LoginHandler extends HttpServlet { apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() .encodeToString((username + HandlerConstants.COLON + password).getBytes())); apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, username, password)); + apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, + username, password, null, null)); ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index 78a95c019f..29ccff3519 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -38,7 +38,6 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HTTP; import org.json.JSONArray; -import org.json.JSONObject; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; @@ -157,6 +156,8 @@ public class SsoLoginHandler extends HttpServlet { JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); sessionTimeOut = Integer.parseInt(String.valueOf(uiConfigJsonObject.get("sessionTimeOut"))); + JsonArray supportedGrantTypes = constructAppGrantTypeUpdateArray(); + String callbackUrl = iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; // Register the client application HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); @@ -165,7 +166,8 @@ public class SsoLoginHandler extends HttpServlet { apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedAdminCredentials); apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, applicationName, adminUsername, adminPassword)); + apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, applicationName, adminUsername, adminPassword, + callbackUrl, supportedGrantTypes)); ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); @@ -325,21 +327,17 @@ public class SsoLoginHandler extends HttpServlet { /*** * Generates payload for application grant_type update payload * - * @return {@link StringEntity} of the payload to update application grant type + * @return {@link JsonArray} of the payload to update application grant type */ - private StringEntity constructAppGrantTypeUpdatePayload() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("supportedGrantTypes", - new JSONArray(new Object[]{ - HandlerConstants.CODE_GRANT_TYPE, - HandlerConstants.REFRESH_TOKEN_GRANT_TYPE, - HandlerConstants.PASSWORD_GRANT_TYPE, - HandlerConstants.JWT_BEARER_GRANT_TYPE - }) - ); - jsonObject.put(HandlerConstants.CALLBACK_URL_KEY, iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK); - String payload = jsonObject.toString(); - return new StringEntity(payload, ContentType.APPLICATION_JSON); + private JsonArray constructAppGrantTypeUpdateArray() { + JsonArray jsonArray = new JsonArray(); + + jsonArray.add( HandlerConstants.CODE_GRANT_TYPE); + jsonArray.add( HandlerConstants.REFRESH_TOKEN_GRANT_TYPE); + jsonArray.add( HandlerConstants.PASSWORD_GRANT_TYPE); + jsonArray.add( HandlerConstants.JWT_BEARER_GRANT_TYPE); + + return jsonArray; } /*** @@ -390,107 +388,107 @@ public class SsoLoginHandler extends HttpServlet { return jTokenResultAsJsonObject.get("access_token").getAsString(); } - /*** - * Updates Application - * - * @param appName - Application name - * @throws IOException IO exception throws if an error occurred when invoking token endpoint - * @throws ParserConfigurationException,SAXException throws if an error occurred when parsing xml - */ - private void updateSaasApp(String appName) throws ParserConfigurationException, IOException, SAXException { - File getAppRequestXmlFile = new File(HandlerConstants.PAYLOADS_DIR + "/get-app-request.xml"); - String identityAppMgtUrl = apiMgtUrl + HandlerConstants.IDENTITY_APP_MGT_ENDPOINT; - - HttpPost getApplicationEndpoint = new HttpPost(identityAppMgtUrl); - getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + - encodedAdminCredentials); - getApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); - getApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:getApplication"); - - String requestBodyString = HandlerUtil.xmlToString(getAppRequestXmlFile); - - Map data = new HashMap<>(); - appName = adminUsername + HandlerConstants.UNDERSCORE + appName + HandlerConstants.UNDERSCORE + - HandlerConstants.PRODUCTION_KEY; - data.put("applicationName", appName); - requestBodyString = StrSubstitutor.replace(requestBodyString, data); - getApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); - - ProxyResponse getApplicationEndpointResponse = HandlerUtil.execute(getApplicationEndpoint); - - Document doc = DocumentBuilderFactory.newInstance() - .newDocumentBuilder() - .parse(new InputSource(new StringReader(getApplicationEndpointResponse.getData()))); - NodeList nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "inboundAuthenticationConfig"); - NodeList childNodeList; - String nodeName; - - data.clear(); - data.put("applicationId", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationID").item(0).getTextContent()); - data.put("applicationName", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationName").item(0).getTextContent()); - data.put("description", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "description").item(0).getTextContent()); - data.put("saasApp", "true"); - - for (int i = 0; i < nodeList.getLength(); i++) { - childNodeList = nodeList.item(i).getChildNodes(); - for (int j = 0; j < childNodeList.getLength(); j++) { - if (childNodeList.item(j).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthenticationRequestConfigs")) { - NodeList inboundAuthRequestConfigs = childNodeList.item(j).getChildNodes(); - for (int k = 0; k < inboundAuthRequestConfigs.getLength(); k++) { - nodeName = inboundAuthRequestConfigs.item(k).getNodeName(); - if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthKey")) { - data.put("inboundAuthKey", inboundAuthRequestConfigs.item(k).getTextContent()); - } - if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthType")) { - data.put("inboundAuthType", inboundAuthRequestConfigs.item(k).getTextContent()); - } - if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundConfigType")) { - data.put("inboundConfigType", inboundAuthRequestConfigs.item(k).getTextContent()); - } - } - } - } - } - - nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "owner"); - for (int i = 0; i < nodeList.getLength(); i++) { - childNodeList = nodeList.item(i).getChildNodes(); - for (int j = 0; j < childNodeList.getLength(); j++) { - switch (childNodeList.item(j).getNodeName()) { - case HandlerConstants.AX_PREFIX + "tenantDomain": - data.put("tenantDomain", childNodeList.item(j).getTextContent()); - break; - case HandlerConstants.AX_PREFIX + "userName": - data.put("userName", childNodeList.item(j).getTextContent()); - break; - case HandlerConstants.AX_PREFIX + "userStoreDomain": - data.put("userStoreDomain", childNodeList.item(j).getTextContent()); - break; - } - } - } - - nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "spProperties"); - for (int k = 0; k < nodeList.getLength(); k++) { - childNodeList = nodeList.item(k).getChildNodes(); - for (int l = 0; l < childNodeList.getLength(); l++) { - if (childNodeList.item(l).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "value")) { - data.put("displayName", childNodeList.item(l).getTextContent()); - } - } - } - - File appUpdateRequest = new File(HandlerConstants.PAYLOADS_DIR + "/update-app-request.xml"); - String docStr = HandlerUtil.xmlToString(appUpdateRequest); - requestBodyString = StrSubstitutor.replace(docStr, data); - - HttpPost updateApplicationEndpoint = new HttpPost(identityAppMgtUrl); - updateApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + - encodedAdminCredentials); - updateApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); - updateApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:updateApplication"); - updateApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); - - HandlerUtil.execute(updateApplicationEndpoint); - } +// /*** +// * Updates Application +// * +// * @param appName - Application name +// * @throws IOException IO exception throws if an error occurred when invoking token endpoint +// * @throws ParserConfigurationException,SAXException throws if an error occurred when parsing xml +// */ +// private void updateSaasApp(String appName) throws ParserConfigurationException, IOException, SAXException { +// File getAppRequestXmlFile = new File(HandlerConstants.PAYLOADS_DIR + "/get-app-request.xml"); +// String identityAppMgtUrl = apiMgtUrl + HandlerConstants.IDENTITY_APP_MGT_ENDPOINT; +// +// HttpPost getApplicationEndpoint = new HttpPost(identityAppMgtUrl); +// getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + +// encodedAdminCredentials); +// getApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); +// getApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:getApplication"); +// +// String requestBodyString = HandlerUtil.xmlToString(getAppRequestXmlFile); +// +// Map data = new HashMap<>(); +// appName = adminUsername + HandlerConstants.UNDERSCORE + appName + HandlerConstants.UNDERSCORE + +// HandlerConstants.PRODUCTION_KEY; +// data.put("applicationName", appName); +// requestBodyString = StrSubstitutor.replace(requestBodyString, data); +// getApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); +// +// ProxyResponse getApplicationEndpointResponse = HandlerUtil.execute(getApplicationEndpoint); +// +// Document doc = DocumentBuilderFactory.newInstance() +// .newDocumentBuilder() +// .parse(new InputSource(new StringReader(getApplicationEndpointResponse.getData()))); +// NodeList nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "inboundAuthenticationConfig"); +// NodeList childNodeList; +// String nodeName; +// +// data.clear(); +// data.put("applicationId", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationID").item(0).getTextContent()); +// data.put("applicationName", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationName").item(0).getTextContent()); +// data.put("description", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "description").item(0).getTextContent()); +// data.put("saasApp", "true"); +// +// for (int i = 0; i < nodeList.getLength(); i++) { +// childNodeList = nodeList.item(i).getChildNodes(); +// for (int j = 0; j < childNodeList.getLength(); j++) { +// if (childNodeList.item(j).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthenticationRequestConfigs")) { +// NodeList inboundAuthRequestConfigs = childNodeList.item(j).getChildNodes(); +// for (int k = 0; k < inboundAuthRequestConfigs.getLength(); k++) { +// nodeName = inboundAuthRequestConfigs.item(k).getNodeName(); +// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthKey")) { +// data.put("inboundAuthKey", inboundAuthRequestConfigs.item(k).getTextContent()); +// } +// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthType")) { +// data.put("inboundAuthType", inboundAuthRequestConfigs.item(k).getTextContent()); +// } +// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundConfigType")) { +// data.put("inboundConfigType", inboundAuthRequestConfigs.item(k).getTextContent()); +// } +// } +// } +// } +// } +// +// nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "owner"); +// for (int i = 0; i < nodeList.getLength(); i++) { +// childNodeList = nodeList.item(i).getChildNodes(); +// for (int j = 0; j < childNodeList.getLength(); j++) { +// switch (childNodeList.item(j).getNodeName()) { +// case HandlerConstants.AX_PREFIX + "tenantDomain": +// data.put("tenantDomain", childNodeList.item(j).getTextContent()); +// break; +// case HandlerConstants.AX_PREFIX + "userName": +// data.put("userName", childNodeList.item(j).getTextContent()); +// break; +// case HandlerConstants.AX_PREFIX + "userStoreDomain": +// data.put("userStoreDomain", childNodeList.item(j).getTextContent()); +// break; +// } +// } +// } +// +// nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "spProperties"); +// for (int k = 0; k < nodeList.getLength(); k++) { +// childNodeList = nodeList.item(k).getChildNodes(); +// for (int l = 0; l < childNodeList.getLength(); l++) { +// if (childNodeList.item(l).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "value")) { +// data.put("displayName", childNodeList.item(l).getTextContent()); +// } +// } +// } +// +// File appUpdateRequest = new File(HandlerConstants.PAYLOADS_DIR + "/update-app-request.xml"); +// String docStr = HandlerUtil.xmlToString(appUpdateRequest); +// requestBodyString = StrSubstitutor.replace(docStr, data); +// +// HttpPost updateApplicationEndpoint = new HttpPost(identityAppMgtUrl); +// updateApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + +// encodedAdminCredentials); +// updateApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); +// updateApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:updateApplication"); +// updateApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); +// +// HandlerUtil.execute(updateApplicationEndpoint); +// } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java index c6058102b6..0b56bbc578 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerConstants.java @@ -43,6 +43,7 @@ public class HandlerConstants { public static final String SESSION_DEFAULT_AUTH_DATA_KEY = "defaultAuthInfo"; public static final String UI_CONFIG_KEY = "ui-config"; public static final String CALLBACK_URL_KEY = "callbackUrl"; + public static final String GRANT_TYPE_KEY = "supportedGrantTypes"; public static final String IS_ALLOWED_TO_ALL_DOMAINS_KEY = "isAllowedToAllDomains"; public static final String JSESSIONID_KEY = "JSESSIONID"; public static final String COMMON_AUTH_ID_KEY = "commonAuthId"; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index cd2f1f8fe0..2257d9e6d0 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -461,15 +461,25 @@ public class HandlerUtil { * @param tags - tags which are retrieved by reading app manager configuration * @param username - username provided from login form or admin username * @param password - password provided from login form or admin password + * @param callbackUrl - callback url + * @param supportedGrantTypes - supported grant types * @return {@link StringEntity} of the payload to create the client application */ - public static StringEntity constructAppRegPayload(JsonArray tags, String appName, String username, String password) { + public static StringEntity constructAppRegPayload(JsonArray tags, String appName, String username, String password, + String callbackUrl, JsonArray supportedGrantTypes) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty(HandlerConstants.APP_NAME_KEY, appName); jsonObject.addProperty(HandlerConstants.USERNAME, username); jsonObject.addProperty(HandlerConstants.PASSWORD, password); jsonObject.addProperty(HandlerConstants.IS_ALLOWED_TO_ALL_DOMAINS_KEY, "false"); jsonObject.add(HandlerConstants.TAGS_KEY, tags); + if (callbackUrl != null) { + jsonObject.addProperty(HandlerConstants.CALLBACK_URL_KEY, callbackUrl); + } + if (supportedGrantTypes != null) { + jsonObject.add(HandlerConstants.GRANT_TYPE_KEY, supportedGrantTypes); + + } String payload = jsonObject.toString(); return new StringEntity(payload, ContentType.APPLICATION_JSON); } From e128a2479f248c0886fa2e1298492018faaa4b4f Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 27 Sep 2023 15:37:35 +0530 Subject: [PATCH 141/343] Clear unused method --- .../request/interceptor/SsoLoginHandler.java | 188 +----------------- 1 file changed, 4 insertions(+), 184 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index 29ccff3519..d063079e74 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -203,87 +203,11 @@ public class SsoLoginHandler extends HttpServlet { HandlerUtil.handleError(resp, null); throw new LoginException(msg); } - - // Get the details of the registered application -// String getApplicationEndpointUrl = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + -// "?query=" + applicationName; -// HttpGet getApplicationEndpoint = new HttpGet(getApplicationEndpointUrl); -// getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + -// getAccessToken(resp, encodedClientApp)); -// -// ProxyResponse getApplicationResponse = HandlerUtil.execute(getApplicationEndpoint); -// -// if (getApplicationResponse.getCode() == HttpStatus.SC_OK) { -// JsonParser jsonParser = new JsonParser(); -// JsonElement jAppResult = jsonParser.parse(getApplicationResponse.getData()); -// if (jAppResult.isJsonObject()) { -// JsonObject jClientAppResultAsJsonObject = jAppResult.getAsJsonObject(); -// JsonArray appList = jClientAppResultAsJsonObject.getAsJsonArray("list"); -// JsonObject app; -// for (JsonElement appJson : appList) { -// app = appJson.getAsJsonObject(); -// if (app.get("name").getAsString().equals(applicationName)) { -// applicationId = app.get("applicationId").getAsString(); -// break; -// } -// } -// } -// } else if (getApplicationResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { -// String msg = "Unauthorized attempt to get registered application data. " + -// "Application Name: " + applicationName + ". Response message: " + clientAppResponse.getData(); -// log.error(msg); -// HandlerUtil.handleError(resp, getApplicationResponse); -// throw new LoginException(msg); -// } else { -// String msg = "Failed the process while getting the data of registered application. " + -// "Application Name: " + applicationName + ". Response Code: " -// + clientAppResponse.getCode() + ", Response message: " + clientAppResponse.getData(); -// log.error(msg); -// HandlerUtil.handleError(resp, null); -// throw new LoginException(msg); -// } - - // Update the grant types of the application -// String url = apiMgtUrl + HandlerConstants.APIM_APPLICATIONS_ENDPOINT + "/" + applicationId + "/keys/" + -// HandlerConstants.PRODUCTION_KEY; -// HttpPut updateApplicationGrantTypesEndpoint = new HttpPut(url); -// updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + -// getAccessToken(resp, encodedClientApp)); -// updateApplicationGrantTypesEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); -// updateApplicationGrantTypesEndpoint.setEntity(constructAppGrantTypeUpdatePayload()); -// -// ProxyResponse updateApplicationGrantTypesEndpointResponse = HandlerUtil.execute(updateApplicationGrantTypesEndpoint); -// -// // Update app as a SaaS app -// this.updateSaasApp(applicationId); -// -// if (updateApplicationGrantTypesEndpointResponse.getCode() == HttpStatus.SC_UNAUTHORIZED) { -// String msg = "Unauthorized attempt to update the grant types of the application. " + -// "Application ID: " + applicationId + ". Response message: " -// + updateApplicationGrantTypesEndpointResponse.getData(); -// log.error(msg); -// HandlerUtil.handleError(resp, updateApplicationGrantTypesEndpointResponse); -// throw new LoginException(msg); -// } else if (updateApplicationGrantTypesEndpointResponse.getCode() != HttpStatus.SC_OK) { -// String msg = "Failed the process while updating the grant types of the application. " + -// "Application ID: " + applicationId + ". Response Code: " -// + updateApplicationGrantTypesEndpointResponse.getCode() + ", Response message: " -// + updateApplicationGrantTypesEndpointResponse.getData(); -// log.error(msg); -// HandlerUtil.handleError(resp, null); -// throw new LoginException(msg); -// } } catch (IOException e) { throw new LoginException("Error occurred while sending the response into the socket.", e); } catch (JsonSyntaxException e) { throw new LoginException("Error occurred while parsing the response.", e); } -// catch (ParserConfigurationException e) { -// throw new LoginException("Error while creating the document builder.", e); -// } -// catch (SAXException e) { -// throw new LoginException("Error while parsing xml file.", e); -// } } /** @@ -332,10 +256,10 @@ public class SsoLoginHandler extends HttpServlet { private JsonArray constructAppGrantTypeUpdateArray() { JsonArray jsonArray = new JsonArray(); - jsonArray.add( HandlerConstants.CODE_GRANT_TYPE); - jsonArray.add( HandlerConstants.REFRESH_TOKEN_GRANT_TYPE); - jsonArray.add( HandlerConstants.PASSWORD_GRANT_TYPE); - jsonArray.add( HandlerConstants.JWT_BEARER_GRANT_TYPE); + jsonArray.add(HandlerConstants.CODE_GRANT_TYPE); + jsonArray.add(HandlerConstants.REFRESH_TOKEN_GRANT_TYPE); + jsonArray.add(HandlerConstants.PASSWORD_GRANT_TYPE); + jsonArray.add(HandlerConstants.JWT_BEARER_GRANT_TYPE); return jsonArray; } @@ -387,108 +311,4 @@ public class SsoLoginHandler extends HttpServlet { JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); return jTokenResultAsJsonObject.get("access_token").getAsString(); } - -// /*** -// * Updates Application -// * -// * @param appName - Application name -// * @throws IOException IO exception throws if an error occurred when invoking token endpoint -// * @throws ParserConfigurationException,SAXException throws if an error occurred when parsing xml -// */ -// private void updateSaasApp(String appName) throws ParserConfigurationException, IOException, SAXException { -// File getAppRequestXmlFile = new File(HandlerConstants.PAYLOADS_DIR + "/get-app-request.xml"); -// String identityAppMgtUrl = apiMgtUrl + HandlerConstants.IDENTITY_APP_MGT_ENDPOINT; -// -// HttpPost getApplicationEndpoint = new HttpPost(identityAppMgtUrl); -// getApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + -// encodedAdminCredentials); -// getApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); -// getApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:getApplication"); -// -// String requestBodyString = HandlerUtil.xmlToString(getAppRequestXmlFile); -// -// Map data = new HashMap<>(); -// appName = adminUsername + HandlerConstants.UNDERSCORE + appName + HandlerConstants.UNDERSCORE + -// HandlerConstants.PRODUCTION_KEY; -// data.put("applicationName", appName); -// requestBodyString = StrSubstitutor.replace(requestBodyString, data); -// getApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); -// -// ProxyResponse getApplicationEndpointResponse = HandlerUtil.execute(getApplicationEndpoint); -// -// Document doc = DocumentBuilderFactory.newInstance() -// .newDocumentBuilder() -// .parse(new InputSource(new StringReader(getApplicationEndpointResponse.getData()))); -// NodeList nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "inboundAuthenticationConfig"); -// NodeList childNodeList; -// String nodeName; -// -// data.clear(); -// data.put("applicationId", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationID").item(0).getTextContent()); -// data.put("applicationName", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "applicationName").item(0).getTextContent()); -// data.put("description", doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "description").item(0).getTextContent()); -// data.put("saasApp", "true"); -// -// for (int i = 0; i < nodeList.getLength(); i++) { -// childNodeList = nodeList.item(i).getChildNodes(); -// for (int j = 0; j < childNodeList.getLength(); j++) { -// if (childNodeList.item(j).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthenticationRequestConfigs")) { -// NodeList inboundAuthRequestConfigs = childNodeList.item(j).getChildNodes(); -// for (int k = 0; k < inboundAuthRequestConfigs.getLength(); k++) { -// nodeName = inboundAuthRequestConfigs.item(k).getNodeName(); -// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthKey")) { -// data.put("inboundAuthKey", inboundAuthRequestConfigs.item(k).getTextContent()); -// } -// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundAuthType")) { -// data.put("inboundAuthType", inboundAuthRequestConfigs.item(k).getTextContent()); -// } -// if (nodeName.equalsIgnoreCase(HandlerConstants.AX_PREFIX + "inboundConfigType")) { -// data.put("inboundConfigType", inboundAuthRequestConfigs.item(k).getTextContent()); -// } -// } -// } -// } -// } -// -// nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "owner"); -// for (int i = 0; i < nodeList.getLength(); i++) { -// childNodeList = nodeList.item(i).getChildNodes(); -// for (int j = 0; j < childNodeList.getLength(); j++) { -// switch (childNodeList.item(j).getNodeName()) { -// case HandlerConstants.AX_PREFIX + "tenantDomain": -// data.put("tenantDomain", childNodeList.item(j).getTextContent()); -// break; -// case HandlerConstants.AX_PREFIX + "userName": -// data.put("userName", childNodeList.item(j).getTextContent()); -// break; -// case HandlerConstants.AX_PREFIX + "userStoreDomain": -// data.put("userStoreDomain", childNodeList.item(j).getTextContent()); -// break; -// } -// } -// } -// -// nodeList = doc.getElementsByTagName(HandlerConstants.AX_PREFIX + "spProperties"); -// for (int k = 0; k < nodeList.getLength(); k++) { -// childNodeList = nodeList.item(k).getChildNodes(); -// for (int l = 0; l < childNodeList.getLength(); l++) { -// if (childNodeList.item(l).getNodeName().equalsIgnoreCase(HandlerConstants.AX_PREFIX + "value")) { -// data.put("displayName", childNodeList.item(l).getTextContent()); -// } -// } -// } -// -// File appUpdateRequest = new File(HandlerConstants.PAYLOADS_DIR + "/update-app-request.xml"); -// String docStr = HandlerUtil.xmlToString(appUpdateRequest); -// requestBodyString = StrSubstitutor.replace(docStr, data); -// -// HttpPost updateApplicationEndpoint = new HttpPost(identityAppMgtUrl); -// updateApplicationEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + -// encodedAdminCredentials); -// updateApplicationEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_XML.toString()); -// updateApplicationEndpoint.setHeader(HandlerConstants.SOAP_ACTION_HEADER, "urn:updateApplication"); -// updateApplicationEndpoint.setEntity(new StringEntity(requestBodyString, ContentType.TEXT_XML)); -// -// HandlerUtil.execute(updateApplicationEndpoint); -// } } From 26a2950f85d6f329bc63ce16ae866af5418e60af Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 23 Oct 2023 18:06:41 +0530 Subject: [PATCH 142/343] Fix webapp publisher issues --- .../pom.xml | 4 ++++ .../publisher/internal/APIPublisherServiceComponent.java | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 2f1ab4dc5e..15141fa9f2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -177,6 +177,10 @@ io.entgra.device.mgt.core.apimgt.webapp.publisher.config, io.entgra.device.mgt.core.apimgt.webapp.publisher.dto, io.entgra.device.mgt.core.apimgt.webapp.publisher.exception, + io.entgra.device.mgt.core.device.mgt.common.exceptions, + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt, + io.entgra.device.mgt.core.device.mgt.core.config, + io.entgra.device.mgt.core.device.mgt.core.config.permission, io.swagger.annotations;version="[1.6,2)", javax.servlet;version="[2.6,3)", javax.xml.bind;version="[0.0,1)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java index 86a790d957..d2aa464136 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java @@ -120,6 +120,12 @@ public class APIPublisherServiceComponent { APIPublisherDataHolder.getInstance().setRegistryService(null); } + @Reference( + name = "io.entgra.meta.mgt", + service = io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetMetaDataMgtService") protected void setMetaDataMgtService(MetadataManagementService metadataManagementService) { if (metadataManagementService != null && log.isDebugEnabled()) { log.debug("Meta data mgt mgt service initialized"); From 52b2cccf9fab314c1871aa8527f8dfdd2dd1de91 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 14 Nov 2023 21:40:42 +0530 Subject: [PATCH 143/343] Upgrade apache http client version --- .../pom.xml | 4 ++-- .../pom.xml | 7 ++----- .../mgt/core/ui/request/interceptor/util/HandlerUtil.java | 6 +++++- pom.xml | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index cb89652674..1b15c16e15 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -189,8 +189,8 @@ compile - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 io.entgra.device.mgt.core diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index b9fe8f9195..b4950a30c3 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -151,13 +151,10 @@ commons-logging commons-logging - - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 - - org.apache.httpcomponents httpcore diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index cd2f1f8fe0..31c45579eb 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -34,6 +34,9 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder; +import org.apache.hc.core5.ssl.SSLContextBuilder; import org.apache.http.Consts; import org.apache.http.Header; import org.apache.http.HttpHeaders; @@ -44,6 +47,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.X509HostnameVerifier; import org.apache.http.cookie.SM; import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.ContentType; @@ -359,7 +363,7 @@ public class HandlerUtil { boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System. getProperty("org.wso2.ignoreHostnameVerification")); if (isIgnoreHostnameVerification) { - return HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build(); + return HttpClients.custom().setHostnameVerifier((X509HostnameVerifier) NoopHostnameVerifier.INSTANCE).build(); } else { return HttpClients.createDefault(); } diff --git a/pom.xml b/pom.xml index 35f338c22e..4fb0968f72 100644 --- a/pom.xml +++ b/pom.xml @@ -1310,8 +1310,8 @@ ${github.openfeign.version} - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 ${apache.http.client.version} @@ -2043,7 +2043,7 @@ 11.0 1.1.1 1.2 - 4.5.6 + 5.2.1 4.4.13 4.5.10 From d4f9472e4883a4f401e361f462a19098bb982739 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 14 Nov 2023 23:06:12 +0530 Subject: [PATCH 144/343] Fix build failure --- .../pom.xml | 5 ++--- .../mgt/core/impl/SubscriptionManagerImpl.java | 10 +++++++++- .../pom.xml | 18 ------------------ pom.xml | 1 - 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 9ebf07202e..21549bb117 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -173,10 +173,9 @@ - - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 org.apache.felix diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 02a7606b45..71dab6fb65 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -40,6 +40,7 @@ import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.TrustStrategy; import org.json.JSONArray; import org.json.JSONObject; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; @@ -120,6 +121,8 @@ import java.net.URL; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -1385,7 +1388,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager { private CloseableHttpClient getHttpClient() throws ApplicationManagementException { try { SSLContextBuilder builder = new SSLContextBuilder(); - builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); + builder.loadTrustMaterial(null, new TrustStrategy() { + @Override + public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + return true; + } + }); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build()); return HttpClients.custom().setSSLSocketFactory(sslsf).useSystemProperties().build(); } catch (NoSuchAlgorithmException e) { diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 0e16c5ef26..808841bd4b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -129,22 +129,10 @@ - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - org.wso2.carbon org.wso2.carbon.core - - org.wso2.carbon - org.wso2.carbon.logging - org.wso2.carbon org.wso2.carbon.utils @@ -193,7 +181,6 @@ org.wso2.carbon org.wso2.carbon.securevault - test @@ -216,11 +203,6 @@ org.wso2.carbon.queuing test - - javax.xml.bind - jaxb-api - test - io.entgra.device.mgt.core io.entgra.device.mgt.core.server.bootup.heartbeat.beacon diff --git a/pom.xml b/pom.xml index 9bd06cbf6d..3e3ed2bd3b 100644 --- a/pom.xml +++ b/pom.xml @@ -594,7 +594,6 @@ - org.testng testng From 2d9352a78817018ae7dedd1009fc89470d2586cb Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 21 Nov 2023 01:41:04 +0530 Subject: [PATCH 145/343] Upgrade with latest http client --- .../ui/request/interceptor/UserHandler.java | 91 +++++++--- .../interceptor/beans/ProxyResponse.java | 9 +- .../request/interceptor/util/HandlerUtil.java | 171 ++++++++++-------- 3 files changed, 167 insertions(+), 104 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index ac423d215c..52ba15712b 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -18,6 +18,10 @@ package io.entgra.device.mgt.core.ui.request.interceptor; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -31,11 +35,11 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; +import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.core5.http.*; +import org.apache.hc.core5.http.io.entity.HttpEntities; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; +import org.apache.hc.core5.http.message.BasicNameValuePair; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -44,7 +48,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.ArrayList; import java.util.Base64; +import java.util.List; +import java.util.Map; @MultipartConfig @WebServlet("/user") @@ -85,7 +92,22 @@ public class UserHandler extends HttpServlet { StringEntity tokenEPPayload = new StringEntity("token=" + accessToken, ContentType.APPLICATION_FORM_URLENCODED); tokenEndpoint.setEntity(tokenEPPayload); - ProxyResponse tokenStatus = HandlerUtil.execute(tokenEndpoint); + + JsonFactory jsonFactory = new JsonFactory(); + ObjectMapper objectMapper = new ObjectMapper(jsonFactory); + + List nvps = new ArrayList<>(); + nvps.add(new BasicNameValuePair("token", accessToken)); +// nvps.add(new BasicNameValuePair("password", "secret")); + + ClassicHttpRequest httpPost = ClassicRequestBuilder.post(keymanagerUrl + HandlerConstants.INTROSPECT_ENDPOINT) + .setEntity(new UrlEncodedFormEntity(nvps)) + .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()) + .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder().encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes())) + .build(); + + + ProxyResponse tokenStatus = HandlerUtil.execute(httpPost); if (tokenStatus.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { if (tokenStatus.getCode() == HttpStatus.SC_UNAUTHORIZED) { @@ -100,29 +122,52 @@ public class UserHandler extends HttpServlet { return; } } - String tokenData = tokenStatus.getData(); + JsonNode tokenData = tokenStatus.getData(); if (tokenData == null) { log.error("Invalid token data is received."); HandlerUtil.handleError(resp, tokenStatus); return; } - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenData); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) { - HandlerUtil.sendUnAuthorizeResponse(resp); - return; - } - ProxyResponse proxyResponse = new ProxyResponse(); - proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); - proxyResponse.setCode(HttpStatus.SC_OK); - proxyResponse.setData( - jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", "")); - HandlerUtil.handleSuccess(resp, proxyResponse); - httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); - log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); + + if (!tokenData.get("active").asBoolean()) { + HandlerUtil.sendUnAuthorizeResponse(resp); + return; } + ProxyResponse proxyResponse = new ProxyResponse(); + proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); + proxyResponse.setCode(HttpStatus.SC_OK); +// proxyResponse.setData( +// tokenData.get("username").textValue().replaceAll("@carbon.super", "")); + + ObjectMapper mapper = new ObjectMapper(); + Map nodeMap = mapper.convertValue(tokenData, new TypeReference>(){}); + nodeMap.put("username", tokenData.get("username").textValue().replaceAll("@carbon.super", "")); + proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); +// tokenData = ; + + + + HandlerUtil.handleSuccess(resp, proxyResponse); + httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); + log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); + +// JsonParser jsonParser = new JsonParser(); +// JsonElement jTokenResult = jsonParser.parse(tokenData); +// if (jTokenResult.isJsonObject()) { +// JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); +// if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) { +// HandlerUtil.sendUnAuthorizeResponse(resp); +// return; +// } +// ProxyResponse proxyResponse = new ProxyResponse(); +// proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); +// proxyResponse.setCode(HttpStatus.SC_OK); +// proxyResponse.setData( +// jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", "")); +// HandlerUtil.handleSuccess(resp, proxyResponse); +// httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); +// log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); +// } } catch (IOException e) { log.error("Error occurred while sending the response into the socket. ", e); } catch (JsonSyntaxException e) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ProxyResponse.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ProxyResponse.java index 263a98bfeb..d259b33314 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ProxyResponse.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ProxyResponse.java @@ -17,7 +17,8 @@ */ package io.entgra.device.mgt.core.ui.request.interceptor.beans; -import org.apache.http.Header; +import com.fasterxml.jackson.databind.JsonNode; +import org.apache.hc.core5.http.Header; public class ProxyResponse { @@ -27,7 +28,7 @@ public class ProxyResponse { } private int code; - private String data; + private JsonNode data; private String executorResponse; private int status; private Header[] headers; @@ -36,9 +37,9 @@ public class ProxyResponse { public void setCode(int code) { this.code = code; } - public String getData() { return data; } + public JsonNode getData() { return data; } - public void setData(String data) { this.data = data; } + public void setData(JsonNode data) { this.data = data; } public String getExecutorResponse() { return executorResponse; } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 78ef321e5d..0161f74ec0 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -18,6 +18,9 @@ package io.entgra.device.mgt.core.ui.request.interceptor.util; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -32,27 +35,25 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.entity.mime.InputStreamBody; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder; +import org.apache.hc.client5.http.ssl.TrustAllStrategy; +import org.apache.hc.core5.http.*; +import org.apache.hc.core5.http.io.entity.BufferedHttpEntity; +import org.apache.hc.core5.http.io.entity.InputStreamEntity; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.ssl.SSLContextBuilder; import org.apache.http.Consts; -import org.apache.http.Header; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.X509HostnameVerifier; import org.apache.http.cookie.SM; -import org.apache.http.entity.BufferedHttpEntity; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.InputStreamEntity; -import org.apache.http.entity.StringEntity; -import org.apache.http.entity.mime.HttpMultipartMode; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.entity.mime.content.InputStreamBody; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; import org.json.JSONArray; @@ -70,13 +71,11 @@ import javax.servlet.http.HttpSession; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.io.StringWriter; +import java.io.*; import java.math.BigInteger; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Enumeration; import java.util.List; @@ -96,71 +95,75 @@ public class HandlerUtil { * @return response as string * @throws IOException IO exception returns if error occurs when executing the httpMethod */ - public static ProxyResponse execute(HttpRequestBase httpRequest) throws IOException { - try (CloseableHttpClient client = getHttpClient()) { - HttpResponse response = client.execute(httpRequest); - ProxyResponse proxyResponse = new ProxyResponse(); + public static ProxyResponse execute(ClassicHttpRequest httpRequest) throws IOException { - if (response == null) { - log.error("Received null response for http request : " + httpRequest.getMethod() + " " + httpRequest - .getURI().toString()); - proxyResponse.setCode(HandlerConstants.INTERNAL_ERROR_CODE); - proxyResponse.setStatus(ProxyResponse.Status.ERROR); - proxyResponse.setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey( - HandlerConstants.INTERNAL_ERROR_CODE)); - return proxyResponse; - } else { - int statusCode = response.getStatusLine().getStatusCode(); - String jsonString = getResponseString(response); - if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { - proxyResponse.setCode(statusCode); - proxyResponse.setData(jsonString); - proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); - proxyResponse.setExecutorResponse("SUCCESS"); - proxyResponse.setHeaders(response.getAllHeaders()); - return proxyResponse; - } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) { - if (isTokenExpired(jsonString)) { - proxyResponse.setCode(statusCode); - proxyResponse.setStatus(ProxyResponse.Status.ERROR); - proxyResponse.setExecutorResponse(HandlerConstants.TOKEN_IS_EXPIRED); - } else { - log.error( - "Received " + statusCode + " response for http request : " + httpRequest.getMethod() - + " " + httpRequest.getURI().toString() + ". Error message: " + jsonString); - proxyResponse.setCode(statusCode); - proxyResponse.setData(jsonString); - proxyResponse.setStatus(ProxyResponse.Status.ERROR); - proxyResponse.setExecutorResponse( - HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); - } - return proxyResponse; + try (CloseableHttpClient client = getHttpClient()) { + + JsonFactory jsonFactory = new JsonFactory(); + ObjectMapper objectMapper = new ObjectMapper(jsonFactory); + + return client.execute(httpRequest, response -> { + final HttpEntity responseEntity = response.getEntity(); + ProxyResponse handlerResponse = new ProxyResponse(); + int statusCode = response.getCode(); + if (responseEntity == null) { + log.error("Received null response for http request : " + httpRequest.getMethod() + " " + httpRequest.getRequestUri()); + handlerResponse.setCode(HandlerConstants.INTERNAL_ERROR_CODE); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse.setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey( + HandlerConstants.INTERNAL_ERROR_CODE)); + return handlerResponse; } - log.error("Received " + statusCode + - " response for http request : " + httpRequest.getMethod() + " " + httpRequest.getURI() - .toString() + ". Error message: " + jsonString); - proxyResponse.setCode(statusCode); - proxyResponse.setData(jsonString); - proxyResponse.setStatus(ProxyResponse.Status.ERROR); - proxyResponse - .setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); - return proxyResponse; - } + try (InputStream inputStream = responseEntity.getContent()) { + JsonNode responseData = objectMapper.readTree(inputStream); + if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { + handlerResponse.setCode(statusCode); + handlerResponse.setData(responseData); + handlerResponse.setStatus(ProxyResponse.Status.SUCCESS); + handlerResponse.setExecutorResponse("SUCCESS"); + handlerResponse.setHeaders(response.getHeaders()); + return handlerResponse; + } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) { + if (isTokenExpired(responseData)) { + handlerResponse.setCode(statusCode); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse.setExecutorResponse(HandlerConstants.TOKEN_IS_EXPIRED); + } else { + log.error( + "Received " + statusCode + " response for http request : " + httpRequest.getMethod() + + " " + httpRequest.getRequestUri() + ". Error message: " + responseData.textValue()); + handlerResponse.setCode(statusCode); + handlerResponse.setData(responseData); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse.setExecutorResponse( + HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); + } + return handlerResponse; + } + log.error("Received " + statusCode + " response for http request : " + httpRequest.getMethod() + + " " + httpRequest.getRequestUri() + ". Error message: " + responseData.textValue()); + handlerResponse.setCode(statusCode); + handlerResponse.setData(responseData); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse + .setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); + return handlerResponse; + } + }); } } - public static boolean isTokenExpired(String jsonBody) { - return jsonBody.contains("Access token expired") || jsonBody + public static boolean isTokenExpired(JsonNode jsonBody) { + return jsonBody.textValue().contains("Access token expired") || jsonBody.textValue() .contains("Invalid input. Access token validation failed"); } public static String getMemeType(HttpResponse response) { - String memeType = ""; Header contentType = response.getEntity().getContentType(); if (contentType != null) { - memeType = contentType.getValue().split(";")[0].trim(); + return contentType.getValue().split(";")[0].trim(); } - return memeType; + return ""; } /*** @@ -367,7 +370,21 @@ public class HandlerUtil { boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System. getProperty("org.wso2.ignoreHostnameVerification")); if (isIgnoreHostnameVerification) { - return HttpClients.custom().setHostnameVerifier((X509HostnameVerifier) NoopHostnameVerifier.INSTANCE).build(); + try { + return HttpClients.custom() + .setConnectionManager(PoolingHttpClientConnectionManagerBuilder.create() + .setSSLSocketFactory(SSLConnectionSocketFactoryBuilder.create() + .setSslContext(SSLContextBuilder.create() + .loadTrustMaterial(TrustAllStrategy.INSTANCE) + .build()) + .setHostnameVerifier(NoopHostnameVerifier.INSTANCE) + .build()) + .build()) + .build(); + } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) { + log.error("Error Occurred while creating the custom http client", e); + throw new RuntimeException(e); + } } else { return HttpClients.createDefault(); } From 717667126cfdc7ca502d4542825f6707b36dd229 Mon Sep 17 00:00:00 2001 From: Lasantha Dharmakeerthi Date: Mon, 20 Nov 2023 20:20:39 +0000 Subject: [PATCH 146/343] revert 52b2cccf9fab314c1871aa8527f8dfdd2dd1de91 revert Upgrade apache http client version --- .../pom.xml | 4 ++-- .../pom.xml | 7 +++++-- .../mgt/core/ui/request/interceptor/util/HandlerUtil.java | 3 +-- pom.xml | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 0c336eadda..0289d44e88 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -189,8 +189,8 @@ compile - org.apache.httpcomponents.client5 - httpclient5 + org.apache.httpcomponents + httpclient io.entgra.device.mgt.core diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 747dd9b838..bf0036bdc7 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -151,10 +151,13 @@ commons-logging commons-logging + - org.apache.httpcomponents.client5 - httpclient5 + org.apache.httpcomponents + httpclient + + org.apache.httpcomponents httpcore diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 78ef321e5d..48285e5214 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -42,7 +42,6 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.X509HostnameVerifier; import org.apache.http.cookie.SM; import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.ContentType; @@ -367,7 +366,7 @@ public class HandlerUtil { boolean isIgnoreHostnameVerification = Boolean.parseBoolean(System. getProperty("org.wso2.ignoreHostnameVerification")); if (isIgnoreHostnameVerification) { - return HttpClients.custom().setHostnameVerifier((X509HostnameVerifier) NoopHostnameVerifier.INSTANCE).build(); + return HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build(); } else { return HttpClients.createDefault(); } diff --git a/pom.xml b/pom.xml index 3e3ed2bd3b..af0f8e6e45 100644 --- a/pom.xml +++ b/pom.xml @@ -1309,8 +1309,8 @@ ${github.openfeign.version} - org.apache.httpcomponents.client5 - httpclient5 + org.apache.httpcomponents + httpclient ${apache.http.client.version} @@ -2054,7 +2054,7 @@ 11.0 1.1.1 1.2 - 5.2.1 + 4.5.6 4.4.13 4.5.10 From 66eac3c7441f19528fb710f8fe38da4465d5c77c Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Sat, 25 Nov 2023 01:18:15 +0530 Subject: [PATCH 147/343] Fix compilation issues in user handler --- .../DefaultOauth2TokenHandler.java | 77 ++++--- .../interceptor/DefaultTokenHandler.java | 26 ++- .../request/interceptor/HubspotHandler.java | 171 ++++++++-------- .../ui/request/interceptor/LoginHandler.java | 6 +- .../interceptor/PermissionScopeHandler.java | 21 +- .../interceptor/SsoLoginCallbackHandler.java | 44 ++-- .../request/interceptor/SsoLoginHandler.java | 140 ++++--------- .../ui/request/interceptor/UserHandler.java | 73 ++----- .../request/interceptor/util/HandlerUtil.java | 192 ++++++------------ 9 files changed, 289 insertions(+), 461 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java index 343a9c620d..b0974a46a5 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java @@ -18,21 +18,20 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpGet; import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import javax.servlet.annotation.MultipartConfig; @@ -42,11 +41,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.Map; @MultipartConfig @WebServlet("/default-oauth2-credentials") public class DefaultOauth2TokenHandler extends HttpServlet { private static final Log log = LogFactory.getLog(DefaultTokenHandler.class); + private static final long serialVersionUID = 2254408216447549205L; @Override @@ -80,17 +81,16 @@ public class DefaultOauth2TokenHandler extends HttpServlet { } } - String iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR - + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - String tokenUrl = iotsCoreUrl + "/api/device-mgt/v1.0/devices/" + clientId - + "/" + clientSecret + "/default-token" + scopeString; + ClassicHttpRequest defaultTokenRequest = + ClassicRequestBuilder.get(req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()) + + "/api/device-mgt/v1.0/devices/" + clientId + HandlerConstants.URI_SEPARATOR + + clientSecret + "/default-token" + scopeString) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, org.apache.hc.core5.http.ContentType.APPLICATION_FORM_URLENCODED.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()) + .build(); - HttpGet defaultTokenRequest = new HttpGet(tokenUrl); - defaultTokenRequest - .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); - defaultTokenRequest - .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); ProxyResponse tokenResultResponse = HandlerUtil.execute(defaultTokenRequest); if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { @@ -98,29 +98,24 @@ public class DefaultOauth2TokenHandler extends HttpServlet { HandlerUtil.handleError(resp, tokenResultResponse); return; } - String tokenResult = tokenResultResponse.getData(); + JsonNode tokenResult = tokenResultResponse.getData(); if (tokenResult == null) { log.error("Invalid default token response is received."); HandlerUtil.handleError(resp, tokenResultResponse); return; } - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResult); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - AuthData newDefaultAuthData = new AuthData(); - newDefaultAuthData.setClientId(clientId); - newDefaultAuthData.setClientSecret(clientSecret); + AuthData newDefaultAuthData = new AuthData(); + newDefaultAuthData.setClientId(clientId); + newDefaultAuthData.setClientSecret(clientSecret); - String defaultToken = jTokenResultAsJsonObject.get("accessToken").getAsString(); - newDefaultAuthData.setAccessToken(defaultToken); - newDefaultAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refreshToken").getAsString()); - newDefaultAuthData.setScope(jTokenResultAsJsonObject.get("scopes").getAsString()); - httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); + String defaultToken = tokenResult.get("accessToken").asText(); + newDefaultAuthData.setAccessToken(defaultToken); + newDefaultAuthData.setRefreshToken(tokenResult.get("refreshToken").asText()); + newDefaultAuthData.setScope(tokenResult.get("scopes").asText()); + httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); - HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken)); - } + HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken)); } else { HandlerUtil.sendUnAuthorizeResponse(resp); } @@ -152,19 +147,19 @@ public class DefaultOauth2TokenHandler extends HttpServlet { ub3.setHost(System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR)); ub3.setPort(Integer.parseInt(System.getProperty(HandlerConstants.IOT_GATEWAY_WEBSOCKET_WS_PORT_ENV_VAR))); - JsonObject responseJsonObj = new JsonObject(); - responseJsonObj.addProperty("default-access-token", defaultAccessToken); - responseJsonObj.addProperty("remote-session-base-url", ub.toString()); - responseJsonObj.addProperty("secured-websocket-gateway-url", ub2.toString()); - responseJsonObj.addProperty("unsecured-websocket-gateway-url", ub3.toString()); - - Gson gson = new Gson(); - String payload = gson.toJson(responseJsonObj); + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = JsonNodeFactory.instance.objectNode(); + Map nodeMap = mapper.convertValue(node, new TypeReference<>() { + }); + nodeMap.put("default-access-token", defaultAccessToken); + nodeMap.put("remote-session-base-url", ub.toString()); + nodeMap.put("secured-websocket-gateway-url", ub2.toString()); + nodeMap.put("unsecured-websocket-gateway-url", ub3.toString()); ProxyResponse proxyResponse = new ProxyResponse(); proxyResponse.setCode(HttpStatus.SC_OK); proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); - proxyResponse.setData(payload); + proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); return proxyResponse; } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java index e61cafd169..951b7b577a 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java @@ -18,8 +18,10 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; @@ -43,11 +45,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.Map; @MultipartConfig @WebServlet("/default-credentials") public class DefaultTokenHandler extends HttpServlet { private static final Log log = LogFactory.getLog(DefaultTokenHandler.class); + private static final long serialVersionUID = 6356346497117534430L; @Override @@ -110,19 +114,19 @@ public class DefaultTokenHandler extends HttpServlet { ub3.setHost(System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR)); ub3.setPort(Integer.parseInt(System.getProperty(HandlerConstants.IOT_GATEWAY_WEBSOCKET_WS_PORT_ENV_VAR))); - JsonObject responseJsonObj = new JsonObject(); - responseJsonObj.addProperty("default-access-token", defaultAccessToken); - responseJsonObj.addProperty("remote-session-base-url", ub.toString()); - responseJsonObj.addProperty("secured-websocket-gateway-url", ub2.toString()); - responseJsonObj.addProperty("unsecured-websocket-gateway-url", ub3.toString()); - - Gson gson = new Gson(); - String payload = gson.toJson(responseJsonObj); + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = JsonNodeFactory.instance.objectNode(); + Map nodeMap = mapper.convertValue(node, new TypeReference<>() { + }); + nodeMap.put("default-access-token", defaultAccessToken); + nodeMap.put("remote-session-base-url", ub.toString()); + nodeMap.put("secured-websocket-gateway-url", ub2.toString()); + nodeMap.put("unsecured-websocket-gateway-url", ub3.toString()); ProxyResponse proxyResponse = new ProxyResponse(); proxyResponse.setCode(HttpStatus.SC_OK); proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); - proxyResponse.setData(payload); + proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); return proxyResponse; } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java index 2e2f5b73bf..f99531cc17 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java @@ -18,17 +18,15 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.JsonObject; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; +import com.fasterxml.jackson.databind.JsonNode; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -48,89 +46,94 @@ import java.io.IOException; ) public class HubspotHandler extends HttpServlet { - private static final Log log = LogFactory.getLog(HubspotHandler.class); - private HttpSession httpSession; - private static String hubspotEndpoint; - private static String chatConfig; - private JsonObject uiConfigJsonObject; - private static String gatewayUrl; - private static String iotsCoreUrl; + private static final Log log = LogFactory.getLog(HubspotHandler.class); + private HttpSession httpSession; + private static String hubspotEndpoint; + private static String chatConfig; + private JsonNode uiConfigJsonObject; + private static String gatewayUrl; + private static String iotsCoreUrl; - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) { - try { - if (validateRequest(req, resp)) { - HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, hubspotEndpoint)); - HandlerUtil.generateChatRequestEntity(req, postRequest); - postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); - postRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig); - ProxyResponse proxyResponse = HandlerUtil.execute(postRequest); - HandlerUtil.handleSuccess(resp, proxyResponse); - } - } catch (IOException e) { - log.error("Error occurred when processing POST request.", e); - } - } - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) { - try { - if (validateRequest(req, resp)) { - HttpGet getRequest = new HttpGet(HandlerUtil.generateBackendRequestURL(req,hubspotEndpoint)); - getRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); - getRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig); - ProxyResponse proxyResponse = HandlerUtil.execute(getRequest); - HandlerUtil.handleSuccess(resp, proxyResponse); - } - } catch (IOException e) { - log.error("Error occurred when processing GET request.", e); - } - } - - @Override - protected void doDelete(HttpServletRequest req, HttpServletResponse resp){ - try{ - if(validateRequest(req, resp)){ - HttpDelete deleteRequest = new HttpDelete(HandlerUtil.generateBackendRequestURL(req,hubspotEndpoint)); - deleteRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); - deleteRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig); - ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest); - HandlerUtil.handleSuccess(resp, proxyResponse); - } - } catch (IOException e){ - log.error("Error occurred when processing DELETE request.", e); + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) { + try { + if (validateRequest(req, resp)) { + ClassicHttpRequest postRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req, hubspotEndpoint)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, "application/json") + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig) + .build(); + HandlerUtil.generateChatRequestEntity(req, postRequest); + HandlerUtil.handleSuccess(resp, HandlerUtil.execute(postRequest)); } + } catch (IOException e) { + log.error("Error occurred when processing POST request.", e); } + } - /*** - * Validates the hubspot's incoming request. - * - * @param req {@link HttpServletRequest} - * @param resp {@link HttpServletResponse} - * @return If request is a valid one, returns TRUE, otherwise return FALSE - * @throws IOException If and error occurs while witting error response to client side - */ - private boolean validateRequest(HttpServletRequest req, HttpServletResponse resp) - throws IOException { - httpSession = req.getSession(false); - if (httpSession == null) { - log.error("Unauthorized, You are not logged in. Please log in to the portal"); - HandlerUtil.handleError(resp, HttpStatus.SC_UNAUTHORIZED); - return false; + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) { + try { + if (validateRequest(req, resp)) { + ClassicHttpRequest getRequest = + ClassicRequestBuilder.get(HandlerUtil.generateBackendRequestURL(req, hubspotEndpoint)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, "application/json") + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, + HandlerConstants.BEARER + chatConfig).build(); + HandlerUtil.handleSuccess(resp, HandlerUtil.execute(getRequest)); } - if (req.getMethod() == null) { - log.error("Bad Request, Request method is empty"); - HandlerUtil.handleError(resp, HttpStatus.SC_BAD_REQUEST); - return false; - } - gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme()); - String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; - uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); - chatConfig = uiConfigJsonObject.get("hubspotChat").getAsJsonObject().get("accessToken").getAsString(); - hubspotEndpoint = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + HandlerConstants.HUBSPOT_CHAT_URL; - return true; + } catch (IOException e) { + log.error("Error occurred when processing GET request.", e); } + } + + @Override + protected void doDelete(HttpServletRequest req, HttpServletResponse resp) { + try { + if (validateRequest(req, resp)) { + ClassicHttpRequest deleteRequest = + ClassicRequestBuilder.delete(HandlerUtil.generateBackendRequestURL(req, hubspotEndpoint)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, "application/json") + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, + HandlerConstants.BEARER + chatConfig).build(); + + deleteRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); + deleteRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig); + HandlerUtil.handleSuccess(resp, HandlerUtil.execute(deleteRequest)); + } + } catch (IOException e) { + log.error("Error occurred when processing DELETE request.", e); + } + } + + /*** + * Validates the hubspot's incoming request. + * + * @param req {@link HttpServletRequest} + * @param resp {@link HttpServletResponse} + * @return If request is a valid one, returns TRUE, otherwise return FALSE + * @throws IOException If and error occurs while witting error response to client side + */ + private boolean validateRequest(HttpServletRequest req, HttpServletResponse resp) + throws IOException { + httpSession = req.getSession(false); + if (httpSession == null) { + log.error("Unauthorized, You are not logged in. Please log in to the portal"); + HandlerUtil.handleError(resp, HttpStatus.SC_UNAUTHORIZED); + return false; + } + if (req.getMethod() == null) { + log.error("Bad Request, Request method is empty"); + HandlerUtil.handleError(resp, HttpStatus.SC_BAD_REQUEST); + return false; + } + gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); + iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + + HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme()); + String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; + uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); + chatConfig = uiConfigJsonObject.get("hubspotChat").get("accessToken").textValue(); + hubspotEndpoint = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + HandlerConstants.HUBSPOT_CHAT_URL; + return true; + } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index 9aa6eec0ad..2286d14c0a 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor; +import com.fasterxml.jackson.databind.JsonNode; import com.google.gson.*; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; @@ -68,7 +69,8 @@ public class LoginHandler extends HttpServlet { } httpSession = req.getSession(true); - JsonObject uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); + JsonNode uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, + resp); JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); int sessionTimeOut = Integer.parseInt(String.valueOf(uiConfigJsonObject.get("sessionTimeOut"))); @@ -225,7 +227,7 @@ public class LoginHandler extends HttpServlet { * @return Invoke token endpoint and return the response as string. * @throws IOException IO exception throws if an error occurred when invoking token endpoint */ - private ProxyResponse getTokenResult(String encodedClientApp, JsonArray scopes) throws IOException { + private ProxyResponse getTokenResult(String encodedClientApp, JsonNode scopes) throws IOException { HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.INTERNAL_TOKEN_ENDPOINT); tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java index 80b88885b7..623fd48b87 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java @@ -18,15 +18,17 @@ package io.entgra.device.mgt.core.ui.request.interceptor; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; -import org.json.JSONObject; -import javax.servlet.ServletException; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; @@ -34,12 +36,15 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.Map; @MultipartConfig @WebServlet("/login-user/scopes") public class PermissionScopeHandler extends HttpServlet { + private static final long serialVersionUID = 976006906915355611L; + @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { HttpSession httpSession = req.getSession(false); if (httpSession == null) { HandlerUtil.sendUnAuthorizeResponse(resp); @@ -54,11 +59,15 @@ public class PermissionScopeHandler extends HttpServlet { if (!StringUtils.isEmpty(authData.getScope())) { ProxyResponse proxyResponse = new ProxyResponse(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put(HandlerConstants.USER_SCOPES, authData.getScope()); + + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = JsonNodeFactory.instance.objectNode(); + Map nodeMap = mapper.convertValue(node, new TypeReference<>() { + }); + nodeMap.put(HandlerConstants.USER_SCOPES, authData.getScope()); proxyResponse.setCode(HttpStatus.SC_OK); proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); - proxyResponse.setData(jsonObject.toString()); + proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); HandlerUtil.handleSuccess(resp, proxyResponse); return; } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java index 242ce38962..ee2b600eb4 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java @@ -18,20 +18,18 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import com.fasterxml.jackson.databind.JsonNode; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -75,33 +73,35 @@ public class SsoLoginCallbackHandler extends HttpServlet { } String scope = session.getAttribute("scope").toString(); - - HttpPost tokenEndpoint = new HttpPost(keyManagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT); - tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp")); - tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); - String loginCallbackUrl = iotsCoreUrl + req.getContextPath() + HandlerConstants.SSO_LOGIN_CALLBACK; StringEntity tokenEPPayload = new StringEntity( "grant_type=" + HandlerConstants.CODE_GRANT_TYPE + "&code=" + code + "&scope=" + scope + "&redirect_uri=" + loginCallbackUrl, ContentType.APPLICATION_FORM_URLENCODED); - tokenEndpoint.setEntity(tokenEPPayload); - ProxyResponse tokenResultResponse = HandlerUtil.execute(tokenEndpoint); - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResultResponse.getData()); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); + ClassicHttpRequest tokenEndpoint = ClassicRequestBuilder.post(keyManagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT) + .setEntity(tokenEPPayload) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, org.apache.hc.core5.http.ContentType.APPLICATION_FORM_URLENCODED.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + session.getAttribute("encodedClientApp")) + .build(); + + ProxyResponse tokenResultResponse = HandlerUtil.execute(tokenEndpoint); + JsonNode jsonNode = tokenResultResponse.getData(); + + if (jsonNode != null) { AuthData authData = new AuthData(); authData.setClientId(session.getAttribute("clientId").toString()); authData.setClientSecret(session.getAttribute("clientSecret").toString()); authData.setEncodedClientApp(session.getAttribute("encodedClientApp").toString()); - authData.setAccessToken(jTokenResultAsJsonObject.get("access_token").getAsString()); - authData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); - authData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); + authData.setAccessToken(jsonNode.get("access_token").textValue()); + authData.setRefreshToken(jsonNode.get("refresh_token").textValue()); + authData.setScope(jsonNode.get("scope").textValue()); session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); resp.sendRedirect(session.getAttribute("redirectUrl").toString()); + } else { + log.error("Found empty response for token call."); + HandlerUtil.handleError(resp, HandlerConstants.INTERNAL_ERROR_CODE); } } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index 8d3bc0d0c2..34584d03c3 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -18,7 +18,8 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.*; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.cache.LoginCache; import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthApp; @@ -26,21 +27,12 @@ import io.entgra.device.mgt.core.ui.request.interceptor.cache.OAuthAppCacheKey; import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.LoginException; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; -import org.apache.commons.lang.text.StrSubstitutor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.protocol.HTTP; -import org.json.JSONArray; import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; import org.xml.sax.SAXException; import javax.servlet.annotation.MultipartConfig; @@ -54,30 +46,25 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.File; import java.io.IOException; -import java.io.StringReader; +import java.util.ArrayList; import java.util.Base64; -import java.util.HashMap; -import java.util.Map; @MultipartConfig @WebServlet("/ssoLogin") public class SsoLoginHandler extends HttpServlet { private static final Log log = LogFactory.getLog(SsoLoginHandler.class); + private static final long serialVersionUID = 5594017767311123453L; private static String adminUsername; private static String adminPassword; private static String gatewayUrl; - private static String iotsCoreUrl; - private static String apiMgtUrl; - private static String keyManagerUrl; + private static String iotSCoreUrl; private static int sessionTimeOut; - private static String encodedAdminCredentials; private static String encodedClientApp; - private static String applicationId; private static String applicationName; private static String baseContextPath; - private JsonObject uiConfigJsonObject; + private JsonNode uiConfigJsonObject; private HttpSession httpSession; private LoginCache loginCache; private OAuthApp oAuthApp; @@ -101,15 +88,14 @@ public class SsoLoginHandler extends HttpServlet { gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme()); - iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + iotSCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme()); - apiMgtUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_APIM_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getAPIManagerPort(req.getScheme()); - keyManagerUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_KM_HOST_ENV_VAR) + String keyManagerUrl = + req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_KM_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getKeyManagerPort(req.getScheme()); // Fetch ui config and persists in session - String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; + String uiConfigUrl = iotSCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT; uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); // Retrieving login cache and do a DCR if the cache is not available. @@ -121,9 +107,10 @@ public class SsoLoginHandler extends HttpServlet { } String clientId = oAuthApp.getClientId(); - JsonArray scopesSsoJson = uiConfigJsonObject.get("scopes").getAsJsonArray(); - String scopesSsoString = HandlerUtil.getScopeString(scopesSsoJson); - String loginCallbackUrl = iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; + + JsonNode scopeJsonNode = uiConfigJsonObject.get("scopes"); + String scopesSsoString = HandlerUtil.getScopeString(scopeJsonNode); + String loginCallbackUrl = iotSCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; persistAuthSessionData(req, oAuthApp.getClientId(), oAuthApp.getClientSecret(), oAuthApp.getEncodedClientApp(), scopesSsoString, state); resp.sendRedirect(keyManagerUrl + HandlerConstants.AUTHORIZATION_ENDPOINT + @@ -134,8 +121,6 @@ public class SsoLoginHandler extends HttpServlet { "&redirect_uri=" + loginCallbackUrl); } catch (IOException e) { log.error("Error occurred while sending the response into the socket. ", e); - } catch (JsonSyntaxException e) { - log.error("Error occurred while parsing the response. ", e); } catch (ParserConfigurationException e) { log.error("Error while creating the document builder."); } catch (SAXException e) { @@ -154,34 +139,32 @@ public class SsoLoginHandler extends HttpServlet { */ private void dynamicClientRegistration(HttpServletRequest req, HttpServletResponse resp) throws LoginException { try { - JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); - JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); + ArrayNode tags = (ArrayNode) uiConfigJsonObject.get("appRegistration").get("tags"); + JsonNode scopes = uiConfigJsonObject.get("scopes"); sessionTimeOut = Integer.parseInt(String.valueOf(uiConfigJsonObject.get("sessionTimeOut"))); - JsonArray supportedGrantTypes = constructAppGrantTypeUpdateArray(); - String callbackUrl = iotsCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; + String callbackUrl = iotSCoreUrl + baseContextPath + HandlerConstants.SSO_LOGIN_CALLBACK; - // Register the client application - HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); - encodedAdminCredentials = Base64.getEncoder() + String encodedAdminCredentials = Base64.getEncoder() .encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes()); - apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + - encodedAdminCredentials); - apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, applicationName, adminUsername, adminPassword, - callbackUrl, supportedGrantTypes)); + ClassicHttpRequest apiRegEndpoint = ClassicRequestBuilder.post(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT) + .setEntity(HandlerUtil.constructAppRegPayload(tags, applicationName, adminUsername, adminPassword, + callbackUrl, constructAppGrantTypeUpdateArray())) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, + org.apache.hc.core5.http.ContentType.APPLICATION_JSON.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + + encodedAdminCredentials) + .build(); ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); if (clientAppResponse.getCode() == HttpStatus.SC_CREATED) { - JsonParser jsonParser = new JsonParser(); - JsonElement jClientAppResult = jsonParser.parse(clientAppResponse.getData()); String clientId = null; String clientSecret = null; + JsonNode jsonNode = clientAppResponse.getData(); - if (jClientAppResult.isJsonObject()) { - JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); - clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); - clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); + if (jsonNode != null) { + clientId = jsonNode.get("client_id").textValue(); + clientSecret = jsonNode.get("client_secret").textValue(); encodedClientApp = Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes()); String scopesString = HandlerUtil.getScopeString(scopes); persistAuthSessionData(req, clientId, clientSecret, encodedClientApp, scopesString, state); @@ -206,8 +189,6 @@ public class SsoLoginHandler extends HttpServlet { } } catch (IOException e) { throw new LoginException("Error occurred while sending the response into the socket.", e); - } catch (JsonSyntaxException e) { - throw new LoginException("Error occurred while parsing the response.", e); } } @@ -228,7 +209,6 @@ public class SsoLoginHandler extends HttpServlet { adminPassword = doc.getElementsByTagName("Password").item(0).getTextContent(); } - /** * Persist the Auth data inside the session * @@ -253,64 +233,14 @@ public class SsoLoginHandler extends HttpServlet { /*** * Generates payload for application grant_type update payload * - * @return {@link JsonArray} of the payload to update application grant type + * @return {@link ArrayList} of the payload to update application grant type */ - private JsonArray constructAppGrantTypeUpdateArray() { - JsonArray jsonArray = new JsonArray(); - + private ArrayList constructAppGrantTypeUpdateArray() { + ArrayList jsonArray = new ArrayList<>(); jsonArray.add(HandlerConstants.CODE_GRANT_TYPE); jsonArray.add(HandlerConstants.REFRESH_TOKEN_GRANT_TYPE); jsonArray.add(HandlerConstants.PASSWORD_GRANT_TYPE); jsonArray.add(HandlerConstants.JWT_BEARER_GRANT_TYPE); - return jsonArray; } - - /*** - * Generates tokens using password grant_type by invoking token endpoint - * - * @param encodedClientApp - Base64 encoded clientId:clientSecret. - * @return Invoke token endpoint and return the response as string. - * @throws IOException IO exception throws if an error occurred when invoking token endpoint - */ - private ProxyResponse getTokenResult(String encodedClientApp) throws IOException { - HttpPost tokenEndpoint = new HttpPost(keyManagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT); - tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); - tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); - - StringEntity tokenEPPayload = new StringEntity( - "grant_type=" + HandlerConstants.PASSWORD_GRANT_TYPE + "&username=" + adminUsername + "&password=" + adminPassword + - "&scope=apim:api_view apim:api_create apim:api_publish apim:subscribe", - ContentType.APPLICATION_FORM_URLENCODED); - tokenEndpoint.setEntity(tokenEPPayload); - return HandlerUtil.execute(tokenEndpoint); - } - - /*** - * Retrieves and returns access token - * - * @param resp - Http Servlet Response - * @param encodedClientApp - Base64 encoded clientId:clientSecret. - * @return Returns access token - * @throws IOException IO exception throws if an error occurred when invoking token endpoint - */ - private String getAccessToken(HttpServletResponse resp, String encodedClientApp) throws IOException { - ProxyResponse tokenResultResponse = getTokenResult(encodedClientApp); - - if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { - log.error("Error occurred while invoking the API to get token data."); - HandlerUtil.handleError(resp, tokenResultResponse); - } - String tokenResult = tokenResultResponse.getData(); - if (tokenResult == null) { - log.error("Invalid token response is received."); - HandlerUtil.handleError(resp, tokenResultResponse); - } - - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResult); - - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - return jTokenResultAsJsonObject.get("access_token").getAsString(); - } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index 52ba15712b..dd06e5f08c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -18,13 +18,9 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; @@ -36,8 +32,11 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; -import org.apache.hc.core5.http.*; -import org.apache.hc.core5.http.io.entity.HttpEntities; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpHeaders; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.NameValuePair; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.hc.core5.http.message.BasicNameValuePair; @@ -63,7 +62,7 @@ public class UserHandler extends HttpServlet { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { - String keymanagerUrl = + String keyManagerUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_KM_HOST_ENV_VAR) + HandlerConstants.COLON + HandlerUtil.getKeyManagerPort(req.getScheme()); @@ -80,39 +79,24 @@ public class UserHandler extends HttpServlet { } String accessToken = authData.getAccessToken(); -// String accessTokenWithoutPrefix = accessToken.substring(accessToken.indexOf("_") + 1); - - HttpPost tokenEndpoint = new HttpPost(keymanagerUrl + HandlerConstants.INTROSPECT_ENDPOINT); - tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); DeviceManagementConfig dmc = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); String adminUsername = dmc.getKeyManagerConfigurations().getAdminUsername(); String adminPassword = dmc.getKeyManagerConfigurations().getAdminPassword(); - tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() - .encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes())); - StringEntity tokenEPPayload = new StringEntity("token=" + accessToken, - ContentType.APPLICATION_FORM_URLENCODED); - tokenEndpoint.setEntity(tokenEPPayload); - JsonFactory jsonFactory = new JsonFactory(); - ObjectMapper objectMapper = new ObjectMapper(jsonFactory); + List nameValuePairs = new ArrayList<>(); + nameValuePairs.add(new BasicNameValuePair("token", accessToken)); - List nvps = new ArrayList<>(); - nvps.add(new BasicNameValuePair("token", accessToken)); -// nvps.add(new BasicNameValuePair("password", "secret")); - - ClassicHttpRequest httpPost = ClassicRequestBuilder.post(keymanagerUrl + HandlerConstants.INTROSPECT_ENDPOINT) - .setEntity(new UrlEncodedFormEntity(nvps)) + ClassicHttpRequest introspectCall = ClassicRequestBuilder.post(keyManagerUrl + HandlerConstants.INTROSPECT_ENDPOINT) + .setEntity(new UrlEncodedFormEntity(nameValuePairs)) .setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()) .setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder().encodeToString((adminUsername + HandlerConstants.COLON + adminPassword).getBytes())) .build(); - - ProxyResponse tokenStatus = HandlerUtil.execute(httpPost); - + ProxyResponse tokenStatus = HandlerUtil.execute(introspectCall); if (tokenStatus.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { if (tokenStatus.getCode() == HttpStatus.SC_UNAUTHORIZED) { - tokenStatus = HandlerUtil.retryRequestWithRefreshedToken(req, tokenEndpoint, keymanagerUrl); - if(!HandlerUtil.isResponseSuccessful(tokenStatus)) { + tokenStatus = HandlerUtil.retryRequestWithRefreshedToken(req, introspectCall, keyManagerUrl); + if (!HandlerUtil.isResponseSuccessful(tokenStatus)) { HandlerUtil.handleError(resp, tokenStatus); return; } @@ -136,38 +120,17 @@ public class UserHandler extends HttpServlet { ProxyResponse proxyResponse = new ProxyResponse(); proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); proxyResponse.setCode(HttpStatus.SC_OK); -// proxyResponse.setData( -// tokenData.get("username").textValue().replaceAll("@carbon.super", "")); ObjectMapper mapper = new ObjectMapper(); - Map nodeMap = mapper.convertValue(tokenData, new TypeReference>(){}); + Map nodeMap = mapper.convertValue(tokenData, new TypeReference<>() { + }); nodeMap.put("username", tokenData.get("username").textValue().replaceAll("@carbon.super", "")); proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); -// tokenData = ; - - HandlerUtil.handleSuccess(resp, proxyResponse); - httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); - log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); - -// JsonParser jsonParser = new JsonParser(); -// JsonElement jTokenResult = jsonParser.parse(tokenData); -// if (jTokenResult.isJsonObject()) { -// JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); -// if (!jTokenResultAsJsonObject.get("active").getAsBoolean()) { -// HandlerUtil.sendUnAuthorizeResponse(resp); -// return; -// } -// ProxyResponse proxyResponse = new ProxyResponse(); -// proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); -// proxyResponse.setCode(HttpStatus.SC_OK); -// proxyResponse.setData( -// jTokenResultAsJsonObject.get("username").getAsString().replaceAll("@carbon.super", "")); -// HandlerUtil.handleSuccess(resp, proxyResponse); -// httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, jTokenResultAsJsonObject.get("username").getAsString()); -// log.info("Customer login", userLogContextBuilder.setUserName(proxyResponse.getData()).setUserRegistered(true).build()); -// } + httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, nodeMap.get("username").toString()); + log.info("Customer login", + userLogContextBuilder.setUserName(nodeMap.get("username").toString()).setUserRegistered(true).build()); } catch (IOException e) { log.error("Error occurred while sending the response into the socket. ", e); } catch (JsonSyntaxException e) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 0161f74ec0..b7a4b4e51c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -21,6 +21,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor.util; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -50,35 +51,25 @@ import org.apache.hc.core5.http.io.entity.BufferedHttpEntity; import org.apache.hc.core5.http.io.entity.InputStreamEntity; import org.apache.hc.core5.http.io.entity.StringEntity; import org.apache.hc.core5.ssl.SSLContextBuilder; +import org.apache.hc.client5.http.entity.mime.HttpMultipartMode; import org.apache.http.Consts; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.cookie.SM; -import org.apache.xml.serialize.OutputFormat; -import org.apache.xml.serialize.XMLSerializer; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.w3c.dom.Document; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; -import org.xml.sax.SAXException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; import java.math.BigInteger; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; -import java.util.Enumeration; -import java.util.List; +import java.util.*; public class HandlerUtil { @@ -159,7 +150,7 @@ public class HandlerUtil { } public static String getMemeType(HttpResponse response) { - Header contentType = response.getEntity().getContentType(); + Header contentType = response.getFirstHeader("Content-Type"); if (contentType != null) { return contentType.getValue().split(";")[0].trim(); } @@ -273,29 +264,9 @@ public class HandlerUtil { resp.setStatus(proxyResponse.getCode()); resp.setContentType(ContentType.APPLICATION_JSON.getMimeType()); resp.setCharacterEncoding(Consts.UTF_8.name()); - JSONObject response = new JSONObject(); - String responseData = proxyResponse.getData(); - - if (!StringUtils.isEmpty(responseData)) { - try { - if (responseData.startsWith("{")) { - JSONObject responseDataJsonObj = new JSONObject(responseData); - response.put("data", responseDataJsonObj); - } else if (responseData.startsWith("[")) { - JSONArray responseDataJsonArr = new JSONArray(responseData); - response.put("data", responseDataJsonArr); - } else { - log.warn("Response data is not valid json string >> " + responseData); - response.put("data", responseData); - } - } catch (JSONException e) { - log.error("Response data is not passable"); - response.put("data", responseData); - } - } try (PrintWriter writer = resp.getWriter()) { - writer.write(response.toString()); + writer.write(proxyResponse.getData().toString()); } } @@ -435,13 +406,13 @@ public class HandlerUtil { * @throws FileUploadException If unable to parse the incoming request for multipart content extraction. * @throws IOException If error occurred while generating the request body. */ - public static void generateRequestEntity(HttpServletRequest req, HttpEntityEnclosingRequestBase proxyRequest) + public static void generateRequestEntity(HttpServletRequest req, ClassicHttpRequest proxyRequest) throws FileUploadException, IOException { if (ServletFileUpload.isMultipartContent(req)) { ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory()); List fileItemList = servletFileUpload.parseRequest(req); MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create(); - entityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + entityBuilder.setMode(HttpMultipartMode.LEGACY); for (FileItem item : fileItemList) { if (!item.isFormField()) { entityBuilder.addPart(item.getFieldName(), new InputStreamBody(item.getInputStream(), @@ -456,7 +427,7 @@ public class HandlerUtil { if (StringUtils.isNotEmpty(req.getHeader(HttpHeaders.CONTENT_LENGTH)) || StringUtils.isNotEmpty(req.getHeader(HttpHeaders.TRANSFER_ENCODING))) { InputStreamEntity entity = new InputStreamEntity(req.getInputStream(), - Long.parseLong(req.getHeader(HttpHeaders.CONTENT_LENGTH))); + Long.parseLong(req.getHeader(HttpHeaders.CONTENT_LENGTH)), ContentType.parse(req.getContentType())); proxyRequest.setEntity(new BufferedHttpEntity(entity)); } HandlerUtil.copyRequestHeaders(req, proxyRequest, true); @@ -470,12 +441,12 @@ public class HandlerUtil { * @param proxyRequest proxy request instance. * @throws IOException If error occurred while generating the request body. */ - public static void generateChatRequestEntity(HttpServletRequest req, HttpEntityEnclosingRequestBase proxyRequest) + public static void generateChatRequestEntity(HttpServletRequest req, ClassicHttpRequest proxyRequest) throws IOException { if (StringUtils.isNotEmpty(req.getHeader(HttpHeaders.CONTENT_LENGTH)) || StringUtils.isNotEmpty(req.getHeader(HttpHeaders.TRANSFER_ENCODING))) { InputStreamEntity entity = new InputStreamEntity(req.getInputStream(), - Long.parseLong(req.getHeader(HttpHeaders.CONTENT_LENGTH))); + Long.parseLong(req.getHeader(HttpHeaders.CONTENT_LENGTH)), ContentType.parse(req.getContentType())); proxyRequest.setEntity(new BufferedHttpEntity(entity)); } } @@ -490,23 +461,26 @@ public class HandlerUtil { * @param supportedGrantTypes - supported grant types * @return {@link StringEntity} of the payload to create the client application */ - public static StringEntity constructAppRegPayload(JsonArray tags, String appName, String username, String password, - String callbackUrl, JsonArray supportedGrantTypes) { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty(HandlerConstants.APP_NAME_KEY, appName); - jsonObject.addProperty(HandlerConstants.USERNAME, username); - jsonObject.addProperty(HandlerConstants.PASSWORD, password); - jsonObject.addProperty(HandlerConstants.IS_ALLOWED_TO_ALL_DOMAINS_KEY, "false"); - jsonObject.add(HandlerConstants.TAGS_KEY, tags); + public static StringEntity constructAppRegPayload(ArrayNode tags, String appName, String username, String password, + String callbackUrl, ArrayList supportedGrantTypes) { + + ObjectMapper objectMapper = new ObjectMapper(); + Map data = new HashMap<>(); + + data.put(HandlerConstants.APP_NAME_KEY, appName); + data.put(HandlerConstants.USERNAME, username); + data.put(HandlerConstants.PASSWORD, password); + data.put(HandlerConstants.IS_ALLOWED_TO_ALL_DOMAINS_KEY, "false"); + data.put(HandlerConstants.TAGS_KEY, tags); if (callbackUrl != null) { - jsonObject.addProperty(HandlerConstants.CALLBACK_URL_KEY, callbackUrl); + data.put(HandlerConstants.CALLBACK_URL_KEY, callbackUrl); } if (supportedGrantTypes != null) { - jsonObject.add(HandlerConstants.GRANT_TYPE_KEY, supportedGrantTypes); + data.put(HandlerConstants.GRANT_TYPE_KEY, supportedGrantTypes); } - String payload = jsonObject.toString(); - return new StringEntity(payload, ContentType.APPLICATION_JSON); + + return new StringEntity(objectMapper.valueToTree(data).toString(), ContentType.APPLICATION_JSON); } /*** @@ -516,9 +490,9 @@ public class HandlerUtil { * @param gatewayUrl - gateway endpoint URL * @param httpSession - current active HttpSession * @param resp - HttpServletResponse - * @return {@link JsonObject} of UI configurations + * @return {@link JsonNode} of UI configurations */ - public static JsonObject getUIConfigAndPersistInSession(String uiConfigUrl, String gatewayUrl, HttpSession httpSession, + public static JsonNode getUIConfigAndPersistInSession(String uiConfigUrl, String gatewayUrl, HttpSession httpSession, HttpServletResponse resp) throws IOException { HttpGet uiConfigEndpoint = new HttpGet(uiConfigUrl); ProxyResponse uiConfigResponse = HandlerUtil.execute(uiConfigEndpoint); @@ -529,39 +503,28 @@ public class HandlerUtil { HandlerUtil.handleError(resp, uiConfigResponse); } - if (uiConfigResponse.getData() == null) { + JsonNode responseData = uiConfigResponse.getData(); + if (responseData == null) { log.error("UI config retrieval is failed, and didn't find UI configuration for App manager."); HandlerUtil.handleError(resp, null); - } - JsonParser jsonParser = new JsonParser(); - - JsonElement uiConfigJsonElement = jsonParser.parse(uiConfigResponse.getData()); - JsonObject uiConfigJsonObject = null; - if (uiConfigJsonElement.isJsonObject()) { - uiConfigJsonObject = uiConfigJsonElement.getAsJsonObject(); - if (uiConfigJsonObject == null) { - log.error( - "Either UI config json element is not an json object or converting rom json element to json object is failed."); - HandlerUtil.handleError(resp, null); - } - httpSession.setAttribute(HandlerConstants.UI_CONFIG_KEY, uiConfigJsonObject); + } else { + httpSession.setAttribute(HandlerConstants.UI_CONFIG_KEY, responseData); httpSession.setAttribute(HandlerConstants.PLATFORM, gatewayUrl); } - return uiConfigJsonObject; + return responseData; } /*** * Converts scopes from JsonArray to string with space separated values. * - * @param scopes - scope Json Array and it is retrieved by reading UI config. + * @param scopes - scope Array and it is retrieved by reading UI config. * @return string value of the defined scopes */ - public static String getScopeString(JsonArray scopes) { - if (scopes != null && scopes.size() > 0) { + public static String getScopeString(JsonNode scopes) { + if (scopes != null && scopes.isArray() && !scopes.isEmpty()) { StringBuilder builder = new StringBuilder(); - for (JsonElement scope : scopes) { - String tmpScope = scope.getAsString() + " "; - builder.append(tmpScope); + for (JsonNode objNode : scopes) { + builder.append(objNode).append(" "); } return builder.toString(); } else { @@ -569,35 +532,6 @@ public class HandlerUtil { } } - /*** - * Converts xml file into string. - * - * @param xmlFile - xmlFile which needs to be converted into string. - * @return string value of the xml file. - */ - public static String xmlToString(File xmlFile) { - String stringOutput = null; - - try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = builder.parse(xmlFile); - OutputFormat format = new OutputFormat(doc); - StringWriter stringWriterOutput = new StringWriter(); - XMLSerializer serial = new XMLSerializer(stringWriterOutput, format); - serial.serialize(doc); - stringOutput = stringWriterOutput.toString(); - } catch (IOException e) { - log.error("Error occurred while sending the response into the socket. ", e); - } catch (ParserConfigurationException e) { - log.error("Error while creating the document builder."); - } catch (SAXException e) { - log.error("Error while parsing xml file.", e); - } - - return stringOutput; - } - /*** * Search a key from a given json string object. * @@ -640,11 +574,11 @@ public class HandlerUtil { * Retry request again after refreshing the access token * * @param req incoming {@link HttpServletRequest} - * @param httpRequest subclass of {@link HttpRequestBase} related to the current request. + * @param httpRequest {@link ClassicHttpRequest} related to the current request. * @return {@link ProxyResponse} if successful and null if failed. * @throws IOException If an error occurs when try to retry the request. */ - public static ProxyResponse retryRequestWithRefreshedToken(HttpServletRequest req, HttpRequestBase httpRequest, + public static ProxyResponse retryRequestWithRefreshedToken(HttpServletRequest req, ClassicHttpRequest httpRequest, String apiEndpoint) throws IOException { ProxyResponse retryResponse = refreshToken(req, apiEndpoint); if (isResponseSuccessful(retryResponse)) { @@ -660,7 +594,6 @@ public class HandlerUtil { return proxyResponse; } return proxyResponse; - } return retryResponse; } @@ -682,7 +615,6 @@ public class HandlerUtil { if (session == null) { log.error("Couldn't find a session, hence it is required to login and proceed."); tokenResultResponse = constructProxyResponseByErrorCode(HttpStatus.SC_UNAUTHORIZED); -// handleError(resp, HttpStatus.SC_UNAUTHORIZED); return tokenResultResponse; } @@ -690,23 +622,20 @@ public class HandlerUtil { tokenResultResponse = getTokenResult(authData, keymanagerUrl); if (tokenResultResponse.getExecutorResponse().contains(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)) { log.error("Error occurred while refreshing access token."); -// HandlerUtil.handleError(resp, tokenResultResponse); return tokenResultResponse; } - JsonParser jsonParser = new JsonParser(); - JsonElement jTokenResult = jsonParser.parse(tokenResultResponse.getData()); - - if (jTokenResult.isJsonObject()) { - setNewAuthData(constructAuthDataFromTokenResult(jTokenResult, authData), session); + JsonNode tokenResponse = tokenResultResponse.getData(); + if (tokenResponse != null) { + setNewAuthData(constructAuthDataFromTokenResult(tokenResponse, authData), session); return tokenResultResponse; } log.error("Error Occurred in token renewal process."); tokenResultResponse = constructProxyResponseByErrorCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); -// handleError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR); return tokenResultResponse; } + public static ProxyResponse getTokenResult(AuthData authData, String keymanagerUrl) throws IOException { HttpPost tokenEndpoint = new HttpPost(keymanagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT); StringEntity tokenEndpointPayload = new StringEntity( @@ -726,12 +655,17 @@ public class HandlerUtil { session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, newAuthData); } - public static AuthData constructAuthDataFromTokenResult(JsonElement tokenResult, AuthData authData) { - JsonObject jTokenResultAsJsonObject = tokenResult.getAsJsonObject(); + /** + * Construct {@link AuthData} from token response + * @param tokenResult {@link JsonNode} + * @param authData {@link AuthData} existing auth data values + * @return new {@link AuthData} object + */ + public static AuthData constructAuthDataFromTokenResult(JsonNode tokenResult, AuthData authData) { AuthData newAuthData = new AuthData(); - newAuthData.setAccessToken(jTokenResultAsJsonObject.get("access_token").getAsString()); - newAuthData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); - newAuthData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); + newAuthData.setAccessToken(tokenResult.get("access_token").textValue()); + newAuthData.setRefreshToken(tokenResult.get("refresh_token").textValue()); + newAuthData.setScope(tokenResult.get("scope").textValue()); newAuthData.setClientId(authData.getClientId()); newAuthData.setClientSecret(authData.getClientSecret()); newAuthData.setEncodedClientApp(authData.getEncodedClientApp()); @@ -748,7 +682,7 @@ public class HandlerUtil { * This should be set to false when handling multipart requests as Http * client will generate the Content-Type header automatically. */ - public static void copyRequestHeaders(HttpServletRequest req, HttpRequestBase httpRequest, boolean preserveContentType) { + public static void copyRequestHeaders(HttpServletRequest req, ClassicHttpRequest httpRequest, boolean preserveContentType) { Enumeration headerNames = req.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); @@ -774,18 +708,6 @@ public class HandlerUtil { return headerValue; } - public static String getResponseString(HttpResponse response) throws IOException { - try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) { - StringBuilder responseBuilder = new StringBuilder(); - String line; - while ((line = rd.readLine()) != null) { - responseBuilder.append(line); - } - return responseBuilder.toString(); - } - } - - public static boolean isPropertyDefined(String property) { return StringUtils.isEmpty(System.getProperty(property)); } From 8c841dfc2e19aee1d363642d122f12a2aa6b052e Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Mon, 1 Jan 2024 00:27:07 +0530 Subject: [PATCH 148/343] Fix login handler --- .../ui/request/interceptor/LoginHandler.java | 99 +++++++++---------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index 2286d14c0a..6f38a18014 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; import com.google.gson.*; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; @@ -30,12 +31,12 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.protocol.HTTP; +import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; +import org.apache.hc.core5.http.message.BasicNameValuePair; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -44,7 +45,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; -import java.util.Base64; +import java.util.*; @MultipartConfig @WebServlet("/login") @@ -71,8 +72,8 @@ public class LoginHandler extends HttpServlet { JsonNode uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); - JsonArray tags = uiConfigJsonObject.get("appRegistration").getAsJsonObject().get("tags").getAsJsonArray(); - JsonArray scopes = uiConfigJsonObject.get("scopes").getAsJsonArray(); + ArrayNode tags = (ArrayNode) uiConfigJsonObject.get("appRegistration").get("tags"); + ArrayNode scopes = (ArrayNode) uiConfigJsonObject.get("scopes"); int sessionTimeOut = Integer.parseInt(String.valueOf(uiConfigJsonObject.get("sessionTimeOut"))); //setting session to expire in 1h @@ -84,12 +85,14 @@ public class LoginHandler extends HttpServlet { OAuthApp oAuthApp = loginCache.getOAuthAppCache(oAuthAppCacheKey); if (oAuthApp == null) { - HttpPost apiRegEndpoint = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); - apiRegEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder() - .encodeToString((username + HandlerConstants.COLON + password).getBytes())); - apiRegEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - apiRegEndpoint.setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, - username, password, null, null)); + + ClassicHttpRequest apiRegEndpoint = ClassicRequestBuilder.post(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT) + .setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, + username, password, null, null)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, + org.apache.hc.core5.http.ContentType.APPLICATION_JSON.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder().encodeToString((username + HandlerConstants.COLON + password).getBytes())) + .build(); ProxyResponse clientAppResponse = HandlerUtil.execute(apiRegEndpoint); @@ -99,15 +102,13 @@ public class LoginHandler extends HttpServlet { } if (clientAppResponse.getCode() == HttpStatus.SC_CREATED) { - JsonParser jsonParser = new JsonParser(); - JsonElement jClientAppResult = jsonParser.parse(clientAppResponse.getData()); + JsonNode jsonNode = clientAppResponse.getData(); String clientId = null; String clientSecret = null; String encodedClientApp = null; - if (jClientAppResult.isJsonObject()) { - JsonObject jClientAppResultAsJsonObject = jClientAppResult.getAsJsonObject(); - clientId = jClientAppResultAsJsonObject.get("client_id").getAsString(); - clientSecret = jClientAppResultAsJsonObject.get("client_secret").getAsString(); + if (jsonNode != null) { + clientId = jsonNode.get("client_id").textValue(); + clientSecret = jsonNode.get("client_secret").textValue(); encodedClientApp = Base64.getEncoder() .encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes()); oAuthApp = new OAuthApp( @@ -155,8 +156,7 @@ public class LoginHandler extends HttpServlet { */ private boolean getTokenAndPersistInSession(HttpServletRequest req, HttpServletResponse resp, String clientId, String clientSecret, String encodedClientApp, - JsonArray scopes) throws LoginException { - JsonParser jsonParser = new JsonParser(); + ArrayNode scopes) throws LoginException { try { ProxyResponse tokenResultResponse = getTokenResult(encodedClientApp, scopes); @@ -166,31 +166,26 @@ public class LoginHandler extends HttpServlet { HandlerUtil.handleError(resp, tokenResultResponse); return false; } - String tokenResult = tokenResultResponse.getData(); + JsonNode tokenResult = tokenResultResponse.getData(); if (tokenResult == null) { log.error("Invalid token response is received."); HandlerUtil.handleError(resp, tokenResultResponse); return false; } - JsonElement jTokenResult = jsonParser.parse(tokenResult); - if (jTokenResult.isJsonObject()) { - JsonObject jTokenResultAsJsonObject = jTokenResult.getAsJsonObject(); - HttpSession session = req.getSession(false); - if (session == null) { - return false; - } - AuthData authData = new AuthData(); - authData.setClientId(clientId); - authData.setClientSecret(clientSecret); - authData.setEncodedClientApp(encodedClientApp); - authData.setAccessToken(jTokenResultAsJsonObject.get("access_token").getAsString()); - authData.setRefreshToken(jTokenResultAsJsonObject.get("refresh_token").getAsString()); - authData.setScope(jTokenResultAsJsonObject.get("scope").getAsString()); - session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); - return true; + HttpSession session = req.getSession(false); + if (session == null) { + return false; } - return false; + AuthData authData = new AuthData(); + authData.setClientId(clientId); + authData.setClientSecret(clientSecret); + authData.setEncodedClientApp(encodedClientApp); + authData.setAccessToken(tokenResult.get("access_token").textValue()); + authData.setRefreshToken(tokenResult.get("refresh_token").textValue()); + authData.setScope(tokenResult.get("scope").textValue()); + session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); + return true; } catch (IOException e) { throw new LoginException("Error occurred while sending the response into the socket", e); } @@ -228,22 +223,26 @@ public class LoginHandler extends HttpServlet { * @throws IOException IO exception throws if an error occurred when invoking token endpoint */ private ProxyResponse getTokenResult(String encodedClientApp, JsonNode scopes) throws IOException { - HttpPost tokenEndpoint = new HttpPost(gatewayUrl + HandlerConstants.INTERNAL_TOKEN_ENDPOINT); - tokenEndpoint.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp); - tokenEndpoint.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); String scopeString = HandlerUtil.getScopeString(scopes); - if (scopeString != null) { scopeString = scopeString.trim(); } else { scopeString = "default"; } - StringEntity tokenEPPayload = new StringEntity( - "grant_type=" + HandlerConstants.PASSWORD_GRANT_TYPE + "&username=" + username + "&password=" + - password + "&scope=" + scopeString, - ContentType.APPLICATION_FORM_URLENCODED); - tokenEndpoint.setEntity(tokenEPPayload); + List nameValuePairs = new ArrayList<>(); + nameValuePairs.add(new BasicNameValuePair("grant_type", HandlerConstants.PASSWORD_GRANT_TYPE)); + nameValuePairs.add(new BasicNameValuePair("username", username)); + nameValuePairs.add(new BasicNameValuePair("password", password)); + nameValuePairs.add(new BasicNameValuePair("scope", scopeString)); + + + ClassicHttpRequest tokenEndpoint = ClassicRequestBuilder.post(gatewayUrl + HandlerConstants.INTERNAL_TOKEN_ENDPOINT) + .setEntity(new UrlEncodedFormEntity(nameValuePairs)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, + org.apache.hc.core5.http.ContentType.APPLICATION_FORM_URLENCODED.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientApp) + .build(); return HandlerUtil.execute(tokenEndpoint); } } From 7007558623260020fa4787346ea96e20c6d037d4 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 4 Jan 2024 01:31:38 +0530 Subject: [PATCH 149/343] Fix OTP request handler --- .../interceptor/OTPInvokerHandler.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java index 31d851ec03..bc52456be7 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java @@ -25,8 +25,9 @@ import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.*; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; @@ -51,7 +52,9 @@ public class OTPInvokerHandler extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); +// HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest postRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + , apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, postRequest); ProxyResponse proxyResponse = HandlerUtil.execute(postRequest); @@ -73,7 +76,8 @@ public class OTPInvokerHandler extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpGet getRequest = new HttpGet(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest getRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, getRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(getRequest); @@ -93,7 +97,8 @@ public class OTPInvokerHandler extends HttpServlet { protected void doHead(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpHead headRequest = new HttpHead(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest headRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, headRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(headRequest); @@ -113,7 +118,8 @@ public class OTPInvokerHandler extends HttpServlet { protected void doPut(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpPut putRequest = new HttpPut(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest putRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + , apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, putRequest); ProxyResponse proxyResponse = HandlerUtil.execute(putRequest); @@ -135,7 +141,8 @@ public class OTPInvokerHandler extends HttpServlet { protected void doDelete(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpDelete deleteRequest = new HttpDelete(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest deleteRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, deleteRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest); From 8bf027f2b34aef3c84ea0c042c919b57d456470c Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 4 Jan 2024 02:13:47 +0530 Subject: [PATCH 150/343] Fix invoker handler --- .../request/interceptor/GrafanaHandler.java | 6 ++++-- .../request/interceptor/InvokerHandler.java | 21 ++++++++++++------- .../interceptor/OTPInvokerHandler.java | 9 ++++---- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java index 5fc86acde2..6f8dab9e68 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java @@ -30,6 +30,8 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -68,7 +70,7 @@ public class GrafanaHandler extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpGet grafanaRequest = new HttpGet(); + ClassicHttpRequest grafanaRequest = ClassicRequestBuilder.get().build(); HandlerUtil.copyRequestHeaders(req, grafanaRequest, true); if (!GrafanaUtil.isGrafanaAPI(req.getRequestURI())) { proxyPassGrafanaRequest(grafanaRequest, resp, req); @@ -112,7 +114,7 @@ public class GrafanaHandler extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpPost grafanaRequest = new HttpPost(); + ClassicHttpRequest grafanaRequest = ClassicRequestBuilder.post().build(); HandlerUtil.generateRequestEntity(req, grafanaRequest); HandlerUtil.copyRequestHeaders(req, grafanaRequest, true); if (!GrafanaUtil.isGrafanaAPI(req.getRequestURI())) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java index ed6d636afd..e8ffb2deef 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java @@ -26,9 +26,10 @@ import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.*; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpHeaders; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -58,7 +59,7 @@ public class InvokerHandler extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest postRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, postRequest); postRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(postRequest); @@ -88,7 +89,8 @@ public class InvokerHandler extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpGet getRequest = new HttpGet(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest getRequest = ClassicRequestBuilder.get(HandlerUtil.generateBackendRequestURL(req, + apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, getRequest, false); getRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(getRequest); @@ -123,7 +125,8 @@ public class InvokerHandler extends HttpServlet { protected void doHead(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpHead headRequest = new HttpHead(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest headRequest = ClassicRequestBuilder.head(HandlerUtil.generateBackendRequestURL(req, + apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, headRequest, false); headRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(headRequest); @@ -150,7 +153,8 @@ public class InvokerHandler extends HttpServlet { protected void doPut(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpPut putRequest = new HttpPut(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest putRequest = ClassicRequestBuilder.put(HandlerUtil.generateBackendRequestURL(req, + apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, putRequest); putRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(putRequest); @@ -180,7 +184,8 @@ public class InvokerHandler extends HttpServlet { protected void doDelete(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - HttpDelete deleteRequest = new HttpDelete(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); + ClassicHttpRequest deleteRequest = ClassicRequestBuilder.delete(HandlerUtil.generateBackendRequestURL(req, + apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, deleteRequest, false); deleteRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java index bc52456be7..9e6954fe47 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/OTPInvokerHandler.java @@ -52,7 +52,6 @@ public class OTPInvokerHandler extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { -// HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)); ClassicHttpRequest postRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req , apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, postRequest); @@ -76,7 +75,7 @@ public class OTPInvokerHandler extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - ClassicHttpRequest getRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + ClassicHttpRequest getRequest = ClassicRequestBuilder.get(HandlerUtil.generateBackendRequestURL(req , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, getRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(getRequest); @@ -97,7 +96,7 @@ public class OTPInvokerHandler extends HttpServlet { protected void doHead(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - ClassicHttpRequest headRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + ClassicHttpRequest headRequest = ClassicRequestBuilder.head(HandlerUtil.generateBackendRequestURL(req , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, headRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(headRequest); @@ -118,7 +117,7 @@ public class OTPInvokerHandler extends HttpServlet { protected void doPut(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - ClassicHttpRequest putRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + ClassicHttpRequest putRequest = ClassicRequestBuilder.put(HandlerUtil.generateBackendRequestURL(req , apiEndpoint)).build(); HandlerUtil.generateRequestEntity(req, putRequest); ProxyResponse proxyResponse = HandlerUtil.execute(putRequest); @@ -141,7 +140,7 @@ public class OTPInvokerHandler extends HttpServlet { protected void doDelete(HttpServletRequest req, HttpServletResponse resp) { try { if (validateRequest(req, resp)) { - ClassicHttpRequest deleteRequest = ClassicRequestBuilder.post(HandlerUtil.generateBackendRequestURL(req + ClassicHttpRequest deleteRequest = ClassicRequestBuilder.delete(HandlerUtil.generateBackendRequestURL(req , apiEndpoint)).build(); HandlerUtil.copyRequestHeaders(req, deleteRequest, false); ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest); From 56033e2e3ac57cf138fd80ec1349f3466b5dbad5 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Fri, 5 Jan 2024 07:22:52 +0530 Subject: [PATCH 151/343] Fix build failure --- .../request/interceptor/GrafanaHandler.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java index 6f8dab9e68..414067ff20 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/GrafanaHandler.java @@ -30,14 +30,12 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpHeaders; +import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.*; -import org.apache.http.impl.client.CloseableHttpClient; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -208,10 +206,10 @@ public class GrafanaHandler extends HttpServlet { return true; } - private ProxyResponse executeGrafanaAPIRequest(HttpRequestBase requestBase, HttpServletRequest request) + private ProxyResponse executeGrafanaAPIRequest(ClassicHttpRequest requestBase, HttpServletRequest request) throws IOException { URI grafanaUri = HttpUtil.createURI(generateGrafanaAPIUrl(request)); - requestBase.setURI(grafanaUri); + requestBase.setUri(grafanaUri); return HandlerUtil.execute(requestBase); } @@ -232,14 +230,14 @@ public class GrafanaHandler extends HttpServlet { } return uri; } - private void proxyPassGrafanaRequest(HttpRequestBase requestBase, HttpServletResponse response, + private void proxyPassGrafanaRequest(ClassicHttpRequest requestBase, HttpServletResponse response, HttpServletRequest request) throws IOException { try (CloseableHttpClient client = HandlerUtil.getHttpClient()) { String grafanaUriStr = GrafanaHandlerUtil.generateGrafanaUrl(HttpUtil.createURI(getURIWithQuery(request)), GrafanaUtil.getGrafanaHTTPBase(request.getScheme())); URI grafanaURI = HttpUtil.createURI(grafanaUriStr); - requestBase.setURI(grafanaURI); - HttpResponse grafanaResponse = invokeGrafanaAPI(client, requestBase); + requestBase.setUri(grafanaURI); + CloseableHttpResponse grafanaResponse = invokeGrafanaAPI(client, requestBase); forwardGrafanaResponse(grafanaResponse, response); } catch (GrafanaEnvVariablesNotDefined e) { handleError(response, HttpStatus.SC_INTERNAL_SERVER_ERROR, e.getMessage()); @@ -250,17 +248,19 @@ public class GrafanaHandler extends HttpServlet { } } - private HttpResponse invokeGrafanaAPI(HttpClient client, HttpRequestBase request) throws IOException, GrafanaManagementException { + private CloseableHttpResponse invokeGrafanaAPI(CloseableHttpClient client, ClassicHttpRequest request) throws IOException, + GrafanaManagementException { setBasicAuthHeader(request); + //todo this is deprecated call return client.execute(request); } - private void setBasicAuthHeader(HttpRequestBase request) throws GrafanaManagementException { + private void setBasicAuthHeader(ClassicHttpRequest request) throws GrafanaManagementException { String basicAuth = GrafanaUtil.getBasicAuthBase64Header(); request.setHeader(HttpHeaders.AUTHORIZATION, basicAuth); } - private void forwardGrafanaResponse(HttpResponse grafanaResponse, HttpServletResponse response) throws IOException { + private void forwardGrafanaResponse(CloseableHttpResponse grafanaResponse, HttpServletResponse response) throws IOException { InputStream responseContent = grafanaResponse.getEntity().getContent(); String grafanaContentType = HandlerUtil.getMemeType(grafanaResponse); response.setHeader(HttpHeaders.CONTENT_TYPE, grafanaContentType); From 54ca87c9dbe2c29fceb4bb9730a5b7694d7640de Mon Sep 17 00:00:00 2001 From: pasindu Date: Sun, 7 Jan 2024 07:38:13 +0530 Subject: [PATCH 152/343] Need to fix http client update --- .../JITEnrollmentCallbackHandler.java | 554 +++++++++--------- 1 file changed, 277 insertions(+), 277 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java index 6a82ae3f26..227391e3e3 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java @@ -1,277 +1,277 @@ -/* - * Copyright (c) 2018 - 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.ui.request.interceptor; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITData; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITEnrollmentData; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; -import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.JITEnrollmentException; -import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; -import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.wso2.carbon.utils.CarbonUtils; -import org.xml.sax.SAXException; - -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.File; -import java.io.IOException; -import java.util.Base64; -import java.util.Objects; - -@WebServlet( - name = "JIT Enrollment callback handler", - description = "Call token endpoint and retrieve token", - urlPatterns = { - "/jit-enrollment-callback" - } -) -public class JITEnrollmentCallbackHandler extends HttpServlet { - private static final Log log = LogFactory.getLog(JITEnrollmentCallbackHandler.class); - private String gatewayUrl; - private String keyManagerUrl; - private JITData JITInfo; - private String encodedClientCredentials; - private String applicationName; - private String clientId; - private String clientSecret; - private String scope; - private String JITConfigurationPath; - private JITEnrollmentData JITEnrollmentInfo; - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) { - gatewayUrl = request.getScheme() + HandlerConstants.SCHEME_SEPARATOR - + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getGatewayPort(request.getScheme()); - keyManagerUrl = request.getScheme() + HandlerConstants.SCHEME_SEPARATOR - + System.getProperty(HandlerConstants.IOT_KM_HOST_ENV_VAR) - + HandlerConstants.COLON + HandlerUtil.getKeyManagerPort(request.getScheme()); - JITConfigurationPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + "jit-config.xml"; - HttpSession session = request.getSession(false); - try { - if (session == null) { - response.sendError(HttpStatus.SC_UNAUTHORIZED); - return; - } - - JITInfo = (JITData) session.getAttribute(HandlerConstants.SESSION_JIT_DATA_KEY); - if (JITInfo == null) { - response.sendError(HttpStatus.SC_UNAUTHORIZED); - return; - } - - JITEnrollmentInfo = (JITEnrollmentData) - session.getAttribute(HandlerConstants.SESSION_JIT_ENROLLMENT_DATA_KEY); - if (JITEnrollmentInfo == null) { - response.sendError(HttpStatus.SC_UNAUTHORIZED); - return; - } - applicationName = request.getContextPath().substring(1, - request.getContextPath().indexOf("-ui-request-handler")); - initializeJITEnrollmentConfigurations(); - populateApplicationData(registerApplication()); - persistAuthData(session, getToken()); - response.sendRedirect(JITEnrollmentInfo.getRedirectUrl() + "?ownershipType=" + - JITEnrollmentInfo.getOwnershipType() + "&os=" + JITEnrollmentInfo.getOs() + "&username=" + - JITEnrollmentInfo.getUsername() + "&tenantDomain=" + JITEnrollmentInfo.getTenantDomain()); - } catch (JITEnrollmentException | IOException ex) { - log.error("Error occurred while processing JIT provisioning callback request", ex); - } - } - - private void initializeJITEnrollmentConfigurations() throws JITEnrollmentException { - try { - File JITConfigurationFile = new File(JITConfigurationPath); - DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); - Document JITConfigurationDoc = documentBuilder.parse(JITConfigurationFile); - JITConfigurationDoc.getDocumentElement().normalize(); - Element enrollmentScopes; - if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_ANDROID)) { - enrollmentScopes = (Element) JITConfigurationDoc. - getElementsByTagName(HandlerConstants.TAG_ANDROID_ENROLLMENT_SCOPES).item(0); - } else if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_IOS)) { - enrollmentScopes = (Element) JITConfigurationDoc. - getElementsByTagName(HandlerConstants.TAG_IOS_ENROLLMENT_SCOPES).item(0); - } else if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_WINDOWS)) { - enrollmentScopes = (Element) JITConfigurationDoc. - getElementsByTagName(HandlerConstants.TAG_WINDOWS_ENROLLMENT_SCOPES).item(0); - } else { - String msg = "OS type not supported"; - if (log.isDebugEnabled()) { - log.error(msg); - } - throw new JITEnrollmentException(msg); - } - NodeList scopeList = enrollmentScopes.getElementsByTagName("Scope"); - StringBuilder scopeStr = new StringBuilder(); - for (int idx = 0; idx < scopeList.getLength(); idx++) { - Node scopeNode = scopeList.item(idx); - if (scopeNode.getNodeType() == Node.ELEMENT_NODE) { - Element scopeElement = (Element) scopeNode; - scopeStr.append(" ").append(scopeElement.getTextContent()); - } - } - scope = scopeStr.toString(); - } catch (ParserConfigurationException ex) { - String msg = "Error occurred when document builder creating the file configuration"; - throw new JITEnrollmentException(msg, ex); - } catch (IOException ex) { - String msg = "IO error occurred while parsing the JIT config file"; - throw new JITEnrollmentException(msg, ex); - } catch (SAXException ex) { - String msg = "Parse error occurred while parsing the JIT config document"; - throw new JITEnrollmentException(msg, ex); - } - } - - /*** - * Parse string data and build json object - * @param data - Json string - * @return {@link JsonObject} Json object corresponding to provided json string - * @throws JITEnrollmentException throws when error occurred while parsing - */ - private JsonObject parseResponseData(String data) throws JITEnrollmentException { - JsonParser parser = new JsonParser(); - JsonElement responseData = parser.parse(data); - if (responseData.isJsonObject()) { - return responseData.getAsJsonObject(); - } - throw new JITEnrollmentException("Unexpected response body return"); - } - - /*** - * Build application registration request - * @return {@link HttpPost} Application registration request - */ - private HttpPost buildApplicationRegistrationRequest() { - HttpPost applicationRegistrationRequest = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); - applicationRegistrationRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC - + JITInfo.getEncodedClientCredentials()); - applicationRegistrationRequest.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); - JsonArray tags = new JsonArray(); - tags.add("device_management"); - JsonObject payload = new JsonObject(); - payload.addProperty("applicationName", applicationName); - payload.add("tags", tags); - payload.addProperty("allowedToAllDomains", false); - payload.addProperty("mappingAnExistingOAuthApp", false); - applicationRegistrationRequest.setEntity(new StringEntity(payload.toString(), ContentType.APPLICATION_JSON)); - return applicationRegistrationRequest; - } - - /*** - * Populate dynamic client's data - * @param application - application data receiving from dcr request - */ - private void populateApplicationData(JsonObject application) { - clientId = application.get("client_id").getAsString(); - clientSecret = application.get("client_secret").getAsString(); - String headerValue = clientId+ ':' + clientSecret; - encodedClientCredentials = Base64.getEncoder().encodeToString(headerValue.getBytes()); - } - - /*** - * Register client application - * @return {@link JsonObject} Json object contain registered application data - * @throws JITEnrollmentException throws when error occurred while application registration - */ - private JsonObject registerApplication() throws JITEnrollmentException { - try { - ProxyResponse proxyResponse = HandlerUtil.execute(buildApplicationRegistrationRequest()); - if (proxyResponse.getCode() == HttpStatus.SC_CREATED || - proxyResponse.getCode() == HttpStatus.SC_OK) { - return parseResponseData(proxyResponse.getData()); - } - throw new JITEnrollmentException("Unexpected response status return for application registration request"); - } catch (IOException ex) { - throw new JITEnrollmentException("Error occurred while executing application registration request", ex); - } - } - - /*** - * Acquire token - * @return {@link JsonObject} Json object containing token data - * @throws JITEnrollmentException throws when error occurred while acquiring token - */ - private JsonObject getToken() throws JITEnrollmentException { - try { - ProxyResponse proxyResponse = HandlerUtil.execute(buildTokenAcquireRequest()); - if (proxyResponse.getCode() == org.apache.http.HttpStatus.SC_CREATED || - proxyResponse.getCode() == org.apache.http.HttpStatus.SC_OK) { - return parseResponseData(proxyResponse.getData()); - } - throw new JITEnrollmentException("Unexpected response status return for token acquiring request"); - } catch (IOException ex) { - throw new JITEnrollmentException("Error occurred while executing token acquiring request", ex); - } - } - - /*** - * Build token acquire request - * @return {@link HttpPost} Token acquire request - */ - private HttpPost buildTokenAcquireRequest() { - HttpPost tokenAcquiringRequest = new HttpPost(keyManagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT); - tokenAcquiringRequest.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); - tokenAcquiringRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC - + encodedClientCredentials); - StringEntity payload = new StringEntity( - "grant_type=" + HandlerConstants.CLIENT_CREDENTIAL_GRANT_TYPE + "&scope=" + scope, - ContentType.APPLICATION_FORM_URLENCODED); - tokenAcquiringRequest.setEntity(payload); - return tokenAcquiringRequest; - } - - /*** - * Persists auth data in session - * @param session - {@link HttpSession} - * @param token - Json object containing token data - */ - private void persistAuthData(HttpSession session, JsonObject token) { - AuthData authData = new AuthData(); - authData.setAccessToken(token.get("access_token").getAsString()); - authData.setClientId(clientId); - authData.setClientSecret(clientSecret); - authData.setEncodedClientApp(encodedClientCredentials); - authData.setScope(token.get("scope").getAsString()); - session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); - } -} +///* +// * Copyright (c) 2018 - 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.ui.request.interceptor; +// +//import com.google.gson.JsonArray; +//import com.google.gson.JsonElement; +//import com.google.gson.JsonObject; +//import com.google.gson.JsonParser; +//import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; +//import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITData; +//import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITEnrollmentData; +//import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; +//import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.JITEnrollmentException; +//import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; +//import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; +//import org.apache.commons.httpclient.HttpStatus; +//import org.apache.commons.logging.Log; +//import org.apache.commons.logging.LogFactory; +//import org.apache.http.HttpHeaders; +//import org.apache.http.client.methods.HttpPost; +//import org.apache.http.entity.ContentType; +//import org.apache.http.entity.StringEntity; +//import org.w3c.dom.Document; +//import org.w3c.dom.Element; +//import org.w3c.dom.Node; +//import org.w3c.dom.NodeList; +//import org.wso2.carbon.utils.CarbonUtils; +//import org.xml.sax.SAXException; +// +//import javax.servlet.annotation.WebServlet; +//import javax.servlet.http.HttpServlet; +//import javax.servlet.http.HttpServletRequest; +//import javax.servlet.http.HttpServletResponse; +//import javax.servlet.http.HttpSession; +//import javax.xml.parsers.DocumentBuilder; +//import javax.xml.parsers.DocumentBuilderFactory; +//import javax.xml.parsers.ParserConfigurationException; +//import java.io.File; +//import java.io.IOException; +//import java.util.Base64; +//import java.util.Objects; +// +//@WebServlet( +// name = "JIT Enrollment callback handler", +// description = "Call token endpoint and retrieve token", +// urlPatterns = { +// "/jit-enrollment-callback" +// } +//) +//public class JITEnrollmentCallbackHandler extends HttpServlet { +// private static final Log log = LogFactory.getLog(JITEnrollmentCallbackHandler.class); +// private String gatewayUrl; +// private String keyManagerUrl; +// private JITData JITInfo; +// private String encodedClientCredentials; +// private String applicationName; +// private String clientId; +// private String clientSecret; +// private String scope; +// private String JITConfigurationPath; +// private JITEnrollmentData JITEnrollmentInfo; +// @Override +// protected void doGet(HttpServletRequest request, HttpServletResponse response) { +// gatewayUrl = request.getScheme() + HandlerConstants.SCHEME_SEPARATOR +// + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) +// + HandlerConstants.COLON + HandlerUtil.getGatewayPort(request.getScheme()); +// keyManagerUrl = request.getScheme() + HandlerConstants.SCHEME_SEPARATOR +// + System.getProperty(HandlerConstants.IOT_KM_HOST_ENV_VAR) +// + HandlerConstants.COLON + HandlerUtil.getKeyManagerPort(request.getScheme()); +// JITConfigurationPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + "jit-config.xml"; +// HttpSession session = request.getSession(false); +// try { +// if (session == null) { +// response.sendError(HttpStatus.SC_UNAUTHORIZED); +// return; +// } +// +// JITInfo = (JITData) session.getAttribute(HandlerConstants.SESSION_JIT_DATA_KEY); +// if (JITInfo == null) { +// response.sendError(HttpStatus.SC_UNAUTHORIZED); +// return; +// } +// +// JITEnrollmentInfo = (JITEnrollmentData) +// session.getAttribute(HandlerConstants.SESSION_JIT_ENROLLMENT_DATA_KEY); +// if (JITEnrollmentInfo == null) { +// response.sendError(HttpStatus.SC_UNAUTHORIZED); +// return; +// } +// applicationName = request.getContextPath().substring(1, +// request.getContextPath().indexOf("-ui-request-handler")); +// initializeJITEnrollmentConfigurations(); +// populateApplicationData(registerApplication()); +// persistAuthData(session, getToken()); +// response.sendRedirect(JITEnrollmentInfo.getRedirectUrl() + "?ownershipType=" + +// JITEnrollmentInfo.getOwnershipType() + "&os=" + JITEnrollmentInfo.getOs() + "&username=" + +// JITEnrollmentInfo.getUsername() + "&tenantDomain=" + JITEnrollmentInfo.getTenantDomain()); +// } catch (JITEnrollmentException | IOException ex) { +// log.error("Error occurred while processing JIT provisioning callback request", ex); +// } +// } +// +// private void initializeJITEnrollmentConfigurations() throws JITEnrollmentException { +// try { +// File JITConfigurationFile = new File(JITConfigurationPath); +// DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); +// DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); +// Document JITConfigurationDoc = documentBuilder.parse(JITConfigurationFile); +// JITConfigurationDoc.getDocumentElement().normalize(); +// Element enrollmentScopes; +// if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_ANDROID)) { +// enrollmentScopes = (Element) JITConfigurationDoc. +// getElementsByTagName(HandlerConstants.TAG_ANDROID_ENROLLMENT_SCOPES).item(0); +// } else if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_IOS)) { +// enrollmentScopes = (Element) JITConfigurationDoc. +// getElementsByTagName(HandlerConstants.TAG_IOS_ENROLLMENT_SCOPES).item(0); +// } else if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_WINDOWS)) { +// enrollmentScopes = (Element) JITConfigurationDoc. +// getElementsByTagName(HandlerConstants.TAG_WINDOWS_ENROLLMENT_SCOPES).item(0); +// } else { +// String msg = "OS type not supported"; +// if (log.isDebugEnabled()) { +// log.error(msg); +// } +// throw new JITEnrollmentException(msg); +// } +// NodeList scopeList = enrollmentScopes.getElementsByTagName("Scope"); +// StringBuilder scopeStr = new StringBuilder(); +// for (int idx = 0; idx < scopeList.getLength(); idx++) { +// Node scopeNode = scopeList.item(idx); +// if (scopeNode.getNodeType() == Node.ELEMENT_NODE) { +// Element scopeElement = (Element) scopeNode; +// scopeStr.append(" ").append(scopeElement.getTextContent()); +// } +// } +// scope = scopeStr.toString(); +// } catch (ParserConfigurationException ex) { +// String msg = "Error occurred when document builder creating the file configuration"; +// throw new JITEnrollmentException(msg, ex); +// } catch (IOException ex) { +// String msg = "IO error occurred while parsing the JIT config file"; +// throw new JITEnrollmentException(msg, ex); +// } catch (SAXException ex) { +// String msg = "Parse error occurred while parsing the JIT config document"; +// throw new JITEnrollmentException(msg, ex); +// } +// } +// +// /*** +// * Parse string data and build json object +// * @param data - Json string +// * @return {@link JsonObject} Json object corresponding to provided json string +// * @throws JITEnrollmentException throws when error occurred while parsing +// */ +// private JsonObject parseResponseData(String data) throws JITEnrollmentException { +// JsonParser parser = new JsonParser(); +// JsonElement responseData = parser.parse(data); +// if (responseData.isJsonObject()) { +// return responseData.getAsJsonObject(); +// } +// throw new JITEnrollmentException("Unexpected response body return"); +// } +// +// /*** +// * Build application registration request +// * @return {@link HttpPost} Application registration request +// */ +// private HttpPost buildApplicationRegistrationRequest() { +// HttpPost applicationRegistrationRequest = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); +// applicationRegistrationRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC +// + JITInfo.getEncodedClientCredentials()); +// applicationRegistrationRequest.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); +// JsonArray tags = new JsonArray(); +// tags.add("device_management"); +// JsonObject payload = new JsonObject(); +// payload.addProperty("applicationName", applicationName); +// payload.add("tags", tags); +// payload.addProperty("allowedToAllDomains", false); +// payload.addProperty("mappingAnExistingOAuthApp", false); +// applicationRegistrationRequest.setEntity(new StringEntity(payload.toString(), ContentType.APPLICATION_JSON)); +// return applicationRegistrationRequest; +// } +// +// /*** +// * Populate dynamic client's data +// * @param application - application data receiving from dcr request +// */ +// private void populateApplicationData(JsonObject application) { +// clientId = application.get("client_id").getAsString(); +// clientSecret = application.get("client_secret").getAsString(); +// String headerValue = clientId+ ':' + clientSecret; +// encodedClientCredentials = Base64.getEncoder().encodeToString(headerValue.getBytes()); +// } +// +// /*** +// * Register client application +// * @return {@link JsonObject} Json object contain registered application data +// * @throws JITEnrollmentException throws when error occurred while application registration +// */ +// private JsonObject registerApplication() throws JITEnrollmentException { +// try { +// ProxyResponse proxyResponse = HandlerUtil.execute(buildApplicationRegistrationRequest()); +// if (proxyResponse.getCode() == HttpStatus.SC_CREATED || +// proxyResponse.getCode() == HttpStatus.SC_OK) { +// return parseResponseData(proxyResponse.getData()); +// } +// throw new JITEnrollmentException("Unexpected response status return for application registration request"); +// } catch (IOException ex) { +// throw new JITEnrollmentException("Error occurred while executing application registration request", ex); +// } +// } +// +// /*** +// * Acquire token +// * @return {@link JsonObject} Json object containing token data +// * @throws JITEnrollmentException throws when error occurred while acquiring token +// */ +// private JsonObject getToken() throws JITEnrollmentException { +// try { +// ProxyResponse proxyResponse = HandlerUtil.execute(buildTokenAcquireRequest()); +// if (proxyResponse.getCode() == org.apache.http.HttpStatus.SC_CREATED || +// proxyResponse.getCode() == org.apache.http.HttpStatus.SC_OK) { +// return parseResponseData(proxyResponse.getData().toString()); +// } +// throw new JITEnrollmentException("Unexpected response status return for token acquiring request"); +// } catch (IOException ex) { +// throw new JITEnrollmentException("Error occurred while executing token acquiring request", ex); +// } +// } +// +// /*** +// * Build token acquire request +// * @return {@link HttpPost} Token acquire request +// */ +// private HttpPost buildTokenAcquireRequest() { +// HttpPost tokenAcquiringRequest = new HttpPost(keyManagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT); +// tokenAcquiringRequest.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); +// tokenAcquiringRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC +// + encodedClientCredentials); +// StringEntity payload = new StringEntity( +// "grant_type=" + HandlerConstants.CLIENT_CREDENTIAL_GRANT_TYPE + "&scope=" + scope, +// ContentType.APPLICATION_FORM_URLENCODED); +// tokenAcquiringRequest.setEntity(payload); +// return tokenAcquiringRequest; +// } +// +// /*** +// * Persists auth data in session +// * @param session - {@link HttpSession} +// * @param token - Json object containing token data +// */ +// private void persistAuthData(HttpSession session, JsonObject token) { +// AuthData authData = new AuthData(); +// authData.setAccessToken(token.get("access_token").getAsString()); +// authData.setClientId(clientId); +// authData.setClientSecret(clientSecret); +// authData.setEncodedClientApp(encodedClientCredentials); +// authData.setScope(token.get("scope").getAsString()); +// session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); +// } +//} From b8e8450108378651786eb606da2dd06650cb0d9a Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 11 Jan 2024 04:17:32 +0530 Subject: [PATCH 153/343] Http update fixes --- .../pom.xml | 6 ++++++ .../interceptor/DefaultOauth2TokenHandler.java | 2 +- .../core/ui/request/interceptor/LoginHandler.java | 2 +- .../request/interceptor/PermissionScopeHandler.java | 10 +++++----- .../interceptor/SsoLoginCallbackHandler.java | 2 +- .../core/ui/request/interceptor/UserHandler.java | 4 ++-- .../core/ui/request/interceptor/beans/AuthData.java | 8 +++++--- .../ui/request/interceptor/util/HandlerUtil.java | 13 +++++++++++-- 8 files changed, 32 insertions(+), 15 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 66df853e17..ad7428b8f5 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -154,6 +154,12 @@ org.apache.httpcomponents.client5 httpclient5 + + + org.slf4j + slf4j-api + + org.apache.httpcomponents diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java index b0974a46a5..93cf1b9491 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java @@ -112,7 +112,7 @@ public class DefaultOauth2TokenHandler extends HttpServlet { String defaultToken = tokenResult.get("accessToken").asText(); newDefaultAuthData.setAccessToken(defaultToken); newDefaultAuthData.setRefreshToken(tokenResult.get("refreshToken").asText()); - newDefaultAuthData.setScope(tokenResult.get("scopes").asText()); + newDefaultAuthData.setScope(tokenResult.get("scopes")); httpSession.setAttribute(HandlerConstants.SESSION_DEFAULT_AUTH_DATA_KEY, newDefaultAuthData); HandlerUtil.handleSuccess(resp, constructSuccessProxyResponse(defaultToken)); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index 6f38a18014..d720842b71 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -183,7 +183,7 @@ public class LoginHandler extends HttpServlet { authData.setEncodedClientApp(encodedClientApp); authData.setAccessToken(tokenResult.get("access_token").textValue()); authData.setRefreshToken(tokenResult.get("refresh_token").textValue()); - authData.setScope(tokenResult.get("scope").textValue()); + authData.setScope(tokenResult.get("scope")); session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); return true; } catch (IOException e) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java index 623fd48b87..42b06124f8 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java @@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.HashMap; import java.util.Map; @MultipartConfig @@ -57,14 +58,13 @@ public class PermissionScopeHandler extends HttpServlet { return; } - if (!StringUtils.isEmpty(authData.getScope())) { + if (!StringUtils.isEmpty(authData.getScope().toString())) { ProxyResponse proxyResponse = new ProxyResponse(); + JsonNode authDataScope = authData.getScope(); ObjectMapper mapper = new ObjectMapper(); - JsonNode node = JsonNodeFactory.instance.objectNode(); - Map nodeMap = mapper.convertValue(node, new TypeReference<>() { - }); - nodeMap.put(HandlerConstants.USER_SCOPES, authData.getScope()); + Map nodeMap = new HashMap<>(); + nodeMap.put(HandlerConstants.USER_SCOPES, authDataScope); proxyResponse.setCode(HttpStatus.SC_OK); proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java index ee2b600eb4..2acd5fc167 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginCallbackHandler.java @@ -96,7 +96,7 @@ public class SsoLoginCallbackHandler extends HttpServlet { authData.setEncodedClientApp(session.getAttribute("encodedClientApp").toString()); authData.setAccessToken(jsonNode.get("access_token").textValue()); authData.setRefreshToken(jsonNode.get("refresh_token").textValue()); - authData.setScope(jsonNode.get("scope").textValue()); + authData.setScope(jsonNode.get("scope")); session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); resp.sendRedirect(session.getAttribute("redirectUrl").toString()); } else { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index dd06e5f08c..e67152cd3d 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -129,8 +129,8 @@ public class UserHandler extends HttpServlet { HandlerUtil.handleSuccess(resp, proxyResponse); httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, nodeMap.get("username").toString()); - log.info("Customer login", - userLogContextBuilder.setUserName(nodeMap.get("username").toString()).setUserRegistered(true).build()); +// log.info("Customer login", +// userLogContextBuilder.setUserName(nodeMap.get("username").toString()).setUserRegistered(true).build()); } catch (IOException e) { log.error("Error occurred while sending the response into the socket. ", e); } catch (JsonSyntaxException e) { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/AuthData.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/AuthData.java index 36cb8aea59..a0c057383c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/AuthData.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/AuthData.java @@ -19,6 +19,8 @@ package io.entgra.device.mgt.core.ui.request.interceptor.beans; +import com.fasterxml.jackson.databind.JsonNode; + public class AuthData implements java.io.Serializable { private static final long serialVersionUID = -5156750882531944849L; @@ -29,7 +31,7 @@ public class AuthData implements java.io.Serializable { private String clientId; private String clientSecret; private String encodedClientApp; - private String scope; + private JsonNode scope; public String getAccessToken() { return accessToken; @@ -79,11 +81,11 @@ public class AuthData implements java.io.Serializable { this.encodedClientApp = encodedClientApp; } - public String getScope() { + public JsonNode getScope() { return scope; } - public void setScope(String scope) { + public void setScope(JsonNode scope) { this.scope = scope; } } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index b7a4b4e51c..af1141ceed 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor.util; import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; @@ -264,9 +265,17 @@ public class HandlerUtil { resp.setStatus(proxyResponse.getCode()); resp.setContentType(ContentType.APPLICATION_JSON.getMimeType()); resp.setCharacterEncoding(Consts.UTF_8.name()); + JsonNode responseData = proxyResponse.getData(); + + if (!(responseData == null)) { + ObjectMapper mapper = new ObjectMapper(); + Map newNodeMap = new HashMap<>(); + newNodeMap.put("data", responseData); + responseData = mapper.convertValue(newNodeMap, JsonNode.class); + } try (PrintWriter writer = resp.getWriter()) { - writer.write(proxyResponse.getData().toString()); + writer.write(responseData != null ? responseData.toString() : "{}"); } } @@ -665,7 +674,7 @@ public class HandlerUtil { AuthData newAuthData = new AuthData(); newAuthData.setAccessToken(tokenResult.get("access_token").textValue()); newAuthData.setRefreshToken(tokenResult.get("refresh_token").textValue()); - newAuthData.setScope(tokenResult.get("scope").textValue()); + newAuthData.setScope(tokenResult.get("scope")); newAuthData.setClientId(authData.getClientId()); newAuthData.setClientSecret(authData.getClientSecret()); newAuthData.setEncodedClientApp(authData.getEncodedClientApp()); From 1d0a087734902dc4e1d7c31c34c6ba93dc91d622 Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 12 Jan 2024 14:56:51 +0530 Subject: [PATCH 154/343] Fix JITEnrollmentCallbackHandler bugs after httpclient update --- .../JITEnrollmentCallbackHandler.java | 575 +++++++++--------- 1 file changed, 298 insertions(+), 277 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java index 227391e3e3..d5b25cf701 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java @@ -1,277 +1,298 @@ -///* -// * Copyright (c) 2018 - 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.ui.request.interceptor; -// -//import com.google.gson.JsonArray; -//import com.google.gson.JsonElement; -//import com.google.gson.JsonObject; -//import com.google.gson.JsonParser; -//import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; -//import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITData; -//import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITEnrollmentData; -//import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; -//import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.JITEnrollmentException; -//import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; -//import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; -//import org.apache.commons.httpclient.HttpStatus; -//import org.apache.commons.logging.Log; -//import org.apache.commons.logging.LogFactory; -//import org.apache.http.HttpHeaders; -//import org.apache.http.client.methods.HttpPost; -//import org.apache.http.entity.ContentType; -//import org.apache.http.entity.StringEntity; -//import org.w3c.dom.Document; -//import org.w3c.dom.Element; -//import org.w3c.dom.Node; -//import org.w3c.dom.NodeList; -//import org.wso2.carbon.utils.CarbonUtils; -//import org.xml.sax.SAXException; -// -//import javax.servlet.annotation.WebServlet; -//import javax.servlet.http.HttpServlet; -//import javax.servlet.http.HttpServletRequest; -//import javax.servlet.http.HttpServletResponse; -//import javax.servlet.http.HttpSession; -//import javax.xml.parsers.DocumentBuilder; -//import javax.xml.parsers.DocumentBuilderFactory; -//import javax.xml.parsers.ParserConfigurationException; -//import java.io.File; -//import java.io.IOException; -//import java.util.Base64; -//import java.util.Objects; -// -//@WebServlet( -// name = "JIT Enrollment callback handler", -// description = "Call token endpoint and retrieve token", -// urlPatterns = { -// "/jit-enrollment-callback" -// } -//) -//public class JITEnrollmentCallbackHandler extends HttpServlet { -// private static final Log log = LogFactory.getLog(JITEnrollmentCallbackHandler.class); -// private String gatewayUrl; -// private String keyManagerUrl; -// private JITData JITInfo; -// private String encodedClientCredentials; -// private String applicationName; -// private String clientId; -// private String clientSecret; -// private String scope; -// private String JITConfigurationPath; -// private JITEnrollmentData JITEnrollmentInfo; -// @Override -// protected void doGet(HttpServletRequest request, HttpServletResponse response) { -// gatewayUrl = request.getScheme() + HandlerConstants.SCHEME_SEPARATOR -// + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) -// + HandlerConstants.COLON + HandlerUtil.getGatewayPort(request.getScheme()); -// keyManagerUrl = request.getScheme() + HandlerConstants.SCHEME_SEPARATOR -// + System.getProperty(HandlerConstants.IOT_KM_HOST_ENV_VAR) -// + HandlerConstants.COLON + HandlerUtil.getKeyManagerPort(request.getScheme()); -// JITConfigurationPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + "jit-config.xml"; -// HttpSession session = request.getSession(false); -// try { -// if (session == null) { -// response.sendError(HttpStatus.SC_UNAUTHORIZED); -// return; -// } -// -// JITInfo = (JITData) session.getAttribute(HandlerConstants.SESSION_JIT_DATA_KEY); -// if (JITInfo == null) { -// response.sendError(HttpStatus.SC_UNAUTHORIZED); -// return; -// } -// -// JITEnrollmentInfo = (JITEnrollmentData) -// session.getAttribute(HandlerConstants.SESSION_JIT_ENROLLMENT_DATA_KEY); -// if (JITEnrollmentInfo == null) { -// response.sendError(HttpStatus.SC_UNAUTHORIZED); -// return; -// } -// applicationName = request.getContextPath().substring(1, -// request.getContextPath().indexOf("-ui-request-handler")); -// initializeJITEnrollmentConfigurations(); -// populateApplicationData(registerApplication()); -// persistAuthData(session, getToken()); -// response.sendRedirect(JITEnrollmentInfo.getRedirectUrl() + "?ownershipType=" + -// JITEnrollmentInfo.getOwnershipType() + "&os=" + JITEnrollmentInfo.getOs() + "&username=" + -// JITEnrollmentInfo.getUsername() + "&tenantDomain=" + JITEnrollmentInfo.getTenantDomain()); -// } catch (JITEnrollmentException | IOException ex) { -// log.error("Error occurred while processing JIT provisioning callback request", ex); -// } -// } -// -// private void initializeJITEnrollmentConfigurations() throws JITEnrollmentException { -// try { -// File JITConfigurationFile = new File(JITConfigurationPath); -// DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); -// DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); -// Document JITConfigurationDoc = documentBuilder.parse(JITConfigurationFile); -// JITConfigurationDoc.getDocumentElement().normalize(); -// Element enrollmentScopes; -// if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_ANDROID)) { -// enrollmentScopes = (Element) JITConfigurationDoc. -// getElementsByTagName(HandlerConstants.TAG_ANDROID_ENROLLMENT_SCOPES).item(0); -// } else if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_IOS)) { -// enrollmentScopes = (Element) JITConfigurationDoc. -// getElementsByTagName(HandlerConstants.TAG_IOS_ENROLLMENT_SCOPES).item(0); -// } else if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_WINDOWS)) { -// enrollmentScopes = (Element) JITConfigurationDoc. -// getElementsByTagName(HandlerConstants.TAG_WINDOWS_ENROLLMENT_SCOPES).item(0); -// } else { -// String msg = "OS type not supported"; -// if (log.isDebugEnabled()) { -// log.error(msg); -// } -// throw new JITEnrollmentException(msg); -// } -// NodeList scopeList = enrollmentScopes.getElementsByTagName("Scope"); -// StringBuilder scopeStr = new StringBuilder(); -// for (int idx = 0; idx < scopeList.getLength(); idx++) { -// Node scopeNode = scopeList.item(idx); -// if (scopeNode.getNodeType() == Node.ELEMENT_NODE) { -// Element scopeElement = (Element) scopeNode; -// scopeStr.append(" ").append(scopeElement.getTextContent()); -// } -// } -// scope = scopeStr.toString(); -// } catch (ParserConfigurationException ex) { -// String msg = "Error occurred when document builder creating the file configuration"; -// throw new JITEnrollmentException(msg, ex); -// } catch (IOException ex) { -// String msg = "IO error occurred while parsing the JIT config file"; -// throw new JITEnrollmentException(msg, ex); -// } catch (SAXException ex) { -// String msg = "Parse error occurred while parsing the JIT config document"; -// throw new JITEnrollmentException(msg, ex); -// } -// } -// -// /*** -// * Parse string data and build json object -// * @param data - Json string -// * @return {@link JsonObject} Json object corresponding to provided json string -// * @throws JITEnrollmentException throws when error occurred while parsing -// */ -// private JsonObject parseResponseData(String data) throws JITEnrollmentException { -// JsonParser parser = new JsonParser(); -// JsonElement responseData = parser.parse(data); -// if (responseData.isJsonObject()) { -// return responseData.getAsJsonObject(); -// } -// throw new JITEnrollmentException("Unexpected response body return"); -// } -// -// /*** -// * Build application registration request -// * @return {@link HttpPost} Application registration request -// */ -// private HttpPost buildApplicationRegistrationRequest() { -// HttpPost applicationRegistrationRequest = new HttpPost(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT); -// applicationRegistrationRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC -// + JITInfo.getEncodedClientCredentials()); -// applicationRegistrationRequest.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString()); -// JsonArray tags = new JsonArray(); -// tags.add("device_management"); -// JsonObject payload = new JsonObject(); -// payload.addProperty("applicationName", applicationName); -// payload.add("tags", tags); -// payload.addProperty("allowedToAllDomains", false); -// payload.addProperty("mappingAnExistingOAuthApp", false); -// applicationRegistrationRequest.setEntity(new StringEntity(payload.toString(), ContentType.APPLICATION_JSON)); -// return applicationRegistrationRequest; -// } -// -// /*** -// * Populate dynamic client's data -// * @param application - application data receiving from dcr request -// */ -// private void populateApplicationData(JsonObject application) { -// clientId = application.get("client_id").getAsString(); -// clientSecret = application.get("client_secret").getAsString(); -// String headerValue = clientId+ ':' + clientSecret; -// encodedClientCredentials = Base64.getEncoder().encodeToString(headerValue.getBytes()); -// } -// -// /*** -// * Register client application -// * @return {@link JsonObject} Json object contain registered application data -// * @throws JITEnrollmentException throws when error occurred while application registration -// */ -// private JsonObject registerApplication() throws JITEnrollmentException { -// try { -// ProxyResponse proxyResponse = HandlerUtil.execute(buildApplicationRegistrationRequest()); -// if (proxyResponse.getCode() == HttpStatus.SC_CREATED || -// proxyResponse.getCode() == HttpStatus.SC_OK) { -// return parseResponseData(proxyResponse.getData()); -// } -// throw new JITEnrollmentException("Unexpected response status return for application registration request"); -// } catch (IOException ex) { -// throw new JITEnrollmentException("Error occurred while executing application registration request", ex); -// } -// } -// -// /*** -// * Acquire token -// * @return {@link JsonObject} Json object containing token data -// * @throws JITEnrollmentException throws when error occurred while acquiring token -// */ -// private JsonObject getToken() throws JITEnrollmentException { -// try { -// ProxyResponse proxyResponse = HandlerUtil.execute(buildTokenAcquireRequest()); -// if (proxyResponse.getCode() == org.apache.http.HttpStatus.SC_CREATED || -// proxyResponse.getCode() == org.apache.http.HttpStatus.SC_OK) { -// return parseResponseData(proxyResponse.getData().toString()); -// } -// throw new JITEnrollmentException("Unexpected response status return for token acquiring request"); -// } catch (IOException ex) { -// throw new JITEnrollmentException("Error occurred while executing token acquiring request", ex); -// } -// } -// -// /*** -// * Build token acquire request -// * @return {@link HttpPost} Token acquire request -// */ -// private HttpPost buildTokenAcquireRequest() { -// HttpPost tokenAcquiringRequest = new HttpPost(keyManagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT); -// tokenAcquiringRequest.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()); -// tokenAcquiringRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC -// + encodedClientCredentials); -// StringEntity payload = new StringEntity( -// "grant_type=" + HandlerConstants.CLIENT_CREDENTIAL_GRANT_TYPE + "&scope=" + scope, -// ContentType.APPLICATION_FORM_URLENCODED); -// tokenAcquiringRequest.setEntity(payload); -// return tokenAcquiringRequest; -// } -// -// /*** -// * Persists auth data in session -// * @param session - {@link HttpSession} -// * @param token - Json object containing token data -// */ -// private void persistAuthData(HttpSession session, JsonObject token) { -// AuthData authData = new AuthData(); -// authData.setAccessToken(token.get("access_token").getAsString()); -// authData.setClientId(clientId); -// authData.setClientSecret(clientSecret); -// authData.setEncodedClientApp(encodedClientCredentials); -// authData.setScope(token.get("scope").getAsString()); -// session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); -// } -//} +/* + * Copyright (c) 2018 - 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.ui.request.interceptor; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITData; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITEnrollmentData; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; +import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.JITEnrollmentException; +import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; +import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; +import org.apache.hc.core5.http.message.BasicNameValuePair; +import org.apache.http.HttpHeaders; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.wso2.carbon.utils.CarbonUtils; +import org.xml.sax.SAXException; + +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.io.IOException; +import java.util.*; + +@WebServlet( + name = "JIT Enrollment callback handler", + description = "Call token endpoint and retrieve token", + urlPatterns = { + "/jit-enrollment-callback" + } +) +public class JITEnrollmentCallbackHandler extends HttpServlet { + private static final Log log = LogFactory.getLog(JITEnrollmentCallbackHandler.class); + private String gatewayUrl; + private String keyManagerUrl; + private JITData JITInfo; + private String encodedClientCredentials; + private String applicationName; + private String clientId; + private String clientSecret; + private String scope; + private String JITConfigurationPath; + private JITEnrollmentData JITEnrollmentInfo; + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) { + gatewayUrl = request.getScheme() + HandlerConstants.SCHEME_SEPARATOR + + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR) + + HandlerConstants.COLON + HandlerUtil.getGatewayPort(request.getScheme()); + keyManagerUrl = request.getScheme() + HandlerConstants.SCHEME_SEPARATOR + + System.getProperty(HandlerConstants.IOT_KM_HOST_ENV_VAR) + + HandlerConstants.COLON + HandlerUtil.getKeyManagerPort(request.getScheme()); + JITConfigurationPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + "jit-config.xml"; + HttpSession session = request.getSession(false); + try { + if (session == null) { + response.sendError(HttpStatus.SC_UNAUTHORIZED); + return; + } + + JITInfo = (JITData) session.getAttribute(HandlerConstants.SESSION_JIT_DATA_KEY); + if (JITInfo == null) { + response.sendError(HttpStatus.SC_UNAUTHORIZED); + return; + } + + JITEnrollmentInfo = (JITEnrollmentData) + session.getAttribute(HandlerConstants.SESSION_JIT_ENROLLMENT_DATA_KEY); + if (JITEnrollmentInfo == null) { + response.sendError(HttpStatus.SC_UNAUTHORIZED); + return; + } + applicationName = request.getContextPath().substring(1, + request.getContextPath().indexOf("-ui-request-handler")); + initializeJITEnrollmentConfigurations(); + populateApplicationData(registerApplication()); + persistAuthData(session, getToken()); + response.sendRedirect(JITEnrollmentInfo.getRedirectUrl() + "?ownershipType=" + + JITEnrollmentInfo.getOwnershipType() + "&os=" + JITEnrollmentInfo.getOs() + "&username=" + + JITEnrollmentInfo.getUsername() + "&tenantDomain=" + JITEnrollmentInfo.getTenantDomain()); + } catch (JITEnrollmentException | IOException ex) { + log.error("Error occurred while processing JIT provisioning callback request", ex); + } + } + + private void initializeJITEnrollmentConfigurations() throws JITEnrollmentException { + try { + File JITConfigurationFile = new File(JITConfigurationPath); + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); + Document JITConfigurationDoc = documentBuilder.parse(JITConfigurationFile); + JITConfigurationDoc.getDocumentElement().normalize(); + Element enrollmentScopes; + if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_ANDROID)) { + enrollmentScopes = (Element) JITConfigurationDoc. + getElementsByTagName(HandlerConstants.TAG_ANDROID_ENROLLMENT_SCOPES).item(0); + } else if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_IOS)) { + enrollmentScopes = (Element) JITConfigurationDoc. + getElementsByTagName(HandlerConstants.TAG_IOS_ENROLLMENT_SCOPES).item(0); + } else if (Objects.equals(JITEnrollmentInfo.getOs(), HandlerConstants.OS_WINDOWS)) { + enrollmentScopes = (Element) JITConfigurationDoc. + getElementsByTagName(HandlerConstants.TAG_WINDOWS_ENROLLMENT_SCOPES).item(0); + } else { + String msg = "OS type not supported"; + if (log.isDebugEnabled()) { + log.error(msg); + } + throw new JITEnrollmentException(msg); + } + NodeList scopeList = enrollmentScopes.getElementsByTagName("Scope"); + StringBuilder scopeStr = new StringBuilder(); + for (int idx = 0; idx < scopeList.getLength(); idx++) { + Node scopeNode = scopeList.item(idx); + if (scopeNode.getNodeType() == Node.ELEMENT_NODE) { + Element scopeElement = (Element) scopeNode; + scopeStr.append(" ").append(scopeElement.getTextContent()); + } + } + scope = scopeStr.toString(); + } catch (ParserConfigurationException ex) { + String msg = "Error occurred when document builder creating the file configuration"; + throw new JITEnrollmentException(msg, ex); + } catch (IOException ex) { + String msg = "IO error occurred while parsing the JIT config file"; + throw new JITEnrollmentException(msg, ex); + } catch (SAXException ex) { + String msg = "Parse error occurred while parsing the JIT config document"; + throw new JITEnrollmentException(msg, ex); + } + } + + /*** + * Parse string data and build json object + * @param data - Json string + * @return {@link JsonObject} Json object corresponding to provided json string + * @throws JITEnrollmentException throws when error occurred while parsing + */ + private JsonNode parseResponseData(String data) throws JITEnrollmentException { + + JsonFactory jsonFactory = new JsonFactory(); + ObjectMapper objectMapper = new ObjectMapper(jsonFactory); + try { + return objectMapper.readTree(data); + } catch (JsonProcessingException e) { + throw new JITEnrollmentException("Unexpected response body return"); + } + } + + /*** + * Build application registration request + * @return {@link HttpPost} Application registration request + */ + private ClassicHttpRequest buildApplicationRegistrationRequest() { + + JsonArray tags = new JsonArray(); + tags.add("device_management"); + + ObjectMapper objectMapper = new ObjectMapper(); + Map payload = new HashMap<>(); + + payload.put("applicationName", applicationName); + payload.put("tags", tags); + payload.put("allowedToAllDomains", false); + payload.put("mappingAnExistingOAuthApp", false); + + ClassicHttpRequest applicationRegistrationRequest = ClassicRequestBuilder.post(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT) + .setEntity(new org.apache.hc.core5.http.io.entity.StringEntity(objectMapper.valueToTree(payload).toString(), + org.apache.hc.core5.http.ContentType.APPLICATION_JSON)) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, + org.apache.hc.core5.http.ContentType.APPLICATION_JSON.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + + JITInfo.getEncodedClientCredentials()) + .build(); + return applicationRegistrationRequest; + } + + /*** + * Populate dynamic client's data + * @param application - application data receiving from dcr request + */ + private void populateApplicationData(JsonNode application) { + clientId = application.get("client_id").asText(); + clientSecret = application.get("client_secret").asText(); + String headerValue = clientId + ':' + clientSecret; + encodedClientCredentials = Base64.getEncoder().encodeToString(headerValue.getBytes()); + } + + /*** + * Register client application + * @return {@link JsonObject} Json object contain registered application data + * @throws JITEnrollmentException throws when error occurred while application registration + */ + private JsonNode registerApplication() throws JITEnrollmentException { + try { + ProxyResponse proxyResponse = HandlerUtil.execute(buildApplicationRegistrationRequest()); + if (proxyResponse.getCode() == HttpStatus.SC_CREATED || + proxyResponse.getCode() == HttpStatus.SC_OK) { + return parseResponseData(proxyResponse.getData().toString()); + } + throw new JITEnrollmentException("Unexpected response status return for application registration request"); + } catch (IOException ex) { + throw new JITEnrollmentException("Error occurred while executing application registration request", ex); + } + } + + /*** + * Acquire token + * @return {@link JsonObject} Json object containing token data + * @throws JITEnrollmentException throws when error occurred while acquiring token + */ + private JsonNode getToken() throws JITEnrollmentException { + try { + ProxyResponse proxyResponse = HandlerUtil.execute(buildTokenAcquireRequest()); + if (proxyResponse.getCode() == org.apache.http.HttpStatus.SC_CREATED || + proxyResponse.getCode() == org.apache.http.HttpStatus.SC_OK) { + return parseResponseData(proxyResponse.getData().toString()); + } + throw new JITEnrollmentException("Unexpected response status return for token acquiring request"); + } catch (IOException ex) { + throw new JITEnrollmentException("Error occurred while executing token acquiring request", ex); + } + } + + /*** + * Build token acquire request + * @return {@link HttpPost} Token acquire request + */ + private ClassicHttpRequest buildTokenAcquireRequest() { + + StringEntity payload = new StringEntity( + "grant_type=" + HandlerConstants.CLIENT_CREDENTIAL_GRANT_TYPE + "&scope=" + scope, + ContentType.APPLICATION_FORM_URLENCODED); + + ClassicHttpRequest tokenAcquiringRequest = ClassicRequestBuilder.post(keyManagerUrl + HandlerConstants.OAUTH2_TOKEN_ENDPOINT) + .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.toString()) + .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + encodedClientCredentials) + .setEntity(new org.apache.hc.core5.http.io.entity.StringEntity(payload.toString(), org.apache.hc.core5.http.ContentType.APPLICATION_JSON)) + .build(); + return tokenAcquiringRequest; + } + + /*** + * Persists auth data in session + * @param session - {@link HttpSession} + * @param token - Json object containing token data + */ + private void persistAuthData(HttpSession session, JsonNode token) { + AuthData authData = new AuthData(); + authData.setAccessToken(token.get("access_token").asText()); + authData.setClientId(clientId); + authData.setClientSecret(clientSecret); + authData.setEncodedClientApp(encodedClientCredentials); + authData.setScope(token.get("scope")); + session.setAttribute(HandlerConstants.SESSION_AUTH_DATA_KEY, authData); + } +} From 5ad0734b7b0ad3fbbf8892d71b59da7545c51cfc Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 19 Jan 2024 11:53:10 +0530 Subject: [PATCH 155/343] Fix import issue in webapp publisher --- .../pom.xml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 07b5a31897..c99ad0899a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -170,10 +170,7 @@ com.google.gson;version="[2.9,3)", com.google.gson.reflect;version="[2.9,3)", io.entgra.device.mgt.core.apimgt.annotations;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.extension.rest.api;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.extension.rest.api.dto;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.apimgt.extension.rest.api.*, io.entgra.device.mgt.core.apimgt.webapp.publisher.config, io.entgra.device.mgt.core.apimgt.webapp.publisher.dto, io.entgra.device.mgt.core.apimgt.webapp.publisher.exception, From cc21c661ae99fb0d023a7c86dddaa27f2e4e8f38 Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 22 Jan 2024 09:02:54 +0530 Subject: [PATCH 156/343] Fix UI issue from interceptor side --- .../mgt/core/ui/request/interceptor/UserHandler.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index 8ef651c3bb..c608585ac4 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -50,7 +50,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Base64; import java.util.List; -import java.util.Map; @MultipartConfig @WebServlet("/user") @@ -122,13 +121,11 @@ public class UserHandler extends HttpServlet { proxyResponse.setCode(HttpStatus.SC_OK); ObjectMapper mapper = new ObjectMapper(); - Map nodeMap = mapper.convertValue(tokenData, new TypeReference<>() { - }); - nodeMap.put("username", tokenData.get("username").textValue().replaceAll("@carbon.super", "")); - proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); + String data = tokenData.get("username").textValue().replaceAll("@carbon.super", ""); + proxyResponse.setData(mapper.convertValue(data, JsonNode.class)); HandlerUtil.handleSuccess(resp, proxyResponse); - httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, nodeMap.get("username").toString()); + httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, tokenData.get("username").toString()); log.info( "User " + proxyResponse.getData() + " logged in", userLoginLogContextBuilder From e2f2237b2ddc1c3a9539d7d818033f25b7dd72b2 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 1 Feb 2024 01:49:49 +0530 Subject: [PATCH 157/343] Fix log class loading issue --- .../pom.xml | 1 - .../pom.xml | 1 - .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 1 - .../pom.xml | 1 - .../io.entgra.device.mgt.core.notification.logger/pom.xml | 4 ++-- 5 files changed, 2 insertions(+), 6 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 08c184a676..9ec44fb8e0 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -131,7 +131,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon.identity.inbound.auth.oauth2 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 6bcad291c4..87b20c6188 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -55,7 +55,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon.apimgt diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 6d697f1055..6689068e68 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -158,7 +158,6 @@ org.ops4j.pax.logging pax-logging-api provided - io.entgra.device.mgt.core diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index ce7fb6b507..314beb5e65 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -62,7 +62,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.wso2.carbon diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 8af7693b98..bd9e2df05f 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -79,8 +79,8 @@ io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="[5.0,6)", io.entgra.device.mgt.core.notification.logger, io.entgra.device.mgt.core.notification.logger.util, - org.apache.commons.logging;version="[1.2,2)" - + org.apache.commons.logging;version="[1.2,2)", + pax-logging-api io.entgra.device.mgt.core.notification.logger.* From 94905d020d190a70979a5089193a2d9a666781c9 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 1 Feb 2024 15:55:46 +0530 Subject: [PATCH 158/343] Fix custom log printing issue --- .../pom.xml | 18 +++++++++++------- .../impl/EntgraAppInstallLoggerImpl.java | 3 ++- .../EntgraDeviceConnectivityLoggerImpl.java | 3 ++- .../impl/EntgraDeviceEnrolmentLoggerImpl.java | 3 ++- .../logger/impl/EntgraDeviceLoggerImpl.java | 3 ++- .../logger/impl/EntgraGroupMgtLoggerImpl.java | 3 ++- .../logger/impl/EntgraPolicyLoggerImpl.java | 3 ++- .../logger/impl/EntgraRoleMgtLoggerImpl.java | 3 ++- .../logger/impl/EntgraUserLoginLoggerImpl.java | 2 +- .../logger/impl/EntgraUserMgtLoggerImpl.java | 3 ++- .../logger/util/MDCContextUtil.java | 6 +++--- .../pom.xml | 2 +- 12 files changed, 32 insertions(+), 20 deletions(-) diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index bd9e2df05f..d04ffa9e13 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -35,7 +35,7 @@ org.ops4j.pax.logging pax-logging-api - provided + org.testng @@ -45,6 +45,11 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.extensions.logger + + org.slf4j + slf4j-ext + 1.7.29 + @@ -58,7 +63,6 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 1.8 @@ -75,12 +79,13 @@ ${io.entgra.device.mgt.core.version} Device Notification Logger Bundle - io.entgra.device.mgt.core.device.mgt.extensions.logger;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="[5.0,6)", io.entgra.device.mgt.core.notification.logger, io.entgra.device.mgt.core.notification.logger.util, - org.apache.commons.logging;version="[1.2,2)", - pax-logging-api + io.entgra.device.mgt.core.device.mgt.extensions.logger;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="[5.0,6)", + org.slf4j, + org.slf4j.ext, + org.apache.commons.logging;version="[1.2,2)" io.entgra.device.mgt.core.notification.logger.* @@ -90,5 +95,4 @@ - \ No newline at end of file diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java index 81f071c2af..e5b9fff02b 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraAppInstallLoggerImpl.java @@ -23,7 +23,8 @@ import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; +import org.slf4j.MDC; + public class EntgraAppInstallLoggerImpl implements EntgraLogger { diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java index aaa62bf488..b928be9583 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceConnectivityLoggerImpl.java @@ -23,7 +23,8 @@ import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContex import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; +import org.slf4j.MDC; + public class EntgraDeviceConnectivityLoggerImpl implements EntgraLogger { diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java index db0b7dd265..acd32c8947 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceEnrolmentLoggerImpl.java @@ -23,7 +23,8 @@ import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext; import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; +import org.slf4j.MDC; + public class EntgraDeviceEnrolmentLoggerImpl implements EntgraLogger { diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java index a51987463f..1ef664a750 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraDeviceLoggerImpl.java @@ -23,7 +23,8 @@ import io.entgra.device.mgt.core.notification.logger.DeviceLogContext; import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; +import org.slf4j.MDC; + public class EntgraDeviceLoggerImpl implements EntgraLogger { diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraGroupMgtLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraGroupMgtLoggerImpl.java index e845acc2d2..7672e65ec1 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraGroupMgtLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraGroupMgtLoggerImpl.java @@ -23,7 +23,8 @@ import io.entgra.device.mgt.core.notification.logger.GroupMgtLogContext; import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; +import org.slf4j.MDC; + public class EntgraGroupMgtLoggerImpl implements EntgraLogger { diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java index 218252f260..3511b94036 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraPolicyLoggerImpl.java @@ -23,7 +23,8 @@ import io.entgra.device.mgt.core.notification.logger.PolicyLogContext; import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; +import org.slf4j.MDC; + public class EntgraPolicyLoggerImpl implements EntgraLogger { diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraRoleMgtLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraRoleMgtLoggerImpl.java index 3e3a831466..67855c0e21 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraRoleMgtLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraRoleMgtLoggerImpl.java @@ -23,7 +23,8 @@ import io.entgra.device.mgt.core.notification.logger.RoleMgtLogContext; import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; +import org.slf4j.MDC; + public class EntgraRoleMgtLoggerImpl implements EntgraLogger { diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoginLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoginLoggerImpl.java index 087fc45eec..292a1a68c7 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoginLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoginLoggerImpl.java @@ -23,7 +23,7 @@ import io.entgra.device.mgt.core.notification.logger.UserLoginLogContext; import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; +import org.slf4j.MDC; public class EntgraUserLoginLoggerImpl implements EntgraLogger { diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserMgtLoggerImpl.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserMgtLoggerImpl.java index fe9fd0ee01..7470eab617 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserMgtLoggerImpl.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserMgtLoggerImpl.java @@ -23,7 +23,8 @@ import io.entgra.device.mgt.core.notification.logger.UserMgtLogContext; import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.MDC; +import org.slf4j.MDC; + public class EntgraUserMgtLoggerImpl implements EntgraLogger { diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java index 1c9afa6948..4ec012e0ca 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/util/MDCContextUtil.java @@ -18,8 +18,8 @@ package io.entgra.device.mgt.core.notification.logger.util; import io.entgra.device.mgt.core.notification.logger.*; -import org.apache.log4j.MDC; - +import org.slf4j.MDC; +// public final class MDCContextUtil { public static void populateDeviceMDCContext(final DeviceLogContext mdcContext) { @@ -54,7 +54,7 @@ public final class MDCContextUtil { MDC.put("IsUserRegistered", "Registered"); } if (mdcContext.isDeviceRegistered()) { - MDC.put("IsDeviceRegistered", mdcContext.isDeviceRegistered()); + MDC.put("IsDeviceRegistered", String.valueOf(mdcContext.isDeviceRegistered())); } if (mdcContext.getTenantDomain() != null) { MDC.put("TenantDomain", mdcContext.getTenantDomain()); diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index e0a5acd7ae..dbcbe8d7f7 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -40,7 +40,7 @@ org.ops4j.pax.logging pax-logging-api - provided + org.testng From 86f78f0a86faee92e8d285d8dcadbbe15ae063e6 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 1 Feb 2024 20:01:48 +0530 Subject: [PATCH 159/343] Fix Role Management Service loger issues --- .../impl/RoleManagementServiceImpl.java | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java index a568035d4b..36258afa62 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -427,6 +427,16 @@ public class RoleManagementServiceImpl implements RoleManagementService { public Response addRole(RoleInfo roleInfo) { RequestValidationUtil.validateRoleDetails(roleInfo); RequestValidationUtil.validateRoleName(roleInfo.getRoleName()); + + String role; + String[] roles = roleInfo.getRoleName().split("/"); + + if (roles.length > 1) { + role = roleInfo.getRoleName().split("/")[1]; + } else { + role = roleInfo.getRoleName().split("/")[0]; + } + try { String tenantId = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); String tenantDomain = String.valueOf(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain()); @@ -436,6 +446,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { log.debug("Persisting the role in the underlying user store"); } + Permission[] permissions = null; if (roleInfo.getPermissions() != null && roleInfo.getPermissions().length > 0) { permissions = new Permission[roleInfo.getPermissions().length]; @@ -458,11 +469,11 @@ public class RoleManagementServiceImpl implements RoleManagementService { } String stringUsers = new Gson().toJson(roleInfo.getUsers()); log.info( - "Role " + roleInfo.getRoleName().split("/")[1] + " created", + "Role " + role + " created", roleMgtContextBuilder .setActionTag("ADD_ROLE") .setUserStoreDomain(roleInfo.getRoleName().split("/")[0]) - .setRoleName(roleInfo.getRoleName().split("/")[1]) + .setRoleName(role) .setUsers(stringUsers) .setTenantID(tenantId) .setTenantDomain(tenantDomain) @@ -481,8 +492,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { errorCode = e.getMessage().split("-")[0].trim(); } if (ErrorMessages.ERROR_CODE_ROLE_ALREADY_EXISTS.getCode().equals(errorCode)) { - String roleName = roleInfo.getRoleName().split("/")[1]; - String msg = "Role already exists with name : " + roleName + ". Try with another role name."; + String msg = "Role already exists with name : " + role + ". Try with another role name."; log.warn(msg); return Response.status(Response.Status.CONFLICT).entity(msg).build(); } else { @@ -609,12 +619,22 @@ public class RoleManagementServiceImpl implements RoleManagementService { updatePermissions(roleDetails[roleDetails.length - 1], roleInfo, userRealm); } String stringUsers = new Gson().toJson(roleInfo.getUsers()); + + String role; + String[] roles = roleInfo.getRoleName().split("/"); + + if (roles.length > 1) { + role = roleInfo.getRoleName().split("/")[1]; + } else { + role = roleInfo.getRoleName().split("/")[0]; + } + log.info( - "Role " + roleInfo.getRoleName().split("/")[1] + " updated", + "Role " + role + " updated", roleMgtContextBuilder .setActionTag("UPDATE_ROLE") .setUserStoreDomain(roleInfo.getRoleName().split("/")[0]) - .setRoleName(roleInfo.getRoleName().split("/")[1]) + .setRoleName(role) .setUsers(stringUsers) .setTenantID(tenantId) .setTenantDomain(tenantDomain) @@ -671,12 +691,21 @@ public class RoleManagementServiceImpl implements RoleManagementService { log.debug("Deleting the role in user store"); } DeviceMgtAPIUtils.getGroupManagementProviderService().deleteRoleAndRoleGroupMapping(roleName, roleToDelete, tenantId, userStoreManager, authorizationManager); + String role; + String[] roles = roleName.split("/"); + + if (roles.length > 1) { + role = roleName.split("/")[1]; + } else { + role = roleName.split("/")[0]; + } + log.info( - "Role " + roleName.split("/")[1] + " deleted", + "Role " + role + " deleted", roleMgtContextBuilder .setActionTag("DELETE_ROLE") .setUserStoreDomain(userStoreName) - .setRoleName(roleName.split("/")[1]) + .setRoleName(role) .setTenantID(String.valueOf(tenantId)) .setTenantDomain(tenantDomain) .setUserName(userName) From f7f0a4a2a4663ffeebd98e72ee7128d9b6e45f85 Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 2 Feb 2024 23:46:47 +0530 Subject: [PATCH 160/343] Fix user scopes payload issue --- .../core/ui/request/interceptor/PermissionScopeHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java index 42b06124f8..b6e6ddd293 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java @@ -63,8 +63,8 @@ public class PermissionScopeHandler extends HttpServlet { JsonNode authDataScope = authData.getScope(); ObjectMapper mapper = new ObjectMapper(); - Map nodeMap = new HashMap<>(); - nodeMap.put(HandlerConstants.USER_SCOPES, authDataScope); + Map nodeMap = new HashMap<>(); + nodeMap.put(HandlerConstants.USER_SCOPES, authDataScope.asText().replace("\"", "")); proxyResponse.setCode(HttpStatus.SC_OK); proxyResponse.setStatus(ProxyResponse.Status.SUCCESS); proxyResponse.setData(mapper.convertValue(nodeMap, JsonNode.class)); From d9381953733a8ce800926d1733504dda460e1a9b Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 5 Feb 2024 19:55:18 +0530 Subject: [PATCH 161/343] Fix osgi reference addings in Service components --- .../APIIntegrationClientServiceComponent.java | 21 ++++---- .../CEAManagementServiceComponent.java | 48 +++++++++-------- .../internal/EnforcementServiceComponent.java | 35 +++++++------ .../pom.xml | 5 ++ ...DeviceOrganizationMgtServiceComponent.java | 51 ++++++++++--------- .../UserStoreRoleMappingServiceComponent.java | 46 +++++++++-------- .../DataPublisherServiceComponent.java | 7 ++- .../OAuthAuthenticatorServiceComponent.java | 21 ++++---- 8 files changed, 129 insertions(+), 105 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java index babfad55d9..8343372d54 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java @@ -27,19 +27,14 @@ import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; -/** - * @scr.component name="org.wso2.carbon.api.integration.client" immediate="true" - * @scr.reference name="api.integration.client.service" - * interface="io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService" - * cardinality="1..1" - * policy="dynamic" - * bind="setJWTClientManagerService" - * unbind="unsetJWTClientManagerService" - */ +@Component( + name = "org.wso2.carbon.api.integration.client", + immediate = true) public class APIIntegrationClientServiceComponent { private static Log log = LogFactory.getLog(APIIntegrationClientServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { try { if (log.isDebugEnabled()) { @@ -59,10 +54,18 @@ public class APIIntegrationClientServiceComponent { } } + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } + @Reference( + name = "api.integration.client.service", + service = org.wso2.carbon.apimgt.impl.APIManagerConfigurationService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + bind = "setJWTClientManagerService", + unbind = "unsetJWTClientManagerService") protected void setJWTClientManagerService(JWTClientManagerService jwtClientManagerService) { if (jwtClientManagerService != null) { log.debug("jwtClientManagerService service is initialized"); diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/src/main/java/io/entgra/device/mgt/core/cea/mgt/core/internal/CEAManagementServiceComponent.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/src/main/java/io/entgra/device/mgt/core/cea/mgt/core/internal/CEAManagementServiceComponent.java index 624391eb7c..007134a78d 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/src/main/java/io/entgra/device/mgt/core/cea/mgt/core/internal/CEAManagementServiceComponent.java +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/src/main/java/io/entgra/device/mgt/core/cea/mgt/core/internal/CEAManagementServiceComponent.java @@ -29,34 +29,17 @@ import io.entgra.device.mgt.core.cea.mgt.core.task.CEAPolicyMonitoringTaskManage import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.ntask.core.service.TaskService; -/** - * @scr.component name="io.entgra.device.mgt.core.cea.mgt.core.CEAManagementServiceComponent" immediate="true" - * @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="io.entgra.device.mgt.core.cea.mgt.enforcementServiceManager" - * interface="io.entgra.device.mgt.core.cea.mgt.common.service.EnforcementServiceManager" - * cardinality="1..1" - * policy="dynamic" - * bind="setEnforcementServiceManager" - * unbind="unsetEnforcementServiceManager" - * @scr.reference name="ntask.component" - * interface="org.wso2.carbon.ntask.core.service.TaskService" - * cardinality="1..1" - * policy="dynamic" - * bind="setTaskService" - * unbind="unsetTaskService" - */ - +@Component( + name = "io.entgra.device.mgt.core.cea.mgt.core.CEAManagementServiceComponent", + immediate = true) public class CEAManagementServiceComponent { private static final Log log = LogFactory.getLog(CEAManagementServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { try { CEAConfigManager ceaConfigManager = CEAConfigManager.getInstance(); @@ -72,6 +55,13 @@ public class CEAManagementServiceComponent { } } + @Reference( + name = "org.wso2.carbon.ndatasource", + service = org.wso2.carbon.ndatasource.core.DataSourceService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + bind = "setDataSourceService", + unbind = "unsetDataSourceService") protected void setDataSourceService(DataSourceService dataSourceService) { // This is to avoid cea management component getting initialized before the underlying datasource registered } @@ -80,6 +70,13 @@ public class CEAManagementServiceComponent { // Do nothing } + @Reference( + name = "io.entgra.device.mgt.core.cea.mgt.enforcementServiceManager", + service = io.entgra.device.mgt.core.cea.mgt.common.service.EnforcementServiceManager.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + bind = "setEnforcementServiceManager", + unbind = "unsetEnforcementServiceManager") protected void setEnforcementServiceManager(EnforcementServiceManager enforcementServiceManager) { CEAManagementDataHolder.getInstance().setEnforcementServiceManager(enforcementServiceManager); if (log.isDebugEnabled()) { @@ -94,6 +91,13 @@ public class CEAManagementServiceComponent { } } + @Reference( + name = "ntask.component", + service = org.wso2.carbon.ntask.core.service.TaskService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + bind = "setTaskService", + unbind = "unsetTaskService") protected void setTaskService(TaskService taskService) { CEAManagementDataHolder.getInstance().setTaskService(taskService); if (log.isDebugEnabled()) { diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/src/main/java/io/entgra/device/mgt/core/cea/mgt/enforce/internal/EnforcementServiceComponent.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/src/main/java/io/entgra/device/mgt/core/cea/mgt/enforce/internal/EnforcementServiceComponent.java index d890eb62f0..29e69dcfd9 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/src/main/java/io/entgra/device/mgt/core/cea/mgt/enforce/internal/EnforcementServiceComponent.java +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/src/main/java/io/entgra/device/mgt/core/cea/mgt/enforce/internal/EnforcementServiceComponent.java @@ -25,27 +25,16 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.user.core.service.RealmService; -/** - * @scr.component name="io.entgra.device.mgt.core.cea.mgt.enforcementServiceManager" immediate="true" - * @scr.reference name="org.wso2.carbon.device.manager" - * interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDeviceManagementServiceProviderService" - * unbind="unsetDeviceManagementServiceProviderService" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - */ - +@Component( + name = "io.entgra.device.mgt.core.cea.mgt.enforcementServiceManager", + immediate = true) public class EnforcementServiceComponent { private static final Log log = LogFactory.getLog(EnforcementServiceComponent.class); + @Activate protected void activate(ComponentContext componentContext) { try { EnforcementServiceManager enforcementServiceManager = new EnforcementServiceManagerImpl(); @@ -60,6 +49,13 @@ public class EnforcementServiceComponent { } } + @Reference( + name = "org.wso2.carbon.device.manager", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + bind = "setDeviceManagementServiceProviderService", + unbind = "unsetDeviceManagementServiceProviderService") protected void setDeviceManagementServiceProviderService(DeviceManagementProviderService deviceManagementProviderService) { EnforcementServiceComponentDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); if (log.isDebugEnabled()) { @@ -74,6 +70,13 @@ public class EnforcementServiceComponent { } } + @Reference( + name = "user.realmservice.default", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + bind = "setRealmService", + unbind = "unsetRealmService") protected void setRealmService(RealmService realmService) { EnforcementServiceComponentDataHolder.getInstance().setRealmService(realmService); if (log.isDebugEnabled()) { diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index 77aa526c4e..79dd397d74 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -95,6 +95,11 @@ + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon org.wso2.carbon.ndatasource.core diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/internal/DeviceOrganizationMgtServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/internal/DeviceOrganizationMgtServiceComponent.java index b7a84ca31a..0cf012c990 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/internal/DeviceOrganizationMgtServiceComponent.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/internal/DeviceOrganizationMgtServiceComponent.java @@ -31,28 +31,11 @@ import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; +import org.osgi.service.component.annotations.*; -/** - * @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.device.organization.internal.DeviceOrganizationMgtServiceComponent" immediate="true" - * @scr.reference name="org.wso2.carbon.device.manager" - * interface="io.entgra.device.mgt.core.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" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.extensions.device.organization.internal.DeviceOrganizationMgtServiceComponent", + immediate = true) public class DeviceOrganizationMgtServiceComponent { private static final Log log = LogFactory.getLog(DeviceOrganizationMgtServiceComponent.class); @@ -60,6 +43,7 @@ public class DeviceOrganizationMgtServiceComponent { /** * @param componentContext */ + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { @@ -87,6 +71,7 @@ public class DeviceOrganizationMgtServiceComponent { /** * @param componentContext */ + @Deactivate protected void deactivate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("De-activating Device Organization Management Service Component"); @@ -94,6 +79,13 @@ public class DeviceOrganizationMgtServiceComponent { } @SuppressWarnings("unused") + @Reference( + name = "org.wso2.carbon.device.manager", + service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + bind = "setDeviceManagementService", + unbind = "unsetDeviceManagementService") protected void setDeviceManagementService(DeviceManagementProviderService deviceManagementProviderService) { if (log.isDebugEnabled()) { log.debug("Setting Device Management Service to Device Organization Mgt SC"); @@ -112,6 +104,14 @@ public class DeviceOrganizationMgtServiceComponent { /** * @param dataSourceService */ + + @Reference( + name = "org.wso2.carbon.ndatasource", + service = org.wso2.carbon.ndatasource.core.DataSourceService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + bind = "setDataSourceService", + unbind = "unsetDataSourceService") protected void setDataSourceService(DataSourceService dataSourceService) { if (log.isDebugEnabled()) { log.debug("Data source service set to Device Organization Mgt component"); @@ -128,7 +128,13 @@ public class DeviceOrganizationMgtServiceComponent { } } - + @Reference( + name = "registry.service", + service = org.wso2.carbon.registry.core.service.RegistryService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + bind = "setRegistryService", + unbind = "unsetRegistryService") protected void setRegistryService(RegistryService registryService) { if (log.isDebugEnabled()) { log.debug("RegistryService set to Device Organization Mgt component"); @@ -143,5 +149,4 @@ public class DeviceOrganizationMgtServiceComponent { DeviceOrganizationMgtDataHolder.getInstance().setRegistryService(null); } - } diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java index 2471c18403..9e2c3ae1e0 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/userstore/role/mapper/internal/UserStoreRoleMappingServiceComponent.java @@ -25,36 +25,19 @@ 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.osgi.service.component.annotations.*; import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.ConfigurationContextService; -/** - * @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal.UserStoreRoleMappingServiceComponent" - * immediate="true" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" - * policy="dynamic" - * bind="setRealmService" - * unbind="unsetRealmService" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" - * policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - * @scr.reference name="entgra.heart.beat.service" - * interface="io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService" - * cardinality="0..1" - * policy="dynamic" - * bind="setHeartBeatService" - * unbind="unsetHeartBeatService" - */ +@Component( + name = "io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal.UserStoreRoleMappingServiceComponent", + immediate = true) public class UserStoreRoleMappingServiceComponent { private static final Log log = LogFactory.getLog(UserStoreRoleMappingServiceComponent.class); + @Activate protected void activate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("Activating Role Management Service Component"); @@ -72,12 +55,19 @@ public class UserStoreRoleMappingServiceComponent { } } + @Deactivate protected void deactivate(ComponentContext ctx) { if (log.isDebugEnabled()) { log.debug("De-activating Role Manager Service Component"); } } + @Reference( + name = "user.realmservice.default", + service = org.wso2.carbon.user.core.service.RealmService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetRealmService") protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { if (log.isDebugEnabled()) { log.debug("Setting ConfigurationContextService"); @@ -86,6 +76,12 @@ public class UserStoreRoleMappingServiceComponent { UserStoreRoleMappingDataHolder.getInstance().setConfigurationContextService(configurationContextService); } + @Reference( + name = "config.context.service", + service = org.wso2.carbon.utils.ConfigurationContextService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetConfigurationContextService") protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) { if (log.isDebugEnabled()) { log.debug("Un-setting ConfigurationContextService"); @@ -118,6 +114,12 @@ public class UserStoreRoleMappingServiceComponent { } @SuppressWarnings("unused") + @Reference( + name = "entgra.heart.beat.service", + service = io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService.class, + cardinality = ReferenceCardinality.OPTIONAL, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetHeartBeatService") protected void setHeartBeatService(HeartBeatManagementService heartBeatService) { if (log.isDebugEnabled()) { log.debug("Setting heart beat service"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java index fe2cad0ea1..0e83028553 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java @@ -27,10 +27,9 @@ import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfi import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherServiceImpl; -/** - * @scr.component name="org.wso2.carbon.device.mgt.analytics.data.publisher.internal.DataPublisherServiceComponent" - * immediate="true" - */ +@Component( + name = "org.wso2.carbon.device.mgt.analytics.data.publisher.internal.DataPublisherServiceComponent", + immediate = true) public class DataPublisherServiceComponent { private ServiceRegistration analyticsServiceRef; diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java index 0da3fa41ef..c4ec7e8aa1 100755 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java @@ -26,20 +26,15 @@ import org.wso2.carbon.core.services.authentication.CarbonServerAuthenticator; import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticator; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; -/** - * @scr.component name="org.wso2.carbon.identity.backend.oauth.authenticator" immediate="true" - * @scr.reference name="identity.oauth2.validation.service" - * interface="org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService" - * cardinality="1..1" - * policy="dynamic" - * bind="setOAuth2ValidationService" - * unbind="unsetOAuth2ValidationService" - */ +@Component( + name = "org.wso2.carbon.identity.backend.oauth.authenticator", + immediate = true) public class OAuthAuthenticatorServiceComponent { private static final Log log = LogFactory.getLog(OAuthAuthenticatorServiceComponent.class); @SuppressWarnings("unused") + @Activate protected void activate(ComponentContext componentContext) { if (log.isDebugEnabled()) { log.debug("Starting Backend OAuthAuthenticator Framework Bundle"); @@ -47,6 +42,7 @@ public class OAuthAuthenticatorServiceComponent { } @SuppressWarnings("unused") + @Deactivate protected void deactivate(ComponentContext componentContext) { //do nothing } @@ -57,6 +53,13 @@ public class OAuthAuthenticatorServiceComponent { * @param tokenValidationService An instance of OAuth2TokenValidationService. */ @SuppressWarnings("unused") + @Reference( + name = "identity.oauth2.validation.service", + service = org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + bind = "setOAuth2ValidationService", + unbind = "unsetOAuth2ValidationService") protected void setOAuth2ValidationService(OAuth2TokenValidationService tokenValidationService) { if (log.isDebugEnabled()) { log.debug("Setting OAuth2TokenValidationService Service"); From 1a9782c3f350ecf6288ecc8eda46a94956c5c18f Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 6 Feb 2024 14:58:39 +0530 Subject: [PATCH 162/343] Fix dependency issues --- .../pom.xml | 10 ++-- .../pom.xml | 34 +++++++++++++ .../pom.xml | 24 ++++++--- .../pom.xml | 50 ++++++++++++++++--- .../pom.xml | 6 +-- .../pom.xml | 30 ++++++----- 6 files changed, 117 insertions(+), 37 deletions(-) diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index 239156f4d9..fde5124a37 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -156,11 +156,11 @@ - - org.wso2.carbon - org.wso2.carbon.logging - provided - + + + + + io.swagger swagger-jaxrs diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index f2649e8498..d74ae06662 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -35,6 +35,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-scr-plugin @@ -59,6 +67,32 @@ + + 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 + + + + diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index a3954bbef3..ab6ecb71e1 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -38,6 +38,14 @@ org.apache.felix maven-scr-plugin + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-bundle-plugin @@ -73,14 +81,14 @@ - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - + + + + + + + + org.wso2.carbon org.wso2.carbon.utils diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index ffa7a98455..1e5507acdf 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -38,6 +38,14 @@ org.apache.felix maven-scr-plugin + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + org.apache.felix maven-bundle-plugin @@ -68,18 +76,44 @@ + + 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.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - + + + + + + + + com.google.code.gson gson diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index 21fd9d2457..13f3859a47 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -180,8 +180,8 @@ - org.wso2.carbon - org.wso2.carbon.logging + org.ops4j.pax.logging + pax-logging-api provided @@ -315,7 +315,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index 79dd397d74..3de4acb1f7 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -130,16 +130,16 @@ - - org.eclipse.osgi - org.eclipse.osgi - provided - - - org.eclipse.osgi - org.eclipse.osgi.services - provided - + + + + + + + + + + @@ -265,7 +265,7 @@ org.powermock - powermock-api-mockito + powermock-api-mockito2 test @@ -309,7 +309,7 @@ test - javax.xml.bind + org.wso2.orbit.javax.xml.bind jaxb-api test @@ -320,6 +320,10 @@ org.apache.maven.plugins maven-compiler-plugin + + 1.8 + 1.8 + org.apache.felix @@ -371,7 +375,7 @@ com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.annotation.*, - com.google.common.cache.*, + com.google.common.cache.* From 14554ba1616dfc658dc97e5303e891f9913f3889 Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 8 Feb 2024 13:25:44 +0530 Subject: [PATCH 163/343] Fix sql issues --- .../carbon-home/dbscripts/dm-db-h2.sql | 64 +++++++++---------- .../resources/carbon-home/dbscripts/h2.sql | 4 +- .../conf/datasources/data-source-config.xml | 2 +- .../datasource/data-source-config-mock.xml | 2 +- .../data-source-config-no-table.xml | 2 +- .../config/datasource/data-source-config.xml | 2 +- .../resources/carbon-home/dbscripts/h2.sql | 19 +++--- .../src/main/resources/dbscripts/cdm/h2.sql | 4 +- pom.xml | 2 +- 9 files changed, 51 insertions(+), 50 deletions(-) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 158615a137..5b2f7147fc 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -65,7 +65,7 @@ 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_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -209,17 +209,17 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT, + ID INT 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, + TENANT_ID INT NOT NULL, + PROFILE_ID INT NOT NULL, OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY @@ -231,11 +231,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY 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, + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_ID INT NOT NULL, + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL, + POLICY_ID INT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID) @@ -251,9 +251,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL, + ID INT NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - POLICY_ID INT(11) NOT NULL, + POLICY_ID INT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID) @@ -264,11 +264,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL, + TENANT_ID INT NOT NULL, CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -280,11 +280,11 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION ( - ID INT(11) NOT NULL AUTO_INCREMENT, + ID INT 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, + CORRECTIVE_POLICY_ID INT DEFAULT NULL, + POLICY_ID INT NOT NULL, + FEATURE_ID INT DEFAULT NULL, IS_REACTIVE BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (ID), CONSTRAINT FK_DM_POLICY_DM_POLICY_CORRECTIVE_ACTION @@ -296,9 +296,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CORRECTIVE_ACTION CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT, + ID INT NOT NULL AUTO_INCREMENT, ROLE_NAME VARCHAR(45) NOT NULL, - POLICY_ID INT(11) NOT NULL, + POLICY_ID INT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID) @@ -324,11 +324,11 @@ 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, POLICY_CONTENT BLOB NULL, TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL, + APPLIED TINYINT NULL, CREATED_TIME TIMESTAMP NULL, UPDATED_TIME TIMESTAMP NULL, APPLIED_TIME TIMESTAMP NULL, @@ -385,7 +385,7 @@ 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, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -401,7 +401,7 @@ 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, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -432,7 +432,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -504,7 +504,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, ALTITUDE DOUBLE NULL, SPEED FLOAT NULL, BEARING FLOAT NULL, @@ -542,8 +542,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL 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, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -570,7 +570,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_HISTORY_LAST_SEVEN_DAYS LONGITUDE DOUBLE NULL, SPEED FLOAT NULL, HEADING FLOAT NULL, - TIMESTAMP BIGINT(15) NOT NULL, + TIMESTAMP BIGINT NOT NULL, GEO_HASH VARCHAR(45) NULL, DEVICE_OWNER VARCHAR(45) NULL, DEVICE_ALTITUDE DOUBLE NULL, @@ -876,8 +876,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_ORGANIZATION ( ORGANIZATION_ID INT NOT NULL AUTO_INCREMENT, TENANT_ID INT DEFAULT 0, - DEVICE_ID INT(11) NOT NULL, - PARENT_DEVICE_ID INT(11) DEFAULT NULL, + DEVICE_ID INT NOT NULL, + PARENT_DEVICE_ID INT DEFAULT NULL, DEVICE_ORGANIZATION_META TEXT DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, PRIMARY KEY (ORGANIZATION_ID), diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/h2.sql b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/h2.sql index d89dfd584b..e738decf52 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/h2.sql +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/h2.sql @@ -22,8 +22,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_ORGANIZATION ( ORGANIZATION_ID INT NOT NULL AUTO_INCREMENT, TENANT_ID INT DEFAULT 0, - DEVICE_ID INT(11) NOT NULL, - PARENT_DEVICE_ID INT(11) DEFAULT NULL, + DEVICE_ID INT NOT NULL, + PARENT_DEVICE_ID INT DEFAULT NULL, DEVICE_ORGANIZATION_META TEXT DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, PRIMARY KEY (ORGANIZATION_ID), diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index a9c81a4710..a237b9af1d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -17,7 +17,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config-mock.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config-mock.xml index 383fc72b75..04445b6397 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config-mock.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config-mock.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE io.entgra.device.mgt.core.device.mgt.extensions.device.organization.mock.MockJDBCDriver wso2carbon wso2carbon diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config-no-table.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config-no-table.xml index b28626efe7..71e35416f3 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config-no-table.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config-no-table.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:nodb-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:nodb-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config.xml index 27b6dfeaeb..533fd82959 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/config/datasource/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql index f3f22f381c..4069c6580a 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/h2.sql @@ -27,17 +27,18 @@ PRIMARY KEY (`SUB_TYPE_ID`,`DEVICE_TYPE`) ); -- SUB_OPERATION_TEMPLATE TABLE-- -CREATE TABLE SUB_OPERATION_TEMPLATE ( - SUB_OPERATION_TEMPLATE_ID int NOT NULL AUTO_INCREMENT, +CREATE TABLE IF NOT EXISTS SUB_OPERATION_TEMPLATE ( + SUB_OPERATION_TEMPLATE_ID INT NOT NULL AUTO_INCREMENT, OPERATION_DEFINITION TEXT NOT NULL, - OPERATION_CODE varchar(100) NOT NULL, - SUB_TYPE_ID int NOT NULL, - DEVICE_TYPE VARCHAR(25) NOT NULL, - CREATE_TIMESTAMP timestamp NULL DEFAULT NULL, - UPDATE_TIMESTAMP timestamp NULL DEFAULT NULL, + OPERATION_CODE VARCHAR (100) NOT NULL, + SUB_TYPE_ID INT NOT NULL, + DEVICE_TYPE VARCHAR (25) NOT NULL, + CREATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, + UPDATE_TIMESTAMP TIMESTAMP NULL DEFAULT NULL, PRIMARY KEY (SUB_OPERATION_TEMPLATE_ID), - UNIQUE KEY SUB_OPERATION_TEMPLATE (SUB_TYPE_ID,OPERATION_CODE, DEVICE_TYPE), - CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) + UNIQUE (SUB_TYPE_ID,OPERATION_CODE, DEVICE_TYPE), + CONSTRAINT fk_SUB_OPERATION_TEMPLATE_DM_DEVICE_SUB_TYPE FOREIGN KEY (SUB_TYPE_ID, DEVICE_TYPE) + REFERENCES DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, DEVICE_TYPE) ); -- ----------------------------------------------------- -- Sample data for test cases diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 5193c625aa..ff71e3be1b 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -846,8 +846,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_ORGANIZATION ( ORGANIZATION_ID INT NOT NULL AUTO_INCREMENT, TENANT_ID INT DEFAULT 0, - DEVICE_ID INT(11) NOT NULL, - PARENT_DEVICE_ID INT(11) DEFAULT NULL, + DEVICE_ID INT NOT NULL, + PARENT_DEVICE_ID INT DEFAULT NULL, DEVICE_ORGANIZATION_META TEXT DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, PRIMARY KEY (ORGANIZATION_ID), diff --git a/pom.xml b/pom.xml index dc824216fb..044319b315 100644 --- a/pom.xml +++ b/pom.xml @@ -2194,7 +2194,7 @@ 2.23.4 2.8.1.wso2v2 4.3.1.wso2v1 - 2.1.210.wso2v1 + 2.1.214.wso2v1 1.1.3 1.11.2 From 47bc27a36d7b24e285bdc24061274ef7a177852c Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 15 Feb 2024 15:18:40 +0530 Subject: [PATCH 164/343] Minor fixes in application registration flow --- .../extension/APIManagementProviderServiceImpl.java | 12 +++++++----- .../keymgt/extension/service/KeyMgtServiceImpl.java | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index 837a1b902c..d3f54d1247 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -112,12 +112,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } Map uniqueApiSet = new HashMap<>(); - for (String tag : tags) { - Map queryParams = new HashMap<>(); - queryParams.put("tag", tag); + if (tags != null) { + for (String tag : tags) { + Map queryParams = new HashMap<>(); + queryParams.put("tag", tag); - APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(apiApplicationInfo, queryParams, headerParams); - Arrays.stream(apiInfos).forEach(apiInfo -> uniqueApiSet.putIfAbsent(apiInfo.getName(), apiInfo)); + APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(apiApplicationInfo, queryParams, headerParams); + Arrays.stream(apiInfos).forEach(apiInfo -> uniqueApiSet.putIfAbsent(apiInfo.getName(), apiInfo)); + } } List uniqueApiList = new ArrayList<>(uniqueApiSet.values()); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index 5afd9dbc65..b6e1e70ca4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -135,7 +135,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { //todo --> can use requestingUserAccessToken token here to get application data - modify getApplication // method signature - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = getApplication(clientName, owner); + io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = + getApplication(clientName, requestingUserAccessToken); String applicationUUID = application.getApplicationId(); // do app key mapping From b6c4cb66f5dbe9793c381dd92cb5b7b86f525253 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Sat, 3 Feb 2024 00:23:41 +0530 Subject: [PATCH 165/343] Improve logger dependencies --- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 4 +--- .../pom.xml | 2 +- pom.xml | 6 ++++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 97e20fdbbd..03bf590308 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -35,7 +35,7 @@ org.ops4j.pax.logging pax-logging-api - + provided org.testng @@ -48,7 +48,6 @@ org.slf4j slf4j-ext - 1.7.29 @@ -84,7 +83,6 @@ io.entgra.device.mgt.core.device.mgt.extensions.logger;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="[5.0,6)", org.slf4j, - org.slf4j.ext, org.apache.commons.logging;version="[1.2,2)" diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index da195dae26..70bea2ba1d 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -40,7 +40,7 @@ org.ops4j.pax.logging pax-logging-api - + provided org.testng diff --git a/pom.xml b/pom.xml index 044319b315..4b34fddaf4 100644 --- a/pom.xml +++ b/pom.xml @@ -1823,6 +1823,11 @@ org.apache.felix.scr.ds-annotations ${apache.felix.scr.ds.annotations.version} + + org.slf4j + slf4j-ext + ${slf4j.ext.version} + @@ -2173,6 +2178,7 @@ 2.0.2 1.4.0.wso2v1 1.7.25 + 1.7.29 1.21 From fdf5c622040902de1ea995fcabc9f7c11c8fddd7 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 20 Feb 2024 15:38:10 +0530 Subject: [PATCH 166/343] Fix scope issue with code grant type --- .../mgt/core/ui/request/interceptor/util/HandlerUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index af1141ceed..3fe3bb381a 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -533,7 +533,7 @@ public class HandlerUtil { if (scopes != null && scopes.isArray() && !scopes.isEmpty()) { StringBuilder builder = new StringBuilder(); for (JsonNode objNode : scopes) { - builder.append(objNode).append(" "); + builder.append(objNode.asText()).append(" "); } return builder.toString(); } else { From 6b79abeaeba747ea226c5676ed5979fe0a8832ed Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 26 Feb 2024 20:21:01 +0530 Subject: [PATCH 167/343] Fix Osgi issues --- .../internal/APIManagerServiceComponent.java | 2 +- .../org.wso2.carbon.apimgt.handlers/pom.xml | 4 -- .../pom.xml | 13 +++--- .../APIIntegrationClientServiceComponent.java | 1 + .../pom.xml | 4 -- .../pom.xml | 17 +++----- .../pom.xml | 9 +++-- .../pom.xml | 4 ++ .../pom.xml | 4 -- .../pom.xml | 11 ++--- .../pom.xml | 13 ++---- .../DataPublisherServiceComponent.java | 1 + .../pom.xml | 13 +++--- .../OAuthAuthenticatorServiceComponent.java | 1 + .../pom.xml | 4 -- pom.xml | 40 ++++++++++++++++++- 16 files changed, 80 insertions(+), 61 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/internal/APIManagerServiceComponent.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/APIManagerServiceComponent.java index 51fbdc912e..69015d5697 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/internal/APIManagerServiceComponent.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/APIManagerServiceComponent.java @@ -32,7 +32,7 @@ import org.osgi.service.component.annotations.*; import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; @Component( - name = "io.entgra.device.mgt.core.apimgt.extension.rest.api.internal.PublisherRESTAPIServiceComponent", + name = "io.entgra.device.mgt.core.apimgt.extension.rest.api.internal.APIManagerServiceComponent", immediate = true) public class APIManagerServiceComponent { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml index c1cfef2e3e..d31e7093e5 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml @@ -65,10 +65,6 @@ - - org.apache.felix - maven-scr-plugin - org.apache.felix maven-bundle-plugin diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 8620769238..51b9f17fcb 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -34,10 +34,6 @@ - - org.apache.felix - maven-scr-plugin - org.apache.felix maven-bundle-plugin @@ -54,8 +50,8 @@ !org.wso2.carbon.apimgt.integration.client.internal - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", feign, feign.codec, feign.auth, @@ -126,6 +122,11 @@ + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + com.squareup.okhttp3 okhttp diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java index 8343372d54..536a5e6c34 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java @@ -25,6 +25,7 @@ import org.osgi.service.component.ComponentContext; import org.wso2.carbon.apimgt.integration.client.IntegrationClientServiceImpl; import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; +import org.osgi.service.component.annotations.*; import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; @Component( diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index d74ae06662..582e766c04 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -43,10 +43,6 @@ 1.8 - - org.apache.felix - maven-scr-plugin - org.apache.felix maven-bundle-plugin diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index ab6ecb71e1..8d9fc5a86c 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -34,10 +34,6 @@ - - org.apache.felix - maven-scr-plugin - org.apache.maven.plugins maven-compiler-plugin @@ -81,14 +77,11 @@ - - - - - - - - + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon org.wso2.carbon.utils diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index 1e5507acdf..c623d45b07 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -34,10 +34,6 @@ - - org.apache.felix - maven-scr-plugin - org.apache.maven.plugins maven-compiler-plugin @@ -106,6 +102,11 @@ + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 8765bab195..9fa160fe27 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -128,6 +128,10 @@ + + org.wso2.orbit.com.fasterxml.jackson.core + jackson-annotations + org.springframework spring-web diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index 3de4acb1f7..144145dceb 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -325,10 +325,6 @@ 1.8 - - org.apache.felix - maven-scr-plugin - org.apache.felix maven-bundle-plugin diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 4cc4db9df3..7f8b9e1131 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -36,16 +36,12 @@ - org.apache.felix - maven-scr-plugin - - + org.apache.maven.plugins maven-compiler-plugin 1.8 1.8 - 2.3.2 org.apache.felix @@ -129,6 +125,11 @@ + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon org.wso2.carbon.core diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index 314beb5e65..43d912832e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -35,12 +35,9 @@ - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services + org.apache.felix + org.apache.felix.scr.ds-annotations + provided org.testng @@ -87,10 +84,6 @@ - - org.apache.felix - maven-scr-plugin - org.apache.felix maven-bundle-plugin diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java index 0e83028553..7472d3800b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java @@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.*; import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfiguration; import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherServiceImpl; diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml index c1c9255354..9c784d0af3 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml @@ -30,6 +30,11 @@ org.wso2.carbon.identity.authenticator.backend.oauth + + org.apache.felix + org.apache.felix.scr.ds-annotations + provided + org.wso2.carbon org.wso2.carbon.utils @@ -80,10 +85,6 @@ - - org.apache.felix - maven-scr-plugin - org.apache.felix maven-bundle-plugin @@ -110,8 +111,8 @@ org.apache.commons.httpclient, org.apache.commons.logging, org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.osgi.framework, - org.osgi.service.component, + org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.core.security, org.wso2.carbon.core.services.authentication, org.wso2.carbon.utils.multitenancy, diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java index c4ec7e8aa1..30de0c2522 100755 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java +++ b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java @@ -25,6 +25,7 @@ import org.osgi.service.component.ComponentContext; import org.wso2.carbon.core.services.authentication.CarbonServerAuthenticator; import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticator; import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; +import org.osgi.service.component.annotations.*; @Component( name = "org.wso2.carbon.identity.backend.oauth.authenticator", diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml index 41edc660b2..2a0aec705c 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml @@ -36,10 +36,6 @@ - - org.apache.felix - maven-scr-plugin - org.apache.felix maven-bundle-plugin diff --git a/pom.xml b/pom.xml index 4b34fddaf4..a08eff82a5 100644 --- a/pom.xml +++ b/pom.xml @@ -172,6 +172,12 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.common ${io.entgra.device.mgt.core.version} + + + com.fasterxml.jackson.core + jackson-annotations + + io.entgra.device.mgt.core @@ -766,6 +772,10 @@ org.wso2.carbon.user.core ${carbon.kernel.version} + + com.fasterxml.jackson.core + jackson-annotations + org.apache.felix javax.servlet @@ -921,11 +931,23 @@ org.wso2.carbon.apimgt org.wso2.carbon.apimgt.api ${carbon.api.mgt.version} + + + com.fasterxml.jackson.core + jackson-annotations + + org.wso2.carbon.apimgt org.wso2.carbon.apimgt.impl ${carbon.api.mgt.version} + + + com.fasterxml.jackson.core + jackson-annotations + + @@ -1430,6 +1452,10 @@ org.wso2.carbon.registry.indexing ${carbon.registry.version} + + com.fasterxml.jackson.core + jackson-annotations + org.wso2.carbon.identity org.wso2.carbon.user.mgt.stub @@ -1510,6 +1536,12 @@ io.swagger swagger-core ${swagger.version} + + + com.fasterxml.jackson.core + jackson-annotations + + io.swagger @@ -1610,6 +1642,12 @@ com.fasterxml.jackson.core jackson-databind ${fasterxml.jackson.databind.version} + + + com.fasterxml.jackson.core + jackson-annotations + + @@ -2194,7 +2232,7 @@ 2.7.18 2.6.1.wso2v2 - [1.6.0, 2.0.0) + [1.3.0, 2.0.0) [1.2.0,1.3.0) 2.23.4 From 3fea1ae32cc2dadf7c3d18b4030773ac073ae2af Mon Sep 17 00:00:00 2001 From: pasindu Date: Wed, 28 Feb 2024 10:32:54 +0530 Subject: [PATCH 168/343] Restore osgi.framework version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a08eff82a5..27ca043eb0 100644 --- a/pom.xml +++ b/pom.xml @@ -2232,7 +2232,7 @@ 2.7.18 2.6.1.wso2v2 - [1.3.0, 2.0.0) + [1.6.0, 2.0.0) [1.2.0,1.3.0) 2.23.4 From 58989472c9fe2751455a440627ea5a9aab8e12e5 Mon Sep 17 00:00:00 2001 From: pasindu Date: Mon, 4 Mar 2024 14:49:15 +0530 Subject: [PATCH 169/343] Fix import issues in certificate management core --- .../pom.xml | 67 +++---------------- 1 file changed, 10 insertions(+), 57 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 2fe1548f2a..7c03218501 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -57,65 +57,17 @@ io.entgra.device.mgt.core.certificate.mgt.core.util - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - io.entgra.device.mgt.core.certificate.mgt.core.*, + com.google.gson;version="[2.9,3)", + io.entgra.device.mgt.core.certificate.mgt.core.bean, + io.entgra.device.mgt.core.certificate.mgt.core.cache, + io.entgra.device.mgt.core.certificate.mgt.core.cache.impl, + io.entgra.device.mgt.core.certificate.mgt.core.config.datasource, + io.entgra.device.mgt.core.certificate.mgt.core.dao, + io.entgra.device.mgt.core.certificate.mgt.core.dto, + io.entgra.device.mgt.core.certificate.mgt.core.exception, io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.config.cache;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", @@ -130,6 +82,7 @@ javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", org.apache.commons.codec.binary;version="[1.4,2)", org.apache.commons.collections.map;version="[3.2,4)", + org.apache.commons.lang;version="[2.4,3)", org.apache.commons.logging;version="[1.2,2)", org.bouncycastle.asn1;version="[1.70,2)", org.bouncycastle.asn1.pkcs;version="[1.70,2)", From e67630feeb3f6d931d84b22a5edac4877cbdcc09 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 7 Mar 2024 12:55:27 +0530 Subject: [PATCH 170/343] Upgrade wso2 tomcat version --- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../authenticator/BSTAuthenticator.java | 30 ++++++------ pom.xml | 46 +++++++++++++++++-- 11 files changed, 75 insertions(+), 37 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 278e649def..262adb08f9 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -287,11 +287,11 @@ org.wso2.carbon.identity.oauth.stub - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat-servlet-api diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 80de344fbb..43e10f2ed6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -54,11 +54,11 @@ testng - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat-servlet-api diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 6dabbcd530..30776534a2 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -72,11 +72,11 @@ scannotation - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat-servlet-api diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index e61a6ac953..19064258e8 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -72,11 +72,11 @@ scannotation - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat-servlet-api diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 170ecfad3d..c2e5ec68bb 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -72,11 +72,11 @@ scannotation - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat-servlet-api diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 1a35ea1354..4487b32b4e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -72,11 +72,11 @@ scannotation - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat-servlet-api diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index c0ae924f8e..6a1fcc1f2e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -398,11 +398,11 @@ org.wso2.carbon.identity.oauth.stub - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat-servlet-api diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 71431a6af9..f6ebe690c0 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -64,11 +64,11 @@ scannotation - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat-servlet-api diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index d4528765d0..91566b67f8 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -174,11 +174,11 @@ provided - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat-servlet-api diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticator.java index 5d64bc5c25..9ea23cc7be 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/BSTAuthenticator.java @@ -33,8 +33,6 @@ import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Response; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.coyote.InputBuffer; -import org.apache.tomcat.util.buf.ByteChunk; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -42,7 +40,12 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; -import java.util.*; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import java.util.StringTokenizer; public class BSTAuthenticator implements WebappAuthenticator { @@ -146,30 +149,27 @@ public class BSTAuthenticator implements WebappAuthenticator { private String getBSTHeader(Request request) throws IOException, XMLStreamException { org.apache.coyote.Request coyoteReq = request.getCoyoteRequest(); - InputBuffer buf = coyoteReq.getInputBuffer(); - ByteChunk bc = new ByteChunk(); + String securityHeader = coyoteReq.getHeader("Security"); - buf.doRead(bc, coyoteReq); - try (InputStream is = new ByteArrayInputStream(getUTF8Bytes(bc.toString()))) { + if (securityHeader == null || securityHeader.isEmpty()) { + return null; + } + + // Process the "Security" header value as needed + try (InputStream is = new ByteArrayInputStream(getUTF8Bytes(securityHeader))) { XMLStreamReader reader = StAXUtils.createXMLStreamReader(is); StAXBuilder builder = new StAXSOAPModelBuilder(reader); SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement(); envelope.build(); SOAPHeader header = envelope.getHeader(); - Iterator headerEls = header.getChildrenWithLocalName("Security"); + Iterator headerEls = header.getChildrenWithLocalName("BinarySecurityToken"); if (!headerEls.hasNext()) { return null; } - OMElement securityHeader = (OMElement) headerEls.next(); - Iterator securityHeaderEls = securityHeader.getChildrenWithLocalName("BinarySecurityToken"); - if (!securityHeaderEls.hasNext()) { - return null; - } - OMElement bstHeader = (OMElement) securityHeaderEls.next(); + OMElement bstHeader = (OMElement) headerEls.next(); bstHeader.build(); return bstHeader.getText(); } } - } diff --git a/pom.xml b/pom.xml index 4b34fddaf4..3b7c0d99fd 100644 --- a/pom.xml +++ b/pom.xml @@ -930,8 +930,9 @@ + - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat ${orbit.version.tomcat} @@ -961,6 +962,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.wso2.carbon org.wso2.carbon.tomcat.ext @@ -997,11 +1029,17 @@ jdbc-pool ${tomcat.jdbc.pooling.version} + - org.wso2.tomcat + org.wso2.orbit.org.apache.tomcat tomcat-servlet-api - ${orbit.version.tomcat.servlet.api} + 9.0.71.wso2v1 + + + + + @@ -2014,7 +2052,7 @@ 3.8.1.v20120830-144521 - 7.0.93.wso2v1 + 9.0.71.wso2v1 7.0.93.wso2v1 7.0.34.wso2v2 From 4e4ff9c960e00991c2d5eb458af04ecafaa36897 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 7 Mar 2024 16:06:45 +0530 Subject: [PATCH 171/343] Improve dependencies --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 3 +- .../pom.xml | 2 +- .../pom.xml | 21 +++------ .../DefaultOauth2TokenHandler.java | 4 +- .../interceptor/DefaultTokenHandler.java | 4 +- .../request/interceptor/HubspotHandler.java | 4 +- .../JITEnrollmentCallbackHandler.java | 11 +---- .../interceptor/JITEnrollmentHandler.java | 4 -- .../JITProvisionCallbackHandler.java | 3 +- .../interceptor/JITProvisionHandler.java | 11 +---- .../ui/request/interceptor/LoginHandler.java | 6 ++- .../ui/request/interceptor/LogoutHandler.java | 2 +- .../interceptor/PermissionScopeHandler.java | 4 +- .../request/interceptor/SsoLoginHandler.java | 2 +- .../request/interceptor/SsoLogoutHandler.java | 2 +- .../ui/request/interceptor/UserHandler.java | 1 - .../exceptions/JITEnrollmentException.java | 2 + .../exceptions/JITProvisionException.java | 2 + .../exceptions/LoginException.java | 2 + .../request/interceptor/util/HandlerUtil.java | 8 ++-- .../websocket/GrafanaLiveSecurityFilter.java | 7 ++- .../websocket/GrafanaWebSocketClient.java | 12 ++++- .../websocket/GrafanaWebSocketHandler.java | 7 ++- pom.xml | 45 ++----------------- 29 files changed, 68 insertions(+), 111 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 262adb08f9..957065ac02 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -259,7 +259,7 @@ org.wso2.carbon.registry.core - org.apache.tomcat.wso2 + org.wso2.orbit.org.apache.tomcat jdbc-pool diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 52565ff227..7df876a94d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -307,7 +307,7 @@ compile - org.apache.tomcat.wso2 + org.wso2.orbit.org.apache.tomcat jdbc-pool diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index 3de4acb1f7..74de56767d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -171,7 +171,7 @@ provided - org.apache.tomcat.wso2 + org.wso2.orbit.org.apache.tomcat jdbc-pool provided diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 6a1fcc1f2e..e6864e3943 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -370,7 +370,7 @@ provided - org.apache.tomcat.wso2 + org.wso2.orbit.org.apache.tomcat jdbc-pool diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 0bec29141d..6d8f24178f 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -276,7 +276,7 @@ provided - org.apache.tomcat.wso2 + org.wso2.orbit.org.apache.tomcat jdbc-pool provided diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 9965a6c292..1e40f4c990 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -227,10 +227,9 @@ test - org.apache.tomcat.wso2 + org.wso2.orbit.org.apache.tomcat jdbc-pool - mysql mysql-connector-java diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 57d0d745ac..6c2cc9c3d3 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -258,7 +258,7 @@ provided - org.apache.tomcat.wso2 + org.wso2.orbit.org.apache.tomcat jdbc-pool provided diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 06fa8d1153..5a44f12d15 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -100,6 +100,12 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.apimgt.application.extension provided + + + org.wso2.carbon + org.wso2.carbon.tomcat + + io.entgra.device.mgt.core @@ -127,26 +133,11 @@ io.entgra.device.mgt.core.notification.logger provided - - org.springframework - spring-web - provided - - - org.apache.cxf - cxf-bundle-jaxrs - provided - javax.servlet javax.servlet-api provided - - junit - junit - test - commons-logging commons-logging diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java index 93cf1b9491..959a911db2 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java @@ -29,10 +29,10 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; -import org.apache.http.HttpStatus; -import org.apache.http.client.utils.URIBuilder; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; +import org.apache.hc.core5.net.URIBuilder; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java index 951b7b577a..c0b407e7ab 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultTokenHandler.java @@ -27,8 +27,8 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; -import org.apache.http.client.utils.URIBuilder; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.net.URIBuilder; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.OTPManagementException; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java index f99531cc17..559336b6e7 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/HubspotHandler.java @@ -24,9 +24,9 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpHeaders; +import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java index d5b25cf701..40db118c7d 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentCallbackHandler.java @@ -23,9 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonArray; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITEnrollmentData; @@ -36,13 +34,8 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; import org.apache.hc.core5.http.ClassicHttpRequest; -import org.apache.hc.core5.http.NameValuePair; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; -import org.apache.hc.core5.http.message.BasicNameValuePair; -import org.apache.http.HttpHeaders; -import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.w3c.dom.Document; @@ -190,7 +183,7 @@ public class JITEnrollmentCallbackHandler extends HttpServlet { /*** * Build application registration request - * @return {@link HttpPost} Application registration request + * @return {@link ClassicHttpRequest} Application registration request */ private ClassicHttpRequest buildApplicationRegistrationRequest() { @@ -265,7 +258,7 @@ public class JITEnrollmentCallbackHandler extends HttpServlet { /*** * Build token acquire request - * @return {@link HttpPost} Token acquire request + * @return {@link ClassicHttpRequest} Token acquire request */ private ClassicHttpRequest buildTokenAcquireRequest() { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentHandler.java index 8ca9cdf98c..0c3de9e429 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITEnrollmentHandler.java @@ -19,14 +19,10 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITEnrollmentData; -import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.JITEnrollmentException; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.wso2.carbon.utils.CarbonUtils; -import org.xml.sax.SAXException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITProvisionCallbackHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITProvisionCallbackHandler.java index 433c1e7de3..b6496e0db3 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITProvisionCallbackHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITProvisionCallbackHandler.java @@ -19,12 +19,11 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITData; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITEnrollmentData; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; -import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hc.core5.http.HttpStatus; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITProvisionHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITProvisionHandler.java index 9c1cf31a94..4b02cec035 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITProvisionHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/JITProvisionHandler.java @@ -18,22 +18,13 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import io.entgra.device.mgt.core.ui.request.interceptor.beans.JITData; -import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; -import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.JITEnrollmentException; import io.entgra.device.mgt.core.ui.request.interceptor.exceptions.JITProvisionException; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; +import org.apache.hc.core5.http.HttpStatus; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index d720842b71..633b18eb52 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -20,7 +20,7 @@ package io.entgra.device.mgt.core.ui.request.interceptor; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; -import com.google.gson.*; +import com.google.gson.JsonSyntaxException; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.cache.LoginCache; @@ -45,7 +45,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Base64; +import java.util.List; @MultipartConfig @WebServlet("/login") diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LogoutHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LogoutHandler.java index 88396bf6d4..496007fe88 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LogoutHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LogoutHandler.java @@ -22,7 +22,7 @@ import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; +import org.apache.hc.core5.http.HttpStatus; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java index b6e6ddd293..90d272907a 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/PermissionScopeHandler.java @@ -18,16 +18,14 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; import io.entgra.device.mgt.core.ui.request.interceptor.beans.ProxyResponse; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.lang.StringUtils; -import org.apache.http.HttpStatus; +import org.apache.hc.core5.http.HttpStatus; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java index 34584d03c3..4f63c48b32 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLoginHandler.java @@ -30,8 +30,8 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; -import org.apache.http.HttpStatus; import org.w3c.dom.Document; import org.xml.sax.SAXException; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLogoutHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLogoutHandler.java index f418199b0a..5dbd7d85f9 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLogoutHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/SsoLogoutHandler.java @@ -23,7 +23,7 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpStatus; +import org.apache.hc.core5.http.HttpStatus; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index c608585ac4..04cb1f08b8 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -18,7 +18,6 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonSyntaxException; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/JITEnrollmentException.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/JITEnrollmentException.java index c845f8b5c8..ae7129985a 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/JITEnrollmentException.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/JITEnrollmentException.java @@ -20,6 +20,8 @@ package io.entgra.device.mgt.core.ui.request.interceptor.exceptions; public class JITEnrollmentException extends Exception { + private static final long serialVersionUID = -5414968249196525915L; + public JITEnrollmentException(String msg, Throwable t) { super(msg, t); } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/JITProvisionException.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/JITProvisionException.java index fc3018890d..34cfc2568c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/JITProvisionException.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/JITProvisionException.java @@ -20,6 +20,8 @@ package io.entgra.device.mgt.core.ui.request.interceptor.exceptions; public class JITProvisionException extends Exception { + private static final long serialVersionUID = 1413607461296734217L; + public JITProvisionException(String msg, Throwable t) { super(msg, t); } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/LoginException.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/LoginException.java index 4a7396a31a..dc9ed4f36e 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/LoginException.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/exceptions/LoginException.java @@ -19,6 +19,8 @@ package io.entgra.device.mgt.core.ui.request.interceptor.exceptions; public class LoginException extends Exception { + private static final long serialVersionUID = -6376045524044788791L; + public LoginException(String message) { super(message); } diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 3fe3bb381a..b0f514f05c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -19,12 +19,10 @@ package io.entgra.device.mgt.core.ui.request.interceptor.util; import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.google.gson.Gson; -import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -70,7 +68,11 @@ import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; -import java.util.*; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class HandlerUtil { diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaLiveSecurityFilter.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaLiveSecurityFilter.java index 77322c2839..dfd3b61c51 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaLiveSecurityFilter.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaLiveSecurityFilter.java @@ -23,7 +23,12 @@ import io.entgra.device.mgt.core.ui.request.interceptor.util.HandlerConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.servlet.*; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import java.io.IOException; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketClient.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketClient.java index 75fb5a7276..630f43c29a 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketClient.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketClient.java @@ -23,7 +23,17 @@ import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util.GrafanaUt import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.websocket.*; +import javax.websocket.ClientEndpoint; +import javax.websocket.ClientEndpointConfig; +import javax.websocket.CloseReason; +import javax.websocket.ContainerProvider; +import javax.websocket.Endpoint; +import javax.websocket.EndpointConfig; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.WebSocketContainer; import javax.ws.rs.core.HttpHeaders; import java.net.URI; import java.util.Collections; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketHandler.java index e492e79965..97e5da899d 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/websocket/GrafanaWebSocketHandler.java @@ -24,7 +24,12 @@ import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util.GrafanaUt import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import javax.websocket.*; +import javax.websocket.CloseReason; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; import javax.websocket.server.ServerEndpoint; import java.io.IOException; import java.net.URI; diff --git a/pom.xml b/pom.xml index 3b7c0d99fd..c9f8bfe9e3 100644 --- a/pom.xml +++ b/pom.xml @@ -962,37 +962,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.wso2.carbon org.wso2.carbon.tomcat.ext @@ -1025,21 +994,15 @@ - org.apache.tomcat.wso2 + org.wso2.orbit.org.apache.tomcat jdbc-pool - ${tomcat.jdbc.pooling.version} + ${orbit.version.tomcat} - org.wso2.orbit.org.apache.tomcat tomcat-servlet-api - 9.0.71.wso2v1 + ${orbit.version.tomcat} - - - - - @@ -2053,8 +2016,6 @@ 9.0.71.wso2v1 - 7.0.93.wso2v1 - 7.0.34.wso2v2 5.24.8 From e1519fa2a88f12e798627457d54cab257892b51f Mon Sep 17 00:00:00 2001 From: Pahansith Date: Sun, 24 Mar 2024 14:56:22 +0530 Subject: [PATCH 172/343] Add policy content store as Json --- .../pom.xml | 4 ++ .../impl/policy/AbstractPolicyDAOImpl.java | 41 ++++--------------- .../mgt/core/util/PolicyManagerUtil.java | 11 ++++- 3 files changed, 22 insertions(+), 34 deletions(-) diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 3c0fabec4b..8fd87c21b2 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -180,6 +180,10 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.policy.mgt.common + + com.google.code.gson + gson + diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java index 85bd77d859..f69e672cf7 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.policy.mgt.core.dao.impl.policy; +import com.google.gson.Gson; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -54,6 +55,7 @@ import java.util.Properties; */ public abstract class AbstractPolicyDAOImpl implements PolicyDAO { + private static final Gson gson = new Gson(); private static final Log log = LogFactory.getLog(AbstractPolicyDAOImpl.class); @Override @@ -1187,13 +1189,13 @@ public abstract class AbstractPolicyDAOImpl implements PolicyDAO { stmt = conn.prepareStatement(query); stmt.setInt(1, deviceId); stmt.setInt(2, policy.getId()); - stmt.setBytes(3, PolicyManagerUtil.getBytes(policy)); + stmt.setString(3, PolicyManagerUtil.convertToJson(policy)); stmt.setTimestamp(4, currentTimestamp); stmt.setTimestamp(5, currentTimestamp); stmt.setInt(6, tenantId); stmt.setInt(7, enrolmentId); stmt.executeUpdate(); - } catch (SQLException | IOException e) { + } catch (SQLException e) { throw new PolicyManagerDAOException("Error occurred while adding the evaluated feature list to device", e); } finally { PolicyManagementDAOUtil.cleanupResources(stmt, null); @@ -1240,7 +1242,7 @@ public abstract class AbstractPolicyDAOImpl implements PolicyDAO { "APPLIED = ? WHERE DEVICE_ID = ? AND TENANT_ID = ? AND ENROLMENT_ID = ?"; stmt = conn.prepareStatement(query); stmt.setInt(1, policy.getId()); - stmt.setBytes(2, PolicyManagerUtil.getBytes(policy)); + stmt.setString(2, PolicyManagerUtil.convertToJson(policy)); stmt.setTimestamp(3, currentTimestamp); stmt.setBoolean(4, false); stmt.setInt(5, deviceId); @@ -1248,7 +1250,7 @@ public abstract class AbstractPolicyDAOImpl implements PolicyDAO { stmt.setInt(7, enrolmentId); stmt.executeUpdate(); - } catch (SQLException | IOException e) { + } catch (SQLException e) { throw new PolicyManagerDAOException("Error occurred while updating the evaluated feature list " + "to device", e); } finally { @@ -1699,39 +1701,12 @@ public abstract class AbstractPolicyDAOImpl implements PolicyDAO { resultSet = stmt.executeQuery(); while (resultSet.next()) { - ByteArrayInputStream bais = null; - ObjectInputStream ois = null; - byte[] contentBytes; - - try { - contentBytes = resultSet.getBytes("POLICY_CONTENT"); - bais = new ByteArrayInputStream(contentBytes); - ois = new ObjectInputStream(bais); - policy = (Policy) ois.readObject(); - } finally { - if (bais != null) { - try { - bais.close(); - } catch (IOException e) { - log.warn("Error occurred while closing ByteArrayOutputStream", e); - } - } - if (ois != null) { - try { - ois.close(); - } catch (IOException e) { - log.warn("Error occurred while closing ObjectOutputStream", e); - } - } - } + String contentString = resultSet.getString("POLICY_CONTENT"); + policy = gson.fromJson(contentString, Policy.class); } } catch (SQLException e) { throw new PolicyManagerDAOException("Error occurred while getting the applied policy", e); - } catch (IOException e) { - throw new PolicyManagerDAOException("Unable to read the byte stream for content", e); - } catch (ClassNotFoundException e) { - throw new PolicyManagerDAOException("Class not found while converting the object", e); } finally { PolicyManagementDAOUtil.cleanupResources(stmt, resultSet); } diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/util/PolicyManagerUtil.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/util/PolicyManagerUtil.java index 0bd3c36396..1aa7947e8e 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/util/PolicyManagerUtil.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/util/PolicyManagerUtil.java @@ -62,7 +62,7 @@ import java.io.ObjectOutputStream; import java.util.*; public class PolicyManagerUtil { - + private static final Gson gson = new Gson(); public static final String GENERAL_CONFIG_RESOURCE_PATH = "general"; public static final String MONITORING_FREQUENCY = "notifierFrequency"; private static final Log log = LogFactory.getLog(PolicyManagerUtil.class); @@ -355,6 +355,15 @@ public class PolicyManagerUtil { return data; } + /** + * Using for converting policy objects into Json strings + * @param obj + * @return + */ + public static String convertToJson(Object obj) { + return gson.toJson(obj); + } + public static boolean convertIntToBoolean(int x) { return x == 1; From 177b8cc831115c02a8d02f6dcb3307c4eb8df791 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Sun, 21 Apr 2024 19:44:18 +0530 Subject: [PATCH 173/343] Sync with master --- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- .../core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 3 --- .../core/device/mgt/core/dao/DeviceManagementDAOFactory.java | 1 + .../mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java | 5 ----- .../ui/request/interceptor/DefaultOauth2TokenHandler.java | 1 - pom.xml | 4 ++-- 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 25c9dad479..75ee1551e9 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -436,12 +436,12 @@ com.squareup.okio okio + ${okio.version} org.wso2.carbon.multitenancy org.wso2.carbon.tenant.mgt compile ->>>>>>> upstream/master diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index 84f29ccb9c..6a4adacd55 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -24,16 +24,13 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationService import io.entgra.device.mgt.core.apimgt.extension.rest.api.ConsumerRESTAPIServices; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; -<<<<<<< HEAD import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceTypeVersionWrapper; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationStatusBean; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.analytics.EventAttributeList; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.InputValidationException; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; -======= import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuthorizationService; ->>>>>>> upstream/master import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; import org.apache.axis2.AxisFault; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java index 9891444fe1..695a6a64c9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.device.mgt.core.config.datasource.JNDILookupDef import io.entgra.device.mgt.core.device.mgt.core.dao.impl.ApplicationDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.DeviceStatusDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.DeviceTypeDAOImpl; +import io.entgra.device.mgt.core.device.mgt.core.dao.impl.TenantDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.device.GenericDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.device.OracleDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.device.PostgreSQLDeviceDAOImpl; diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java index 063e2f3b74..de63497e87 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.tenant.mgt.core.impl; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; -<<<<<<< HEAD import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; @@ -27,15 +26,12 @@ import io.entgra.device.mgt.core.device.mgt.common.roles.config.Role; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; -======= import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.TenantDAO; import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; ->>>>>>> upstream/master import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException; -import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; import io.entgra.device.mgt.core.tenant.mgt.core.internal.TenantMgtDataHolder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -46,7 +42,6 @@ import org.wso2.carbon.user.api.Permission; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; -import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java index 7c4b0d2cb9..959a911db2 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/DefaultOauth2TokenHandler.java @@ -18,7 +18,6 @@ package io.entgra.device.mgt.core.ui.request.interceptor; -<<<<<<< HEAD import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/pom.xml b/pom.xml index de50e6e0bc..dcbac2b442 100644 --- a/pom.xml +++ b/pom.xml @@ -2131,8 +2131,8 @@ 1.3 2.9.1 31.0.1-jre - 4.6.0 - 1.13.0 + 4.12.0 + 3.6.0 11.0 1.1.1 1.2 From 8cf830b7c810b67944717246d9726b1d8042a503 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 1 May 2024 00:04:53 +0530 Subject: [PATCH 174/343] Fix server starting issue with latest WUM --- .../pom.xml | 26 +- .../org.wso2.carbon.apimgt.handlers/pom.xml | 139 - .../handlers/APIMCertificateMGTException.java | 33 - .../handlers/AuthenticationHandler.java | 235 -- .../apimgt/handlers/beans/Certificate.java | 58 - .../carbon/apimgt/handlers/beans/DCR.java | 88 - .../handlers/beans/ValidationResponce.java | 64 - .../config/IOTServerConfiguration.java | 122 - .../apimgt/handlers/invoker/RESTInvoker.java | 110 - .../apimgt/handlers/invoker/RESTResponse.java | 57 - .../apimgt/handlers/utils/AuthConstants.java | 40 - .../carbon/apimgt/handlers/utils/Utils.java | 205 - .../src/main/resources/iot-api-config.xml | 40 - .../handlers/AuthenticationHandlerTest.java | 296 -- .../apimgt/handlers/BaseAPIHandlerTest.java | 60 - .../handlers/IOTServerConfigurationTest.java | 97 - .../carbon/apimgt/handlers/TestUtils.java | 61 - .../apimgt/handlers/mock/MockClient.java | 76 - .../handlers/mock/MockHttpResponse.java | 178 - .../test/resources/accesstoken-response.json | 7 - .../carbon-home/repository/conf/carbon.xml | 658 --- .../conf/iot-api-config-invalid-xml.xml | 40 - .../conf/iot-api-config-invalid.xml | 40 - .../repository/conf/iot-api-config.xml | 40 - .../carbon-home/repository/conf/registry.xml | 52 - .../src/test/resources/dcr-response.json | 6 - .../src/test/resources/ra_cert.pem | 33 - .../src/test/resources/testng.xml | 30 - .../pom.xml | 204 - .../client/IntegrationClientServiceImpl.java | 68 - .../client/OAuthRequestInterceptor.java | 142 - .../client/configs/APIMConfig.java | 90 - .../client/configs/APIMConfigReader.java | 95 - .../client/exception/APIMClientException.java | 58 - .../exception/APIMClientOAuthException.java | 58 - .../InvalidConfigurationStateException.java | 78 - .../APIIntegrationClientDataHolder.java | 45 - .../APIIntegrationClientServiceComponent.java | 81 - .../client/model/ClientProfile.java | 96 - .../integration/client/model/DCRClient.java | 36 - .../client/model/OAuthApplication.java | 103 - .../client/publisher/PublisherClient.java | 96 - .../service/IntegrationClientService.java | 44 - .../integration/client/store/StoreClient.java | 117 - .../apimgt/integration/client/util/Utils.java | 238 -- .../pom.xml | 212 - .../src/main/resources/publisher-api.yaml | 3691 ----------------- .../src/main/resources/store-api.yaml | 2693 ------------ .../pom.xml | 8 +- .../pom.xml | 1 - .../pom.xml | 5 +- .../pom.xml | 158 - .../data/publisher/DataPublisherUtil.java | 124 - .../data/publisher/DeviceDataPublisher.java | 110 - .../config/AnalyticsConfiguration.java | 135 - .../InvalidConfigurationStateException.java | 29 - .../DataPublisherConfigurationException.java | 31 - .../DataPublisherServiceComponent.java | 67 - .../service/EventsPublisherService.java | 41 - .../service/EventsPublisherServiceImpl.java | 100 - .../BaseAnalyticsDataPublisherTest.java | 57 - .../publisher/DataPublisherConfigTest.java | 83 - .../DataPublisherServiceComponentTest.java | 67 - .../publisher/EventPublisherServiceTest.java | 144 - .../publisher/util/TestComponentContext.java | 81 - .../carbon-home/repository/conf/carbon.xml | 658 --- .../data-bridge/data-agent-config-invalid.xml | 69 - .../conf/data-bridge/data-agent-config.xml | 69 - .../device-analytics-config-invalid-xml.xml | 35 - .../etc/device-analytics-config-invalid.xml | 35 - .../conf/etc/device-analytics-config.xml | 36 - .../carbon-home/repository/conf/registry.xml | 52 - .../src/test/resources/client-truststore.jks | Bin 102330 -> 0 bytes .../src/test/resources/testng.xml | 31 - .../pom.xml | 80 - .../wsproxy/exception/WSProxyException.java | 37 - .../wsproxy/inbound/SubscriptionEndpoint.java | 145 - .../SuperTenantSubscriptionEndpoint.java | 104 - .../inbound/TenantSubscriptionEndpoint.java | 103 - .../wsproxy/outbound/AnalyticsClient.java | 133 - .../src/main/webapp/WEB-INF/web.xml | 46 - .../pom.xml | 154 - .../backend/oauth/AuthenticatorException.java | 39 - .../backend/oauth/OauthAuthenticator.java | 155 - .../oauth/OauthAuthenticatorConstants.java | 29 - .../OAuthAuthenticatorDataHolder.java | 49 - .../OAuthAuthenticatorServiceComponent.java | 83 - .../oauth/validator/OAuth2TokenValidator.java | 35 - .../validator/OAuthValidationResponse.java | 59 - .../validator/OAuthValidatorFactory.java | 68 - .../impl/ExternalOAuthValidator.java | 95 - .../validator/impl/LocalOAuthValidator.java | 60 - .../pom.xml | 4 +- .../pom.xml | 107 - .../policy/evaluator/FeatureFilter.java | 48 - .../policy/evaluator/FeatureFilterImpl.java | 250 -- .../carbon/policy/evaluator/FeatureRules.java | 41 - .../carbon/policy/evaluator/PDPException.java | 54 - .../policy/evaluator/PDPServiceImpl.java | 37 - .../carbon/policy/evaluator/PolicyFilter.java | 43 - .../policy/evaluator/PolicyFilterImpl.java | 72 - .../policy/evaluator/spi/PDPService.java | 34 - .../policy/evaluator/utils/Constants.java | 30 - .../pom.xml | 2 +- .../pom.xml | 104 - .../src/main/resources/build.properties | 19 - .../main/resources/conf/iot-api-config.xml | 40 - .../src/main/resources/p2.inf | 2 - .../pom.xml | 118 - .../src/main/resources/build.properties | 19 - .../main/resources/conf/apim-integration.xml | 26 - .../src/main/resources/p2.inf | 2 - .../pom.xml | 144 - .../src/main/resources/build.properties | 19 - .../conf/device-analytics-config.xml | 49 - .../src/main/resources/p2.inf | 4 - pom.xml | 6 +- 117 files changed, 30 insertions(+), 16080 deletions(-) delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/APIMCertificateMGTException.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandler.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/Certificate.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/DCR.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/ValidationResponce.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/config/IOTServerConfiguration.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/invoker/RESTInvoker.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/invoker/RESTResponse.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/AuthConstants.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/Utils.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/resources/iot-api-config.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandlerTest.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/BaseAPIHandlerTest.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/IOTServerConfigurationTest.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/TestUtils.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/mock/MockClient.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/mock/MockHttpResponse.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/accesstoken-response.json delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/carbon.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/iot-api-config-invalid-xml.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/iot-api-config-invalid.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/iot-api-config.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/registry.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/dcr-response.json delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/ra_cert.pem delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/testng.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java delete mode 100755 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfig.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfigReader.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientException.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/InvalidConfigurationStateException.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientDataHolder.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/ClientProfile.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/DCRClient.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/OAuthApplication.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/util/Utils.java delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml delete mode 100644 components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/store-api.yaml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherUtil.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/AnalyticsConfiguration.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/InvalidConfigurationStateException.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/exception/DataPublisherConfigurationException.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherService.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherServiceImpl.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/BaseAnalyticsDataPublisherTest.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherServiceComponentTest.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/EventPublisherServiceTest.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/util/TestComponentContext.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/carbon.xml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/data-bridge/data-agent-config-invalid.xml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/data-bridge/data-agent-config.xml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config-invalid-xml.xml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config-invalid.xml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config.xml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/registry.xml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/client-truststore.jks delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/testng.xml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/exception/WSProxyException.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SubscriptionEndpoint.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SuperTenantSubscriptionEndpoint.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/TenantSubscriptionEndpoint.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/outbound/AnalyticsClient.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/webapp/WEB-INF/web.xml delete mode 100644 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml delete mode 100755 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/AuthenticatorException.java delete mode 100755 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticator.java delete mode 100755 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticatorConstants.java delete mode 100644 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorDataHolder.java delete mode 100755 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java delete mode 100755 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuth2TokenValidator.java delete mode 100755 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuthValidationResponse.java delete mode 100755 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuthValidatorFactory.java delete mode 100755 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/ExternalOAuthValidator.java delete mode 100755 components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/LocalOAuthValidator.java delete mode 100644 components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml delete mode 100644 components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java delete mode 100644 components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java delete mode 100644 components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java delete mode 100644 components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java delete mode 100644 components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java delete mode 100644 components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java delete mode 100644 components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java delete mode 100644 components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java delete mode 100644 components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java delete mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml delete mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/build.properties delete mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/conf/iot-api-config.xml delete mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/p2.inf delete mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml delete mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/build.properties delete mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml delete mode 100644 features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf delete mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml delete mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/build.properties delete mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/conf/device-analytics-config.xml delete mode 100644 features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/p2.inf diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 4842750edf..5e7a9cc8fb 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -81,7 +81,7 @@ Grafana API Management Core Bundle io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.internal - com.google.common.cache;version="[31.0,32)", + com.google.common.cache;version="[32.1,33)";resolution:=optional, com.google.gson;version="[2.9,3)", io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception;version="[5.0,6)", io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean, @@ -109,9 +109,9 @@ javax.xml.bind;version="[0.0,1)", javax.xml.bind.annotation;version="[0.0,1)", javax.xml.parsers, - org.apache.commons.codec.binary;version="[1.9,2)", + org.apache.commons.codec.binary;version="[1.4,2)", org.apache.commons.lang;version="[2.6,3)", - org.apache.commons.lang3;version="[3.1,4)", + org.apache.commons.lang3;version="[3.11,4)", org.apache.commons.logging;version="[1.2,2)", org.apache.http;version="[4.4,5)", org.apache.http.client, @@ -178,6 +178,12 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.core + + + com.google.guava + guava + + io.entgra.device.mgt.core @@ -196,6 +202,12 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.identity.jwt.client.extension provided + + + com.google.guava + guava + + javax.ws.rs @@ -306,23 +318,19 @@ commons-collections.wso2 commons-collections - io.entgra.device.mgt.core io.entgra.device.mgt.core.transport.mgt.email.sender.core - mysql mysql-connector-java test - com.google.code.gson gson - io.swagger swagger-annotations @@ -351,9 +359,7 @@ com.google.guava guava + provided - - - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml deleted file mode 100644 index d31e7093e5..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - apimgt-extensions - io.entgra.device.mgt.core - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.apimgt.handlers - bundle - WSO2 Carbon - API Security Handler Component - WSO2 Carbon - API Management Security Handler Module - https://entgra.io - - - - - org.ops4j.pax.logging - pax-logging-api - provided - - - - org.apache.synapse - synapse-core - - - org.apache.ws.security.wso2 - wss4j - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.certificate.mgt.core - - - org.json.wso2 - json - - - org.slf4j - slf4j-simple - test - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${io.entgra.device.mgt.core.version} - WSO2 Carbon - API Security Handler Component - - org.apache.axiom.*, - javax.security.cert.*, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - javax.xml.*, - org.apache.axis2.*, - org.apache.commons.*, - org.apache.http.*, - org.apache.http.util, - org.apache.ws.*;version="${org.apache.ws.security.wso2.version}", - org.json, - org.wso2.carbon.utils, - org.wso2.carbon.context, - com.google.gson, - org.w3c.dom, - org.apache.synapse, - org.apache.synapse.core.axis2, - org.apache.synapse.rest, - io.entgra.device.mgt.core.certificate.mgt.core.* - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - src/test/resources/testng.xml - - - - - 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 - - - - - - - - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/APIMCertificateMGTException.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/APIMCertificateMGTException.java deleted file mode 100644 index b0e2d41b83..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/APIMCertificateMGTException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -import io.entgra.device.mgt.core.device.mgt.api.jaxrs..carbon.apimgt.handlers; - -/** - * Error handling class for the apimgt handler. - */ -public class APIMCertificateMGTException extends Exception{ - - private static final long serialVersionUID = -37676242646464497L; - - public APIMCertificateMGTException(String msg, Exception nestedEx) { - super(msg, nestedEx); - } -} - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandler.java deleted file mode 100644 index 885d7f5cc5..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandler.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.apimgt.handlers; - -import com.google.gson.Gson; -import org.apache.axis2.context.MessageContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.synapse.core.axis2.Axis2MessageContext; -import org.apache.synapse.rest.AbstractHandler; -import org.wso2.carbon.apimgt.handlers.beans.Certificate; -import org.wso2.carbon.apimgt.handlers.beans.ValidationResponce; -import org.wso2.carbon.apimgt.handlers.config.IOTServerConfiguration; -import org.wso2.carbon.apimgt.handlers.invoker.RESTInvoker; -import org.wso2.carbon.apimgt.handlers.invoker.RESTResponse; -import org.wso2.carbon.apimgt.handlers.utils.AuthConstants; -import org.wso2.carbon.apimgt.handlers.utils.Utils; -import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; -import io.entgra.device.mgt.core.certificate.mgt.core.impl.CertificateGenerator; -import org.wso2.carbon.context.PrivilegedCarbonContext; - -import javax.security.cert.CertificateEncodingException; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.util.HashMap; -import java.util.Map; -import java.util.StringTokenizer; - -/** - * Synapse gateway handler for API authentication. - */ -public class AuthenticationHandler extends AbstractHandler { - private static final Log log = LogFactory.getLog(AuthenticationHandler.class); - private RESTInvoker restInvoker; - - private static final String X_JWT_ASSERTION = "X-JWT-Assertion"; - private static final String JWTTOKEN = "JWTToken"; - private static final String AUTHORIZATION = "Authorization"; - private static final String BEARER = "Basic "; - private static final String CONTENT_TYPE = "Content-Type"; - private static final boolean USE_INTERNAL_CERT_VERIFIER = true; - - private IOTServerConfiguration iotServerConfiguration; - - /** - * Setting up configurations at the constructor - */ - public AuthenticationHandler() { - log.info("Engaging API Security Handler.........."); - restInvoker = new RESTInvoker(); - this.iotServerConfiguration = Utils.initConfig(); - } - - /** - * Handling the message and checking the security. - * - * @param messageContext Request message context. - * @return Boolean value of the result of the processing the request. - */ - @Override - public boolean handleRequest(org.apache.synapse.MessageContext messageContext) { - org.apache.axis2.context.MessageContext axisMC = ((Axis2MessageContext) messageContext).getAxis2MessageContext(); - - String ctxPath = messageContext.getTo().getAddress().trim(); - - if (log.isDebugEnabled()) { - log.debug("Authentication handler invoked by: " + ctxPath); - } - Map headers = (Map) axisMC.getProperty(MessageContext.TRANSPORT_HEADERS); - try { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - RESTResponse response = null; - if (headers.containsKey(AuthConstants.MDM_SIGNATURE)) { - - String mdmSignature = headers.get(AuthConstants.MDM_SIGNATURE); - if (log.isDebugEnabled()) { - log.debug("Verify Cert:\n" + mdmSignature); - } - URI certVerifyUrl = new URI(iotServerConfiguration.getVerificationEndpoint() + "ios"); - Map certVerifyHeaders = this.setHeaders(); - - Certificate certificate = new Certificate(); - certificate.setPem(mdmSignature); - certificate.setTenantId(tenantId); - certificate.setSerial(""); - - Gson gson = new Gson(); - String certVerifyContent = gson.toJson(certificate); - response = restInvoker.invokePOST(certVerifyUrl, certVerifyHeaders, certVerifyContent); - - String str = response.getContent(); - if (log.isDebugEnabled()) { - log.debug("Verify response:" + response.getContent()); - log.debug("Response String : " + str); - } - if (response.getHttpStatus() == 200 && str.contains(JWTTOKEN)) { - ValidationResponce validationResponce = gson.fromJson(str, ValidationResponce.class); - headers.put(X_JWT_ASSERTION, validationResponce.getJWTToken()); - } else { - return false; - } - - } else if (headers.containsKey(AuthConstants.PROXY_MUTUAL_AUTH_HEADER)) { - String subjectDN = headers.get(AuthConstants.PROXY_MUTUAL_AUTH_HEADER); - - if (log.isDebugEnabled()) { - log.debug("Verify subject DN: " + subjectDN); - } - - if (USE_INTERNAL_CERT_VERIFIER) { - CertificateResponse certificateResponse = Utils.getCertificateManagementService() - .verifySubjectDN(subjectDN); - if (certificateResponse != null && certificateResponse.getCommonName() != null - && !certificateResponse.getCommonName().isEmpty()) { - return true; - } - } else { - String deviceType = this.getDeviceType(messageContext.getTo().getAddress().trim()); - URI certVerifyUrl = new URI(iotServerConfiguration.getVerificationEndpoint() + deviceType); - Map certVerifyHeaders = this.setHeaders(); - - Certificate certificate = new Certificate(); - certificate.setPem(subjectDN); - certificate.setTenantId(tenantId); - certificate.setSerial(AuthConstants.PROXY_MUTUAL_AUTH_HEADER); - - Gson gson = new Gson(); - String certVerifyContent = gson.toJson(certificate); - response = restInvoker.invokePOST(certVerifyUrl, certVerifyHeaders, certVerifyContent); - if (log.isDebugEnabled()) { - log.debug("Verify response:" + response.getContent()); - } - } - } else if (headers.containsKey(AuthConstants.MUTUAL_AUTH_HEADER)) { - javax.security.cert.X509Certificate[] certs = - (javax.security.cert.X509Certificate[]) axisMC.getProperty(AuthConstants.CLIENT_CERTIFICATE); - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - ByteArrayInputStream bais = new ByteArrayInputStream(certs[0].getEncoded()); - X509Certificate x509 = (X509Certificate) cf.generateCertificate(bais); - bais.close(); - if (x509 != null) { - headers.put(AuthConstants.PROXY_MUTUAL_AUTH_HEADER, CertificateGenerator.getCommonName(x509)); - return true; - } - } else if (headers.containsKey(AuthConstants.ENCODED_PEM)) { - String encodedPem = headers.get(AuthConstants.ENCODED_PEM); - if (log.isDebugEnabled()) { - log.debug("Verify Cert:\n" + encodedPem); - } - String deviceType = this.getDeviceType(messageContext.getTo().getAddress().trim()); - URI certVerifyUrl = new URI(iotServerConfiguration.getVerificationEndpoint() + deviceType); - Map certVerifyHeaders = this.setHeaders(); - - Certificate certificate = new Certificate(); - certificate.setPem(encodedPem); - certificate.setTenantId(tenantId); - certificate.setSerial(""); - Gson gson = new Gson(); - String certVerifyContent = gson.toJson(certificate); - response = restInvoker.invokePOST(certVerifyUrl, certVerifyHeaders, certVerifyContent); - if (log.isDebugEnabled()) { - log.debug("Verify response:" + response.getContent()); - } - } else { - log.warn("Unauthorized request for api: " + ctxPath); - return false; - } - if (response != null && !response.getContent().contains("invalid")) { - return true; - } - log.warn("Unauthorized request for api: " + ctxPath); - return false; - } catch (IOException e) { - log.error("Error while processing certificate.", e); - return false; - } catch (URISyntaxException e) { - log.error("Error while processing certificate.", e); - return false; - } catch (CertificateException e) { - log.error("Certificate issue occurred when generating converting PEM to x509Certificate", e); - return false; - } catch (CertificateEncodingException e) { - log.error("Error while attempting to encode certificate.", e); - return false; - } catch (KeystoreException e) { - log.error("Error while attempting to validate certificate.", e); - return false; - } - } - - @Override - public boolean handleResponse(org.apache.synapse.MessageContext messageContext) { - return true; - } - - - private String getDeviceType(String url) { - StringTokenizer parts = new StringTokenizer(url, "/"); - while (parts.hasMoreElements()) { - if (parts.nextElement().equals("device-mgt")) { - return (String) parts.nextElement(); - } - } - return null; - } - - private Map setHeaders() { - Map map = new HashMap<>(); - String accessToken = Utils.getBase64EncodedToken(iotServerConfiguration); - map.put(AUTHORIZATION, BEARER + accessToken); - map.put(CONTENT_TYPE, "application/json"); - return map; - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/Certificate.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/Certificate.java deleted file mode 100644 index b3389a82c5..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/Certificate.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package org.wso2.carbon.apimgt.handlers.beans; - -/** - * This class keeps the certificate data. - */ -public class Certificate { - - // public key of the certificate - private String pem; - // Tenant id - private int tenantId; - // Serial of the certificate. - private String serial; - - public String getPem() { - return pem; - } - - public void setPem(String pem) { - this.pem = pem; - } - - public int getTenantId() { - return tenantId; - } - - public void setTenantId(int tenantId) { - this.tenantId = tenantId; - } - - public String getSerial() { - return serial; - } - - public void setSerial(String serial) { - this.serial = serial; - } -} - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/DCR.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/DCR.java deleted file mode 100644 index ae5e42b59a..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/DCR.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package org.wso2.carbon.apimgt.handlers.beans; - -/** - * This class holds the DCR endpoints data to create an application. - */ -public class DCR { - - private String callbackUrl; - private String owner; - private String clientName; - private String grantType; - private String tokenScope; - private boolean isSaasApp; - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getClientName() { - return clientName; - } - - public void setClientName(String clientName) { - this.clientName = clientName; - } - - public String getGrantType() { - return grantType; - } - - public void setGrantType(String grantType) { - this.grantType = grantType; - } - - public String getTokenScope() { - return tokenScope; - } - - public void setTokenScope(String tokenScope) { - this.tokenScope = tokenScope; - } - - public boolean getIsSaasApp() { - return isSaasApp; - } - - public void setIsSaasApp(boolean isSaasApp) { - this.isSaasApp = isSaasApp; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public void setCallbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - } - - public String toJSON() { - return "{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + "\", \"tokenScope\": " + - "\"" + tokenScope + "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType + - "\", \"saasApp\" :" + isSaasApp + " }\n"; - } -} - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/ValidationResponce.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/ValidationResponce.java deleted file mode 100644 index b9b385e2f3..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/beans/ValidationResponce.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package org.wso2.carbon.apimgt.handlers.beans; - -/** - * This class holds the data returned from the backend after the certificate was authenticated. - */ -public class ValidationResponce { - - private String JWTToken; // X-JWT-Assertion - private String deviceId; - private String deviceType; - private int tenantId; - - public String getJWTToken() { - return JWTToken; - } - - public void setJWTToken(String JWTToken) { - this.JWTToken = JWTToken; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getDeviceType() { - return deviceType; - } - - public void setDeviceType(String deviceType) { - this.deviceType = deviceType; - } - - public int getTenantId() { - return tenantId; - } - - public void setTenantId(int tenantId) { - this.tenantId = tenantId; - } -} - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/config/IOTServerConfiguration.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/config/IOTServerConfiguration.java deleted file mode 100644 index 3beecf11f0..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/config/IOTServerConfiguration.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package org.wso2.carbon.apimgt.handlers.config; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; -import java.util.List; - -/** - * This class initialize the iot-api-config.xml and hold the values, in order to be read from the relevant classes. This - * get initialized at the start of the server when apis get loaded. - */ -@XmlRootElement(name = "ServerConfiguration") -public class IOTServerConfiguration { - - private String hostname; - private String verificationEndpoint; - private String username; - private String password; - private String dynamicClientRegistrationEndpoint; - private String oauthTokenEndpoint; - private List apis; - - @XmlElement(name = "Hostname", required = true) - public String getHostname() { - return hostname; - } - - public void setHostname(String hostname) { - this.hostname = hostname; - } - - @XmlElement(name = "VerificationEndpoint", required = true) - public String getVerificationEndpoint() { - return verificationEndpoint; - } - - public void setVerificationEndpoint(String verificationEndpoint) { - this.verificationEndpoint = verificationEndpoint; - } - - @XmlElement(name = "Username", required = true) - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - @XmlElement(name = "Password", required = true) - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @XmlElement(name = "DynamicClientRegistrationEndpoint", required = true) - public String getDynamicClientRegistrationEndpoint() { - return dynamicClientRegistrationEndpoint; - } - - public void setDynamicClientRegistrationEndpoint(String dynamicClientRegistrationEndpoint) { - this.dynamicClientRegistrationEndpoint = dynamicClientRegistrationEndpoint; - } - - @XmlElement(name = "OauthTokenEndpoint", required = true) - public String getOauthTokenEndpoint() { - return oauthTokenEndpoint; - } - - public void setOauthTokenEndpoint(String oauthTokenEndpoint) { - this.oauthTokenEndpoint = oauthTokenEndpoint; - } - - @XmlElementWrapper(name="APIS") - @XmlElement(name = "ContextPath", required = true) - public List getApis() { - return apis; - } - - public void setApis(List apis) { - this.apis = apis; - } - - @XmlRootElement(name = "ContextPath") - public static class ContextPath { - - private String contextPath; - - @XmlValue() - public String getContextPath() { - return contextPath; - } - - public void setContextPath(String contextPath) { - this.contextPath = contextPath; - } - } -} - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/invoker/RESTInvoker.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/invoker/RESTInvoker.java deleted file mode 100644 index bd59e03dc1..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/invoker/RESTInvoker.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.apimgt.handlers.invoker; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.*; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.apache.http.util.EntityUtils; - -import java.io.IOException; -import java.net.URI; -import java.util.Map; -import java.util.Set; - -public class RESTInvoker { - - private static final Log log = LogFactory.getLog(RESTInvoker.class); - - private CloseableHttpClient client = null; - - public RESTInvoker() { - configureHttpClient(); - } - - private void configureHttpClient() { - int connectionTimeout = 120000; - int socketTimeout = 120000; - int maxTotalConnectionsPerRoute = 100; - int maxTotalConnections = 100; - RequestConfig defaultRequestConfig = RequestConfig.custom() - .setExpectContinueEnabled(true) - .setConnectTimeout(connectionTimeout) - .setSocketTimeout(socketTimeout) - .build(); - PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); - connectionManager.setDefaultMaxPerRoute(maxTotalConnectionsPerRoute); - connectionManager.setMaxTotal(maxTotalConnections); - client = HttpClients.custom() - .setConnectionManager(connectionManager) - .setDefaultRequestConfig(defaultRequestConfig) - .build(); - if (log.isDebugEnabled()) { - log.debug("REST client initialized with " + - "maxTotalConnection = " + maxTotalConnections + - "maxConnectionsPerRoute = " + maxTotalConnectionsPerRoute + - "connectionTimeout = " + connectionTimeout); - } - - } - - public RESTResponse invokePOST(URI uri, Map requestHeaders, String payload) throws IOException { - - HttpPost httpPost = null; - CloseableHttpResponse response = null; - int httpStatus; - String output; - try { - httpPost = new HttpPost(uri); - httpPost.setEntity(new StringEntity(payload)); - if (requestHeaders != null && !requestHeaders.isEmpty()) { - Set keys = requestHeaders.keySet(); - for (String header : keys) { - httpPost.setHeader(header, requestHeaders.get(header)); - } - } - response = sendReceiveRequest(httpPost); - output = IOUtils.toString(response.getEntity().getContent()); - httpStatus = response.getStatusLine().getStatusCode(); - if (log.isDebugEnabled()) { - log.debug("Invoked POST " + uri.toString() + - " - Input payload: " + payload + " - Response message: " + output); - } - EntityUtils.consume(response.getEntity()); - } finally { - if (response != null) { - IOUtils.closeQuietly(response); - } - if (httpPost != null) { - httpPost.releaseConnection(); - } - } - return new RESTResponse(output, httpStatus); - } - - private CloseableHttpResponse sendReceiveRequest(HttpRequestBase requestBase) - throws IOException { - return client.execute(requestBase); - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/invoker/RESTResponse.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/invoker/RESTResponse.java deleted file mode 100644 index 205130b30e..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/invoker/RESTResponse.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.apimgt.handlers.invoker; - - -/** - * RESTResponse class holds the data retrieved from the HTTP invoke response. - */ -public class RESTResponse { - private String content; - private int httpStatus; - - /** - * Constructor - * - * @param content from the REST invoke response - * @param httpStatus from the REST invoke response - */ - RESTResponse(String content, int httpStatus) { - this.content = content; - this.httpStatus = httpStatus; - } - - - /** - * Get contents of the REST invoke response - * - * @return contents of the REST invoke response - */ - public String getContent() { - return content; - } - - /** - * Get the HTTP Status code from REST invoke response - * - * @return int HTTP status code - */ - public int getHttpStatus() { - return httpStatus; - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/AuthConstants.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/AuthConstants.java deleted file mode 100644 index d9a9ef8a7b..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/AuthConstants.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.apimgt.handlers.utils; - -/** - * This initializes the constance. - */ -public class AuthConstants { - public static final String MDM_SIGNATURE = "mdm-signature"; - public static final String PROXY_MUTUAL_AUTH_HEADER = "proxy-mutual-auth-header"; - public static final String MUTUAL_AUTH_HEADER = "mutual-auth-header"; - public static final String ONE_TIME_TOKEN_HEADER = "one-time-token"; - public static final String ENCODED_PEM = "encoded-pem"; - public static final String CALLBACK_URL = ""; - public static final String CLIENT_NAME = "IOT-API-MANAGER"; - public static final String GRANT_TYPE = "refresh_token password client_credentials"; - public static final String TOKEN_SCOPE = "default"; - public static final String CONTENT_TYPE_HEADER = "Content-Type"; - public static final String CONTENT_TYPE = "application/json"; - public static final String AUTHORIZATION_HEADER = "Authorization"; - public static final String BASIC_AUTH_PREFIX = "Basic "; - public static final String CLIENT_ID = "clientId"; - public static final String CLIENT_SECRET = "clientSecret"; - public static final String CLIENT_CERTIFICATE = "ssl.client.auth.cert.X509"; -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/Utils.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/Utils.java deleted file mode 100644 index 2e5d2e164a..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org/wso2/carbon/apimgt/handlers/utils/Utils.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package org.wso2.carbon.apimgt.handlers.utils; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.ws.security.util.Base64; -import org.json.JSONException; -import org.json.JSONObject; -import org.w3c.dom.Document; -import org.wso2.carbon.apimgt.handlers.APIMCertificateMGTException; -import org.wso2.carbon.apimgt.handlers.beans.DCR; -import org.wso2.carbon.apimgt.handlers.config.IOTServerConfiguration; -import org.wso2.carbon.apimgt.handlers.invoker.RESTInvoker; -import org.wso2.carbon.apimgt.handlers.invoker.RESTResponse; -import io.entgra.device.mgt.core.certificate.mgt.core.service.CertificateManagementService; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.utils.CarbonUtils; - -import javax.xml.XMLConstants; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Contains util methods for synapse gateway authentication handler - */ -public class Utils { - - private static final Log log = LogFactory.getLog(Utils.class); - private static final String IOT_APIS_CONFIG_FILE = "iot-api-config.xml"; - private static String clientId; - private static String clientSecret; - - /** - * This method initializes the iot-api-config.xml file. - * - * @return IoTServerConfiguration Object based on the configuration file. - */ - public static IOTServerConfiguration initConfig() { - return initConfig(CarbonUtils.getCarbonConfigDirPath() + File.separator + IOT_APIS_CONFIG_FILE); - } - - /** - * This methods initialized the iot-api-config.xml from provided path. - * - * @param path The actual file path of iot-api-config.xml - * @return The instance of the IOTServerConfiguration based on the configuration. - */ - public static IOTServerConfiguration initConfig(String path) { - try { - File file = new File(path); - Document doc = Utils.convertToDocument(file); - - JAXBContext fileContext = JAXBContext.newInstance(IOTServerConfiguration.class); - Unmarshaller unmarshaller = fileContext.createUnmarshaller(); - - IOTServerConfiguration iotServerConfiguration = (IOTServerConfiguration) unmarshaller.unmarshal( - doc); - iotServerConfiguration.setHostname(replaceProperties(iotServerConfiguration.getHostname())); - iotServerConfiguration.setVerificationEndpoint( - replaceProperties(iotServerConfiguration.getVerificationEndpoint())); - iotServerConfiguration.setDynamicClientRegistrationEndpoint( - replaceProperties(iotServerConfiguration.getDynamicClientRegistrationEndpoint())); - iotServerConfiguration.setOauthTokenEndpoint( - replaceProperties(iotServerConfiguration.getOauthTokenEndpoint())); - return iotServerConfiguration; - } catch (JAXBException | APIMCertificateMGTException e) { - log.error("Error occurred while initializing Data Source config", e); - return null; - } - } - - /** - * This method gets the values from system variables and sets to xml. - */ - private static String replaceProperties(String text) { - String regex = "\\$\\{(.*?)\\}"; - Pattern pattern = Pattern.compile(regex); - Matcher matchPattern = pattern.matcher(text); - while (matchPattern.find()) { - String sysPropertyName = matchPattern.group(1); - String sysPropertyValue = System.getProperty(sysPropertyName); - if (sysPropertyValue != null && !sysPropertyName.isEmpty()) { - text = text.replaceAll("\\$\\{(" + sysPropertyName + ")\\}", sysPropertyValue); - } - } - return text; - } - - /** - * This class build the iot-api-config.xml file. - * - * @param file The file object of iot-api-config.xml. - * @return Document instance of the file - * @throws APIMCertificateMGTException - */ - private static Document convertToDocument(File file) throws APIMCertificateMGTException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - try { - factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); - DocumentBuilder docBuilder = factory.newDocumentBuilder(); - return docBuilder.parse(file); - } catch (Exception e) { - throw new APIMCertificateMGTException("Error occurred while parsing file, while converting " + - "to a org.w3c.dom.Document", e); - } - } - - /** - * This method is used to get the base64 encoded token. - * - * @param iotServerConfiguration Instance of the IoTsererConfiguration. - * @return Access token will be returned. - */ - public static String getBase64EncodedToken(IOTServerConfiguration iotServerConfiguration) { - return Base64.encode((iotServerConfiguration.getUsername() + ":" + iotServerConfiguration.getPassword()). - getBytes()); - } - - /** - * This method register an application to get the client key and secret. - * - * @param iotServerConfiguration Instance of the IoTServerConfiguration. - * @throws APIMCertificateMGTException - */ - private static void getClientSecretes(IOTServerConfiguration iotServerConfiguration, RESTInvoker restInvoker) - throws APIMCertificateMGTException { - try { - String username = iotServerConfiguration.getUsername(); - String password = iotServerConfiguration.getPassword(); - DCR dcr = new DCR(); - dcr.setOwner(iotServerConfiguration.getUsername()); - dcr.setClientName(AuthConstants.CLIENT_NAME); - dcr.setGrantType(AuthConstants.GRANT_TYPE); - dcr.setTokenScope(AuthConstants.TOKEN_SCOPE); - dcr.setCallbackUrl(AuthConstants.CALLBACK_URL); - dcr.setIsSaasApp(true); - String dcrContent = dcr.toJSON(); - Map dcrHeaders = new HashMap<>(); - String basicAuth = Base64.encode((username + ":" + password).getBytes()); - dcrHeaders.put(AuthConstants.CONTENT_TYPE_HEADER, AuthConstants.CONTENT_TYPE); - dcrHeaders.put(AuthConstants.AUTHORIZATION_HEADER, AuthConstants.BASIC_AUTH_PREFIX + basicAuth); - URI dcrUrl = new URI(iotServerConfiguration.getDynamicClientRegistrationEndpoint()); - RESTResponse response = restInvoker.invokePOST(dcrUrl, dcrHeaders, dcrContent); - if (log.isDebugEnabled()) { - log.debug("DCR response :" + response.getContent()); - } - JSONObject jsonResponse = new JSONObject(response.getContent()); - clientId = jsonResponse.getString(AuthConstants.CLIENT_ID); - clientSecret = jsonResponse.getString(AuthConstants.CLIENT_SECRET); - } catch (JSONException e) { - throw new APIMCertificateMGTException("Error occurred while converting the json to object", e); - } catch (IOException | URISyntaxException e) { - throw new APIMCertificateMGTException("Error occurred while trying to call DCR endpoint", e); - } - - } - - public static CertificateManagementService getCertificateManagementService() { - - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - CertificateManagementService certificateManagementService = (CertificateManagementService) - ctx.getOSGiService(CertificateManagementService.class, null); - - if (certificateManagementService == null) { - String msg = "CertificateManagementAdminServiceImpl Management service not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - - return certificateManagementService; - } - -} - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/resources/iot-api-config.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/resources/iot-api-config.xml deleted file mode 100644 index 7b1462746b..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/resources/iot-api-config.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - https://${iot.core.host}:${iot.core.https.port}/ - - - https://${iot.core.host}:${iot.core.https.port}/api/certificate-mgt/v1.0/admin/certificates/verify/ - - - admin - admin - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token - - - /services - - \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandlerTest.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandlerTest.java deleted file mode 100644 index 5a9370a56e..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/AuthenticationHandlerTest.java +++ /dev/null @@ -1,296 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.apimgt.handlers; - -import com.google.gson.Gson; -import junit.framework.Assert; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMDocument; -import org.apache.axiom.soap.SOAPEnvelope; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.axis2.engine.AxisConfiguration; -import org.apache.http.ProtocolVersion; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.entity.BasicHttpEntity; -import org.apache.http.message.BasicStatusLine; -import org.apache.synapse.MessageContext; -import org.apache.synapse.config.SynapseConfigUtils; -import org.apache.synapse.config.SynapseConfiguration; -import org.apache.synapse.core.SynapseEnvironment; -import org.apache.synapse.core.axis2.Axis2MessageContext; -import org.apache.synapse.core.axis2.Axis2SynapseEnvironment; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.apimgt.handlers.beans.ValidationResponce; -import org.wso2.carbon.apimgt.handlers.invoker.RESTInvoker; -import org.wso2.carbon.apimgt.handlers.mock.MockClient; -import org.wso2.carbon.apimgt.handlers.mock.MockHttpResponse; -import org.wso2.carbon.apimgt.handlers.utils.AuthConstants; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Field; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import javax.security.cert.X509Certificate; - -/** - * This testcase will focus on covering the methods of {@link AuthenticationHandler} - */ -public class AuthenticationHandlerTest extends BaseAPIHandlerTest { - - private AuthenticationHandler handler; - private SynapseConfiguration synapseConfiguration; - private MockClient mockClient; - - @BeforeClass - public void initTest() { - TestUtils.setSystemProperties(); - this.handler = new AuthenticationHandler(); - this.synapseConfiguration = new SynapseConfiguration(); - } - - @Test(description = "Handle request with empty transport headers") - public void testHandleRequestWithEmptyTransportHeader() throws Exception { - boolean response = this.handler.handleRequest(createSynapseMessageContext("", this.synapseConfiguration, - new HashMap<>(), "https://test.com/testservice")); - Assert.assertFalse(response); - } - - @Test(description = "Handle request with without device type", - dependsOnMethods = "testHandleRequestWithEmptyTransportHeader") - public void testHandleRequestWithoutDeviceType() throws Exception { - HashMap transportHeaders = new HashMap<>(); - transportHeaders.put(AuthConstants.MDM_SIGNATURE, "some cert"); - boolean response = this.handler.handleRequest(createSynapseMessageContext("", this.synapseConfiguration, - transportHeaders, "https://test.com/testservice")); - Assert.assertFalse(response); - } - - @Test(description = "Handle request with device type URI with MDM ceritificate", - dependsOnMethods = "testHandleRequestWithoutDeviceType") - public void testHandleSuccessfulRequestMDMCertificate() throws Exception { - HashMap transportHeaders = new HashMap<>(); - transportHeaders.put(AuthConstants.MDM_SIGNATURE, "some cert"); - setMockClient(); - this.mockClient.setResponse(getValidationResponse()); - boolean response = this.handler.handleRequest(createSynapseMessageContext("", this.synapseConfiguration, - transportHeaders, "https://test.com/testservice/device-mgt/testdevice")); - Assert.assertTrue(response); - this.mockClient.reset(); - } - - @Test(description = "Handle request with device type URI with Mutual Auth Header", - dependsOnMethods = "testHandleSuccessfulRequestMDMCertificate") - public void testHandleSuccessRequestMutualAuthHeader() throws Exception { - HashMap transportHeaders = new HashMap<>(); - transportHeaders.put(AuthConstants.MUTUAL_AUTH_HEADER, "Test Header"); - setMockClient(); - this.mockClient.setResponse(getValidationResponse()); - MessageContext messageContext = createSynapseMessageContext("", this.synapseConfiguration, - transportHeaders, "https://test.com/testservice/device-mgt/testdevice"); - org.apache.axis2.context.MessageContext axisMC = ((Axis2MessageContext) messageContext).getAxis2MessageContext(); - String certStr = getContent(TestUtils.getAbsolutePathOfConfig("ra_cert.pem")); - X509Certificate cert = X509Certificate.getInstance(new ByteArrayInputStream(certStr. - getBytes(StandardCharsets.UTF_8.name()))); - axisMC.setProperty(AuthConstants.CLIENT_CERTIFICATE, new X509Certificate[]{cert}); - boolean response = this.handler.handleRequest(messageContext); - Assert.assertTrue(response); - this.mockClient.reset(); - } - - @Test(description = "Handle request with device type URI with Encoded Pem", - dependsOnMethods = "testHandleSuccessRequestMutualAuthHeader") - public void testHandleSuccessRequestEncodedPem() throws Exception { - HashMap transportHeaders = new HashMap<>(); - transportHeaders.put(AuthConstants.ENCODED_PEM, "encoded pem"); - setMockClient(); - this.mockClient.setResponse(getValidationResponse()); - MessageContext messageContext = createSynapseMessageContext("", this.synapseConfiguration, - transportHeaders, "https://test.com/testservice/device-mgt/testdevice"); - boolean response = this.handler.handleRequest(messageContext); - Assert.assertTrue(response); - this.mockClient.reset(); - } - - @Test(description = "Handle request with device type URI with Encoded Pem with invalid response", - dependsOnMethods = "testHandleSuccessRequestEncodedPem") - public void testHandleSuccessRequestEncodedPemInvalidResponse() throws Exception { - HashMap transportHeaders = new HashMap<>(); - transportHeaders.put(AuthConstants.ENCODED_PEM, "encoded pem"); - setMockClient(); - this.mockClient.setResponse(getInvalidResponse()); - MessageContext messageContext = createSynapseMessageContext("", this.synapseConfiguration, - transportHeaders, "https://test.com/testservice/device-mgt/testdevice"); - boolean response = this.handler.handleRequest(messageContext); - Assert.assertFalse(response); - this.mockClient.reset(); - } - - @Test(description = "Handle request with cert management exception ", - dependsOnMethods = "testHandleSuccessRequestEncodedPem") - public void testHandleRequestWithCertMgmtException() throws Exception { - HashMap transportHeaders = new HashMap<>(); - transportHeaders.put(AuthConstants.ENCODED_PEM, "encoded pem"); - setMockClient(); - this.mockClient.setResponse(null); - MessageContext messageContext = createSynapseMessageContext("", this.synapseConfiguration, - transportHeaders, "https://test.com/testservice/device-mgt/testdevice"); - boolean response = this.handler.handleRequest(messageContext); - Assert.assertFalse(response); - this.mockClient.reset(); - } - - @Test(description = "Handle request with IO exception", - dependsOnMethods = "testHandleRequestWithCertMgmtException") - public void testHandleRequestWithIOException() throws Exception { - HashMap transportHeaders = new HashMap<>(); - transportHeaders.put(AuthConstants.ENCODED_PEM, "encoded pem"); - setMockClient(); - this.mockClient.setResponse(null); - MessageContext messageContext = createSynapseMessageContext("", this.synapseConfiguration, - transportHeaders, "https://test.com/testservice/device-mgt/testdevice"); - boolean response = this.handler.handleRequest(messageContext); - Assert.assertFalse(response); - this.mockClient.reset(); - } - - @Test(description = "Handle request with URI exception", - dependsOnMethods = "testHandleRequestWithIOException") - public void testHandleRequestWithURIException() throws Exception { - TestUtils.resetSystemProperties(); - HashMap transportHeaders = new HashMap<>(); - transportHeaders.put(AuthConstants.MDM_SIGNATURE, "some cert"); - AuthenticationHandler handler = new AuthenticationHandler(); - boolean response = handler.handleRequest(createSynapseMessageContext("", this.synapseConfiguration, - transportHeaders, "https://test.com/testservice/device-mgt/testdevice")); - Assert.assertFalse(response); - TestUtils.setSystemProperties(); - } - - @Test(description = "Handle response") - public void testHandleResponse() throws Exception { - boolean response = this.handler.handleResponse(null); - Assert.assertTrue(response); - } - - - private static MessageContext createSynapseMessageContext( - String payload, SynapseConfiguration config, HashMap transportHeaders, - String address) throws Exception { - org.apache.axis2.context.MessageContext mc = - new org.apache.axis2.context.MessageContext(); - AxisConfiguration axisConfig = config.getAxisConfiguration(); - if (axisConfig == null) { - axisConfig = new AxisConfiguration(); - config.setAxisConfiguration(axisConfig); - } - ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig); - SynapseEnvironment env = new Axis2SynapseEnvironment(cfgCtx, config); - MessageContext synMc = new Axis2MessageContext(mc, config, env); - SOAPEnvelope envelope = - OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope(); - OMDocument omDoc = - OMAbstractFactory.getSOAP11Factory().createOMDocument(); - omDoc.addChild(envelope); - envelope.getBody().addChild(SynapseConfigUtils.stringToOM(payload)); - synMc.setEnvelope(envelope); - synMc.setTo(new EndpointReference(address)); - org.apache.axis2.context.MessageContext axis2MessageContext = - ((Axis2MessageContext) synMc).getAxis2MessageContext(); - axis2MessageContext.setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, transportHeaders); - return synMc; - } - - private void setMockClient() throws NoSuchFieldException, IllegalAccessException { - Field restInvokerField = this.handler.getClass().getDeclaredField("restInvoker"); - restInvokerField.setAccessible(true); - RESTInvoker restInvoker = (RESTInvoker) restInvokerField.get(this.handler); - Field clientField = restInvoker.getClass().getDeclaredField("client"); - clientField.setAccessible(true); - this.mockClient = new MockClient(); - clientField.set(restInvoker, this.mockClient); - } - - private CloseableHttpResponse getDCRResponse() throws IOException { - CloseableHttpResponse mockDCRResponse = new MockHttpResponse(); - String dcrResponseFile = TestUtils.getAbsolutePathOfConfig("dcr-response.json"); - BasicHttpEntity responseEntity = new BasicHttpEntity(); - responseEntity.setContent(new ByteArrayInputStream(getContent(dcrResponseFile). - getBytes(StandardCharsets.UTF_8.name()))); - responseEntity.setContentType(TestUtils.CONTENT_TYPE); - mockDCRResponse.setEntity(responseEntity); - mockDCRResponse.setStatusLine(new BasicStatusLine(new ProtocolVersion("http", 1, 0), 200, "OK")); - return mockDCRResponse; - } - - private CloseableHttpResponse getAccessTokenReponse() throws IOException { - CloseableHttpResponse mockDCRResponse = new MockHttpResponse(); - String dcrResponseFile = TestUtils.getAbsolutePathOfConfig("accesstoken-response.json"); - BasicHttpEntity responseEntity = new BasicHttpEntity(); - responseEntity.setContent(new ByteArrayInputStream(getContent(dcrResponseFile). - getBytes(StandardCharsets.UTF_8.name()))); - responseEntity.setContentType(TestUtils.CONTENT_TYPE); - mockDCRResponse.setEntity(responseEntity); - mockDCRResponse.setStatusLine(new BasicStatusLine(new ProtocolVersion("http", 1, 0), 200, "OK")); - return mockDCRResponse; - } - - private CloseableHttpResponse getValidationResponse() throws UnsupportedEncodingException { - ValidationResponce response = new ValidationResponce(); - response.setDeviceId("1234"); - response.setDeviceType("testdevice"); - response.setJWTToken("1234567788888888"); - response.setTenantId(-1234); - Gson gson = new Gson(); - String jsonReponse = gson.toJson(response); - CloseableHttpResponse mockDCRResponse = new MockHttpResponse(); - BasicHttpEntity responseEntity = new BasicHttpEntity(); - responseEntity.setContent(new ByteArrayInputStream(jsonReponse.getBytes(StandardCharsets.UTF_8.name()))); - responseEntity.setContentType(TestUtils.CONTENT_TYPE); - mockDCRResponse.setEntity(responseEntity); - mockDCRResponse.setStatusLine(new BasicStatusLine(new ProtocolVersion("http", 1, 0), 200, "OK")); - return mockDCRResponse; - } - - private CloseableHttpResponse getInvalidResponse() throws UnsupportedEncodingException { - CloseableHttpResponse mockDCRResponse = new MockHttpResponse(); - BasicHttpEntity responseEntity = new BasicHttpEntity(); - responseEntity.setContent(new ByteArrayInputStream("invalid response".getBytes(StandardCharsets.UTF_8.name()))); - responseEntity.setContentType(TestUtils.CONTENT_TYPE); - mockDCRResponse.setEntity(responseEntity); - mockDCRResponse.setStatusLine(new BasicStatusLine(new ProtocolVersion("http", 1, 0), 400, "Bad Request")); - return mockDCRResponse; - } - - private String getContent(String filePath) throws IOException { - FileReader fileReader = new FileReader(filePath); - BufferedReader bufferedReader = new BufferedReader(fileReader); - String content = ""; - String line; - while ((line = bufferedReader.readLine()) != null) { - content += line + "\n"; - } - bufferedReader.close(); - return content; - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/BaseAPIHandlerTest.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/BaseAPIHandlerTest.java deleted file mode 100644 index 57a293e2eb..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/BaseAPIHandlerTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.apimgt.handlers; - -import org.testng.annotations.BeforeSuite; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; - -import java.io.File; - -/** - * This is the base test case for API Handler tests. - */ -public class BaseAPIHandlerTest { - - @BeforeSuite - public void init() { - setUpCarbonHome(); - } - - private void setUpCarbonHome() { - 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("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); - } - -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/IOTServerConfigurationTest.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/IOTServerConfigurationTest.java deleted file mode 100644 index 1b7a88dd3b..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/IOTServerConfigurationTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.apimgt.handlers; - -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.apimgt.handlers.config.IOTServerConfiguration; -import org.wso2.carbon.apimgt.handlers.utils.Utils; - -import java.io.File; - -/** - * This class validates the behaviour of {@link IOTServerConfiguration} - */ -public class IOTServerConfigurationTest extends BaseAPIHandlerTest { - private static final String CONFIG_DIR = "carbon-home" + File.separator + "repository" + File.separator + - "conf" + File.separator; - - @BeforeClass - public void initTest(){ - TestUtils.resetSystemProperties(); - } - - @Test(description = "Validating the IoT Server configuration initialization without system properties") - public void initConfigWithoutSystemProps() { - IOTServerConfiguration serverConfiguration = Utils.initConfig(); - Assert.assertTrue(serverConfiguration != null); - Assert.assertEquals(serverConfiguration.getHostname(), "https://${iot.core.host}:${iot.core.https.port}/"); - Assert.assertEquals(serverConfiguration.getVerificationEndpoint(), - "https://${iot.core.host}:${iot.core.https.port}/api/certificate-mgt/v1.0/admin/certificates/verify/"); - Assert.assertEquals(serverConfiguration.getUsername(), "testuser"); - Assert.assertEquals(serverConfiguration.getPassword(), "testuserpwd"); - Assert.assertEquals(serverConfiguration.getDynamicClientRegistrationEndpoint(), - "https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register"); - Assert.assertEquals(serverConfiguration.getOauthTokenEndpoint(), - "https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token"); - Assert.assertEquals(serverConfiguration.getApis().size(), 1); - Assert.assertEquals(serverConfiguration.getApis().get(0).getContextPath(), "/services"); - } - - @Test(description = "Initializing IoT server config with invalid configuration", - dependsOnMethods = "initConfigWithoutSystemProps") - public void initConfigWithInvalidConfig() { - IOTServerConfiguration serverConfig = Utils.initConfig(TestUtils.getAbsolutePathOfConfig(CONFIG_DIR - + "iot-api-config-invalid.xml")); - Assert.assertEquals(serverConfig, null); - } - - @Test(description = "Initializing IoT server config with invalid xml", - dependsOnMethods = "initConfigWithInvalidConfig") - public void initConfigWithInvalidXMLConfig() { - IOTServerConfiguration serverConfig = Utils.initConfig(TestUtils.getAbsolutePathOfConfig(CONFIG_DIR + - "iot-api-config-invalid-xml.xml")); - Assert.assertEquals(serverConfig, null); - } - - @Test(description = "Initializing IoT server config with system configs", - dependsOnMethods = "initConfigWithInvalidXMLConfig") - public void initConfigWithSystemProps() { - TestUtils.setSystemProperties(); - IOTServerConfiguration serverConfiguration = Utils.initConfig(); - Assert.assertTrue(serverConfiguration != null); - Assert.assertEquals(serverConfiguration.getHostname(), "https://" + TestUtils.IOT_CORE_HOST + ":" - + TestUtils.IOT_CORE_HTTPS_PORT - + "/"); - Assert.assertEquals(serverConfiguration.getVerificationEndpoint(), - "https://" + TestUtils.IOT_CORE_HOST + ":" + TestUtils.IOT_CORE_HTTPS_PORT + - "/api/certificate-mgt/v1.0/admin/certificates/" + - "verify/"); - Assert.assertEquals(serverConfiguration.getUsername(), "testuser"); - Assert.assertEquals(serverConfiguration.getPassword(), "testuserpwd"); - Assert.assertEquals(serverConfiguration.getDynamicClientRegistrationEndpoint(), - "https://" + TestUtils.IOT_KEYMANAGER_HOST + ":" + TestUtils.IOT_KEYMANAGER_PORT - + "/client-registration/v0.12/register"); - Assert.assertEquals(serverConfiguration.getOauthTokenEndpoint(), - "https://" + TestUtils.IOT_KEYMANAGER_HOST + ":" + TestUtils.IOT_KEYMANAGER_PORT - + "/oauth2/token"); - Assert.assertEquals(serverConfiguration.getApis().size(), 1); - Assert.assertEquals(serverConfiguration.getApis().get(0).getContextPath(), "/services"); - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/TestUtils.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/TestUtils.java deleted file mode 100644 index 5b22e1c5d9..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/TestUtils.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.apimgt.handlers; - -import org.testng.Assert; - -import java.io.File; -import java.net.URL; - -/** - * Utils class which provides utility methods for other testcases. - */ -public class TestUtils { - static final String IOT_CORE_HOST = "iot.core.wso2.com"; - static final String IOT_CORE_HTTPS_PORT = "9443"; - static final String IOT_KEYMANAGER_HOST = "iot.keymanager.wso2.com"; - static final String IOT_KEYMANAGER_PORT = "9443"; - static final String CONTENT_TYPE = "application/json"; - - private static final String IOT_HOST_PROPERTY = "iot.core.host"; - private static final String IOT_PORT_PROPERTY = "iot.core.https.port"; - private static final String IOT_KEY_MANAGER_HOST_PROPERTY = "iot.keymanager.host"; - private static final String IOT_KEY_MANAGER_PORT_PROPERTY = "iot.keymanager.https.port"; - - static String getAbsolutePathOfConfig(String configFilePath) { - ClassLoader classLoader = TestUtils.class.getClassLoader(); - URL invalidConfig = classLoader.getResource(configFilePath); - Assert.assertTrue(invalidConfig != null); - File file = new File(invalidConfig.getFile()); - return file.getAbsolutePath(); - } - - static void setSystemProperties() { - System.setProperty(IOT_HOST_PROPERTY, IOT_CORE_HOST); - System.setProperty(IOT_PORT_PROPERTY, IOT_CORE_HTTPS_PORT); - System.setProperty(IOT_KEY_MANAGER_HOST_PROPERTY, IOT_KEYMANAGER_HOST); - System.setProperty(IOT_KEY_MANAGER_PORT_PROPERTY, IOT_KEYMANAGER_PORT); - } - - static void resetSystemProperties() { - System.clearProperty(IOT_HOST_PROPERTY); - System.clearProperty(IOT_PORT_PROPERTY); - System.clearProperty(IOT_KEY_MANAGER_HOST_PROPERTY); - System.clearProperty(IOT_KEY_MANAGER_PORT_PROPERTY); - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/mock/MockClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/mock/MockClient.java deleted file mode 100644 index 0c8ab4f6bd..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/mock/MockClient.java +++ /dev/null @@ -1,76 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.apimgt.handlers.mock; - -import org.apache.http.HttpHost; -import org.apache.http.HttpRequest; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.conn.ClientConnectionManager; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.params.HttpParams; -import org.apache.http.protocol.HttpContext; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Mock implementation for CloseableHttpClient to be used in test cases. - */ -public class MockClient extends CloseableHttpClient { - private List responses = new ArrayList<>(); - private int responseCount = 0; - - @Override - protected CloseableHttpResponse doExecute(HttpHost httpHost, HttpRequest httpRequest, HttpContext httpContext) - throws IOException { - if (this.responseCount < this.responses.size()) { - this.responseCount++; - CloseableHttpResponse response = this.responses.get(this.responseCount - 1); - if (response == null) { - throw new IOException("test exception"); - } - return response; - } else { - return new MockHttpResponse(); - } - } - - @Override - public void close() throws IOException { - } - - @Override - public HttpParams getParams() { - return null; - } - - @Override - public ClientConnectionManager getConnectionManager() { - return null; - } - - public void setResponse(CloseableHttpResponse reponse) { - this.responses.add(reponse); - } - - public void reset() { - this.responses.clear(); - this.responseCount = 0; - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/mock/MockHttpResponse.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/mock/MockHttpResponse.java deleted file mode 100644 index adfd7652c5..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/java/org/wso2/carbon/apimgt/handlers/mock/MockHttpResponse.java +++ /dev/null @@ -1,178 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.apimgt.handlers.mock; - -import org.apache.http.Header; -import org.apache.http.HeaderIterator; -import org.apache.http.HttpEntity; -import org.apache.http.ProtocolVersion; -import org.apache.http.StatusLine; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.params.HttpParams; - -import java.io.IOException; -import java.util.Locale; - -/** - * Mock http response to be used in the test cases. - * - */ -public class MockHttpResponse implements CloseableHttpResponse { - private HttpEntity httpEntity; - private StatusLine statusLine; - - @Override - public void close() throws IOException { - - } - - @Override - public StatusLine getStatusLine() { - return this.statusLine; - } - - @Override - public void setStatusLine(StatusLine statusLine) { - this.statusLine = statusLine; - } - - @Override - public void setStatusLine(ProtocolVersion protocolVersion, int i) { - - } - - @Override - public void setStatusLine(ProtocolVersion protocolVersion, int i, String s) { - - } - - @Override - public void setStatusCode(int i) throws IllegalStateException { - - } - - @Override - public void setReasonPhrase(String s) throws IllegalStateException { - - } - - @Override - public HttpEntity getEntity() { - return this.httpEntity; - } - - @Override - public void setEntity(HttpEntity httpEntity) { - this.httpEntity = httpEntity; - } - - @Override - public Locale getLocale() { - return null; - } - - @Override - public void setLocale(Locale locale) { - - } - - @Override - public ProtocolVersion getProtocolVersion() { - return null; - } - - @Override - public boolean containsHeader(String s) { - return false; - } - - @Override - public Header[] getHeaders(String s) { - return new Header[0]; - } - - @Override - public Header getFirstHeader(String s) { - return null; - } - - @Override - public Header getLastHeader(String s) { - return null; - } - - @Override - public Header[] getAllHeaders() { - return new Header[0]; - } - - @Override - public void addHeader(Header header) { - - } - - @Override - public void addHeader(String s, String s1) { - - } - - @Override - public void setHeader(Header header) { - - } - - @Override - public void setHeader(String s, String s1) { - - } - - @Override - public void setHeaders(Header[] headers) { - - } - - @Override - public void removeHeader(Header header) { - - } - - @Override - public void removeHeaders(String s) { - - } - - @Override - public HeaderIterator headerIterator() { - return null; - } - - @Override - public HeaderIterator headerIterator(String s) { - return null; - } - - @Override - public HttpParams getParams() { - return null; - } - - @Override - public void setParams(HttpParams httpParams) { - - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/accesstoken-response.json b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/accesstoken-response.json deleted file mode 100644 index 11be1e29eb..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/accesstoken-response.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "scope": "API_SUBSCRIBER_SCOPE", - "token_type": "Bearer", - "expires_in": 3600, - "refresh_token": "33c3be152ebf0030b3fb76f2c1f80bf8", - "access_token": "292ff0fd256814536baca0926f483c8d" -} \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/carbon.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/carbon.xml deleted file mode 100644 index a5518cb720..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/carbon.xml +++ /dev/null @@ -1,658 +0,0 @@ - - - - - - - - - ${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/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/iot-api-config-invalid-xml.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/iot-api-config-invalid-xml.xml deleted file mode 100644 index 2f174b3f03..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/iot-api-config-invalid-xml.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - https://${iot.core.host}:${iot.core.https.port}/ - - - https://${iot.core.host}:${iot.core.https.port}/api/certificate-mgt/v1.0/admin/certificates/verify/ - - - testuser - testuserpwd - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token - - - /services - - - - - - - https://${iot.core.host}:${iot.core.https.port}/ - - - https://${iot.core.host}:${iot.core.https.port}/api/certificate-mgt/v1.0/admin/certificates/verify/ - - - testuser - testuserpwd - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token - - - /services - - \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/iot-api-config.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/iot-api-config.xml deleted file mode 100644 index 4224c27a07..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/iot-api-config.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - https://${iot.core.host}:${iot.core.https.port}/ - - - https://${iot.core.host}:${iot.core.https.port}/api/certificate-mgt/v1.0/admin/certificates/verify/ - - - testuser - testuserpwd - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token - - - /services - - \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/registry.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/registry.xml deleted file mode 100644 index 331c448c87..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/carbon-home/repository/conf/registry.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - wso2registry - false - true - / - - - jdbc:h2:./target/databasetest/CARBON_TEST - - org.h2.Driver - 80 - 60000 - 5 - - - false - - - - true - true - true - true - - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/dcr-response.json b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/dcr-response.json deleted file mode 100644 index 1672f812d7..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/dcr-response.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "callBackURL": "www.google.lk", - "clientName": null, - "clientId": "HfEl1jJPdg5tbtrxhAwybN05QGoa", - "clientSecret": "l6c0aoLcWR3fwezHhc7XoGOht5Aa" -} \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/ra_cert.pem b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/ra_cert.pem deleted file mode 100644 index 516b08ccee..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/ra_cert.pem +++ /dev/null @@ -1,33 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFqDCCA5CgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBizELMAkGA1UEBhMCVVMx -DTALBgNVBAgTBFRlc3QxDTALBgNVBAcTBFRlc3QxETAPBgNVBAoTCFRlc3QgT3Jn -MRYwFAYDVQQLEw1UZXN0IG9yZyB1bml0MRUwEwYDVQQDEwxXU08yIFJvb3QgQ0Ex -HDAaBgkqhkiG9w0BCQEWDXJvb3RAd3NvMi5jb20wHhcNMTUwMTI3MTI1MzAxWhcN -MTcxMDIzMTI1MzAxWjCBgzELMAkGA1UEBhMCVVMxGTAXBgNVBAgTEFRlc3QgUkEg -UHJvdmluY2UxFTATBgNVBAcTDFRlc3QgUkEgQ2l0eTEUMBIGA1UEChMLVGVzdCBS -QSBPcmcxGTAXBgNVBAsTEFRlc3QgUkEgb3JnIHVuaXQxETAPBgNVBAMTCFdTTzIg -UkEgMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtUMgUlYYU3/TPfEe -zNAvBaiOi/jUjfZ9IbxvMl7obDT17/5vU68TCGkZRjyfYUEiGNBisUEFWjSk/sGL -/ofYKUAxw33cd456FLMjaJX/4Zk4y8eYB1m1GGlHejoDyjPhq8S6GDmy+PXbJr8n -lSTROR2mQHkGwYrCreWeU4AYWzdctIFk7U2DKeIvZYSidIIjfSpDXURxrt9LPvig -fMzr5l/WkZfjvk5S+W7rgMtpllxlEPgyDc07pNAdNSq5FB990oaUsVX8o6l6wdCw -grYz83edPOKwZa04fsVztz2oF3ZYSGGjD3lwh0KS/jUL+awRyhMx5p/O1hySg6PP -pJjeqRuobNTuwSAXxp3nsNSY0DkGW04pSxWoDQqhnpaqBbAf71l6ya2e3so1SHm/ -jouWSYTHncq5bmGE4AN7ZGVGZvfx84+UR8fNxJxxLo+DFFE0oJNzpPGNxILpHxgT -V7IOII6mhfkrQk+AFQiW2Y5FXLVYv8r+SPXW8pYsjaWl971XZeM/HC3L9IZkCrrr -a0ID5oT6vt+xTmdo4yiBqIP5TBYm+1a9YzMAy7XGtPih9k6cufMLcfzvUZdOXw9x -3T05nM5ZtcDq0gHvUzQ7sfHTguWVnuHVEdb2ox4x2L5NzEA475fbSdXpMok9z/z7 -Xa71vIZi28InDAFBQehUlJnFtf0CAwEAAaMdMBswDAYDVR0TBAUwAwEB/zALBgNV -HQ8EBAMCBaAwDQYJKoZIhvcNAQEFBQADggIBAAO0TwnQBMJvL8wbfsnTqAGCCHM4 -x1cpW+KgTmflPEliYGOn/dJYDz/dUowCgoj5mrSxjQ3G1/qL+9Y7E33h0tyw37vH -YDL1p2Tn+fwmXRHrk+CHoPHNcImEfSIDWbbG7ehBR6erVfbQSZjmj4fwPkItp8rP -nyUtXHOLpfFYoAxYkNP9+C8vpC9W/H1pj3rzmQFA1z+EZAKVV7vDAxbe6sun84nf -YAaMSIzHx1B+XLHokgChmnZr3wV7EypBEmmKp4ITvJqK7WsIG9t1M6hI7OTPCURR -mdy+DJtIoIUbZxHyIyC9nPcVJFkdBusnfXq4uMb0KMaWYCU8ESqZPySukF2qZ5KA -acB+0ZhY+EGQ6QF/hB6iiUj96BlQ7XAPXFU6xUt6nRjDiJmb3vW1IEv0hpbs7PRl -UMlbOwQk37rXpFqQc6ZW7lsxI2RmfkD4DOkQIGH3q5foVr+PEp0uSPWrFX62eBet -1S4c/opVv6BcuUgilYABHTYxb45GfYwJAI9Qw2uQWT8DmhtVbcYu6GLYGlnRyaOC -EPzc0z0KQTjhsgHWzi60IYBBh+fy+Z7w5X1rTTvhFOoU5J7kedGEqiBatIZmhF5t -UFbT0u350ET5a0Kg83gu5aLwXdoIP9o7bp3XzLBMVNny2RX3tOHUA2HBe/p0h0OU -Ggt3G6oD0gBe9pZI ------END CERTIFICATE----- diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/testng.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/testng.xml deleted file mode 100644 index 3902ad4c3a..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/test/resources/testng.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml deleted file mode 100644 index 51b9f17fcb..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - apimgt-extensions - io.entgra.device.mgt.core - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.apimgt.integration.client - bundle - WSO2 Carbon - API Management Integration Client - WSO2 Carbon - API Management Integration Client - https://entgra.io - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${project.version} - APIM Integration - org.wso2.carbon.apimgt.integration.client.internal - - org.wso2.carbon.apimgt.integration.client.*, - !org.wso2.carbon.apimgt.integration.client.internal - - - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", - feign, - feign.codec, - feign.auth, - feign.gson, - feign.slf4j, - org.wso2.carbon.apimgt.integration.generated.client.publisher.api, - org.wso2.carbon.apimgt.integration.generated.client.store.api, - javax.xml.bind, - javax.xml.bind.annotation, - javax.xml.parsers;resolution:=optional, - org.apache.commons.logging, - org.w3c.dom, - org.wso2.carbon.context, - org.wso2.carbon.identity.jwt.client.*, - org.wso2.carbon.user.api, - org.wso2.carbon.utils, - com.fasterxml.jackson.annotation, - io.swagger.annotations, - org.wso2.carbon.core.util, - javax.xml, - org.wso2.carbon.base, - javax.net.ssl, - org.apache.commons.lang, - android.util;resolution:=optional, - javax.annotation;resolution:=optional, - javax.net;resolution:=optional, - javax.security.auth.x500;resolution:=optional, - javax.crypto;resolution:=optional, - javax.crypto.spec;resolution:=optional - - - jsr311-api, - feign-jaxrs, - feign-okhttp, - okhttp, - okio - - - - - - 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.felix - org.apache.felix.scr.ds-annotations - provided - - - com.squareup.okhttp3 - okhttp - - - com.squareup.okio - okio - - - io.github.openfeign - feign-okhttp - - - org.ops4j.pax.logging - pax-logging-api - provided - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - com.google.code.gson - gson - - - javax.ws.rs - jsr311-api - - - - io.swagger - swagger-annotations - - - junit - junit - - - io.github.openfeign - feign-core - - - io.github.openfeign - feign-jackson - - - io.github.openfeign - feign-jaxrs - - - io.github.openfeign - feign-gson - - - - org.testng - testng - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.identity.jwt.client.extension - - - io.entgra.device.mgt.core - org.wso2.carbon.apimgt.integration.generated.client - - - - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java deleted file mode 100644 index 2dcefcce20..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/IntegrationClientServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.apimgt.integration.client; - -import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; -import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; -import org.wso2.carbon.apimgt.integration.client.store.StoreClient; - -public class IntegrationClientServiceImpl implements IntegrationClientService { - - private static volatile IntegrationClientServiceImpl instance; - private StoreClient storeClient; - private PublisherClient publisherClient; - private OAuthRequestInterceptor oAuthRequestInterceptor; - - private IntegrationClientServiceImpl() { - oAuthRequestInterceptor = new OAuthRequestInterceptor(); - storeClient = new StoreClient(oAuthRequestInterceptor); - publisherClient = new PublisherClient(oAuthRequestInterceptor); - } - - public IntegrationClientServiceImpl(OAuthRequestInterceptor oAuthRequestInterceptor) { - this.oAuthRequestInterceptor = oAuthRequestInterceptor; - storeClient = new StoreClient(oAuthRequestInterceptor); - publisherClient = new PublisherClient(oAuthRequestInterceptor); - } - - public static IntegrationClientServiceImpl getInstance() { - if (instance == null) { - synchronized (IntegrationClientService.class) { - if (instance == null) { - instance = new IntegrationClientServiceImpl(); - } - } - } - return instance; - } - - public void resetUserInfo(String userName, String tenantDomain) { - oAuthRequestInterceptor.removeToken(userName, tenantDomain); - } - - @Override - public StoreClient getStoreClient() { - return storeClient; - } - - @Override - public PublisherClient getPublisherClient() { - return publisherClient; - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java deleted file mode 100755 index 46289b3ca1..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/OAuthRequestInterceptor.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * 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. - * - */ - -package org.wso2.carbon.apimgt.integration.client; - -import feign.Feign; -import feign.Logger; -import feign.RequestInterceptor; -import feign.RequestTemplate; -import feign.auth.BasicAuthRequestInterceptor; -import feign.gson.GsonDecoder; -import feign.gson.GsonEncoder; -import feign.jaxrs.JAXRSContract; -import feign.okhttp.OkHttpClient; -import feign.slf4j.Slf4jLogger; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; -import org.wso2.carbon.apimgt.integration.client.exception.APIMClientOAuthException; -import org.wso2.carbon.apimgt.integration.client.internal.APIIntegrationClientDataHolder; -import org.wso2.carbon.apimgt.integration.client.model.ClientProfile; -import org.wso2.carbon.apimgt.integration.client.model.DCRClient; -import org.wso2.carbon.apimgt.integration.client.model.OAuthApplication; -import org.wso2.carbon.apimgt.integration.client.util.Utils; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.identity.jwt.client.extension.JWTClient; -import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; -import io.entgra.device.mgt.core.identity.jwt.client.extension.exception.JWTClientException; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * This is a request interceptor to add oauth token header. - */ -public class OAuthRequestInterceptor implements RequestInterceptor { - - private static final String APPLICATION_NAME = "api_integration_client"; - private static final String GRANT_TYPES = "password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer"; - private static final String REQUIRED_SCOPE = - "apim:api_create apim:api_view apim:api_publish apim:subscribe apim:tier_view apim:tier_manage " + - "apim:subscription_view apim:subscription_block"; - private static final String APIM_SUBSCRIBE_SCOPE = "apim:subscribe"; - private static final long DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS = 100000; - private DCRClient dcrClient; - private OAuthApplication oAuthApplication; - private static Map tenantUserTokenMap = new ConcurrentHashMap<>(); - private static final Log log = LogFactory.getLog(OAuthRequestInterceptor.class); - private String username; - private String password; - - /** - * Creates an interceptor that authenticates all requests. - */ - public OAuthRequestInterceptor() { - username = APIMConfigReader.getInstance().getConfig().getUsername(); - password = APIMConfigReader.getInstance().getConfig().getPassword(); - dcrClient = Feign.builder().client(new OkHttpClient(Utils.getSSLClient())).logger(new Slf4jLogger()) - .logLevel(Logger.Level.FULL).requestInterceptor(new BasicAuthRequestInterceptor(username, password)) - .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) - .target(DCRClient.class, Utils.replaceProperties( - APIMConfigReader.getInstance().getConfig().getDcrEndpoint())); - } - - public OAuthRequestInterceptor(String username, String password) { - this.username = username; - this.password = password; - dcrClient = Feign.builder().client(new OkHttpClient(Utils.getSSLClient())).logger(new Slf4jLogger()) - .logLevel(Logger.Level.FULL).requestInterceptor(new BasicAuthRequestInterceptor(username, password)) - .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) - .target(DCRClient.class, Utils.replaceProperties( - APIMConfigReader.getInstance().getConfig().getDcrEndpoint())); - } - - @Override - public void apply(RequestTemplate template) { - if (oAuthApplication == null) { - //had to do on demand initialization due to start up error. - ClientProfile clientProfile = new ClientProfile(); - clientProfile.setClientName(APPLICATION_NAME); - clientProfile.setCallbackUrl(""); - clientProfile.setGrantType(GRANT_TYPES); - clientProfile.setOwner(username); - clientProfile.setSaasApp(true); - oAuthApplication = dcrClient.register(clientProfile); - } - try { - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { - username = username + "@" + tenantDomain; - } - AccessTokenInfo tenantBasedAccessTokenInfo = tenantUserTokenMap.get(username); - if ((tenantBasedAccessTokenInfo == null || - ((System.currentTimeMillis() + DEFAULT_REFRESH_TIME_OFFSET_IN_MILLIS) > - tenantBasedAccessTokenInfo.getExpiresIn()))) { - - JWTClient jwtClient = APIIntegrationClientDataHolder.getInstance().getJwtClientManagerService() - .getJWTClient(); - tenantBasedAccessTokenInfo = jwtClient.getAccessToken(oAuthApplication.getClientId(), - oAuthApplication.getClientSecret(), username, REQUIRED_SCOPE); - tenantBasedAccessTokenInfo.setExpiresIn( - System.currentTimeMillis() + (tenantBasedAccessTokenInfo.getExpiresIn() * 1000)); - if (tenantBasedAccessTokenInfo.getScopes() == null) { - throw new APIMClientOAuthException("Failed to retrieve scopes from access token"); - } - - if (tenantBasedAccessTokenInfo.getScopes().contains(APIM_SUBSCRIBE_SCOPE)) { - tenantUserTokenMap.put(username, tenantBasedAccessTokenInfo); - } - - } - if (tenantBasedAccessTokenInfo.getAccessToken() != null) { - String headerValue = "Bearer " + tenantBasedAccessTokenInfo.getAccessToken(); - template.header("Authorization", headerValue); - } - } catch (JWTClientException e) { - throw new APIMClientOAuthException("failed to retrieve oauth token using jwt", e); - } - } - - public void removeToken(String username, String tenantDomain) { - if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { - username = username + "@" + tenantDomain; - } - tenantUserTokenMap.remove(username); - } - -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfig.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfig.java deleted file mode 100644 index 1e3d34c746..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfig.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.apimgt.integration.client.configs; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * This holds the configuration api manager integration. - */ -@XmlRootElement(name = "APIMConfiguration") -public class APIMConfig { - - String dcrEndpoint; - String tokenEndpoint; - String publisherEndpoint; - String storeEndpoint; - String username; - String password; - - @XmlElement(name = "DCREndpoint", required = true) - public String getDcrEndpoint() { - return dcrEndpoint; - } - - public void setDcrEndpoint(String dcrEndpoint) { - this.dcrEndpoint = dcrEndpoint; - } - - @XmlElement(name = "TokenEndpoint", required = true) - public String getTokenEndpoint() { - return tokenEndpoint; - } - - public void setTokenEndpoint(String tokenEndpoint) { - this.tokenEndpoint = tokenEndpoint; - } - - @XmlElement(name = "PublisherEndpoint", required = true) - public String getPublisherEndpoint() { - return publisherEndpoint; - } - - public void setPublisherEndpoint(String publisherEndpoint) { - this.publisherEndpoint = publisherEndpoint; - } - - @XmlElement(name = "StoreEndpoint", required = true) - public String getStoreEndpoint() { - return storeEndpoint; - } - - public void setStoreEndpoint(String storeEndpoint) { - this.storeEndpoint = storeEndpoint; - } - - @XmlElement(name = "Username", required = true) - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - @XmlElement(name = "Password", required = true) - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfigReader.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfigReader.java deleted file mode 100644 index 58f39f1a5b..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/configs/APIMConfigReader.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.apimgt.integration.client.configs; - -import org.w3c.dom.Document; -import org.wso2.carbon.apimgt.integration.client.exception.APIMClientException; -import org.wso2.carbon.apimgt.integration.client.exception.InvalidConfigurationStateException; -import org.wso2.carbon.utils.CarbonUtils; - -import javax.xml.XMLConstants; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; - -/** - * This holds the configuration parser for api integration.xml - */ -public class APIMConfigReader { - - private static APIMConfig config; - private static APIMConfigReader configReader= new APIMConfigReader(); - private static boolean isInitialized = false; - private static final String API_INTEGRATION_CONFIG_PATH = - CarbonUtils.getCarbonConfigDirPath() + File.separator + "apim-integration.xml"; - - private APIMConfigReader() { - - } - - private static String apimIntegrationXmlFilePath = ""; - - //TOD file may be a part of another file - public static APIMConfigReader getInstance() { - if (!isInitialized) { - try { - init(); - } catch (APIMClientException e) { - throw new InvalidConfigurationStateException("Webapp Authenticator Configuration is not " + - "initialized properly"); - } - } - return configReader; - } - - public static void init() throws APIMClientException { - try { - File apimConfigFile = new File(API_INTEGRATION_CONFIG_PATH); - Document doc = convertToDocument(apimConfigFile); - - JAXBContext ctx = JAXBContext.newInstance(APIMConfig.class); - Unmarshaller unmarshaller = ctx.createUnmarshaller(); - config = (APIMConfig) unmarshaller.unmarshal(doc); - isInitialized = true; - } catch (JAXBException e) { - throw new APIMClientException("Error occurred while un-marshalling APIMConfig", e); - } - } - - private static Document convertToDocument(File file) throws APIMClientException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - try { - factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); - DocumentBuilder docBuilder = factory.newDocumentBuilder(); - return docBuilder.parse(file); - } catch (Exception e) { - throw new APIMClientException("Error occurred while parsing file 'apim-integration.xml' to a org.w3c.dom.Document", e); - } - } - - public APIMConfig getConfig() { - return config; - } - -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientException.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientException.java deleted file mode 100644 index f893f6d276..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.apimgt.integration.client.exception; - -/** - * This holds api client exception. - */ -public class APIMClientException extends Exception { - - private static final long serialVersionUID = -3976392476319079281L; - private String responseReason; - private int responseStatus; - private String methodKey; - - APIMClientException(String methodKey, String reason, int status) { - super("Exception occured while invoking " + methodKey + " status = " + status + " reason = " + reason); - this.methodKey = methodKey; - this.responseReason = reason; - this.responseStatus = status; - } - - APIMClientException(String message) { - super(message); - } - - public APIMClientException(String message, Exception e) { - super(message, e); - } - - public String getResponseReason() { - return responseReason; - } - - public int getResponseStatus() { - return responseStatus; - } - - public String getMethodKey() { - return methodKey; - } - -} \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java deleted file mode 100644 index 359b4b621e..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/APIMClientOAuthException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.apimgt.integration.client.exception; - -/** - * This holds api client exception. - */ -public class APIMClientOAuthException extends RuntimeException { - - private static final long serialVersionUID = -3976392476319079281L; - private String responseReason; - private int responseStatus; - private String methodKey; - - APIMClientOAuthException(String methodKey, String reason, int status) { - super("Exception occured while invoking " + methodKey + " status = " + status + " reason = " + reason); - this.methodKey = methodKey; - this.responseReason = reason; - this.responseStatus = status; - } - - public APIMClientOAuthException(String message) { - super(message); - } - - public APIMClientOAuthException(String message, Exception e) { - super(message, e); - } - - public String getResponseReason() { - return responseReason; - } - - public int getResponseStatus() { - return responseStatus; - } - - public String getMethodKey() { - return methodKey; - } - -} \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/InvalidConfigurationStateException.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/InvalidConfigurationStateException.java deleted file mode 100644 index dedb63c4bd..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/exception/InvalidConfigurationStateException.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.wso2.carbon.apimgt.integration.client.exception; - -/** - * This error is thrown when there is an issue with the client. - */ -public class InvalidConfigurationStateException extends RuntimeException { - - private static final long serialVersionUID = -3151279311329070397L; - - private String errorMessage; - private int errorCode; - - public InvalidConfigurationStateException(int errorCode, String message) { - super(message); - this.errorCode = errorCode; - } - - public InvalidConfigurationStateException(int errorCode, String message, Throwable cause) { - super(message, cause); - this.errorCode = errorCode; - } - - public int getErrorCode() { - return errorCode; - } - - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public InvalidConfigurationStateException(String msg, Exception nestedEx) { - super(msg, nestedEx); - setErrorMessage(msg); - } - - public InvalidConfigurationStateException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - public InvalidConfigurationStateException(String msg) { - super(msg); - setErrorMessage(msg); - } - - public InvalidConfigurationStateException() { - super(); - } - - public InvalidConfigurationStateException(Throwable cause) { - super(cause); - } - -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientDataHolder.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientDataHolder.java deleted file mode 100644 index 56584dfdac..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientDataHolder.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.apimgt.integration.client.internal; - - -import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; - -/** - * This holds the required service for this component - */ -public class APIIntegrationClientDataHolder { - private static APIIntegrationClientDataHolder thisInstance = new APIIntegrationClientDataHolder(); - private JWTClientManagerService jwtClientManagerService; - private APIIntegrationClientDataHolder() { - } - - - public static APIIntegrationClientDataHolder getInstance() { - return thisInstance; - } - - public void setJwtClientManagerService(JWTClientManagerService jwtClientManagerService) { - this.jwtClientManagerService = jwtClientManagerService; - } - - public JWTClientManagerService getJwtClientManagerService() { - return jwtClientManagerService; - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java deleted file mode 100644 index 536a5e6c34..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/internal/APIIntegrationClientServiceComponent.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.apimgt.integration.client.internal; - -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.integration.client.IntegrationClientServiceImpl; -import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; -import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService; -import org.osgi.service.component.annotations.*; -import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService; - -@Component( - name = "org.wso2.carbon.api.integration.client", - immediate = true) -public class APIIntegrationClientServiceComponent { - - private static Log log = LogFactory.getLog(APIIntegrationClientServiceComponent.class); - - @Activate - protected void activate(ComponentContext componentContext) { - try { - if (log.isDebugEnabled()) { - log.debug("Initializing apimgt client bundle"); - } - - /* Initializing webapp publisher configuration */ - APIMConfigReader.init(); - BundleContext bundleContext = componentContext.getBundleContext(); - bundleContext.registerService(IntegrationClientService.class.getName(), IntegrationClientServiceImpl.getInstance(), null); - - if (log.isDebugEnabled()) { - log.debug("apimgt client bundle has been successfully initialized"); - } - } catch (Throwable e) { - log.error("Error occurred while initializing apimgt client bundle", e); - } - } - - @Deactivate - protected void deactivate(ComponentContext componentContext) { - //do nothing - } - - @Reference( - name = "api.integration.client.service", - service = org.wso2.carbon.apimgt.impl.APIManagerConfigurationService.class, - cardinality = ReferenceCardinality.MANDATORY, - policy = ReferencePolicy.DYNAMIC, - bind = "setJWTClientManagerService", - unbind = "unsetJWTClientManagerService") - protected void setJWTClientManagerService(JWTClientManagerService jwtClientManagerService) { - if (jwtClientManagerService != null) { - log.debug("jwtClientManagerService service is initialized"); - } - APIIntegrationClientDataHolder.getInstance().setJwtClientManagerService(jwtClientManagerService); - } - - protected void unsetJWTClientManagerService(JWTClientManagerService jwtClientManagerService) { - APIIntegrationClientDataHolder.getInstance().setJwtClientManagerService(null); - } - -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/ClientProfile.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/ClientProfile.java deleted file mode 100644 index fe1821d3a4..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/ClientProfile.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.apimgt.integration.client.model; - -/** - * DTO fo DCR request. - */ -public class ClientProfile { - - private String clientName; - private String callbackUrl; - private String tokenScope; - private String owner; - private String grantType; - private boolean saasApp; - - 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 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 grantTypem) { - this.grantType = grantTypem; - } - - public boolean isSaasApp() { - return saasApp; - } - - public void setSaasApp(boolean saasApp) { - this.saasApp = saasApp; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("{\n"); - - sb.append(" clientName: ").append(clientName).append("\n"); - sb.append(" callbackUrl: ").append("callbackUrl").append("\n"); - sb.append(" grantType: ").append(grantType).append("\n"); - sb.append(" tokenScope: ").append(tokenScope).append("\n"); - sb.append(" owner: ").append(owner).append("\n"); - sb.append(" saasApp: ").append(saasApp).append("\n"); - sb.append("}\n"); - return sb.toString(); - } - -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/DCRClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/DCRClient.java deleted file mode 100644 index 2adcfa45ad..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/DCRClient.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.apimgt.integration.client.model; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; - -/** - * DCR Rest resource. - */ -@Path("/") -public interface DCRClient { - - // DCR APIs - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - OAuthApplication register(ClientProfile registrationProfile); - -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/OAuthApplication.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/OAuthApplication.java deleted file mode 100644 index 7f3bf458f4..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/model/OAuthApplication.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.apimgt.integration.client.model; - -public class OAuthApplication { - - private String jsonString; - private String appOwner; - private String clientName; - private String callBackURL; - private String isSaasApplication; - private String clientId; - private String clientSecret; - - public String getJsonString() { - return jsonString; - } - - public void setJsonString(String jsonString) { - this.jsonString = jsonString; - } - - public String getAppOwner() { - return appOwner; - } - - public void setAppOwner(String appOwner) { - this.appOwner = appOwner; - } - - 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 getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getClientSecret() { - return clientSecret; - } - - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class OAuthApplication {\n"); - - sb.append(" jsonString: ").append(jsonString).append("\n"); - sb.append(" appOwner: ").append(appOwner).append("\n"); - sb.append(" clientName: ").append(clientName).append("\n"); - sb.append(" callBackURL: ").append(callBackURL).append("\n"); - sb.append(" isSaasApplication: ").append(isSaasApplication).append("\n"); - sb.append(" clientId: ").append(isSaasApplication).append("\n"); - sb.append(" clientSecret: ").append(clientSecret).append("\n"); - sb.append("}\n"); - return sb.toString(); - } - -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java deleted file mode 100644 index 3887d59c66..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/publisher/PublisherClient.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.apimgt.integration.client.publisher; - -import feign.Feign; -import feign.Logger; -import feign.RequestInterceptor; -import feign.gson.GsonDecoder; -import feign.gson.GsonEncoder; -import feign.okhttp.OkHttpClient; -import feign.slf4j.Slf4jLogger; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; -import org.wso2.carbon.apimgt.integration.generated.client.publisher.api.*; -import org.wso2.carbon.core.util.Utils; - -/** - * Publisher client generated using swagger. - */ -public class PublisherClient { - - private static final Log log = LogFactory.getLog(PublisherClient.class); - private APIIndividualApi api = null; - private APICollectionApi apis = null; - private DocumentIndividualApi document = null; - private ApplicationIndividualApi application = null; - private EnvironmentCollectionApi environments = null; - private SubscriptionCollectionApi subscriptions = null; - private ThrottlingTierCollectionApi tiers = null; - - - /** - * PublisherClient constructor - Initialize a PublisherClient instance - * - */ - public PublisherClient(RequestInterceptor requestInterceptor) { - Feign.Builder builder = Feign.builder().client(new OkHttpClient( - org.wso2.carbon.apimgt.integration.client.util.Utils.getSSLClient())).logger(new - Slf4jLogger()) - .logLevel(Logger.Level.FULL) - .requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder()); - String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getPublisherEndpoint()); - - api = builder.target(APIIndividualApi.class, basePath); - apis = builder.target(APICollectionApi.class, basePath); - document = builder.target(DocumentIndividualApi.class, basePath); - application = builder.target(ApplicationIndividualApi.class, basePath); - environments = builder.target(EnvironmentCollectionApi.class, basePath); - subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); - tiers = builder.target(ThrottlingTierCollectionApi.class, basePath); - } - - public APIIndividualApi getApi() { - return api; - } - - public APICollectionApi getApis() { - return apis; - } - - public DocumentIndividualApi getDocument() { - return document; - } - - public ApplicationIndividualApi getApplication() { - return application; - } - - public EnvironmentCollectionApi getEnvironments() { - return environments; - } - - public SubscriptionCollectionApi getSubscriptions() { - return subscriptions; - } - - public ThrottlingTierCollectionApi getTiers() { - return tiers; - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java deleted file mode 100644 index a98571ef4f..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/service/IntegrationClientService.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.apimgt.integration.client.service; - - -import org.wso2.carbon.apimgt.integration.client.publisher.PublisherClient; -import org.wso2.carbon.apimgt.integration.client.store.StoreClient; - -/** - * This is a service that can be called upon to access store and publisher. - */ -public interface IntegrationClientService { - - - void resetUserInfo(String username, String tenantDomain); - - /** - * - * @return API Store Client. - */ - StoreClient getStoreClient(); - - /** - * - * @return API Publisher Client. - */ - PublisherClient getPublisherClient(); - -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java deleted file mode 100644 index db751f204e..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/store/StoreClient.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.apimgt.integration.client.store; - -import feign.Feign; -import feign.Logger; -import feign.Request; -import feign.RequestInterceptor; -import feign.Retryer; -import feign.gson.GsonDecoder; -import feign.gson.GsonEncoder; -import feign.okhttp.OkHttpClient; -import feign.slf4j.Slf4jLogger; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader; -import org.wso2.carbon.apimgt.integration.generated.client.store.api.*; -import org.wso2.carbon.core.util.Utils; - -import java.util.concurrent.TimeUnit; - -/** - * API Store client, created using swagger gen. - */ -public class StoreClient { - - private static final org.apache.commons.logging.Log log = LogFactory.getLog(StoreClient.class); - private APICollectionApi apis = null; - private APIIndividualApi individualApi = null; - private ApplicationCollectionApi applications = null; - private ApplicationIndividualApi individualApplication = null; - private SubscriptionCollectionApi subscriptions = null; - private SubscriptionIndividualApi individualSubscription = null; - private SubscriptionMultitpleApi subscriptionMultitpleApi = null; - private ThrottlingTierIndividualApi individualTier = null; - private TagCollectionApi tags = null; - private ThrottlingTierCollectionApi tiers = null; - - - public StoreClient(RequestInterceptor requestInterceptor) { - - Feign.Builder builder = Feign.builder().client(new OkHttpClient( - org.wso2.carbon.apimgt.integration.client.util.Utils.getSSLClient())).logger(new - Slf4jLogger()) - .logLevel(Logger.Level.FULL) - .requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder()); - String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getStoreEndpoint()); - - apis = builder.target(APICollectionApi.class, basePath); - individualApi = builder.target(APIIndividualApi.class, basePath); - applications = builder.target(ApplicationCollectionApi.class, basePath); - individualApplication = builder.target(ApplicationIndividualApi.class, basePath); - subscriptions = builder.target(SubscriptionCollectionApi.class, basePath); - individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath); - subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath); - tags = builder.target(TagCollectionApi.class, basePath); - individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath); - tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1)) - .options(new Request.Options(10000, 5000)) - .target(ThrottlingTierCollectionApi.class, basePath); - - } - - public APICollectionApi getApis() { - return apis; - } - - public APIIndividualApi getIndividualApi() { - return individualApi; - } - - public ApplicationCollectionApi getApplications() { - return applications; - } - - public ApplicationIndividualApi getIndividualApplication() { - return individualApplication; - } - - public SubscriptionCollectionApi getSubscriptions() { - return subscriptions; - } - - public SubscriptionIndividualApi getIndividualSubscription() { - return individualSubscription; - } - - public ThrottlingTierIndividualApi getIndividualTier() { - return individualTier; - } - - public TagCollectionApi getTags() { - return tags; - } - - public ThrottlingTierCollectionApi getTiers() { - return tiers; - } - - public SubscriptionMultitpleApi getSubscriptionMultitpleApi() { - return subscriptionMultitpleApi; - } -} diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/util/Utils.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/util/Utils.java deleted file mode 100644 index 369f357ddd..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/src/main/java/org/wso2/carbon/apimgt/integration/client/util/Utils.java +++ /dev/null @@ -1,238 +0,0 @@ -/* -* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - -package org.wso2.carbon.apimgt.integration.client.util; - -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.HostnameVerifier; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; -import javax.net.ssl.X509TrustManager; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.InetSocketAddress; -import java.net.Proxy; -import java.net.ProxySelector; -import java.net.SocketAddress; -import java.net.URI; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; -import java.security.cert.CertificateException; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class Utils { - - private static final Log log = LogFactory.getLog(Utils.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"; - - - //This method is only used if the mb features are within DAS. - public static String replaceProperties(String text) { - String regex = "\\$\\{(.*?)\\}"; - Pattern pattern = Pattern.compile(regex); - Matcher matchPattern = pattern.matcher(text); - while (matchPattern.find()) { - String sysPropertyName = matchPattern.group(1); - String sysPropertyValue = System.getProperty(sysPropertyName); - if (sysPropertyValue != null && !sysPropertyName.isEmpty()) { - text = text.replaceAll("\\$\\{(" + sysPropertyName + ")\\}", sysPropertyValue); - } - } - return text; - } - - 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() - .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().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 java.security.SecureRandom()); - return sc.getSocketFactory(); - } catch (KeyManagementException | NoSuchAlgorithmException 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.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml deleted file mode 100644 index 78a5d81d7f..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - apimgt-extensions - io.entgra.device.mgt.core - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.apimgt.integration.generated.client - bundle - WSO2 Carbon - API Management Integration Generated Client - WSO2 Carbon - API Management Integration Client - https://entgra.io - - - - - - io.swagger - swagger-codegen-maven-plugin - 2.2.1 - - - process-resources - publisher - - generate - - - ${project.basedir}/src/main/resources/publisher-api.yaml - java - - ${project.artifactId}.publisher.api - ${project.artifactId}.publisher.model - - feign - - - - process-resources - store - - generate - - - ${project.basedir}/src/main/resources/store-api.yaml - java - - ${project.artifactId}.store.api - ${project.artifactId}.store.model - - feign - - - - - - com.google.code.maven-replacer-plugin - replacer - - - - process-resources - replace-for-swagger-genenerated-code-publisher - - replace - - - ${project.basedir}/target/generated-sources/swagger/src/main/java/org/wso2/carbon/apimgt/integration/generated/client/publisher/model/API.java - - - CURRENT_TENANT - current_tenant - - - ALL_TENANTS - all_tenants - - - SPECIFIC_TENANTS - specific_tenants - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${project.version} - APIM Integration - - org.wso2.carbon.apimgt.integration.generated.client.publisher.api.*, - org.wso2.carbon.apimgt.integration.generated.client.publisher.model.*, - org.wso2.carbon.apimgt.integration.generated.client.store.api.*, - org.wso2.carbon.apimgt.integration.generated.client.store.model.* - - - feign;version="${io.github.openfeign.version.range}", - feign.jackson;version="${io.github.openfeign.version.range}", - feign.codec;version="${io.github.openfeign.version.range}", - feign.auth;version="${io.github.openfeign.version.range}", - feign.gson;version="${io.github.openfeign.version.range}", - feign.slf4j;version="${io.github.openfeign.version.range}", - com.google.gson, - com.fasterxml.jackson.core;resolution:=optional, - com.fasterxml.jackson.annotation, - com.fasterxml.jackson.databind;resolution:=optional, - io.swagger.annotations, - javax.net.ssl, - com.fasterxml.jackson.datatype.joda;resolution:=optional, - org.apache.oltu.oauth2.client.*;resolution:=optional, - org.apache.oltu.oauth2.common.*;resolution:=optional, - org.junit;resolution:=optional, - - - jsr311-api, - feign-jaxrs - - - - - - - - - - - com.google.code.gson - gson - - - javax.ws.rs - jsr311-api - - - - io.swagger - swagger-annotations - - - junit - junit - - - io.github.openfeign - feign-core - - - io.github.openfeign - feign-jackson - - - io.github.openfeign - feign-jaxrs - - - io.github.openfeign - feign-gson - - - org.testng - testng - - - org.apache.oltu.oauth2 - org.apache.oltu.oauth2.client - - - io.github.openfeign - feign-slf4j - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-databind - ${jackson-databind.version} - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - - - - true - - diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml deleted file mode 100644 index b2068857a7..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/publisher-api.yaml +++ /dev/null @@ -1,3691 +0,0 @@ - -swagger: '2.0' -###################################################### -# Prolog -###################################################### -info: - version: "0.12.0" - title: "WSO2 API Manager - Publisher API" - description: | - This specifies a **RESTful API** for WSO2 **API Manager** - Publisher. - - Please see [full swagger definition](https://raw.githubusercontent.com/wso2/carbon-apimgt/v6.1.66/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher/src/main/resources/publisher-api.yaml) of the API which is written using [swagger 2.0](http://swagger.io/) specification. - contact: - name: "WSO2" - url: "http://wso2.com/products/api-manager/" - email: "architecture@wso2.com" - license: - name: "Apache 2.0" - url: "http://www.apache.org/licenses/LICENSE-2.0.html" - -###################################################### -# The fixed parts of the URLs of the API -###################################################### - -# The schemes supported by the API -schemes: - - https - -# The domain of the API. -# This is configured by the customer during deployment. -# The given host is just an example. -host: apis.wso2.com - -# The base path of the API. -# Will be prefixed to all paths. -basePath: /api/am/publisher/v0.12 - -# The following media types can be passed as input in message bodies of the API. -# The actual media type must be specified in the Content-Type header field of the request. -# The default is json, i.e. the Content-Type header is not needed to -# be set, but supporting it serves extensibility. -consumes: - - application/json - -# The following media types may be passed as output in message bodies of the API. -# The media type(s) consumable by the requestor is specified in the Accept header field -# of the corresponding request. -# The actual media type returned will be specfied in the Content-Type header field -# of the of the response. -# The default of the Accept header is json, i.e. there is not needed to -# set the value, but supporting it serves extensibility. -produces: - - application/json - - -x-wso2-security: - apim: - x-wso2-scopes: - - description: "" - roles: admin - name: apim:api_view - key: apim:api_view - - description: "" - roles: admin - name: apim:api_create - key: apim:api_create - - description: "" - roles: admin - name: apim:api_publish - key: apim:api_publish - - description: "" - roles: admin - name: apim:tier_view - key: apim:tier_view - - description: "" - roles: admin - name: apim:tier_manage - key: apim:tier_manage - - description: "" - roles: admin - name: apim:subscription_view - key: apim:subscription_view - - description: "" - roles: admin - name: apim:subscription_block - key: apim:subscription_block - - description: "" - roles: admin - name: apim:mediation_policy_view - key: apim:mediation_policy_view - - description: "" - roles: admin - name: apim:api_workflow - key: apim:api_workflow - - -###################################################### -# The "API Collection" resource APIs -###################################################### -paths: - /apis: - -#----------------------------------------------------- -# Retrieving the list of all APIs qualifying under a given search condition -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/apis" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"This sample API provides Account Status Validation\",\n \"name\": \"AccountVal\",\n \"context\": \"/account\",\n \"id\": \"2e81f147-c8a8-4f68-b4f0-69e0e7510b01\",\n \"status\": \"PUBLISHED\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": null,\n \"name\": \"api1\",\n \"context\": \"/api1\",\n \"id\": \"3e22d2fb-277a-4e9e-8c7e-1c0f7f73960e\",\n \"status\": \"PUBLISHED\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" - summary: | - Retrieve/Search APIs - description: | - This operation provides you a list of available APIs qualifying under a given search condition. - - Each retrieved API is represented with a minimal amount of attributes. If you want to get complete details of an API, you need to use **Get details of an API** operation. - parameters: - - $ref : '#/parameters/limit' - - $ref : '#/parameters/offset' - - name : query - in: query - description: | - **Search condition**. - - You can search in attributes by using an **":"** modifier. - - Eg. - "provider:wso2" will match an API if the provider of the API is exactly "wso2". - - Additionally you can use wildcards. - - Eg. - "provider:wso2*" will match an API if the provider of the API starts with "wso2". - - Supported attribute modifiers are [**version, context, status, - description, subcontext, doc, provider**] - - If no advanced attribute modifier has been specified, the API names containing - the search term will be returned as a result. - - type: string - - $ref : "#/parameters/Accept" - - $ref : "#/parameters/If-None-Match" - tags: - - API (Collection) - responses: - 200: - description: | - OK. - List of qualifying APIs is returned. - schema: - $ref: '#/definitions/APIList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Create a new API -API (Individual) -#----------------------------------------------------- - post: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json https://localhost:9443/api/am/publisher/v0.12/apis" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\n\n{\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"PUBLISHED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": false,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"http\",\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 5000,\r\n \"production\": 1000\r\n },\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\": \"in\"},{\"name\":\"log_out_message\",\"type\": \"out\"}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"integer\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"http\",\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 5000,\r\n \"production\": 1000\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\":\"in\",\"id\":\"142ece76-b208-4aab-b29a-f382045ed066\",\"shared\":false},{\"name\":\"log_out_message\",\"type\":\"out\",\"id\":\"b3527be8-95e6-41e0-8097-3276987b7d4b\",\"shared\":false}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - summary: Create a new API - description: | - This operation can be used to create a new API specifying the details of the API in the payload. The new API will be in `CREATED` state. - - There is a special capability for a user who has `APIM Admin` permission such that he can create APIs on behalf of other users. For that he can to specify `"provider" : "some_other_user"` in the payload so that the API's creator will be shown as `some_other_user` in the UI. - parameters: - - in: body - name: body - description: | - API object that needs to be added - required: true - schema: - $ref: '#/definitions/API' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/Authorization' - tags: - - API (Individual) - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - schema: - $ref: '#/definitions/API' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - Authorization: - description: | - The brearer token. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported Media Type. - The entity of the request was in a not supported format. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual API" resource APIs -###################################################### - /apis/{apiId}: - -#----------------------------------------------------- -# Retrieve the details of an API definition -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"http\",\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 5000,\r\n \"production\": 1000\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - summary: Get details of an API - description: | - Using this operation, you can retrieve complete details of a single API. You need to provide the Id of the API to retrive it. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Requested API is returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - schema: - $ref: '#/definitions/API' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update the definition of an API -#----------------------------------------------------- - put: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X PUT -d @data.json https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f" - x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/apis/7a2298c4-c905-403f-8fac-38c73301631f\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"integer\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\",\"chicken\"],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 500,\r\n \"production\": 100\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\": \"in\"},{\"name\":\"log_out_message\",\"type\": \"out\"}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\r\n \"id\": \"7a2298c4-c905-403f-8fac-38c73301631f\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"1.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created.\\\"}}}},\\\"/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"headers\\\":{},\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#/definitions/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\"https\"],\r\n \"tags\": [\r\n \"chicken\",\r\n \"pizza\"\r\n ],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 500,\r\n \"production\": 100\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [{\"name\":\"json_validator\",\"type\":\"in\",\"id\":\"142ece76-b208-4aab-b29a-f382045ed066\",\"shared\":false},{\"name\":\"log_out_message\",\"type\":\"out\",\"id\":\"b3527be8-95e6-41e0-8097-3276987b7d4b\",\"shared\":false}],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - summary: Update an API - description: | - This operation can be used to update an existing API. - But the properties `name`, `version`, `context`, `provider`, `state` will not be changed by this operation. - parameters: - - $ref: '#/parameters/apiId' - - in: body - name: body - description: | - API object that needs to be added - required: true - schema: - $ref: '#/definitions/API' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Successful response with updated API object - schema: - $ref: '#/definitions/API' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete the definition of an API -#----------------------------------------------------- - delete: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE https://localhost:9443/api/am/publisher/v0.12/apis/6fb74674-4ab8-4b52-9886-f9a376985060" - x-wso2-request: | - DELETE https://localhost:9443/api/am/publisher/v0.12/apis/6fb74674-4ab8-4b52-9886-f9a376985060 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK" - summary: Delete an API - description: | - This operation can be used to delete an existing API proving the Id of the API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Resource successfully deleted. - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -################################################################ -# The swagger resource of "Individual API" resource APIs -################################################################ - - /apis/{apiId}/swagger: -#----------------------------------------------------- -# Retrieve the API swagger definition -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/swagger" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/swagger - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\nContent-Length: 329\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" - summary: Get swagger definition - description: | - This operation can be used to retrieve the swagger definition of an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Requested swagger document of the API is returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update the API swagger definition -#----------------------------------------------------- - put: - consumes: - - multipart/form-data - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer 5311eca3-8ac8-354e-ab36-7e2fdd6a4013\" -F apiDefinition=\"{\\\"paths\\\":{\\\"\\/*\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"responses\\\":{\\\"200\\\":{\\\"description\\\":\\\"OK\\\"}}}}},\\\"x-wso2-security\\\":{\\\"apim\\\":{\\\"x-wso2-scopes\\\":[]}},\\\"swagger\\\":\\\"2.0\\\",\\\"info\\\":{\\\"title\\\":\\\"PhoneVerification\\\",\\\"description\\\":\\\"Verify a phone number\\\",\\\"contact\\\":{\\\"email\\\":\\\"xx@ee.com\\\",\\\"name\\\":\\\"xx\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\" -X PUT \"https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/swagger\"" - x-wso2-request: | - PUT https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/swagger - Authorization:Bearer 5311eca3-8ac8-354e-ab36-7e2fdd6a4013 - Content-Length: 477 - Content-Type: multipart/form-data; boundary=------------------------4f51e636c0003d99 - - --------------------------4f51e636c0003d99 - Content-Disposition: form-data; name="apiDefinition" - - {"paths":{"\/*":{"get":{"x-auth-type":"Application","x-throttling-tier":"Unlimited","responses":{"200":{"description":"OK"}}}}},"x-wso2-security":{"apim":{"x-wso2-scopes":[]}},"swagger":"2.0","info":{"title":"PhoneVerification","description":"Verify a phone number","contact":{"email":"xx@ee.com","name":"xx"},"version":"1.0.0"}} - --------------------------4f51e636c0003d99-- - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"1.0.0\"\n }\n}" - summary: Update swagger definition - description: | - This operation can be used to update the swagger definition of an existing API. Swagger definition to be updated is passed as a form data parameter `apiDefinition`. - parameters: - - $ref: '#/parameters/apiId' - - in: formData - name: apiDefinition - description: Swagger definition of the API - type: string - required: true - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Successful response with updated Swagger definition - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -################################################################ -# The thumbnail resource of "Individual API" resource APIs -################################################################ - - /apis/{apiId}/thumbnail: -#------------------------------------------------------------------------------------------------- -# Downloads a thumbnail image of an API -#------------------------------------------------------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9\" https://localhost:9443/api/am/publisher/v0.12/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail > image.jpg" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail - Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9 - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\n\r\n[image content]" - summary: Get thumbnail image - description: | - This operation can be used to download a thumbnail image of an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Thumbnail image returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#---------------------------------------------------------------------------- -# Upload a thumbnail image to a certain API -#---------------------------------------------------------------------------- - post: - consumes: - - multipart/form-data - x-scope: apim:api_create - x-wso2-curl: "curl -X POST -H \"Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9\" https://localhost:9443/api/am/publisher/v0.12/apis/29c9ec3d-f590-467e-83e6-96d43517080f/thumbnail -F file=@image.jpg" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/thumbnail - Authorization: Bearer d34baf74-3f02-3929-814e-88b27f750ba9 - Content-Type: multipart/form-data; boundary=------------------------5e542e0e5b50e1e4 - Content-Length: 18333 - - --------------------------5e542e0e5b50e1e4 - Content-Disposition: form-data; name="file"; filename="image.jpg" - Content-Type: image/jpeg - - [image content] - - --------------------------5e542e0e5b50e1e4-- - x-wso2-response: "HTTP/1.1 201 Created\r\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/thumbnail\r\nContent-Type: application/json\r\n\r\n{\r\n \"relativePath\": \"/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/thumbnail\",\r\n \"mediaType\": \"image/jpeg\"\r\n}" - summary: Upload a thumbnail image - description: | - This operation can be used to upload a thumbnail image of an API. The thumbnail to be uploaded should be given as a form data parameter `file`. - parameters: - - $ref: '#/parameters/apiId' - - in: formData - name: file - description: Image to upload - type: file - required: true - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Image updated - schema: - $ref : '#/definitions/FileInfo' - headers: - Location: - description: | - The URL of the uploaded thumbnail image of the API. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Copy API" Processing Function resource API -###################################################### - /apis/copy-api: - -#----------------------------------------------------- -# Create a new API based on an already existing one -#----------------------------------------------------- - post: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/apis/copy-api?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&newVersion=2.0.0\"" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/apis/copy-api?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&newVersion=2.0.0 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/25a84fc9-38c0-4578-95e8-29fb6b1c4771\nContent-Type: application/json\n\n{\r\n \"id\": \"25a84fc9-38c0-4578-95e8-29fb6b1c4771\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"context\": \"/pizzashack\",\r\n \"version\": \"2.0.0\",\r\n \"provider\": \"admin\",\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"\\\\/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#\\\\/definitions\\\\/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"schema\\\":{\\\"$ref\\\":\\\"#\\\\/definitions\\\\/Order\\\"},\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"}},\\\"description\\\":\\\"Created.\\\"}}}},\\\"\\\\/menu\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Return a list of available menu items\\\",\\\"parameters\\\":[],\\\"responses\\\":{\\\"200\\\":{\\\"schema\\\":{\\\"title\\\":\\\"Menu\\\",\\\"properties\\\":{\\\"list\\\":{\\\"items\\\":{\\\"$ref\\\":\\\"#\\\\/definitions\\\\/MenuItem\\\"},\\\"type\\\":\\\"array\\\"}},\\\"type\\\":\\\"object\\\"},\\\"headers\\\":{},\\\"description\\\":\\\"OK.\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application\\\\/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"MenuItem\\\":{\\\"title\\\":\\\"Pizza menu Item\\\",\\\"properties\\\":{\\\"price\\\":{\\\"type\\\":\\\"string\\\"},\\\"description\\\":{\\\"type\\\":\\\"string\\\"},\\\"name\\\":{\\\"type\\\":\\\"string\\\"},\\\"image\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"name\\\"]},\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application\\\\/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http:\\\\/\\\\/www.apache.org\\\\/licenses\\\\/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http:\\\\/\\\\/www.pizzashack.com\\\"},\\\"version\\\":\\\"2.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"status\": \"CREATED\",\r\n \"responseCaching\": \"Disabled\",\r\n \"cacheTimeout\": 300,\r\n \"destinationStatsEnabled\": null,\r\n \"isDefaultVersion\": false,\r\n \"type\": \"HTTP\",\r\n \"transport\": [\"https\"],\r\n \"tags\": [\r\n \"chicken\",\r\n \"pizza\"\r\n ],\r\n \"tiers\": [\"Unlimited\"],\r\n \"maxTps\": {\r\n \"sandbox\": 500,\r\n \"production\": 100\r\n },\r\n \"thumbnailUri\": null,\r\n \"visibility\": \"PUBLIC\",\r\n \"visibleRoles\": [],\\r\n \"endpointConfig\": \"{\\\"production_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"sandbox_endpoints\\\":{\\\"url\\\":\\\"https://localhost:9443/am/sample/pizzashack/v1/api/\\\",\\\"config\\\":null},\\\"endpoint_type\\\":\\\"http\\\"}\",\r\n \"endpointSecurity\": {\r\n \"username\": \"user\",\r\n \"type\": \"basic\",\r\n \"password\": \"pass\"\r\n },\r\n \"gatewayEnvironments\": \"Production and Sandbox\",\r\n \"sequences\": [],\r\n \"subscriptionAvailability\": null,\r\n \"subscriptionAvailableTenants\": [],\r\n \"businessInformation\": {\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"technicalOwner\": \"John Doe\",\r\n \"businessOwner\": \"Jane Roe\"\r\n },\r\n \"corsConfiguration\": {\r\n \"accessControlAllowOrigins\": [\"*\"],\r\n \"accessControlAllowHeaders\": [\r\n \"authorization\",\r\n \"Access-Control-Allow-Origin\",\r\n \"Content-Type\",\r\n \"SOAPAction\"\r\n ],\r\n \"accessControlAllowMethods\": [\r\n \"GET\",\r\n \"PUT\",\r\n \"POST\",\r\n \"DELETE\",\r\n \"PATCH\",\r\n \"OPTIONS\"\r\n ],\r\n \"accessControlAllowCredentials\": false,\r\n \"corsConfigurationEnabled\": false\r\n }\r\n}" - summary: Create a new API version - description: | - This operation can be used to create a new version of an existing API. The new version is specified as `newVersion` query parameter. New API will be in `CREATED` state. - parameters: - - name: newVersion - description: Version of the new API. - type: string - in: query - required: true - - $ref: '#/parameters/apiId-Q' - tags: - - API (Individual) - responses: - 201: - description: | - Created. - Successful response with the newly created API as entity in the body. Location header contains URL of newly created API. - headers: - Location: - description: | - The URL of the newly created API. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - API to copy does not exist. - 401: - description: | - Unauthenticated request. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Change Lifecycle" Processing Function resource API -###################################################### - /apis/change-lifecycle: - -#----------------------------------------------------- -# Change the lifecycle of an API -#----------------------------------------------------- - post: - x-scope: apim:api_publish - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish\"" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK" - summary: Change API Status - description: | - This operation is used to change the lifecycle of an API. Eg: Publish an API which is in `CREATED` state. In order to change the lifecycle, we need to provide the lifecycle `action` as a query parameter. - - For example, to Publish an API, `action` should be `Publish`. Note that the `Re-publish` action is available only after calling `Block`. - - Some actions supports providing additional paramters which should be provided as `lifecycleChecklist` parameter. Please see parameters table for more information. - parameters: - - name: action - description: | - The action to demote or promote the state of the API. - - Supported actions are [ **Publish, Deploy as a Prototype, Demote to Created, Demote to Prototyped, Block, Deprecate, Re-Publish, Retire **] - - in: query - type: string - required: true - enum: - - Publish - - Deploy as a Prototype - - Demote to Created - - Demote to Prototyped - - Block - - Deprecate - - Re-Publish - - Retire - - name: lifecycleChecklist - description: | - - Supported checklist items are as follows. - 1. **Deprecate Old Versions**: Setting this to true will deprecate older versions of a particular API when it is promoted to Published state from Created state. - 2. **Require Re-Subscription**: If you set this to true, users need to re subscribe to the API although they may have subscribed to an older version. - - You can specify additional checklist items by using an **"attribute:"** modifier. - - Eg: "Deprecate Old Versions:true" will deprecate older versions of a particular API when it is promoted to Published state from Created state. Multiple checklist items can be given in "attribute1:true, attribute2:false" format. - - **Sample CURL :** curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X POST "https://localhost:9443/api/am/publisher/v0.12/apis/change-lifecycle?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b&action=Publish&lifecycleChecklist=Deprecate Old Versions:true,Require Re-Subscription:true" - - type: string - in: query - - $ref: '#/parameters/apiId-Q' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Lifecycle changed successfully. - headers: - ETag: - description: | - Entity Tag of the changed API. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the API lifecycle has been modified the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Document Collection" resource APIs -###################################################### - /apis/{apiId}/documents: - -#----------------------------------------------------- -# Retrieve the documents associated with an API that qualify under a search condition -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents\"" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n },\n {\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"URL\",\n \"sourceUrl\": \"http://wiki.cdyne.com/index.php/Phone_Verification\",\n \"otherTypeName\": null,\n \"documentId\": \"4145df31-04f1-440c-8d08-68952874622c\",\n \"summary\": \"This is the URL for online documentation\",\n \"name\": \"Online Documentation\",\n \"type\": \"SAMPLES\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" - summary: Get a list of documents of an API - description: | - This operation can be used to retrive a list of documents belonging to an API by providing the id of the API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Document (Collection) - responses: - 200: - description: | - OK. - Document list is returned. - schema: - $ref: '#/definitions/DocumentList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Add a document to a certain API -#----------------------------------------------------- - post: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"summary\": \"This is a sample documentation\",\n \"name\": \"Introduction to PhoneVerification API\",\n \"type\": \"HOWTO\"\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058\",\n \"summary\": \"This is a sample documentation\",\n \"name\": \"Introduction to PhoneVerification API\",\n \"type\": \"HOWTO\"\n}" - summary: Add a new document to an API - description: | - This operation can be used to add a new documentation to an API. This operation only adds the metadata of a document. To add the actual content we need to use **Upload the content of an API document ** API once we obtain a document Id by this operation. - parameters: - - $ref: '#/parameters/apiId' - - in: body - name: body - description: | - Document object that needs to be added - required: true - schema: - $ref: '#/definitions/Document' - - $ref: '#/parameters/Content-Type' - tags: - - Document (Collection) - responses: - 201: - description: | - Created. - Successful response with the newly created Document object as entity in the body. - Location header contains URL of newly added document. - schema: - $ref: '#/definitions/Document' - headers: - Location: - description: | - Location to the newly created Document. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. - -###################################################### -# The "Individual Document" resource APIs -###################################################### - '/apis/{apiId}/documents/{documentId}': - -#----------------------------------------------------- -# Retrieve a particular document of a certain API -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\"" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - summary: Get a document of an API - description: | - This operation can be used to retrieve a particular document's metadata associated with an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Document (Individual) - responses: - 200: - description: | - OK. - Document returned. - schema: - $ref: '#/definitions/Document' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update a particular document of a certain API -#----------------------------------------------------- - put: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" -H \"Content-Type: application/json\" -X PUT -d data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\"" - x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\nAuthorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"visibility\": \"API_LEVEL\",\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"0bcb7f05-599d-4e1a-adce-5cb89bfe58d5\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - summary: Update a document of an API - description: | - This operation can be used to update metadata of an API's document. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - in: body - name: body - description: | - Document object that needs to be added - required: true - schema: - $ref: '#/definitions/Document' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Document (Individual) - responses: - 200: - description: | - OK. - Document updated - schema: - $ref: '#/definitions/Document' - headers: - Location: - description: | - The URL of the updated document. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete a particular document of a certain API -#----------------------------------------------------- - delete: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058" - x-wso2-request: | - DELETE https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/ffd5790d-b7a9-4cb6-b76a-f8b83ecdd058 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK" - summary: Delete a document of an API - description: | - This operation can be used to delete a document associated with an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Document (Individual) - responses: - 200: - description: | - OK. - Resource successfully deleted. - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -################################################################ -# The content resource of "Individual Document" resource APIs -################################################################ - - '/apis/{apiId}/documents/{documentId}/content': - - #------------------------------------------------------------------------------------------------- - # Downloads a FILE type document/get the inline content or source url of a certain document - #------------------------------------------------------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a\" \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\" > sample.pdf" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content - Authorization:Bearer b0982cd2aacd463ff5f63cd5ebe58f4a - x-wso2-response: "HTTP/1.1 200 OK\nContent-Disposition: attachment; filename=\"sample.pdf\"\nContent-Type: application/octet-stream\nContent-Length: 7802\n\n%PDF-1.4\n%äüöß\n2 0 obj\n<>\nstream\n..\n>>\nstartxref\n7279\n%%EOF" - summary: Get the content of an API document - description: | - This operation can be used to retrive the content of an API's document. - - The document can be of 3 types. In each cases responses are different. - - 1. **Inline type**: - The content of the document will be retrieved in `text/plain` content type - - _Sample cURL_ : `curl -k -H "Authorization:Bearer 579f0af4-37be-35c7-81a4-f1f1e9ee7c51" -F inlineContent=@"docs.txt" -X POST "https://localhost:9443/api/am/publisher/v0.12/apis/995a4972-3178-4b17-a374-756e0e19127c/documents/43c2bcce-60e7-405f-bc36-e39c0c5e189e/content` - 2. **FILE type**: - The file will be downloaded with the related content type (eg. `application/pdf`) - 3. **URL type**: - The client will recieve the URL of the document as the Location header with the response with - `303 See Other` - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Document (Individual) - responses: - 200: - description: | - OK. - File or inline content returned. - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 303: - description: | - See Other. - Source can be retrived from the URL specified at the Location header. - headers: - Location: - description: | - The Source URL of the document. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - - #---------------------------------------------------------------------------- - # Upload a file or add inline content to a document of a certain API - #---------------------------------------------------------------------------- - post: - consumes: - - multipart/form-data - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -F file=@\"sample.pdf\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/daf732d3-bda2-46da-b381-2c39d901ea61/content\"" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/documents/b3a79270-02bb-4e39-9ac1-90ce8f6c84af/content - Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - Content-Length: 8004 - Content-Type: multipart/form-data; boundary=------------------------7b9a53f1ffa452b9 - - --------------------------7b9a53f1ffa452b9 - Content-Disposition: form-data; name="file"; filename="sample.pdf" - Content-Type: application/octet-stream - - [file content] - - --------------------------7b9a53f1ffa452b9-- - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/apis/8848faaa-7fd1-478a-baa2-48a4ebb92c98/documents/b3a79270-02bb-4e39-9ac1-90ce8f6c84af/content\nContent-Type: application/json\n\n{\n \"visibility\":\"API_LEVEL\",\n \"sourceType\":\"FILE\",\n \"sourceUrl\":null,\n \"otherTypeName\":null,\n \"documentId\":\"daf732d3-bda2-46da-b381-2c39d901ea61\",\n \"summary\":\"This is a sample documentation pdf\",\n \"name\":\"Introduction to PhoneVerification API PDF\",\n \"type\":\"HOWTO\"\n}" - summary: Upload the content of an API document - description: | - Thid operation can be used to upload a file or add inline content to an API document. - - **IMPORTANT:** - * Either **file** or **inlineContent** form data parameters should be specified at one time. - * Document's source type should be **FILE** in order to upload a file to the document using **file** parameter. - * Document's source type should be **INLINE** in order to add inline content to the document using **inlineContent** parameter. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - in: formData - name: file - description: Document to upload - type: file - required: false - - in: formData - name: inlineContent - description: Inline content of the document - type: string - required: false - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Document (Individual) - responses: - 200: - description: | - OK. - Document updated - schema: - $ref: '#/definitions/Document' - headers: - Location: - description: | - The URL of the updated content of the document. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - - ##pp -###################################################### -# The "specific mediation policy" resource APIs -###################################################### - '/apis/{apiId}/policies/mediation': - - #----------------------------------------------------------------------------------------- - # Retrieving the list of all API specific mediation sequences under a given search condition - #----------------------------------------------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc\" https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation" - x-wso2-request: "GET https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation\r\nAuthorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"count\": 1,\r\n \"next\": null,\r\n \"previous\": null,\r\n \"list\": [ {\r\n \"name\": \"add_custom_header_fault\",\r\n \"id\": \"6460d7e6-4272-4e3a-9879-437228d83123\",\r\n \"type\": \"fault\"\r\n }]\r\n}" - summary: | - Get all mediation policies of an API - description: | - This operation provides you a list of available mediation policies of an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref : '#/parameters/limit' - - $ref : '#/parameters/offset' - - name : query - in: query - description: "-Not supported yet-" - type: string - - $ref : "#/parameters/Accept" - - $ref : "#/parameters/If-None-Match" - tags: - - Mediation Policy (Collection) - responses: - 200: - description: | - OK. - List of qualifying APIs is returned. - schema: - $ref: '#/definitions/mediationList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#---------------------------------------------------------------------------- -# Upload an API specific mediation policy -#---------------------------------------------------------------------------- - post: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer 6cea3696-0151-3282-bf79-a0c4db6f308a\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation\r\nContent-Type: application/json\r\nAuthorization: Bearer 6cea3696-0151-3282-bf79-a0c4db6f308a\r\n\r\n{\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" - x-wso2-response: "HTTP/1.1 201 Created\r\nLocation: https://localhost:9443/api/am/publisher/v0.12/registry/resource/_system/governance/apimgt/applicationdata/provider/admin/hello/1.0.0/fault/add_custom_header_fault.xml\r\nContent-Type: application/json\r\n\r\n{ \r\n \"id\":\"624b9f7d-bfaf-484b-94cc-e84491f5d725\",\r\n \"name\":\"add_custom_header_fault\",\r\n \"type\":\"fault\",\r\n \"config\":\"\\n \\n\\n\"\r\n}" - summary: Add an API specific mediation policy - description: | - This operation can be used to add an API specifc mediation policy. - parameters: - - in: body - name: body - description: mediation policy to upload - required: true - schema: - $ref: '#/definitions/Mediation' - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Mediation Policy (Collection) - responses: - 200: - description: | - OK. - mediation policy uploaded - schema: - $ref : '#/definitions/Mediation' - headers: - Location: - description: | - The URL of the uploaded thumbnail image of the API. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual API specific mediation sequence" resource -###################################################### - /apis/{apiId}/policies/mediation/{mediationPolicyId}: - -#----------------------------------------------------- -# Retrieve a particular API specific mediation squence -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer 5aa0acc0-0ce3-3a0b-8cc8-db5ef696ee23\" https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/624b9f7d-bfaf-484b-94cc-e84491f5d725" - x-wso2-request: "GET https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/624b9f7d-bfaf-484b-94cc-e84491f5d725\r\nAuthorization: Bearer 5aa0acc0-0ce3-3a0b-8cc8-db5ef696ee23" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"id\": \"624b9f7d-bfaf-484b-94cc-e84491f5d725\",\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" - summary: Get an API specific mediation policy - description: | - This operation can be used to retrieve a particular API specific mediation policy. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/mediationPolicyId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Mediation Policy (Individual) - responses: - 200: - description: | - OK. - Mediation policy returned. - schema: - $ref: '#/definitions/Mediation' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete the mediation policy -#----------------------------------------------------- - delete: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc\" -X DELETE https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/60f5146d-1774-405d-86b3-9b040ac266d5" - x-wso2-request: "DELETE https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/60f5146d-1774-405d-86b3-9b040ac266d5\r\nAuthorization: Bearer fb2a0784-f60c-3276-8fde-5b0f70e61ecc" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Delete an API specific mediation policy - description: | - This operation can be used to delete an existing API specific mediation policy providing the Id of the API and the Id of the mediation policy. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/mediationPolicyId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Mediation Policy (Individual) - responses: - 200: - description: | - OK. - Resource successfully deleted. - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update the a mediation policy -#----------------------------------------------------- - put: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer 9e41fae2-3ada-3dd1-8f12-2077202f4285\" -H \"Content-Type: application/json\" -X PUT -d @data.json https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/820fdcf7-7258-42b5-809e-674b893644d1" - x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/apis/40082986-6488-4b86-801a-b0b069d4588c/policies/mediation/820fdcf7-7258-42b5-809e-674b893644d1\r\nContent-Type: application/json\r\nAuthorization: Bearer 9e41fae2-3ada-3dd1-8f12-2077202f4285\r\n\r\n{\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"id\": \"a7365481-5b3f-463c-a646-a498895ac210\",\r\n \"name\": \"add_custom_header_fault\",\r\n \"type\": \"fault\",\r\n \"config\": \"\\n \\n<\\/sequence>\\n\"\r\n}" - summary: Update an API specific mediation policy - description: | - This operation can be used to update an existing mediation policy of an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/mediationPolicyId' - - in: body - name: body - description: | - Mediation policy object that needs to be updated - required: true - schema: - $ref: '#/definitions/Mediation' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Mediation Policy (Individual) - responses: - 200: - description: | - OK. - Successful response with updated API object - schema: - $ref: '#/definitions/Mediation' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The wsdl Resource -###################################################### - /apis/{apiId}/wsdl: - -#----------------------------------------------------- -# Retrieve the details about a certain wsdl -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/apis/7f82f6b0-2667-441e-af23-c0fc44cf3a17/wsdl\"" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/apis/7f82f6b0-2667-441e-af23-c0fc44cf3a17/wsdl - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"name\": \"admin--hello1.0.0.wsdl\",\r\n \"wsdlDefinition\": \"\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n \\n <\\/input>\\n \\n <\\/output>\\n <\\/operation>\\n <\\/portType>\\n \\n \\n \\n \\n \\n \\n <\\/input>\\n \\n \\n <\\/output>\\n <\\/operation>\\n <\\/binding>\\n \\nWSDL File for HelloService<\\/documentation>\\n \\n \\n <\\/port>\\n <\\/service>\\n<\\/definitions>\"\r\n}" - summary: Get the WSDL of an API - description: | - This operation can be used to retrieve the WSDL definition of an API. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Wsdl (Individual) - responses: - 200: - description: | - OK. - Requested WSDL DTO object belongs to the API - schema: - $ref: '#/definitions/Wsdl' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' -#----------------------------------------------------- -# Add a wsdl to the registry -#----------------------------------------------------- - post: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization:Bearer 5311eca3-8ac8-354e-ab36-7e2fdd6a4013\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/apis/af3f96da-9ccf-463f-8cee-13ec8530a9cd/wsdl\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/apis/af3f96da-9ccf-463f-8cee-13ec8530a9cd/wsdl\r\nContent-Type: application/json\r\nAuthorization: Bearer 7d237cab-7011-3f81-b384-24d03e750873\r\n\r\n{\r\n \"name\": \"admin--PizzaShackAPI1.0.0.wsdl\",\r\n \"wsdlDefinition\": \"\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n \\n <\\/input>\\n \\n <\\/output>\\n <\\/operation>\\n <\\/portType>\\n \\n \\n \\n \\n \\n \\n <\\/input>\\n \\n \\n <\\/output>\\n <\\/operation>\\n <\\/binding>\\n \\nWSDL File for HelloService<\\/documentation>\\n \\n \\n <\\/port>\\n <\\/service>\\n<\\/definitions>\"\r\n}" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"name\": \"admin--PizzaShackAPI1.0.0.wsdl\",\r\n \"wsdlDefinition\": \"\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n <\\/part>\\n <\\/message>\\n \\n \\n \\n <\\/input>\\n \\n <\\/output>\\n <\\/operation>\\n <\\/portType>\\n \\n \\n \\n \\n \\n \\n <\\/input>\\n \\n \\n <\\/output>\\n <\\/operation>\\n <\\/binding>\\n \\nWSDL File for HelloService<\\/documentation>\\n \\n \\n <\\/port>\\n <\\/service>\\n<\\/definitions>\"\r\n}" - summary: Add a WSDL to an API - description: | - This operation can be used to add a WSDL definition to an existing API. - parameters: - - $ref: '#/parameters/apiId' - - in: body - name: body - description: | - JSON payload including WSDL definition that needs to be added - required: true - schema: - $ref: '#/definitions/Wsdl' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Wsdl (Individual) - responses: - 200: - description: | - OK. - Successful response with updated wsdl definition - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - - -###################################################### -# The "Individual Application" resource APIs -###################################################### - '/applications/{applicationId}': - -#----------------------------------------------------- -# Retrieve the details about a certain application -#----------------------------------------------------- - get: - x-scope: apim:api_create - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"name\": \"DefaultApplication\"\n}" - summary: Get details of an application - description: | - This operation can be used to retrieve details of an individual application specifying the application id in the URI. - parameters: - - $ref: '#/parameters/applicationId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Application (Individual) - responses: - 200: - description: | - OK. - Application returned. - schema: - $ref: '#/definitions/Application' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested application does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Subscription Collection" resource APIs -###################################################### - /subscriptions: - -#----------------------------------------------------- -# Retrieve all subscriptions of a certain API -#----------------------------------------------------- - get: - x-scope: apim:subscription_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/subscriptions?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b\"" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/subscriptions?apiId=890a4f4d-09eb-4877-a323-57f6ce2ed79b - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n \n{\n \"previous\": \"\",\n \"list\": [\n {\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n },\n {\n \"subscriptionId\": \"7ac22c34-8745-4cfe-91e0-262c50b2f2e3\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"367a2361-8db5-4140-8133-c6c8dc7fa0c4\",\n \"status\": \"UNBLOCKED\"\n }\n ],\n \"next\": \"\",\n \"count\": 2\n}" - summary: Get all Subscriptions - description: | - This operation can be used to retrieve a list of subscriptions of the user associated with the provided access token. This operation is capable of - - 1. Retrieving all subscriptions for the user's APIs. - `GET https://localhost:9443/api/am/publisher/v0.12/subscriptions` - - 2. Retrieving subscriptions for a specific API. - `GET https://localhost:9443/api/am/publisher/v0.12/subscriptions?apiId=c43a325c-260b-4302-81cb-768eafaa3aed` - parameters: - - $ref: '#/parameters/apiId-Q' - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Subscription (Collection) - responses: - 200: - description: | - OK. - Subscription list returned. - schema: - $ref: '#/definitions/SubscriptionList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 406: - description: | - Not Acceptable. The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual Subscription" resource APIs -###################################################### - '/subscriptions/{subscriptionId}': - -#----------------------------------------------------- -# Retrieve a certain subscription -#----------------------------------------------------- - get: - x-scope: apim:subscription_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/subscriptions/64eca60b-2e55-4c38-8603-e9e6bad7d809 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n}" - summary: Get details of a subscription - description: | - This operation can be used to get details of a single subscription. - parameters: - - $ref: '#/parameters/subscriptionId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Subscription (Individual) - responses: - 200: - description: | - OK. - Subscription returned - schema: - $ref: '#/definitions/ExtendedSubscription' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: 'Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future).' - type: string - Last-Modified: - description: 'Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future).' - type: string - '304': - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - '404': - description: | - Not Found. - Requested Subscription does not exist. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Block Subscription" Processing Function resource API -###################################################### - /subscriptions/block-subscription: - -#----------------------------------------------------- -# Block a certain subscription -#----------------------------------------------------- - post: - x-scope: apim:subscription_block - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/subscriptions/block-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809&blockState=PROD_ONLY_BLOCKED\"" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/subscriptions/block-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809&blockState=PROD_ONLY_BLOCKED - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n \n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"PROD_ONLY_BLOCKED\"\n}" - summary: Block a subscription - description: | - This operation can be used to block a subscription. Along with the request, `blockState` must be specified as a query parameter. - - 1. `BLOCKED` : Subscription is completely blocked for both Production and Sandbox environments. - 2. `PROD_ONLY_BLOCKED` : Subscription is blocked for Production environment only. - parameters: - - $ref: '#/parameters/subscriptionId-Q' - - name: blockState - in: query - description: | - Subscription block state. - type: string - required: true - enum: - - BLOCKED - - PROD_ONLY_BLOCKED - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Subscription (Individual) - responses: - 200: - description: | - OK. - Subscription was blocked successfully. - headers: - ETag: - description: | - Entity Tag of the blocked subscription. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the subscription has been blocked. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Requested subscription does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Unblock Subscription" Processing Function resource API -###################################################### - /subscriptions/unblock-subscription: - -#----------------------------------------------------- -# Unblock a certain subscription -#----------------------------------------------------- - post: - x-scope: apim:subscription_block - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X POST \"https://localhost:9443/api/am/publisher/v0.12/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809\"" - x-wso2-request: | - POST https://localhost:9443/api/am/publisher/v0.12/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8` - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"subscriptionId\": \"64eca60b-2e55-4c38-8603-e9e6bad7d809\",\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"admin-PhoneVerification-1.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n} " - summary: Unblock a Subscription - parameters: - - $ref: '#/parameters/subscriptionId-Q' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - description: | - This operation can be used to unblock a subscription specifying the subscription Id. The subscription will be fully unblocked after performing this operation. - tags: - - Subscription (Individual) - responses: - 200: - description: | - OK. - Subscription was unblocked successfully. - headers: - ETag: - description: | - Entity Tag of the unblocked subscription. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the subscription has been unblocked. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Requested subscription does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Tier Collection" resource APIs -###################################################### - '/tiers/{tierLevel}': - -#----------------------------------------------------- -# Retrieve the list of all available tiers -#----------------------------------------------------- - get: - x-scope: apim:tier_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/tiers/api" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/tiers/api - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 20,\n \"description\": \"Allows 20 request(s) per minute.\",\n \"name\": \"Gold\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Silver\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 0,\n \"tierPlan\": null,\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 0,\n \"description\": \"Allows unlimited requests\",\n \"name\": \"Unlimited\",\n \"attributes\": {}\n }\n ],\n \"next\": \"\",\n \"count\": 4\n}" - summary: Get all tiers - description: | - This operation can be used to list the available tiers for a given tier level. Tier level should be specified as a path parameter and should be one of `api`, `application` and `resource`. - parameters: - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Throttling Tier (Collection) - responses: - 200: - description: | - OK. - List of tiers returned. - schema: - $ref: '#/definitions/TierList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Create a new tier -#----------------------------------------------------- - post: - x-scope: apim:tier_manage - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/tiers/api\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/tiers/api\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"a\":10,\n \"b\":30\n }\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/publisher/v0.12/tiers/Low\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"b\": \"30\",\n \"a\": \"10\"\n }\n}" - summary: Create a Tier - description: | - This operation can be used to create a new throttling tier. The only supported tier level is `api` tiers. - `POST https://localhost:9443/api/am/publisher/v0.12/tiers/api` - - **IMPORTANT:** - * This is only effective when Advanced Throttling is disabled in the Server. If enabled, we need to use Admin REST API for throttling tiers modification related operations. - parameters: - - in: body - name: body - description: | - Tier object that should to be added - required: true - schema: - $ref: '#/definitions/Tier' - - $ref: '#/parameters/tierLevel-A' - - $ref: '#/parameters/Content-Type' - tags: - - Throttling Tier (Collection) - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - schema: - $ref: '#/definitions/Tier' - headers: - Location: - description: | - Location of the newly created tier. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional request' - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. - -###################################################### -# The "Individual Tier" resource APIs -###################################################### - '/tiers/{tierLevel}/{tierName}': - -#----------------------------------------------------- -# Retrieve a certain tier -#----------------------------------------------------- - get: - x-scope: apim:tier_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/tiers/api/Bronze" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/tiers/api/Bronze - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n}" - summary: Get details of a tier - description: | - This operation can be used to retrieve details of a single tier by specifying the tier level and tier name. - Note that the scope of the API is mandatory while retreiving the access token with the following cURL command : `curl -k -d \"grant_type=password&username=username&password=password&scope=apim:tier_view\" -H \"Authorization: Basic \" https://localhost:8243/token`. - You will receive the access token as the response, for example `"access_token":"8644c013-7ff1-3217-b150-d7b92cae6be7"`. - parameters: - - $ref: '#/parameters/tierName' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Throttling Tier (Individual) - responses: - 200: - description: | - OK. - Tier returned - schema: - $ref: '#/definitions/Tier' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested Tier does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update a certain tier -#----------------------------------------------------- - put: - x-scope: apim:tier_manage - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X PUT -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low\"" - x-wso2-request: "PUT https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 10,\n \"description\": \"Allows 10 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"a\": \"30\",\n \"b\": \"10\",\n \"c\": \"20\"\n }\n}\n" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"tierLevel\": \"api\",\n \"stopOnQuotaReach\": true,\n \"requestCount\": 10,\n \"description\": \"Allows 10 request(s) per minute.\",\n \"name\": \"Low\",\n \"attributes\": {\n \"b\": \"10\",\n \"c\": \"20\",\n \"a\": \"30\"\n }\n}" - summary: Update a Tier - description: | - This operation can be used to update an existing tier. The only supported tier level is `api` tiers. - `PUT https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low` - - **IMPORTANT:** - * This is only effective when Advanced Throttling is disabled in the Server. If enabled, we need to use Admin REST API for throttling tiers modification related operations. - parameters: - - $ref: '#/parameters/tierName' - - in: body - name: body - description: | - Tier object that needs to be modified - required: true - schema: - $ref: '#/definitions/Tier' - - $ref: '#/parameters/tierLevel-A' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Throttling Tier (Individual) - responses: - 200: - description: | - OK. - Subscription updated. - schema: - $ref: '#/definitions/Tier' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete a certain tier -#----------------------------------------------------- - delete: - x-scope: apim:tier_manage - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE \"https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low\"" - x-wso2-request: | - DELETE https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK" - summary: Delete a Tier - description: | - This operation can be used to delete an existing tier. The only supported tier level is `api` tiers. - `DELETE https://localhost:9443/api/am/publisher/v0.12/tiers/api/Low` - - **IMPORTANT:** - * This is only effective when Advanced Throttling is disabled in the Server. If enabled, we need to use Admin REST API for throttling tiers modification related operations. - parameters: - - $ref: '#/parameters/tierName' - - $ref: '#/parameters/tierLevel-A' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Throttling Tier (Individual) - responses: - 200: - description: | - OK. - Resource successfully deleted. - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Update Permission" Processing Function resource API -###################################################### - '/tiers/update-permission': - -#----------------------------------------------------- -# Update the permission of a certain tier -#----------------------------------------------------- - post: - x-scope: apim:tier_manage - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/tiers/update-permission?tierName=Bronze&tierLevel=api\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/tiers/update-permission?tierName=Bronze&tierLevel=api\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"permissionType\":\"deny\",\n \"roles\": [\"Internal/everyone\",\"admin\"]\n}" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Update tier permission - description: | - This operation can be used to update tier permissions which controls access for the particular tier based on the subscribers' roles. - parameters: - - $ref: '#/parameters/tierName-Q' - - $ref: '#/parameters/tierLevel-Q' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - - in: body - name: permissions - schema: - $ref: '#/definitions/TierPermission' - tags: - - Throttling Tier (Individual) - responses: - 200: - description: | - OK. - Successfully updated tier permissions - schema: - type: array - items: - $ref: '#/definitions/Tier' - headers: - ETag: - description: | - Entity Tag of the modified tier. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the tier has been modified. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 403: - description: | - Forbidden. - The request must be conditional but no condition has been specified. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Requested tier does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - - -###################################################### -# The "Environment Collection" resource API -###################################################### - /environments: - -#----------------------------------------------------- -# Retrieve the list of environments configured for a certain API -#----------------------------------------------------- - get: - x-scope: apim:api_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/publisher/v0.12/environments\"" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/environments - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"list\": [ {\n \"showInApiConsole\": true,\n \"serverUrl\": \"https://localhost:9443/services/\",\n \"endpoints\": {\n \"http\": \"http://localhost:8280\",\n \"https\": \"https://localhost:8243\"\n },\n \"name\": \"Production and Sandbox\",\n \"type\": \"hybrid\"\n }],\n \"count\": 1\n}" - summary: Get all gateway environments - description: | - This operation can be used to retrieve the list of gateway environments available. - parameters: - - $ref: '#/parameters/apiId-Q' - tags: - - Environment (Collection) - responses: - 200: - description: | - OK. - Environment list is returned. - schema: - $ref: '#/definitions/EnvironmentList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - /policies/mediation: - -#----------------------------------------------------------------------------------------- -# Retrieving the list of all global mediation sequences under a given search condition -#----------------------------------------------------------------------------------------- - get: - x-scope: apim:mediation_policy_view - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" https://localhost:9443/api/am/publisher/v0.12/policies/mediation" - x-wso2-request: | - GET https://localhost:9443/api/am/publisher/v0.12/policies/mediation - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{\r\n \"count\": 10,\r\n \"next\": null,\r\n \"previous\": null,\r\n \"list\": [\r\n {\r\n \"name\": \"debug_json_fault\",\r\n \"id\": \"563de8f3-dd1d-4ec7-afc2-d158c663ed34\",\r\n \"type\": \"fault\"\r\n },\r\n {\r\n \"name\": \"json_fault\",\r\n \"id\": \"f9c36f4d-a2b6-41e7-b311-d358a47916be\",\r\n \"type\": \"fault\"\r\n },\r\n {\r\n \"name\": \"json_to_xml_in_message\",\r\n \"id\": \"3921225b-7918-4b95-a851-22c4e4e3e911\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"debug_in_flow\",\r\n \"id\": \"2bc15f93-4455-4763-89b8-83600fb9d731\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"log_in_message\",\r\n \"id\": \"4d287cca-76ab-44ca-b22e-919fc27c50e3\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"preserve_accept_header\",\r\n \"id\": \"3776b215-b3bc-40b6-bdcb-06efa7de64be\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"xml_to_json_in_message\",\r\n \"id\": \"50ac2002-769e-4f90-8549-6d0248dff7d2\",\r\n \"type\": \"in\"\r\n },\r\n {\r\n \"name\": \"xml_to_json_out_message\",\r\n \"id\": \"2af75853-ed75-4d25-81aa-0ebbeca691ea\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"json_to_xml_out_message\",\r\n \"id\": \"d9fa3ffc-f6b6-4171-ab97-eb44196cb66e\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"debug_out_flow\",\r\n \"id\": \"260b7701-4071-46bd-9b66-900ac6fffed6\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"apply_accept_header\",\r\n \"id\": \"15c17c2f-33e3-4c37-a262-04dfa49983a4\",\r\n \"type\": \"out\"\r\n },\r\n {\r\n \"name\": \"log_out_message\",\r\n \"id\": \"d37dca41-c048-492a-82cf-9a2292c6fff0\",\r\n \"type\": \"out\"\r\n }\r\n ]\r\n}" - summary: | - Get all global level mediation policies - description: | - This operation provides you a list of available all global level mediation policies. - parameters: - - $ref : '#/parameters/limit' - - $ref : '#/parameters/offset' - - name : query - in: query - description: "-Not supported yet-" - type: string - - $ref : "#/parameters/Accept" - - $ref : "#/parameters/If-None-Match" - tags: - - Mediation Policy (Collection) - responses: - 200: - description: | - OK. - List of mediation policies is returned. - schema: - $ref: '#/definitions/mediationList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - - - -###################################################### -# The "Workflow approval" resource API -###################################################### - /workflows/update-workflow-status: - -#------------------------------------------------------------------- -# Resume the workflow by approving or rejecting the workflow request -#------------------------------------------------------------------- - post: - x-scope: apim:api_workflow - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/publisher/v0.12/workflows/update-workflow-status?workflowReferenceId=56e3a170-a7a7-45f8-b051-7e43a58a67e1\"" - x-wso2-request: "POST https://localhost:9443/api/am/publisher/v0.12/workflows/update-workflow-status?workflowReferenceId=56e3a170-a7a7-45f8-b051-7e43a58a67e1\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\nContent-Type: application/json\n\n{\n \"status\" : \"APPROVED\",\n \"attributes\" : {\n \"apiCurrentState\": \"Created\",\n \"apiLCAction\": \"Publish\",\n \"apiName\":\"APIname\",\n \"apiVersion\" : \"1.0.0\",\n \"apiProvider\" : \"admin\",\n \"invoker\": \"admin\"\n }\n}" - x-wso2-response: "HTTP/1.1 200 OK" - summary: Update workflow status - description: | - This operation can be used to approve or reject a workflow task. - parameters: - - $ref: '#/parameters/workflowReferenceId-Q' - - in: body - name: body - description: | - Workflow event that need to be updated - required: true - schema: - $ref: '#/definitions/Workflow' - tags: - - Workflows (Individual) - responses: - 200: - description: | - OK. - Workflow request information is returned. - schema: - $ref: '#/definitions/Workflow' - headers: - Content-Type: - description: | - The content type of the body. - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Workflow for the given reference in not found. - schema: - $ref: '#/definitions/Error' -###################################################### -# Parameters - required by some of the APIs above -###################################################### -parameters: - -# API Identifier -# Specified as part of the path expression - apiId: - name: apiId - in: path - description: | - **API ID** consisting of the **UUID** of the API. Using the **UUID** in the API call is recommended. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. - Should be formatted as **provider-name-version**. - required: true - type: string - x-encoded: true - -# API Identifier -# Specified as part of the query string - apiId-Q: - name: apiId - in: query - description: | - **API ID** consisting of the **UUID** of the API. Using the **UUID** in the API call is recommended. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. - Should be formatted as **provider-name-version**. - required: true - type: string - x-encoded: true - - -# Document Identifier -# Specified as part of the path expression - documentId: - name: documentId - in: path - description: | - Document Identifier - required: true - type: string - -# Application Identifier -# Specified as part of the path expression - applicationId: - name: applicationId - in: path - description: | - **Application Identifier** consisting of the UUID of the Application. - required: true - type: string - -# Subscription Identifier -# Specified as part of the path expression - subscriptionId: - name: subscriptionId - in: path - description: | - Subscription Id - required: true - type: string - -# Mediation policy identifier -# Specified as part of the path expression - mediationPolicyId: - name: mediationPolicyId - in: path - description: | - Mediation policy Id - required: true - type: string - - - -# Subscription Identifier -# Specified as part of the query string - subscriptionId-Q: - name: subscriptionId - in: query - description: | - Subscription Id - required: true - type: string - -# Tier Name -# Specified as part of the path expression - tierName: - name: tierName - in: path - description: | - Tier name - required: true - type: string - -# Tier Name -# Specified as part of the query string - tierName-Q: - name: tierName - in: query - description: | - Name of the tier - required: true - type: string - -# Tier Type -# Specified as part of the path expression - tierLevel: - name: tierLevel - in: path - description: | - List API or Application or Resource type tiers. - type: string - enum: - - api - - application - - resource - required: true - -# Tier Type -# Specified as part of the path expression - tierLevel-A: - name: tierLevel - in: path - description: | - List API or Application or Resource type tiers. - type: string - enum: - - api - required: true - -# Tier Type -# Specified as part of the query string - tierLevel-Q: - name: tierLevel - in: query - description: | - List API or Application or Resource type tiers. - type: string - enum: - - api - - application - - resource - required: true - -# Used for pagination: -# The maximum number of resoures to be returned by a GET - limit: - name: limit - in: query - description: | - Maximum length of resource array to return. - default: 25 - type: integer - -# Used for pagination: -# The order number of an instance in a qualified set of resoures -# at which to start to return the next batch of qualified resources - offset: - name: offset - in: query - description: | - Starting point within the complete list of items qualified. - default: 0 - type: integer - -# The HTTP Accept header - Accept: - name: Accept - in: header - description: | - Media types acceptable for the response. Default is application/json. - default: application/json - type: string - -# The HTTP Content-Type header - Content-Type: - name: Content-Type - in: header - description: | - Media type of the entity in the body. Default is application/json. - default: application/json - required: true - type : string - -# The HTTP Authorization header - Authorization: - name: Authorization - in: header - description: | - Holds the bearer token for apis that require authentication. - required: true - type : string - -# The HTTP If-None-Match header -# Used to avoid retrieving data that are already cached - If-None-Match: - name: If-None-Match - in: header - description: | - Validator for conditional requests; based on the ETag of the formerly retrieved - variant of the resource (Will be supported in future). - type : string - -# The HTTP If-Modified-Since header -# Used to avoid retrieving data that are already cached - If-Modified-Since: - name: If-Modified-Since - in: header - description: | - Validator for conditional requests; based on Last Modified header of the - formerly retrieved variant of the resource (Will be supported in future). - type: string - -# The HTTP If-Match header -# Used to avoid concurrent updates - If-Match: - name: If-Match - in: header - description: | - Validator for conditional requests; based on ETag (Will be supported in future). - type: string - -# The HTTP If-Unmodified-Since header -# Used to avoid concurrent updates - If-Unmodified-Since: - name: If-Unmodified-Since - in: header - description: | - Validator for conditional requests; based on Last Modified header (Will be supported in future). - type: string - - -# Workflow reference ID -# Specified as part of the path expression - workflowReferenceId-Q: - name: workflowReferenceId - in: query - description: | - Workflow reference id - required: true - type: string - -###################################################### -# The resources used by some of the APIs above within the message body -###################################################### -definitions: - -#----------------------------------------------------- -# The API List resource -#----------------------------------------------------- - APIList: - title: API List - properties: - count: - type: integer - description: | - Number of APIs returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/apis?limit=1&offset=2&query=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/apis?limit=1&offset=0&query=" - list: - type: array - items: - $ref: '#/definitions/APIInfo' - pagination: - properties: - offset: - type: integer - example: 12 - limit: - type: integer - example: 25 - total: - type: integer - example: 1290 - -#----------------------------------------------------- -# The API Info resource -#----------------------------------------------------- - APIInfo: - title: API Info object with basic API details. - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorAPI - description: - type: string - example: A calculator API that supports basic operations - context: - type: string - example: CalculatorAPI - version: - type: string - example: 1.0.0 - provider: - description: | - If the provider value is not given, the user invoking the API will be used as the provider. - type: string - example: admin - status: - type: string - example: CREATED - thumbnailUri: - type: string - example: /apis/01234567-0123-0123-0123-012345678901/thumbnail - -#----------------------------------------------------- -# The API resource -#----------------------------------------------------- - API: - title: API object - required: - - name - - context - - version - - tiers - - isDefaultVersion - - transport - - endpointConfig - - visibility - - type - properties: - id: - type: string - description: | - UUID of the api registry artifact - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - description: Name of the API - example: CalculatorAPI - description: - type: string - description: A brief description about the API - example: A calculator API that supports basic operations - context: - type: string - description: A string that represents the context of the user's request - example: CalculatorAPI - version: - type: string - description: The version of the API - example: 1.0.0 - provider: - description: | - If the provider value is not given user invoking the api will be used as the provider. - type: string - example: admin - apiDefinition: - description: | - Swagger definition of the API which contains details about URI templates and scopes - type: string - example: "{\"paths\":{\"/substract\":{\"get\":{\"x-auth-type\":\"Application & Application User\",\"x-throttling-tier\":\"Unlimited\",\"parameters\":[{\"name\":\"x\",\"required\":true,\"type\":\"string\",\"in\":\"query\"},{\"name\":\"y\",\"required\":true,\"type\":\"string\",\"in\":\"query\"}],\"responses\":{\"200\":{}}}},\"/add\":{\"get\":{\"x-auth-type\":\"Application & Application User\",\"x-throttling-tier\":\"Unlimited\",\"parameters\":[{\"name\":\"x\",\"required\":true,\"type\":\"string\",\"in\":\"query\"},{\"name\":\"y\",\"required\":true,\"type\":\"string\",\"in\":\"query\"}],\"responses\":{\"200\":{}}}}},\"swagger\":\"2.0\",\"info\":{\"title\":\"CalculatorAPI\",\"version\":\"1.0.0\"}}" - wsdlUri: - description: | - WSDL URL if the API is based on a WSDL endpoint - type: string - example: "http://www.webservicex.com/globalweather.asmx?wsdl" - status: - type: string - description: This describes in which status of the lifecycle the API is - example: CREATED - responseCaching: - type: string - example: Disabled - cacheTimeout: - type: integer - example: 300 - destinationStatsEnabled: - type: string - example: Disabled - isDefaultVersion: - type: boolean - example: false - type: - type: string - description: The transport to be set. Accepted values are HTTP, WS - enum: - - HTTP - - WS - example: HTTP - default: HTTP - transport: - description: | - Supported transports for the API (http and/or https). - type: array - items: - type: string - example: ["http","https"] - tags: - type: array - description: Search keywords related to the API - items: - type: string - example: ["substract","add"] - tiers: - type: array - description: The subscription tiers selected for the particular API - items: - type: string - example: ["Unlimited"] - apiLevelPolicy: - description: The policy selected for the particular API - type: string - example: "Unlimited" - maxTps: - properties: - production: - type: integer - format: int64 - example: 1000 - sandbox: - type: integer - format: int64 - example: 1000 - thumbnailUri: - type: string - example: "/apis/01234567-0123-0123-0123-012345678901/thumbnail" - visibility: - type: string - description: The visibility level of the API. Accepts one of the following. PUBLIC, PRIVATE, RESTRICTED OR CONTROLLED. - enum: - - PUBLIC - - PRIVATE - - RESTRICTED - - CONTROLLED - example: PUBLIC - visibleRoles: - type: array - description: The user roles that are able to access the API - items: - type: string - example: [] - endpointConfig: - type: string - example: "{\"production_endpoints\":{\"url\":\"https://localhost:9443/am/sample/pizzashack/v1/api/\",\"config\":{\"suspendErrorCode\":\"101000\",\"suspendDuration\":\"2000\",\"suspendMaxDuration\":\"3\",\"factor\":\"2\",\"retryErroCode\":\"101000\",\"retryTimeOut\":\"4\",\"retryDelay\":\"1000\",\"actionSelect\":\"fault\",\"actionDuration\":\"3000\"}},\"sandbox_endpoints\":{\"url\":\"https://localhost:9443/am/sample/pizzashack/v1/api/\",\"config\":null},\"endpoint_type\":\"http\"}" - endpointSecurity: - properties: - type: - type: string - example: basic - description: Accepts one of the following, basic or digest. - enum: - - basic - - digest - username: - type: string - example: admin - password: - type: string - example: password - gatewayEnvironments: - description: | - Comma separated list of gateway environments. - type: string - example: Production and Sandbox - sequences: - type: array - items: - $ref: '#/definitions/Sequence' - example: [] - subscriptionAvailability: - type: string - description: The subscription availability. Accepts one of the following. current_tenant, all_tenants or specific_tenants. - enum: - - current_tenant - - all_tenants - - specific_tenants - example: current_tenant - subscriptionAvailableTenants: - type: array - items: - type: string - example: ["tenant1", "tenant2"] - additionalProperties: - type: object - description : Map of custom properties of API - accessControl: - type: string - description: | - Is the API is restricted to certain set of publishers or creators or is it visible to all the - publishers and creators. If the accessControl restriction is none, this API can be modified by all the - publishers and creators, if not it can only be viewable/modifiable by certain set of publishers and creators, - based on the restriction. enum: - - NONE - - RESTRICTED - accessControlRoles: - type: array - description: The user roles that are able to view/modify as API publisher or creator. - items: - type: string - example: [admin] - businessInformation: - properties: - businessOwner: - type: string - example: businessowner - businessOwnerEmail: - type: string - example: businessowner@wso2.com - technicalOwner: - type: string - example: technicalowner - technicalOwnerEmail: - type: string - example: technicalowner@wso2.com - corsConfiguration: - description: | - CORS configuration for the API - properties: - corsConfigurationEnabled: - type: boolean - default: false - accessControlAllowOrigins: - type: array - items: - type: string - accessControlAllowCredentials: - type: boolean - default: false - accessControlAllowHeaders: - type: array - items: - type: string - accessControlAllowMethods: - type: array - items: - type: string - -#----------------------------------------------------- -# The Application resource -#----------------------------------------------------- - Application: - title: Application - required: - - name - - throttlingTier - properties: - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorApp - subscriber: - type: string - example: admin - throttlingTier: - type: string - example: Unlimited - description: - type: string - example: Sample calculator application - groupId: - type: string - example: "" - -#----------------------------------------------------- -# The Document List resource -#----------------------------------------------------- - DocumentList: - title: Document List - properties: - count: - type: integer - description: | - Number of Documents returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Document' - -#----------------------------------------------------- -# The Document resource -#----------------------------------------------------- - Document: - title: Document - required: - - name - - type - - sourceType - - visibility - properties: - documentId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorDoc - type: - type: string - enum: - - HOWTO - - SAMPLES - - PUBLIC_FORUM - - SUPPORT_FORUM - - API_MESSAGE_FORMAT - - SWAGGER_DOC - - OTHER - example: HOWTO - summary: - type: string - example: "Summary of Calculator Documentation" - sourceType: - type: string - enum: - - INLINE - - URL - - FILE - example: INLINE - sourceUrl: - type: string - example: "" - otherTypeName: - type: string - example: "" - visibility: - type: string - enum: - - OWNER_ONLY - - PRIVATE - - API_LEVEL - example: API_LEVEL - -#----------------------------------------------------- -# The Mediation List resource -#----------------------------------------------------- - mediationList: - title: Mediation List - properties: - count: - type: integer - description: | - Number of mediation sequences returned. - example: 1 - next: - type: string - description: | - Link to the next subset of sequences qualified. - Empty if no more sequences are to be returned. - example: "" - previous: - type: string - description: | - Link to the previous subset of sequences qualified. - Empty if current subset is the first subset returned. - example: "" - list: - type: array - items: - $ref: '#/definitions/MediationInfo' - -#----------------------------------------------------- -# The MediationInfo resource -#----------------------------------------------------- - MediationInfo: - title: MediationInfo - required: - - name - - type - - id - properties: - name: - type: string - example: json_fault.xml - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - type: - type: string - enum: - - in - - out - - fault - example: in -#----------------------------------------------------- -# The Mediation resource -#----------------------------------------------------- - Mediation: - title: Mediation - required: - - name - - type - - config - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: json_fault.xml - type: - type: string - enum: - - in - - out - - fault - example: in - config: - type: string - example: ' - - - - ' - -#----------------------------------------------------- -# The MediationInfo resource -#----------------------------------------------------- - Wsdl: - title: Wsdl - required: - - name - properties: - name: - type: string - example: admin--calculatorAPI2.0.wsdl - wsdlDefinition: - type: string - - -# The Tier List resource -#----------------------------------------------------- - TierList: - title: Tier List - properties: - count: - type: integer - description: | - Number of Tiers returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/tiers/api?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/tiers/api?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Tier' - -#----------------------------------------------------- -# The Tier resource -#----------------------------------------------------- - Tier: - title: Tier - required: - - name - - tierPlan - - requestCount - - unitTime - - stopOnQuotaReach - properties: - name: - type: string - example: Platinum - description: - type: string - example: "Allows 50 request(s) per minute." - tierLevel: - type: string - enum: - - api - - application - - resource - example: api - attributes: - description: | - Custom attributes added to the tier policy - type: object - additionalProperties: - type: string - example: {} - requestCount: - description: | - Maximum number of requests which can be sent within a provided unit time - type: integer - format: int64 - example: 50 - unitTime: - type: integer - format: int64 - example: 60000 - timeUnit: - type: string - example: "min" - tierPlan: - description: | - This attribute declares whether this tier is available under commercial or free - type: string - enum: - - FREE - - COMMERCIAL - example: FREE - stopOnQuotaReach: - description: | - By making this attribute to false, you are capabale of sending requests - even if the request count exceeded within a unit time - type: boolean - example: true - -#----------------------------------------------------- -# The Tier Permission resource -#----------------------------------------------------- - TierPermission: - title: tierPermission - required: - - permissionType - - roles - properties: - permissionType: - type: string - enum: - - allow - - deny - example: deny - roles: - type: array - items: - type: string - example: ["Internal/everyone"] - -#----------------------------------------------------- -# The Subscription List resource -#----------------------------------------------------- - SubscriptionList: - title: Subscription List - properties: - count: - type: integer - description: | - Number of Subscriptions returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/subscriptions?limit=1&offset=2&apiId=01234567-0123-0123-0123-012345678901&groupId=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/subscriptions?limit=1&offset=0&apiId=01234567-0123-0123-0123-012345678901&groupId=" - list: - type: array - items: - $ref: '#/definitions/Subscription' - -#----------------------------------------------------- -# The Subscription resource -#----------------------------------------------------- - Subscription: - title: Subscription - required: - - applicationId - - apiIdentifier - - tier - properties: - subscriptionId: - type: string - example: 01234567-0123-0123-0123-012345678901 - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - apiIdentifier: - type: string - example: 01234567-0123-0123-0123-012345678901 - tier: - type: string - example: Unlimited - status: - type: string - enum: - - BLOCKED - - PROD_ONLY_BLOCKED - - UNBLOCKED - - ON_HOLD - - REJECTED - example: UNBLOCKED - -#----------------------------------------------------- -# The Extended Subscription resource -#----------------------------------------------------- - ExtendedSubscription: - title: Subscription with Ext. Workflow Reference - required: - - workflowId - allOf: - - $ref: '#/definitions/Subscription' - - properties: - workflowId: - type: string - example: 01234567-0123-0123-0123-012345678901 - -#----------------------------------------------------- -# The Sequence resource -#----------------------------------------------------- - Sequence: - title: Sequence - required: - - name - properties: - name: - type: string - example: log_in_message - type: - type: string - example: in - id: - type: string - example: 69ea3fa6-55c6-472e-896d-e449dd34a824 - shared: - type: boolean - example: true - -#----------------------------------------------------- -# The Error resource -#----------------------------------------------------- - Error: - title: Error object returned with 4XX HTTP status - required: - - code - - message - properties: - code: - type: integer - format: int64 - message: - type: string - description: Error message. - description: - type: string - description: | - A detail description about the error message. - moreInfo: - type: string - description: | - Preferably an url with more details about the error. - error: - type: array - description: | - If there are more than one error list them out. - For example, list out validation errors by each field. - items: - $ref: '#/definitions/ErrorListItem' - -#----------------------------------------------------- -# The Error List Item resource -#----------------------------------------------------- - ErrorListItem: - title: Description of individual errors that may have occurred during a request. - required: - - code - - message - properties: - code: - type: string - message: - type: string - description: | - Description about individual errors occurred - -#----------------------------------------------------- -# The Environment resource -#----------------------------------------------------- - Environment: - title: Environment - required: - - name - - type - - serverUrl - - endpoints - - showInApiConsole - properties: - name: - type: string - example: Production and Sandbox - type: - type: string - example: hybrid - serverUrl: - type: string - example: "https://localhost:9443/services/" - showInApiConsole: - type: boolean - example: true - endpoints: - $ref: '#/definitions/EnvironmentEndpoints' - -#----------------------------------------------------- -# The Environment List resource -#----------------------------------------------------- - EnvironmentList: - title: Environment List - properties: - count: - type: integer - description: | - Number of Environments returned. - example: 1 - list: - type: array - items: - $ref: '#/definitions/Environment' - - -#----------------------------------------------------- -# The Environment Endpoint resource -#----------------------------------------------------- - EnvironmentEndpoints : - title: Environment Endpoints - properties: - http: - type: string - description: HTTP environment URL - example: "http://localhost:8280" - https: - type: string - description: HTTPS environment URL - example: "https://localhost:8243" - -#----------------------------------------------------- -# The File Information resource -#----------------------------------------------------- - FileInfo : - title: File Information including meta data - properties: - relativePath: - type: string - description: relative location of the file (excluding the base context and host of the Publisher API) - example: "apis/01234567-0123-0123-0123-012345678901/thumbnail" - mediaType: - type: string - description: media-type of the file - example: "image/jpeg" - - -#----------------------------------------------------- -# The workflow response resource -#----------------------------------------------------- - Workflow: - title: workflow - required: - - status - properties: - status: - description: | - This attribute declares whether this workflow task is approved or rejected. - type: string - enum: - - APPROVED - - REJECTED - example: APPROVED - attributes: - description: | - Custom attributes to complete the workflow task - type: object - additionalProperties: - type: string - example: {} - description: - type: string - example: "Approve workflow request." \ No newline at end of file diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/store-api.yaml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/store-api.yaml deleted file mode 100644 index a57b96d4ab..0000000000 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/src/main/resources/store-api.yaml +++ /dev/null @@ -1,2693 +0,0 @@ -# Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -# -# 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. -################################################################################ - -swagger: '2.0' -###################################################### -# Prolog -###################################################### -info: - version: "0.12.0" - title: "WSO2 API Manager - Store" - description: | - This specifies a **RESTful API** for WSO2 **API Manager** - Store. - - Please see [full swagger definition](https://raw.githubusercontent.com/wso2/carbon-apimgt/v6.1.66/components/apimgt/org.wso2.carbon.apimgt.rest.api.store/src/main/resources/store-api.yaml) of the API which is written using [swagger 2.0](http://swagger.io/) specification. - contact: - name: "WSO2" - url: "http://wso2.com/products/api-manager/" - email: "architecture@wso2.com" - license: - name: "Apache 2.0" - url: "http://www.apache.org/licenses/LICENSE-2.0.html" - -###################################################### -# The fixed parts of the URLs of the API -###################################################### - -# The schemes supported by the API -schemes: - - https - -# The domain of the API. -# This is configured by the customer during deployment. -# The given host is just an example. -host: apis.wso2.com - -# The base path of the API. -# Will be prefixed to all paths. -basePath: /api/am/store/v0.12 - -# The following media types can be passed as input in message bodies of the API. -# The actual media type must be specified in the Content-Type header field of the request. -# The default is json, i.e. the Content-Type header is not needed to -# be set, but supporting it serves extensibility. -consumes: - - application/json - -# The following media types may be passed as output in message bodies of the API. -# The media type(s) consumable by the requestor is specified in the Accept header field -# of the corresponding request. -# The actual media type returned will be specfied in the Content-Type header field -# of the of the response. -# The default of the Accept header is json, i.e. there is not needed to -# set the value, but supporting it serves extensibility. -produces: - - application/json - -x-wso2-security: - apim: - x-wso2-scopes: - - description: "" - roles: Internal/subscriber - name: apim:subscribe - key: apim:subscribe - -###################################################### -# The "API Collection" resource APIs -###################################################### -paths: - /apis: - -#----------------------------------------------------- -# Retrieving the list of all APIs qualifying under a given search condition -#----------------------------------------------------- - get: - x-wso2-curl: "curl https://localhost:9443/api/am/store/v0.12/apis" - x-wso2-curl-tenant: "curl -k -H \"X-WSO2-Tenant:test.com\" https://localhost:9443/api/am/store/v0.12/apis" - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/apis - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": \"This API provide Account Status Validation.\",\n \"status\": \"PUBLISHED\",\n \"name\": \"AccountVal\",\n \"context\": \"/account/1.0.0\",\n \"id\": \"2e81f147-c8a8-4f68-b4f0-69e0e7510b01\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"1.0.0\",\n \"description\": null,\n \"status\": \"PUBLISHED\",\n \"name\": \"api1\",\n \"context\": \"/api1/1.0.0\",\n \"id\": \"3e22d2fb-277a-4e9e-8c7e-1c0f7f73960e\"\n },\n {\n \"provider\": \"admin\",\n \"version\": \"2.0.0\",\n \"description\": \"Verify a phone number\",\n \"status\": \"PUBLISHED\",\n \"name\": \"PhoneVerification\",\n \"context\": \"/phoneverify/2.0.0\",\n \"id\": \"c43a325c-260b-4302-81cb-768eafaa3aed\"\n }\n ],\n \"count\": 3,\n \"next\": \"\"\n}" - summary: | - Retrieve/Search APIs - description: | - This operation provides you a list of available APIs qualifying under a given search condition. - - Each retrieved API is represented with a minimal amount of attributes. If you want to get complete details of an API, you need to use **Get details of an API** operation. - - This operation supports retriving APIs of other tenants. The required tenant domain need to be specified as a header `X-WSO2-Tenant`. If not specified super tenant's APIs will be retrieved. If you used an Authorization header, the user's tenant associated with the access token will be used. - - **NOTE:** - * By default, this operation retrieves Published APIs. In order to retrieve Prototyped APIs, you need to use **query** parameter and specify **status:PROTOTYPED**. - * This operation does not require an Authorization header by default. But if it is provided, it will be validated and checked for permissions of the user, hence you may be able to see APIs which are restricted for special permissions/roles. - parameters: - - $ref : '#/parameters/limit' - - $ref : '#/parameters/offset' - - $ref : '#/parameters/requestedTenant' - - name : query - in: query - description: | - **Search condition**. - - You can search in attributes by using an **":"** modifier. - - Eg. - "provider:wso2" will match an API if the provider of the API is exactly "wso2". - - Additionally you can use wildcards. - - Eg. - "provider:wso2*" will match an API if the provider of the API starts with "wso2". - - Supported attribute modifiers are [**version, context, status, - description, subcontext, doc, provider, tag**] - - If no advanced attribute modifier has been specified, search will match the - given query string against API Name. - - type: string - - $ref : "#/parameters/Accept" - - $ref : "#/parameters/If-None-Match" - tags: - - API (Collection) - responses: - 200: - description: | - OK. - List of qualifying APIs is returned. - schema: - $ref: '#/definitions/APIList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual API" resource APIs -###################################################### - /apis/{apiId}: - -#----------------------------------------------------- -# Retrieve the details of an API definition -#----------------------------------------------------- - get: - x-wso2-curl: "curl https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed" - x-wso2-curl-tenant: "curl -k -H \"X-WSO2-Tenant:test.com\" https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed" - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\r\n \"thumbnailUrl\": null,\r\n \"tiers\": [\"Unlimited\"],\r\n \"businessInformation\": {\r\n \"technicalOwner\": \"John Doe\",\r\n \"technicalOwnerEmail\": \"architecture@pizzashack.com\",\r\n \"businessOwner\": \"Jane Roe\",\r\n \"businessOwnerEmail\": \"marketing@pizzashack.com\"\r\n },\r\n \"apiDefinition\": \"{\\\"paths\\\":{\\\"/order\\\":{\\\"post\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Create a new Order\\\",\\\"parameters\\\":[{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Order object that needs to be added\\\",\\\"name\\\":\\\"body\\\",\\\"required\\\":true,\\\"in\\\":\\\"body\\\"}],\\\"responses\\\":{\\\"201\\\":{\\\"headers\\\":{\\\"Location\\\":{\\\"description\\\":\\\"The URL of the newly created resource.\\\",\\\"type\\\":\\\"string\\\"},\\\"Content-Type\\\":{\\\"description\\\":\\\"The content type of the body.\\\",\\\"type\\\":\\\"string\\\"}},\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"description\\\":\\\"Created. Successful response with the newly created object as entity in the body. Location header contains URL of newly created entity.\\\"}}}},\\\"/order/{orderId}\\\":{\\\"get\\\":{\\\"x-auth-type\\\":\\\"Application & Application User\\\",\\\"x-throttling-tier\\\":\\\"Unlimited\\\",\\\"description\\\":\\\"Get details of an Order\\\",\\\"parameters\\\":[{\\\"description\\\":\\\"Order Id\\\",\\\"name\\\":\\\"orderId\\\",\\\"format\\\":\\\"string\\\",\\\"type\\\":\\\"string\\\",\\\"required\\\":true,\\\"in\\\":\\\"path\\\"}],\\\"responses\\\":{\\\"200\\\":{\\\"schema\\\":{\\\"$ref\\\":\\\"#/definitions/Order\\\"},\\\"headers\\\":{},\\\"description\\\":\\\"OK Requested Order will be returned\\\"}}}}},\\\"schemes\\\":[\\\"https\\\"],\\\"produces\\\":[\\\"application/json\\\"],\\\"swagger\\\":\\\"2.0\\\",\\\"definitions\\\":{\\\"Order\\\":{\\\"title\\\":\\\"Pizza Order\\\",\\\"properties\\\":{\\\"customerName\\\":{\\\"type\\\":\\\"string\\\"},\\\"delivered\\\":{\\\"type\\\":\\\"boolean\\\"},\\\"address\\\":{\\\"type\\\":\\\"string\\\"},\\\"pizzaType\\\":{\\\"type\\\":\\\"string\\\"},\\\"creditCardNumber\\\":{\\\"type\\\":\\\"string\\\"},\\\"quantity\\\":{\\\"type\\\":\\\"number\\\"},\\\"orderId\\\":{\\\"type\\\":\\\"string\\\"}},\\\"required\\\":[\\\"orderId\\\"]}},\\\"consumes\\\":[\\\"application/json\\\"],\\\"info\\\":{\\\"title\\\":\\\"PizzaShackAPI\\\",\\\"description\\\":\\\"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\\\n\\\",\\\"license\\\":{\\\"name\\\":\\\"Apache 2.0\\\",\\\"url\\\":\\\"http://www.apache.org/licenses/LICENSE-2.0.html\\\"},\\\"contact\\\":{\\\"email\\\":\\\"architecture@pizzashack.com\\\",\\\"name\\\":\\\"John Doe\\\",\\\"url\\\":\\\"http://www.pizzashack.com\\\"},\\\"version\\\":\\\"1.0.0\\\"}}\",\r\n \"wsdlUri\": null,\r\n \"isDefaultVersion\": false,\r\n \"endpointURLs\": [ {\r\n \"environmentName\": \"Production and Sandbox\",\r\n \"environmentType\": \"hybrid\",\r\n \"environmentURLs\": {\r\n \"http\": \"http://localhost:8280//pizzashack/1.0.0\",\r\n \"https\": \"https://localhost:8243//pizzashack/1.0.0\"\r\n }\r\n }],\r\n \"transport\": [\r\n \"http\",\r\n \"https\"\r\n ],\r\n \"tags\": [\"pizza\"],\r\n \"version\": \"1.0.0\",\r\n \"description\": \"This document describe a RESTFul API for Pizza Shack online pizza delivery store.\\r\\n\",\r\n \"provider\": \"admin\",\r\n \"name\": \"PizzaShackAPI\",\r\n \"context\": \"/pizzashack/1.0.0\",\r\n \"id\": \"8848faaa-7fd1-478a-baa2-48a4ebb92c98\",\r\n \"status\": \"PUBLISHED\"\r\n} " - summary: | - Get details of an API - description: | - Using this operation, you can retrieve complete details of a single API. You need to provide the Id of the API to retrive it. - - `X-WSO2-Tenant` header can be used to retrive an API of a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. - - **NOTE:** - * This operation does not require an Authorization header by default. But if it is provided, it will be validated and checked for permissions of the user, hence you may be able to see APIs which are restricted for special permissions/roles. \n - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - - $ref: '#/parameters/requestedTenant' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Requested API is returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - schema: - $ref: '#/definitions/API' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - - - /apis/{apiId}/swagger: -#----------------------------------------------------- -# Retrieve the API swagger definition -#----------------------------------------------------- - get: - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed/swagger - x-wso2-curl: "curl https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed/swagger" - x-wso2-curl-tenant: "curl -k -H \"X-WSO2-Tenant:test.com\" https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed/swagger" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"paths\": {\"/*\": {\"get\": {\n \"x-auth-type\": \"Application\",\n \"x-throttling-tier\": \"Unlimited\",\n \"responses\": {\"200\": {\"description\": \"OK\"}}\n }}},\n \"x-wso2-security\": {\"apim\": {\"x-wso2-scopes\": []}},\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": \"PhoneVerification\",\n \"description\": \"Verify a phone number\",\n \"contact\": {\n \"email\": \"xx@ee.com\",\n \"name\": \"xx\"\n },\n \"version\": \"2.0.0\"\n }\n}\n" - summary: | - Get swagger definition - description: | - You can use this operation to retrieve the swagger definition of an API. - - `X-WSO2-Tenant` header can be used to retrive the swagger definition an API of a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. - - **NOTE:** - * This operation does not require an Authorization header by default. But in order to see a restricted API's swagger definition, you need to provide Authorization header. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - - $ref: '#/parameters/requestedTenant' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Requested swagger document of the API is returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Generate SDK for an API -#----------------------------------------------------- - /apis/generate-sdk/: - post: - x-scope: apim:subscribe - x-wso2-request: | - POST https://localhost:9443/api/am/store/v0.12/apis/generate-sdk?apiId=e93fb282-b456-48fc-8981-003fb89086ae&language=java - Authorization: Bearer 2e29904b-f3b0-366e-ba13-b469abedd88e - x-wso2-curl: "curl -k -H \"Authorization: Bearer 2e29904b-f3b0-366e-ba13-b469abedd88e\" -X POST 'https://localhost:9443/api/am/store/v0.12/apis/generate-sdk?apiId=5721d128-76d0-4cb9-b300-2bd9578beddb&language=java' > PizzaAPI_Java_SDK.zip" - x-wso2-response: "HTTP/1.1 200 OK \nContent-Disposition: attachment; filename=\"PizzaShackAPI_1.0.0_java.zip\"\nContent-Type: application/zip\n\n[zip content]" - summary: | - Generate SDK for an API - description: | - This operation can be used to generate SDK for an API by providing the id of the API along with the preferred language. - parameters: - - $ref: '#/parameters/apiId-Q' - - $ref: '#/parameters/language' - - $ref : '#/parameters/requestedTenant' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - SDK generated successfully. - headers: - Content-Type: - description: | - The content type of the body. - type: string - 400: - description: | - Bad request. - SDK language is not supported. - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Document Collection" resource APIs -###################################################### - /apis/{apiId}/documents: - -#----------------------------------------------------- -# Retrieve the documents associated with an API that qualify under a search condition -#----------------------------------------------------- - get: - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents - x-wso2-curl: "curl https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents" - x-wso2-curl-tenant: "curl -k -H \"X-WSO2-Tenant:test.com\" https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"850a4f34-db2c-4d23-9d85-3f95fbfb082c\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n },\n {\n \"sourceType\": \"URL\",\n \"sourceUrl\": \"http://wiki.cdyne.com/index.php/Phone_Verification\",\n \"otherTypeName\": null,\n \"documentId\": \"98e18be8-5861-43c7-ba26-8cbbccd3a76f\",\n \"summary\": \"This is the URL for online documentation\",\n \"name\": \"Online Documentation\",\n \"type\": \"SAMPLES\"\n },\n {\n \"sourceType\": \"FILE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"b66451ff-c6c2-4f6a-b91d-3821dc119b04\",\n \"summary\": \"This is a sample documentation pdf\",\n \"name\": \"Introduction to PhoneVerification API PDF\",\n \"type\": \"HOWTO\"\n }\n ],\n \"count\": 3,\n \"next\": \"\"\n}" - summary: | - Get a list of documents of an API - description: | - This operation can be used to retrive a list of documents belonging to an API by providing the id of the API. - - `X-WSO2-Tenant` header can be used to retrive documents of an API that belongs to a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. - - **NOTE:** - * This operation does not require an Authorization header by default. But in order to see a restricted API's documents, you need to provide Authorization header. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Document (Collection) - responses: - 200: - description: | - OK. - Document list is returned. - schema: - $ref: '#/definitions/DocumentList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual Document" resource APIs -###################################################### - '/apis/{apiId}/documents/{documentId}': - -#----------------------------------------------------- -# Retrieve a particular document of a certain API -#----------------------------------------------------- - get: - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents/850a4f34-db2c-4d23-9d85-3f95fbfb082c - x-wso2-curl: "curl \"https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents/850a4f34-db2c-4d23-9d85-3f95fbfb082c\"" - x-wso2-curl-tenant: "curl -k -H \"X-WSO2-Tenant:test.com\" https://localhost:9443/api/am/store/v0.12/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents/850a4f34-db2c-4d23-9d85-3f95fbfb082c" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"sourceType\": \"INLINE\",\n \"sourceUrl\": null,\n \"otherTypeName\": null,\n \"documentId\": \"850a4f34-db2c-4d23-9d85-3f95fbfb082c\",\n \"summary\": \"This is a sample documentation for v1.0.0\",\n \"name\": \"PhoneVerification API Documentation\",\n \"type\": \"HOWTO\"\n}" - summary: | - Get a document of an API - description: | - This operation can be used to retrieve a particular document's metadata associated with an API. - - `X-WSO2-Tenant` header can be used to retrive a document of an API that belongs to a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. - - **NOTE:** - * This operation does not require an Authorization header by default. But in order to see a restricted API's document, you need to provide Authorization header. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Document (Individual) - responses: - 200: - description: | - OK. - Document returned. - schema: - $ref: '#/definitions/Document' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - - -################################################################ -# The content resource of "Individual Document" resource APIs -################################################################ - - '/apis/{apiId}/documents/{documentId}/content': - - #------------------------------------------------------------------------------------------------- - # Downloads a FILE type document/get the inline content or source url of a certain document - #------------------------------------------------------------------------------------------------- - get: - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content - x-wso2-curl: "curl \"https://localhost:9443/api/am/store/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content\" > sample.pdf" - x-wso2-curl-tenant: "curl -k -H \"X-WSO2-Tenant:test.com\" \"https://localhost:9443/api/am/store/v0.12/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content\" > sample.pdf" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Disposition: attachment; filename=\"sample.pdf\"\nContent-Type: application/octet-stream\nContent-Length: 7802\n\n%PDF-1.4\n%äüöß\n2 0 obj\n<>\nstream\n..\n>>\nstartxref\n7279\n%%EOF" - - summary: | - Get the content of an API document - description: | - This operation can be used to retrive the content of an API's document. - - The document can be of 3 types. In each cases responses are different. - - 1. **Inline type**: - The content of the document will be retrieved in `text/plain` content type - 2. **FILE type**: - The file will be downloaded with the related content type (eg. `application/pdf`) - 3. **URL type**: - The client will recieve the URL of the document as the Location header with the response with - `303 See Other` - - `X-WSO2-Tenant` header can be used to retrive the content of a document of an API that belongs to a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. - - **NOTE:** - * This operation does not require an Authorization header by default. But in order to see a restricted API's document content, you need to provide Authorization header. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/documentId' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Document (Individual) - responses: - 200: - description: | - OK. - File or inline content returned. - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 303: - description: | - See Other. - Source can be retrived from the URL specified at the Location header. - headers: - Location: - description: | - The Source URL of the document. - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -################################################################ -# The thumbnail resource of "Individual API" resource APIs -################################################################ - - /apis/{apiId}/thumbnail: -#------------------------------------------------------------------------------------------------- -# Downloads a thumbnail image of an API -#------------------------------------------------------------------------------------------------- - get: - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/apis/e93fb282-b456-48fc-8981-003fb89086ae/thumbnail - x-wso2-curl: "curl https://localhost:9443/api/am/store/v0.12/apis/e93fb282-b456-48fc-8981-003fb89086ae/thumbnail > image.jpg" - x-wso2-curl-tenant: "curl -k -H \"X-WSO2-Tenant:test.com\" https://localhost:9443/api/am/store/v0.12/apis/e93fb282-b456-48fc-8981-003fb89086ae/thumbnail > image.jpg" - x-wso2-response: "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\n\r\n[image content]" - summary: Get thumbnail image - description: | - This operation can be used to download a thumbnail image of an API. - - `X-WSO2-Tenant` header can be used to retrive a thumbnail of an API that belongs to a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. - - **NOTE:** - * This operation does not require an Authorization header by default. But in order to see a restricted API's thumbnail, you need to provide Authorization header. - parameters: - - $ref: '#/parameters/apiId' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - API (Individual) - responses: - 200: - description: | - OK. - Thumbnail image returned - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested Document does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Application Collection" resource APIs -###################################################### - /applications: - -#----------------------------------------------------- -# Retrieve a list of all applications of a certain subscriber -#----------------------------------------------------- - get: - x-scope: apim:subscribe - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/applications - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/store/v0.12/applications\"" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"367a2361-8db5-4140-8133-c6c8dc7fa0c4\",\n \"description\": \"\",\n \"status\": \"APPROVED\",\n \"name\": \"app1\"\n },\n {\n \"groupId\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"status\": \"APPROVED\",\n \"name\": \"DefaultApplication\"\n }\n ],\n \"count\": 2,\n \"next\": \"\"\n}" - summary: | - Retrieve/Search applications - description: | - This operation can be used to retrieve list of applications that is belonged to the user associated with the provided access token. - parameters: - - $ref: '#/parameters/groupId' - - name : query - in: query - description: | - **Search condition**. - - You can search for an application by specifying the name as "query" attribute. - - Eg. - "app1" will match an application if the name is exactly "app1". - - Currently this does not support wildcards. Given name must exactly match the application name. - type: string - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Application (Collection) - responses: - 200: - description: | - OK. - Application list returned. - schema: - $ref: '#/definitions/ApplicationList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Create a new application -#----------------------------------------------------- - post: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/store/v0.12/applications\"" - x-wso2-request: "POST https://localhost:9443/api/am/store/v0.12/applications\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\n\n{\n \"throttlingTier\": \"Unlimited\",\n \"description\": \"sample app description\",\n \"name\": \"sampleapp\",\n \"callbackUrl\": \"http://my.server.com/callback\"\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/store/v0.12/applications/c30f3a6e-ffa4-4ae7-afce-224d1f820524\nContent-Type: application/json\n\n{\n \"groupId\": null,\n \"callbackUrl\": \"http://my.server.com/callback\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"description\": \"sample app description\",\n \"status\": \"APPROVED\",\n \"name\": \"sampleapp\",\n \"keys\": []\n}" - summary: | - Create a new application - description: | - This operation can be used to create a new application specifying the details of the application in the payload. - parameters: - - in: body - name: body - description: | - Application object that is to be created. - required: true - schema: - $ref: '#/definitions/Application' - - $ref: '#/parameters/Content-Type' - tags: - - Application (Individual) - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - schema: - $ref: '#/definitions/Application' - headers: - Location: - description: | - Location of the newly created Application. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 409: - description: | - Conflict. - Application already exists. - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual Application" resource APIs -###################################################### - '/applications/{applicationId}': - -#----------------------------------------------------- -# Retrieve the details about a certain application -#----------------------------------------------------- - get: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/store/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015\"" - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": \"\",\n \"callbackUrl\": null,\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Unlimited\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"description\": null,\n \"status\": \"APPROVED\",\n \"name\": \"DefaultApplication\",\n \"keys\": [ {\n \"consumerKey\": \"AVoREWiB16kY_GTIzscl40GYYZQa\",\n \"consumerSecret\": \"KXQxmS8W3xDvvJH4AfR6xrhKIeIa\",\n \"keyState\": \"COMPLETED\",\n \"keyType\": \"PRODUCTION\",\n \"supportedGrantTypes\": null,\n \"token\": {\n \"validityTime\": 3600,\n \"accessToken\": \"3887da6d111f0429c6dff47a46e87209\",\n \"tokenScopes\": [\n \"am_application_scope\",\n \"default\"\n ]\n }\n }]\n}" - summary: | - Get details of an application - description: | - This operation can be used to retrieve details of an individual application specifying the application id in the URI. - parameters: - - $ref: '#/parameters/applicationId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Application (Individual) - responses: - 200: - description: | - OK. - Application returned. - schema: - $ref: '#/definitions/Application' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - 404: - description: | - Not Found. - Requested application does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update a certain application -#----------------------------------------------------- - put: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X PUT -d @data.json \"https://localhost:9443/api/am/store/v0.12/applications/c30f3a6e-ffa4-4ae7-afce-224d1f820524\"" - x-wso2-request: "PUT https://localhost:9443/api/am/store/v0.12/applications/c30f3a6e-ffa4-4ae7-afce-224d1f820524\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\n\n{\n \"callbackUrl\": \"\",\n \"throttlingTier\": \"Bronze\",\n \"description\": \"sample app description updated\",\n \"name\": \"sampleapp\"\n}" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"groupId\": null,\n \"callbackUrl\": \"\",\n \"subscriber\": \"admin\",\n \"throttlingTier\": \"Bronze\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"description\": \"sample app description updated\",\n \"status\": \"APPROVED\",\n \"name\": \"sampleapp\",\n \"keys\": []\n}" - summary: | - Update an application - description: | - This operation can be used to update an application. Upon succesfull you will retrieve the updated application as the response. - parameters: - - $ref: '#/parameters/applicationId' - - in: body - name: body - description: | - Application object that needs to be updated - required: true - schema: - $ref: '#/definitions/Application' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Application (Individual) - responses: - 200: - description: | - OK. - Application updated. - schema: - $ref: '#/definitions/Application' - headers: - Location: - description: | - The URL of the newly created resource. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete a certain application -#----------------------------------------------------- - delete: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE \"https://localhost:9443/api/am/store/v0.12/applications/367a2361-8db5-4140-8133-c6c8dc7fa0c4\"" - x-wso2-request: | - DELETE https://localhost:9443/api/am/store/v0.12/applications/367a2361-8db5-4140-8133-c6c8dc7fa0c4 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK" - summary: | - Remove an application - description: | - This operation can be used to remove an application specifying its id. - parameters: - - $ref: '#/parameters/applicationId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Application (Individual) - responses: - 200: - description: | - OK. - Resource successfully deleted. - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Application Keys of a Given Type" resource APIs -###################################################### - '/applications/{applicationId}/keys/{keyType}': - -#----------------------------------------------------------- -# Retrieve key details of a given type (PRODUCTION/SANDBOX) -#----------------------------------------------------------- - get: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/store/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015/keys/PRODUCTION\"" - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015/keys/PRODUCTION - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n {\n \"consumerKey\": \"QwEtRHd4NJkcFuRUfAT5af8XEEoa\",\n \"consumerSecret\": \"7Fairfeu321ENjOR9w2xgJl3i70a\",\n \"supportedGrantTypes\": [\n \"refresh_token\",\n \"urn:ietf:params:oauth:grant-type:saml2-bearer\",\n \"password\",\n \"client_credentials\",\n \"iwa:ntlm\"\n ],\n \"callbackUrl\": \"http://sample/com/callback\",\n \"keyState\": \"COMPLETED\",\n \"keyType\": \"PRODUCTION\"}\n" - summary: | - Get key details of a given type - description: | - This operation can be used to retrieve key details of an individual application specifying the key type in the URI. - parameters: - - $ref: '#/parameters/applicationId' - - $ref: '#/parameters/keyType' - - $ref: '#/parameters/groupId' - - $ref: '#/parameters/Accept' - tags: - - Application (Individual) - - Application Keys - responses: - 200: - description: | - OK. - Application key details returned. - schema: - $ref: '#/definitions/ApplicationKey' - headers: - Content-Type: - description: | - The content type of the body. - type: string - 404: - description: | - Not Found. - Requested application does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Update grant types and callback url of an application -#----------------------------------------------------- - put: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X PUT -d @data.json \"https://localhost:9443/api/am/store/v0.12/applications/c30f3a6e-ffa4-4ae7-afce-224d1f820524/keys/SANDBOX\"" - x-wso2-request: | - PUT https://localhost:9443/api/am/store/v0.12/applications/896658a0-b4ee-4535-bbfa-806c894a4015/keys/SANDBOX - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - { - "supportedGrantTypes": [ - "refresh_token", - "urn:ietf:params:oauth:grant-type:saml2-bearer", - "password", - "client_credentials", - "iwa:ntlm" - ], - "callbackUrl": "http://sample/com/callback" - } - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n {\n \"consumerKey\": \"QwEtRHd4NJkcFuRUfAT5af8XEEoa\",\n \"consumerSecret\": \"7Fairfeu321ENjOR9w2xgJl3i70a\",\n \"supportedGrantTypes\": [\n \"refresh_token\",\n \"urn:ietf:params:oauth:grant-type:saml2-bearer\",\n \"password\",\n \"client_credentials\",\n \"iwa:ntlm\"\n ],\n \"callbackUrl\": \"http://sample/com/callback\",\n \"keyState\": \"COMPLETED\",\n \"keyType\": \"PRODUCTION\"}\n" - summary: | - Update grant types and callback url of an application - description: | - This operation can be used to update grant types and callback url of an application. (Consumer Key and Consumer Secret are ignored) Upon succesfull you will retrieve the updated key details as the response. - parameters: - - $ref: '#/parameters/applicationId' - - $ref: '#/parameters/keyType' - - in: body - name: body - description: | - Grant types/Callback URL update request object - required: true - schema: - $ref: '#/definitions/ApplicationKey' - tags: - - Application (Individual) - - Application Keys - responses: - 200: - description: | - Ok. - Grant types or/and callback url is/are updated. - schema: - $ref: '#/definitions/ApplicationKey' - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - - -###################################################### -# The "Generate Keys" Processing Function resource API -###################################################### - '/applications/generate-keys': - -#----------------------------------------------------- -# Generate keys for an application -#----------------------------------------------------- - post: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/store/v0.12/applications/generate-keys?applicationId=c30f3a6e-ffa4-4ae7-afce-224d1f820524\"" - x-wso2-request: "POST https://localhost:9443/api/am/store/v0.12/applications/generate-keys?applicationId=c30f3a6e-ffa4-4ae7-afce-224d1f820524\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\n\n{\n \"validityTime\": \"3600\",\n \"keyType\": \"PRODUCTION\",\n \"accessAllowDomains\": [\"ALL\"\n ]\n}" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"consumerSecret\": \"8V7DDKtKGtuG_9GDjaOJ5sijdX0a\",\n \"consumerKey\": \"LOFL8He72MSGVil4SS_bsh9O8MQa\",\n \"keyState\": \"APPROVED\",\n \"keyType\": \"PRODUCTION\",\n \"supportedGrantTypes\": [\n \"urn:ietf:params:oauth:grant-type:saml2-bearer\",\n \"iwa:ntlm\",\n \"refresh_token\",\n \"client_credentials\",\n \"password\"\n ],\n \"token\": {\n \"validityTime\": 3600,\n \"accessToken\": \"fd2cdc4906fbc162e033d57f85a71c21\",\n \"tokenScopes\": [\n \"am_application_scope\",\n \"default\"\n ]\n }\n}" - summary: | - Generate keys for application - description: | - This operation can be used to generate client Id and client secret for an application - parameters: - - $ref: '#/parameters/applicationId-Q' - - in: body - name: body - description: | - Application object the keys of which are to be generated - required: true - schema: - $ref: '#/definitions/ApplicationKeyGenerateRequest' - - $ref: '#/parameters/Content-Type' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Application (Individual) - responses: - 200: - description: | - OK. - Keys are generated. - schema: - $ref: '#/definitions/ApplicationKey' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future).‚ - type: string - 400: - description: | - Bad Request. - Invalid request or validation error - schema: - $ref: '#/definitions/Error' - 404: - description: | - Not Found. - The resource to be updated does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met (Will be supported in future). - schema: - $ref: '#/definitions/Error' - '/applications/scopes/{applicationId}': - get: - x-scope: 'apim:subscribe' - x-wso2-request: |- - GET https://127.0.0.1:9443/api/am/store/v0.12/applications/scopes/896658a0-b4ee-4535-bbfa-806c894a4015 - Authorization: Beareraa0ddec1ac656744234477f20fafcb0d - x-wso2-curl: 'curl -k -H "Authorization: Bearer aa0ddec1ac656744234477f20fafcb0d" "https://127.0.0.1:9443/api/am/store/v0.12/applications/scopes/896658a0-b4ee-4535-bbfa-806c894a4015"' - x-wso2-response: |- - HTTP/1.1 200 OK - Content-Type: application/json - - { - "groupId": "", - "callbackUrl": null, - "subscriber": "admin", - "throttlingTier": "Unlimited", - "applicationId": "896658a0-b4ee-4535-bbfa-806c894a4015", - "description": null, - "status": "APPROVED", - "name": "DefaultApplication", - "keys": [ { - "consumerKey": "AVoREWiB16kY_GTIzscl40GYYZQa", - "consumerSecret": "KXQxmS8W3xDvvJH4AfR6xrhKIeIa", - "keyState": "COMPLETED", - "keyType": "PRODUCTION", - "supportedGrantTypes": null, - "token": { - "validityTime": 3600, - "accessToken": "3887da6d111f0429c6dff47a46e87209", - "tokenScopes": [ - "am_application_scope", - "default" - ] - } - }] - } - summary: | - Get scopes associated with a particular application based on subscribed APIs - description: | - Get scopes associated with a particular application based on subscribed APIs - parameters: - - $ref: '#/parameters/applicationId' - - $ref: '#/parameters/filterByUserRoles' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Application (Individual) - responses: - '200': - description: | - OK. - Scope returned. - schema: - $ref: '#/definitions/ScopeList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional reuquests. - type: string - '304': - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - '401': - description: | - Un authorized. - The user is not authorized to view the application . - schema: - $ref: '#/definitions/Error' - '404': - description: | - Not Found. - Requested application does not exist. - schema: - $ref: '#/definitions/Error' - '406': - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Subscription Collection" resource APIs -###################################################### - /subscriptions: - -#----------------------------------------------------- -# Retrieve all subscriptions of a certain API and application -#----------------------------------------------------- - get: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/store/v0.12/subscriptions?apiId=c43a325c-260b-4302-81cb-768eafaa3aed\"" - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/subscriptions?apiId=c43a325c-260b-4302-81cb-768eafaa3aed - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"tier\": \"Bronze\",\n \"subscriptionId\": \"03b8ef2b-5ae5-41f5-968e-52fa7fbd5d33\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"896658a0-b4ee-4535-bbfa-806c894a4015\",\n \"status\": \"UNBLOCKED\"\n },\n {\n \"tier\": \"Bronze\",\n \"subscriptionId\": \"5ed42650-9f5e-4dd4-94f3-3f09f1b17354\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"846118a5-3b25-4c22-a983-2d0278936f09\",\n \"status\": \"UNBLOCKED\"\n }\n ],\n \"count\": 2,\n \"next\": \"\"\n}" - summary: | - Get all subscriptions - description: | - This operation can be used to retrieve a list of subscriptions of the user associated with the provided access token. This operation is capable of - - 1. Retrieving applications which are subscibed to a specific API. - `GET https://localhost:9443/api/am/store/v0.12/subscriptions?apiId=c43a325c-260b-4302-81cb-768eafaa3aed` - - 2. Retrieving APIs which are subscribed by a specific application. - `GET https://localhost:9443/api/am/store/v0.12/subscriptions?applicationId=c43a325c-260b-4302-81cb-768eafaa3aed` - - **IMPORTANT:** - * It is mandatory to provide either **apiId** or **applicationId**. - parameters: - - $ref: '#/parameters/apiId-Q' - - $ref: '#/parameters/applicationId-Q' - - $ref: '#/parameters/groupId' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/limit' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Subscription (Collection) - responses: - 200: - description: | - OK. - Subscription list returned. - schema: - $ref: '#/definitions/SubscriptionList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 406: - description: | - Not Acceptable. The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Create a new subscription -#----------------------------------------------------- - post: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/store/v0.12/subscriptions\"" - x-wso2-request: "POST https://localhost:9443/api/am/store/v0.12/subscriptions\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\n\n{\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"c43a325c-260b-4302-81cb-768eafaa3aed\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\"\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/store/v0.12/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9\nContent-Type: application/json\n\n{\n \"tier\": \"Gold\",\n \"subscriptionId\": \"5b65808c-cdf2-43e1-a695-de63e3ad0ae9\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"status\": \"UNBLOCKED\"\n}" - summary: | - Add a new subscription - description: | - This operation can be used to add a new subscription providing the id of the API and the application. - parameters: - - in: body - name: body - description: | - Subscription object that should to be added - required: true - schema: - $ref: '#/definitions/Subscription' - - $ref: '#/parameters/Content-Type' - tags: - - Subscription (Individual) - responses: - 201: - description: | - Created. - Successful response with the newly created object as entity in the body. - Location header contains URL of newly created entity. - schema: - $ref: '#/definitions/Subscription' - headers: - Location: - description: | - Location to the newly created subscription. - type: string - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. - -###################################################### -# The "Multiple Subscriptions" resource API -###################################################### - '/subscriptions/multiple': -#----------------------------------------------------- -# Create a batch of Subscriptions -#----------------------------------------------------- - post: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -H \"Content-Type: application/json\" -X POST -d @data.json \"https://localhost:9443/api/am/store/v0.12/subscriptions/multiple\"" - x-wso2-request: "POST https://localhost:9443/api/am/store/v0.12/subscriptions/multiple\nAuthorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\n\n{\n \"tier\": \"Gold\",\n \"apiIdentifier\": \"c43a325c-260b-4302-81cb-768eafaa3aed\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\"\n}" - x-wso2-response: "HTTP/1.1 201 Created\nLocation: https://localhost:9443/api/am/store/v0.12/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9\nContent-Type: application/json\n\n{\n \"tier\": \"Gold\",\n \"subscriptionId\": \"5b65808c-cdf2-43e1-a695-de63e3ad0ae9\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"status\": \"UNBLOCKED\"\n}" - summary: | - Add new subscriptions - description: | - This operation can be used to add a new subscriptions providing the ids of the APIs and the applications. - parameters: - - in: body - name: body - description: | - Subscription objects that should to be added - required: true - schema: - type: array - items: - $ref: '#/definitions/Subscription' - - $ref: '#/parameters/Content-Type' - tags: - - Subscription (Multitple) - responses: - 200: - description: | - OK. - Successful response with the newly created objects as entity in the body. - schema: - type: array - items: - $ref: '#/definitions/Subscription' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests (Will be supported in future). - type: string - 400: - description: | - Bad Request. - Invalid request or validation error. - schema: - $ref: '#/definitions/Error' - 415: - description: | - Unsupported media type. - The entity of the request was in a not supported format. - -###################################################### -# The "Individual Subscription" resource APIs -###################################################### - '/subscriptions/{subscriptionId}': - -#----------------------------------------------------- -# Retrieve a certain subscription -#----------------------------------------------------- - get: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" \"https://localhost:9443/api/am/store/v0.12/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9\"" - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9 - Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8 - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"tier\": \"Gold\",\n \"subscriptionId\": \"5b65808c-cdf2-43e1-a695-de63e3ad0ae9\",\n \"apiIdentifier\": \"admin-PhoneVerification-2.0.0\",\n \"applicationId\": \"c30f3a6e-ffa4-4ae7-afce-224d1f820524\",\n \"status\": \"UNBLOCKED\"\n}" - summary: | - Get details of a subscription - description: | - This operation can be used to get details of a single subscription. - parameters: - - $ref: '#/parameters/subscriptionId' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Subscription (Individual) - responses: - 200: - description: | - OK. - Subscription returned - schema: - $ref: '#/definitions/Subscription' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. Used by caches, or in conditional requests (Will be supported in future). - type: string - '304': - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource. - '404': - description: | - Not Found. - Requested Subscription does not exist. - schema: - $ref: '#/definitions/Error' - -#----------------------------------------------------- -# Delete a certain subscription -#----------------------------------------------------- - delete: - x-scope: apim:subscribe - x-wso2-curl: "curl -k -H \"Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8\" -X DELETE \"https://localhost:9443/api/am/store/v0.12/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9\"" - x-wso2-request: | - DELETE https://localhost:9443/api/am/store/v0.12/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9 - x-wso2-response: "HTTP/1.1 200 OK" - summary: | - Remove a subscription - description: | - This operation can be used to remove a subscription. - parameters: - - $ref: '#/parameters/subscriptionId' - - $ref: '#/parameters/If-Match' - - $ref: '#/parameters/If-Unmodified-Since' - tags: - - Subscription (Individual) - responses: - 200: - description: | - OK. - Resource successfully deleted. - 404: - description: | - Not Found. - Resource to be deleted does not exist. - schema: - $ref: '#/definitions/Error' - 412: - description: | - Precondition Failed. - The request has not been performed because one of the preconditions is not met. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Tier Collection" resource APIs -###################################################### - /tiers/{tierLevel}: - -#----------------------------------------------------- -# Retrieve the list of all available tiers -#----------------------------------------------------- - get: - x-wso2-curl: "curl \"https://localhost:9443/api/am/store/v0.12/tiers/api\"" - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/tiers/api - x-wso2-curl-tenant: "curl -k -H \"X-WSO2-Tenant:test.com\" https://localhost:9443/api/am/store/v0.12/tiers/api" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 20,\n \"description\": \"Allows 20 request(s) per minute.\",\n \"name\": \"Gold\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 5,\n \"description\": \"Allows 5 request(s) per minute.\",\n \"name\": \"Silver\",\n \"attributes\": {}\n },\n {\n \"unitTime\": 0,\n \"tierPlan\": null,\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 0,\n \"description\": \"Allows unlimited requests\",\n \"name\": \"Unlimited\",\n \"attributes\": {}\n }\n ],\n \"count\": 4,\n \"next\": \"\"\n}" - summary: | - Get available tiers - description: | - This operation can be used to retrieve all the tiers available for the provided tier level. Tier level should be specified as a path parameter and should be one of `api` and `application`. - - `X-WSO2-Tenant` header can be used to retrive tiers that belongs to a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. - - **NOTE**: - * API tiers are the ones that is available during subscription of an application to an API. Hence they are also called subscription tiers and are same as the subscription policies in Admin REST API. - parameters: - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Throttling Tier (Collection) - responses: - 200: - description: | - OK. - List of tiers returned. - schema: - type: array - items: - $ref: '#/definitions/TierList' - headers: - Content-Type: - description: The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 406: - description: | - Not Acceptable. - The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Individual Tier" resource APIs -###################################################### - '/tiers/{tierLevel}/{tierName}': - -#----------------------------------------------------- -# Retrieve a certain tier -#----------------------------------------------------- - get: - x-wso2-curl: "curl \"https://localhost:9443/api/am/store/v0.12/tiers/api/Bronze\"" - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/tiers/api/Bronze - x-wso2-curl-tenant: "curl -k -H \"X-WSO2-Tenant:test.com\" https://localhost:9443/api/am/store/v0.12/tiers/api/Bronze" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"unitTime\": 60000,\n \"tierPlan\": \"FREE\",\n \"stopOnQuotaReach\": true,\n \"tierLevel\": \"api\",\n \"requestCount\": 1,\n \"description\": \"Allows 1 request(s) per minute.\",\n \"name\": \"Bronze\",\n \"attributes\": {}\n}" - summary: | - Get details of a tier - description: | - This operation can be used to retrieve details of a single tier by specifying the tier level and tier name. - - `X-WSO2-Tenant` header can be used to retrive tiers that belongs to a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. - parameters: - - $ref: '#/parameters/tierName' - - $ref: '#/parameters/tierLevel' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - - $ref: '#/parameters/If-Modified-Since' - tags: - - Throttling Tier (Individual) - responses: - 200: - description: | - OK. - Tier returned - schema: - $ref: '#/definitions/Tier' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - Last-Modified: - description: | - Date and time the resource has been modifed the last time. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. - Requested Tier does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. - The requested media type is not supported. - schema: - $ref: '#/definitions/Error' - -###################################################### -# The "Tag Collection" resource API -###################################################### - /tags: - -#----------------------------------------------------- -# Retrieve the list of tags qualifying under a search condition -#----------------------------------------------------- - get: - x-wso2-curl: "curl \"https://localhost:9443/api/am/store/v0.12/tags\"" - x-wso2-request: | - GET https://localhost:9443/api/am/store/v0.12/tags - x-wso2-curl-tenant: "curl -k -H \"X-WSO2-Tenant:test.com\" https://localhost:9443/api/am/store/v0.12/tags" - x-wso2-response: "HTTP/1.1 200 OK\nContent-Type: application/json\n\n{\n \"previous\": \"\",\n \"list\": [\n {\n \"weight\": 1,\n \"name\": \"mobile\"\n },\n {\n \"weight\": 1,\n \"name\": \"multimedia\"\n },\n {\n \"weight\": 1,\n \"name\": \"phone\"\n }\n ],\n \"count\": 3,\n \"next\": \"\"\n}" - summary: | - Get all tags - description: | - This operation can be used to retrieve a list of tags that are already added to APIs. - - `X-WSO2-Tenant` header can be used to retrive tags that belongs to a different tenant domain. If not specified super tenant will be used. If Authorization header is present in the request, the user's tenant associated with the access token will be used. - - **NOTE:** - * This operation does not require an Authorization header by default. But in order to see a restricted API's tags, you need to provide Authorization header. - parameters: - - $ref: '#/parameters/limit' - - $ref: '#/parameters/offset' - - $ref: '#/parameters/requestedTenant' - - $ref: '#/parameters/Accept' - - $ref: '#/parameters/If-None-Match' - tags: - - Tag (Collection) - responses: - 200: - description: | - OK. - Tag list is returned. - schema: - $ref: '#/definitions/TagList' - headers: - Content-Type: - description: | - The content type of the body. - type: string - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in future). - type: string - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in future). - 404: - description: | - Not Found. Requested API does not exist. - schema: - $ref: '#/definitions/Error' - 406: - description: | - Not Acceptable. The requested media type is not supported - schema: - $ref: '#/definitions/Error' - -###################################################### -# Parameters - required by some of the APIs above -###################################################### -parameters: - -# Requested Tenant domain -# Specified as a header parameter - requestedTenant: - name: X-WSO2-Tenant - in: header - description: | - For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be - retirieved from. - required: false - type: string - -# API Identifier -# Specified as part of the path expression - apiId: - name: apiId - in: path - description: | - **API ID** consisting of the **UUID** of the API. Using the **UUID** in the API call is recommended. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API ID. - Should be formatted as **provider-name-version**. - required: true - type: string - x-encoded: true - -# API Identifier -# Specified as part of the query string - apiId-Q: - name: apiId - in: query - description: | - **API ID** consisting of the **UUID** of the API. Using the **UUID** in the API call is recommended. - The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. - Should be formatted as **provider-name-version**. - required: true - type: string - x-encoded: true - -# API Identifier -# Specified as part of the path expression - language: - name: language - in: query - description: | - Programming language to generate SDK. - required: true - type: string - - -# Document Identifier -# Specified as part of the path expression - documentId: - name: documentId - in: path - description: | - Document Identifier - required: true - type: string - -# Application Identifier -# Specified as part of the path expression - applicationId: - name: applicationId - in: path - description: | - Application Identifier consisting of the UUID of the Application. - required: true - type: string - -# Filter By user roles -# Specified as part of the query string - filterByUserRoles: - name: filterByUserRoles - in: query - description : | - Filter user by roles. - required : false - type: boolean - -# Application Identifier -# Specified as part of the query string - applicationId-Q: - name: applicationId - in: query - description: | - Application Identifier consisting of the UUID of the Application. - required: true - type: string - -# Group Identifier of the application - groupId: - name: groupId - in: query - description: | - Application Group Id - required: false - type: string - -# Subscription Identifier -# Specified as part of the path expression - subscriptionId: - name: subscriptionId - in: path - description: | - Subscription Id - required: true - type: string - -# Tier Name -# Specified as part of the path expression - tierName: - name: tierName - in: path - description: | - Tier name - required: true - type: string - -# Tier Type -# Specified as part of the path expression - tierLevel: - name: tierLevel - in: path - description: | - List API or Application type tiers. - type: string - enum: - - api - - application - required: true - -# Used for pagination: -# The maximum number of resoures to be returned by a GET - limit: - name: limit - in: query - description: | - Maximum length of resource array to return. - default: 25 - type: integer - -# Used for pagination: -# The order number of an instance in a qualified set of resoures -# at which to start to return the next batch of qualified resources - offset: - name: offset - in: query - description: | - Starting point within the complete list of items qualified. - default: 0 - type: integer - -# Application Key Type -# Specified as part of the path expression - keyType: - name: keyType - in: path - description: | - **Application Key Type** standing for the type of the keys (i.e. Production or Sandbox). - required: true - type: string - enum: - - PRODUCTION - - SANDBOX - -# The HTTP Accept header - Accept: - name: Accept - in: header - description: | - Media types acceptable for the response. Default is application/json. - default: application/json - type: string - -# The HTTP Content-Type header - Content-Type: - name: Content-Type - in: header - description: | - Media type of the entity in the body. Default is application/json. - default: application/json - required: true - type : string - -# The HTTP If-None-Match header -# Used to avoid retrieving data that are already cached - If-None-Match: - name: If-None-Match - in: header - description: | - Validator for conditional requests; based on the ETag of the formerly retrieved - variant of the resource. - type : string - -# The HTTP If-Modified-Since header -# Used to avoid retrieving data that are already cached - If-Modified-Since: - name: If-Modified-Since - in: header - description: | - Validator for conditional requests; based on Last Modified header of the - formerly retrieved variant of the resource (Will be supported in future). - type: string - -# The HTTP If-Match header -# Used to avoid concurrent updates - If-Match: - name: If-Match - in: header - description: | - Validator for conditional requests; based on ETag. - type: string - -# The HTTP If-Unmodified-Since header -# Used to avoid concurrent updates - If-Unmodified-Since: - name: If-Unmodified-Since - in: header - description: | - Validator for conditional requests; based on Last Modified header (Will be supported in future). - type: string - -###################################################### -# The resources used by some of the APIs above within the message body -###################################################### -definitions: - -#----------------------------------------------------- -# The API List resource -#----------------------------------------------------- - APIList: - title: API List - properties: - count: - type: integer - description: | - Number of APIs returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/apis?limit=1&offset=2&query=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/apis?limit=1&offset=0&query=" - list: - type: array - items: - $ref: '#/definitions/APIInfo' - pagination: - properties: - offset: - type: integer - example: 12 - limit: - type: integer - example: 25 - total: - type: integer - example: 1290 -#----------------------------------------------------- -# The API Info resource -#----------------------------------------------------- - APIInfo: - title: API Info object with basic API details. - properties: - id: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorAPI - description: - type: string - example: A calculator API that supports basic operations - context: - type: string - example: CalculatorAPI - version: - type: string - example: 1.0.0 - provider: - description: | - If the provider value is not given, the user invoking the API will be used as the provider. - type: string - example: admin - status: - type: string - example: PUBLISHED - thumbnailUri: - type: string - example: /apis/01234567-0123-0123-0123-012345678901/thumbnail - scopes: - type: array - items: - $ref: '#/definitions/ScopeInfo' -#----------------------------------------------------- -# The API resource -#----------------------------------------------------- - API: - title: API object - required: - - name - - context - - version - - provider - - status - - apiDefinition - properties: - id: - type: string - description: | - UUID of the api registry artifact - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - description: Name of the API - example: CalculatorAPI - description: - type: string - description: A brief description about the API - example: A calculator API that supports basic operations - context: - type: string - description: A string that represents thecontext of the user's request - example: CalculatorAPI - version: - type: string - description: The version of the API - example: 1.0.0 - provider: - description: | - If the provider value is not given user invoking the api will be used as the provider. - type: string - example: admin - apiDefinition: - description: | - Swagger definition of the API which contains details about URI templates and scopes - type: string - example: "{'paths':{'/substract':{'get':{'x-auth-type':'Application & Application User','x-throttling-tier':'Unlimited','parameters':[{'name':'x','required':true,'type':'string','in':'query'},{'name':'y','required':true,'type':'string','in':'query'}],'responses':{'200':{}}}},'/add':{'get':{'x-auth-type':'Application & Application User','x-throttling-tier':'Unlimited','parameters':[{'name':'x','required':true,'type':'string','in':'query'},{'name':'y','required':true,'type':'string','in':'query'}],'responses':{'200':{}}}}},'swagger':'2.0','info':{'title':'CalculatorAPI','version':'1.0.0'}}" - wsdlUri: - description: | - WSDL URL if the API is based on a WSDL endpoint - type: string - example: "http://www.webservicex.com/globalweather.asmx?wsdl" - status: - type: string - description: This describes in which status of the lifecycle the API is. - example: PUBLISHED - isDefaultVersion: - type: boolean - example: false - transport: - type: array - items: - description: | - Supported transports for the API (http and/or https). - type: string - example: ["http","https"] - tags: - type: array - description: Search keywords related to the API - items: - type: string - example: ["substract","add"] - tiers: - type: array - description: The subscription tiers selected for the particular API - items: - type: string - example: ["Unlimited"] - thumbnailUrl: - type: string - example: "" - additionalProperties: - description: | - Custom(user defined) properties of API - type: object - additionalProperties: - type: string - example: {} - endpointURLs: - type: array - items: - properties: - environmentName: - type: string - example: Production and Sandbox - environmentType: - type: string - example: hybrid - environmentURLs: - properties: - http: - type: string - description: HTTP environment URL - example: "http://localhost:8280/phoneverify/1.0.0" - https: - type: string - description: HTTPS environment URL - example: "https://localhost:8243/phoneverify/1.0.0" - businessInformation: - properties: - businessOwner: - type: string - example: businessowner - businessOwnerEmail: - type: string - example: businessowner@wso2.com - technicalOwner: - type: string - example: technicalowner - technicalOwnerEmail: - type: string - example: technicalowner@wso2.com - -#----------------------------------------------------- -# The Application List resource -#----------------------------------------------------- - ApplicationList: - title: Application List - properties: - count: - type: integer - description: | - Number of applications returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/applications?limit=1&offset=2&groupId=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/applications?limit=1&offset=0&groupId=" - list: - type: array - items: - $ref: '#/definitions/ApplicationInfo' - -#----------------------------------------------------- -# The Application resource -#----------------------------------------------------- - Application: - title: Application - required: - - name - - throttlingTier - properties: - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorApp - subscriber: - description: | - If subscriber is not given user invoking the API will be taken as the subscriber. - type: string - example: admin - throttlingTier: - type: string - example: Unlimited - callbackUrl: - type: string - example: "" - description: - type: string - example: Sample calculator application - status: - type: string - example: APPROVED - default: "" - groupId: - type: string - example: "" - keys: - type: array - items: - $ref: '#/definitions/ApplicationKey' - example: [] - -#----------------------------------------------------- -# The Application Info resource -#----------------------------------------------------- - ApplicationInfo: - title: Application info object with basic application details - properties: - applicationId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorApp - subscriber: - type: string - example: admin - throttlingTier: - type: string - example: Unlimited - description: - type: string - example: Sample calculator application - status: - type: string - example: APPROVED - groupId: - type: string - example: "" - -#----------------------------------------------------- -# The Document List resource -#----------------------------------------------------- - DocumentList: - title: Document List - properties: - count: - type: integer - description: | - Number of Documents returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/apis/01234567-0123-0123-0123-012345678901/documents?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Document' - -#----------------------------------------------------- -# The Document resource -#----------------------------------------------------- - Document: - title: Document - required: - - name - - type - - sourceType - properties: - documentId: - type: string - example: 01234567-0123-0123-0123-012345678901 - name: - type: string - example: CalculatorDoc - type: - type: string - enum: - - HOWTO - - SAMPLES - - PUBLIC_FORUM - - SUPPORT_FORUM - - API_MESSAGE_FORMAT - - SWAGGER_DOC - - OTHER - example: HOWTO - summary: - type: string - example: "Summary of Calculator Documentation" - sourceType: - type: string - enum: - - INLINE - - URL - - FILE - example: INLINE - sourceUrl: - type: string - example: "" - otherTypeName: - type: string - example: "" - -#----------------------------------------------------- -# The Tier List resource -#----------------------------------------------------- - TierList: - title: Tier List - properties: - count: - type: integer - description: | - Number of Tiers returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/tiers/api?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/tiers/api?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Tier' - -#----------------------------------------------------- -# The Tier resource -#----------------------------------------------------- - Tier: - title: Tier - required: - - name - - tierPlan - - requestCount - - unitTime - - stopOnQuotaReach - properties: - name: - type: string - example: Platinum - description: - type: string - example: "Allows 50 request(s) per minute." - tierLevel: - type: string - enum: - - api - - application - example: api - attributes: - description: | - Custom attributes added to the tier policy - type: object - additionalProperties: - type: string - example: {} - requestCount: - description: | - Maximum number of requests which can be sent within a provided unit time - type: integer - format: int64 - example: 50 - unitTime: - type: integer - format: int64 - example: 60000 - tierPlan: - description: | - This attribute declares whether this tier is available under commercial or free - type: string - enum: - - FREE - - COMMERCIAL - example: FREE - stopOnQuotaReach: - description: | - If this attribute is set to false, you are capabale of sending requests - even if the request count exceeded within a unit time - type: boolean - example: true - TierPermissions: - $ref: '#/definitions/TierPermissionInfo' -#----------------------------------------------------- -# The Subscription List resource -#----------------------------------------------------- - SubscriptionList: - title: Subscription List - properties: - count: - type: integer - description: | - Number of Subscriptions returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/subscriptions?limit=1&offset=2&apiId=01234567-0123-0123-0123-012345678901&groupId=" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/subscriptions?limit=1&offset=0&apiId=01234567-0123-0123-0123-012345678901&groupId=" - list: - type: array - items: - $ref: '#/definitions/Subscription' - -#----------------------------------------------------- -# The Subscription resource -#----------------------------------------------------- - Subscription: - title: Subscription - required: - - applicationId - - apiIdentifier - - tier - properties: - subscriptionId: - type: string - description: The UUID of the subscription - example: faae5fcc-cbae-40c4-bf43-89931630d313 - applicationId: - type: string - description: The UUID of the application - example: b3ade481-30b0-4b38-9a67-498a40873a6d - apiIdentifier: - type: string - description: The unique identifier of the API. - example: admin-PizzaShackAPI-1.0.0 - tier: - type: string - example: Unlimited - status: - type: string - enum: - - BLOCKED - - PROD_ONLY_BLOCKED - - UNBLOCKED - - ON_HOLD - - REJECTED - example: UNBLOCKED - - -#----------------------------------------------------- -# The Tag resource -#----------------------------------------------------- - Tag: - title: Tag - required: - - name - - weight - properties: - name: - type: string - example: tag1 - weight: - type: integer - example: 5 - -#----------------------------------------------------- -# The Tag List resource -#----------------------------------------------------- - TagList: - title: Tag List - properties: - count: - type: integer - description: | - Number of Tags returned. - example: 1 - next: - type: string - description: | - Link to the next subset of resources qualified. - Empty if no more resources are to be returned. - example: "/tags?limit=1&offset=2" - previous: - type: string - description: | - Link to the previous subset of resources qualified. - Empty if current subset is the first subset returned. - example: "/tags?limit=1&offset=0" - list: - type: array - items: - $ref: '#/definitions/Tag' - -#----------------------------------------------------- -# The Error resource -#----------------------------------------------------- - Error: - title: Error object returned with 4XX HTTP status - required: - - code - - message - properties: - code: - type: integer - format: int64 - message: - type: string - description: Error message. - description: - type: string - description: | - A detail description about the error message. - moreInfo: - type: string - description: | - Preferably an url with more details about the error. - error: - type: array - description: | - If there are more than one error list them out. - For example, list out validation errors by each field. - items: - $ref: '#/definitions/ErrorListItem' - -#----------------------------------------------------- -# The Error List Item resource -#----------------------------------------------------- - ErrorListItem: - title: Description of Individual errors that may have occurred during a request. - required: - - code - - message - properties: - code: - type: string - message: - type: string - description: | - Description about Individual errors occurred - -#----------------------------------------------------- -# The Token resource -#----------------------------------------------------- - Token : - title: Token details for invoking APIs - properties: - accessToken: - type: string - description: Access token - example: 01234567890123456789012345678901 - tokenScopes: - type: array - items: - type: string - description: Valid scopes for the access token - example: ["default"] - validityTime: - type: integer - format: int64 - description: Maximum validity time for the access token - example: 3600 - -#----------------------------------------------------- -# The Application Key resource -#----------------------------------------------------- - ApplicationKey : - title: Application key details - properties: - consumerKey: - type: string - description: The consumer key associated with the application and identifying the client - example: vYDoc9s7IgAFdkSyNDaswBX7ejoa - consumerSecret: - type: string - description: The client secret that is used to authenticate the client with the authentication server - example: TIDlOFkpzB7WjufO3OJUhy1fsvAa - supportedGrantTypes: - type: array - items: - type: string - description: The grant types that are supported by the application - example: ["client_credentials","password"] - callbackUrl: - type: string - description: Callback URL - example: "http://sample.com/callback/url" - keyState: - type: string - description: Describes the state of the key generation. - example: APPROVED - keyType: - description: Describes to which endpoint the key belongs - type: string - enum: - - PRODUCTION - - SANDBOX - example: PRODUCTION - groupId: - type: string - description: Application group id (if any). - example: 02 - token: - $ref: '#/definitions/Token' - -#----------------------------------------------------- -# The Application Key Generation Request schema -#----------------------------------------------------- - ApplicationKeyGenerateRequest : - title: Application key generation request object - required: - - keyType - - validityTime - - accessAllowDomains - properties: - keyType: - type: string - enum: - - PRODUCTION - - SANDBOX - example: PRODUCTION - validityTime: - type: string - example: 3600 - supportedGrantTypes: - type: array - items: - type: string - description: The grant types that are supported by the application - example: ["client_credentials","password"] - callbackUrl: - type: string - description: Callback URL - example: "" - accessAllowDomains: - type: array - items: - type: string - description: Allowed domains for the access token - example: ["ALL"] - scopes: - type: array - items: - type: string - description: Allowed scopes for the access token - example: ["am_application_scope","default"] - -#----------------------------------------------------- -# Scope Info resource -#----------------------------------------------------- - ScopeInfo: - title: API Scope info object with scope details - properties: - key: - type: string - example: admin_scope - name: - type: string - example: admin scope - roles: - type: array - items: - type: string - description: Allowed roles for the scope - example: ["manager","developer"] - -#----------------------------------------------------- -# Tier Permission Info resource -#----------------------------------------------------- - TierPermissionInfo: - title: Tier Permission info object with tier permission details - properties: - type: - type: string - enum: - - allow - - deny - roles: - type: array - items: - type: string - description: roles for this permission - example: ["manager","developer"] - - ApplicationScope : - title: Scope of the APIs - properties: - key: - type: string - description: Key of scope - example: apim:fileread - name: - type: string - description: Name of the scope - example: apim file read - roles : - type: string - description: Roles scope is bounded to - example : admin, role1 - description: - type: string - description: Description of the scope - - ScopeList : - title : Scope list - properties: - list : - type : array - items: - $ref: '#/definitions/ApplicationScope' - - -#----------------------------------------------------- -# END-OF-FILE -#----------------------------------------------------- \ No newline at end of file diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index 4cdf1c9f1f..83db52b885 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -144,9 +144,8 @@ provided - org.apache.cxf + org.apache.cxf.wso2 cxf-bundle - 3.0.0-milestone2 test @@ -234,6 +233,10 @@ org.wso2.orbit.com.fasterxml.jackson.core jackson-core + + com.fasterxml.jackson.core + jackson-databind + @@ -267,6 +270,7 @@ org.wso2.orbit.com.fasterxml.jackson.core jackson-annotations + provided org.hibernate diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index f05dd89d70..df9fbe8578 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -243,7 +243,6 @@ com.google.guava guava - ${guava.version} provided diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index d95fa8e1df..047c073084 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -82,8 +82,8 @@ io.entgra.device.mgt.core.device.mgt.core.internal com.fasterxml.jackson.databind;version="[2.14,3)", - com.google.common.collect;version="[31.0,32)", - com.google.common.reflect;version="[31.0,32)", + com.google.common.collect;version="[32.1,33)";resolution:=optional, + com.google.common.reflect;version="[32.1,33)";resolution:=optional, com.google.gson;version="[2.9,3)", com.google.gson.reflect;version="[2.9,3)", io.entgra.device.mgt.core.apimgt.annotations;version="[5.0,6)", @@ -501,6 +501,7 @@ com.google.guava guava + provided com.squareup.okhttp3 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml deleted file mode 100644 index 43d912832e..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - io.entgra.device.mgt.core - device-mgt - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.analytics.data.publisher - bundle - WSO2 Carbon - Device Analytics - WSO2 Carbon - Device Analytics - https://entgra.io - - - - org.apache.felix - org.apache.felix.scr.ds-annotations - provided - - - org.testng - testng - - - org.wso2.tomcat - tomcat - - - org.wso2.tomcat - tomcat-servlet-api - - - org.wso2.carbon - org.wso2.carbon.core - - - org.ops4j.pax.logging - pax-logging-api - provided - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.wso2.carbon.analytics-common - org.wso2.carbon.databridge.agent - - - org.wso2.carbon.analytics-common - org.wso2.carbon.databridge.commons - - - org.wso2.carbon - org.wso2.carbon.securevault - - - org.apache.sling - org.apache.sling.testing.osgi-mock - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${io.entgra.device.mgt.core.version} - Data Publisher - org.wso2.carbon.device.mgt.analytics.data.publisher.internal - - !org.wso2.carbon.device.mgt.analytics.data.publisher.internal, - org.wso2.carbon.device.mgt.analytics.data.publisher.*;version="${io.entgra.device.mgt.core.version}" - - - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.apache.commons.logging.*, - org.wso2.carbon.utils.multitenancy, - org.wso2.carbon.context;version="${carbon.kernel.version.range}", - org.wso2.carbon.utils;version="${carbon.kernel.version.range}", - org.wso2.carbon.databridge.*;version="${carbon.analytics.common.version.range}", - org.json;version="${commons-json.version}", - javax.xml.*, - javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, - org.w3c.dom, - org.wso2.carbon.base, - org.wso2.carbon.utils.multitenancy - - - - - - 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 - - - src/test/resources/testng.xml - - - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherUtil.java deleted file mode 100644 index 1d65b3092e..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherUtil.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.analytics.data.publisher; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.wso2.carbon.databridge.agent.exception.DataEndpointConfigurationException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; - -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.File; -import java.util.ArrayList; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class DataPublisherUtil { - - private static final Log log = LogFactory.getLog(DataPublisherUtil.class); - - private DataPublisherUtil(){ - } - - public static Document convertToDocument(File file) throws DataPublisherConfigurationException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - try { - factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); - factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - DocumentBuilder docBuilder = factory.newDocumentBuilder(); - return docBuilder.parse(file); - } catch (Exception e) { - throw new DataPublisherConfigurationException("Error occurred while parsing file, while converting " + - "to a org.w3c.dom.Document", e); - } - } - - public static ArrayList getEndpointGroups(String urlSet) { - ArrayList urlGroups = new ArrayList<>(); - Pattern regex = Pattern.compile("\\{.*?\\}"); - Matcher regexMatcher = regex.matcher(urlSet); - - while(regexMatcher.find()) { - urlGroups.add(regexMatcher.group().replace("{", "").replace("}", "")); - } - - if (urlGroups.size() == 0) { - urlGroups.add(urlSet.replace("{", "").replace("}", "")); - } - return urlGroups; - } - - public static String[] getEndpoints(String aURLGroup) throws DataEndpointConfigurationException { - boolean isLBURL = false; - boolean isFailOverURL = false; - if (aURLGroup.contains(",")) { - isLBURL = true; - } - - if (aURLGroup.contains("|")) { - isFailOverURL = true; - } - - if (isLBURL && isFailOverURL) { - String msg = "Invalid data endpoints URL set provided : " + aURLGroup + - ", a URL group can be configured as failover OR load balancing endpoints."; - log.error(msg); - throw new DataEndpointConfigurationException(msg); - } else { - String[] urls; - if (isLBURL) { - urls = aURLGroup.split(","); - } else if (isFailOverURL) { - urls = aURLGroup.split("\\|"); - } else { - urls = new String[]{aURLGroup}; - } - return urls; - } - } - - public static int obtainHashId(String deviceId, int urlGroupsCount) { - byte[] chars = deviceId.getBytes(); - int sum = 0; - for (byte b : chars) { - sum += b; - } - return sum % urlGroupsCount; - } - - @SuppressWarnings("Duplicates") - public static String replaceProperty(String urlWithPlaceholders) { - String regex = "\\$\\{(.*?)\\}"; - Pattern pattern = Pattern.compile(regex); - Matcher matchPattern = pattern.matcher(urlWithPlaceholders); - while (matchPattern.find()) { - String sysPropertyName = matchPattern.group(1); - String sysPropertyValue = System.getProperty(sysPropertyName); - if (sysPropertyValue != null && !sysPropertyName.isEmpty()) { - urlWithPlaceholders = urlWithPlaceholders.replaceAll("\\$\\{(" + sysPropertyName + ")\\}", sysPropertyValue); - } - } - return urlWithPlaceholders; - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java deleted file mode 100644 index 18d5be4287..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.analytics.data.publisher; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.databridge.agent.DataPublisher; -import org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException; -import org.wso2.carbon.databridge.agent.exception.DataEndpointAuthenticationException; -import org.wso2.carbon.databridge.agent.exception.DataEndpointConfigurationException; -import org.wso2.carbon.databridge.agent.exception.DataEndpointException; -import org.wso2.carbon.databridge.commons.exception.TransportException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfiguration; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherServiceImpl; - -import java.util.HashMap; -import java.util.Map; - -/** - * This is used to manage data publisher per tenant. - */ -public class DeviceDataPublisher { - - private static Log log = LogFactory.getLog(EventsPublisherServiceImpl.class); - - private Map dataPublishers; - private static DeviceDataPublisher deviceDataPublisher; - - private DeviceDataPublisher() { - dataPublishers = new HashMap<>(); - } - - public static DeviceDataPublisher getInstance() { - if (deviceDataPublisher == null) { - synchronized (DeviceDataPublisher.class) { - if (deviceDataPublisher == null) { - deviceDataPublisher = new DeviceDataPublisher(); - } - } - } - return deviceDataPublisher; - } - - /** - * This returns the data publisher for the tenant based on the analytics node id. - * - * @param analyticsConfig Analytics configurations - * @param receiverURLSet Data receiver URL set as string - * @return instance of data publisher - * @throws DataPublisherConfigurationException on exception - */ - public DataPublisher getDataPublisher(AnalyticsConfiguration analyticsConfig, String receiverURLSet) - throws DataPublisherConfigurationException { - synchronized (this) { - if (this.dataPublishers.containsKey(receiverURLSet)) { - return this.dataPublishers.get(receiverURLSet); - } else { - String analyticsServerUrlGroups = analyticsConfig.getReceiverServerUrl(); - String analyticsServerUsername = analyticsConfig.getAdminUsername(); - String analyticsServerPassword = analyticsConfig.getAdminPassword(); - - try { - DataPublisher dataPublisher = new DataPublisher(receiverURLSet, analyticsServerUsername, - analyticsServerPassword); - this.dataPublishers.put(receiverURLSet, dataPublisher); - return dataPublisher; - } catch (DataEndpointAgentConfigurationException e) { - String msg = "Configuration Exception on data publisher for " + - "ReceiverGroup = " + analyticsServerUrlGroups + " for username " + analyticsServerUsername; - log.error(msg, e); - throw new DataPublisherConfigurationException(msg, e); - } catch (DataEndpointException e) { - String msg = "Invalid ReceiverGroup = " + analyticsServerUrlGroups; - log.error(msg, e); - throw new DataPublisherConfigurationException(msg, e); - } catch (DataEndpointConfigurationException e) { - String msg = "Invalid Data endpoint configuration."; - log.error(msg, e); - throw new DataPublisherConfigurationException(msg, e); - } catch (DataEndpointAuthenticationException e) { - String msg = "Authentication Failed for user " + analyticsServerUsername; - log.error(msg, e); - throw new DataPublisherConfigurationException(msg, e); - } catch (TransportException e) { - String msg = "Error occurred while retrieving data publisher"; - log.error(msg, e); - throw new DataPublisherConfigurationException(msg, e); - } - } - } - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/AnalyticsConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/AnalyticsConfiguration.java deleted file mode 100644 index 67a8c36333..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/AnalyticsConfiguration.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.analytics.data.publisher.config; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.analytics.data.publisher.DataPublisherUtil; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; -import org.wso2.carbon.utils.CarbonUtils; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.io.File; - -/** - * Configurations related to DAS data publisher and DAL. - */ -@XmlRootElement(name = "AnalyticsConfiguration") -public class AnalyticsConfiguration { - - private String receiverServerUrl; - private String analyticsPublisherUrl; - private String adminUsername; - private String adminPassword; - private boolean enable; - - private static AnalyticsConfiguration config; - - private static final Log log = LogFactory.getLog(AnalyticsConfiguration.class); - private static final String DEVICE_ANALYTICS_CONFIG_PATH = - CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-analytics-config.xml"; - - private AnalyticsConfiguration() { - } - - public static AnalyticsConfiguration getInstance() { - if (config == null) { - throw new InvalidConfigurationStateException("Device analytics configuration is not " + - "initialized properly"); - } - return config; - } - - - @XmlElement(name = "AdminUsername", required = true) - public String getAdminUsername() { - return adminUsername; - } - - public void setAdminUsername(String adminUsername) { - this.adminUsername = adminUsername; - } - - @XmlElement(name = "AdminPassword", required = true) - public String getAdminPassword() { - return adminPassword; - } - - public void setAdminPassword(String adminPassword) { - this.adminPassword = adminPassword; - } - - @XmlElement(name = "ReceiverServerUrl", required = true) - public String getReceiverServerUrl() { - return DataPublisherUtil.replaceProperty(receiverServerUrl); - } - - public void setReceiverServerUrl(String receiverServerUrl) { - this.receiverServerUrl = receiverServerUrl; - } - - @XmlElement(name = "AnalyticsPublisherUrl", required = true) - public String getAnalyticsPublisherUrl() { - return DataPublisherUtil.replaceProperty(analyticsPublisherUrl); - } - - public void setAnalyticsPublisherUrl(String analyticsPublisherUrl) { - this.analyticsPublisherUrl = analyticsPublisherUrl; - } - - @XmlElement(name = "Enabled", required = true) - public boolean isEnable() { - return enable; - } - - public void setEnable(boolean status) { - this.enable = status; - } - - public static void init() throws DataPublisherConfigurationException { - init(AnalyticsConfiguration.DEVICE_ANALYTICS_CONFIG_PATH); - } - - public static void init(String analyticsConfigPath) throws DataPublisherConfigurationException { - File authConfig = new File(analyticsConfigPath); - if (!authConfig.exists()) { - log.warn(DEVICE_ANALYTICS_CONFIG_PATH + " does not exist. Disabling AnalyticsConfiguration."); - config = new AnalyticsConfiguration(); - config.setEnable(false); - return; - } - try { - Document doc = DataPublisherUtil.convertToDocument(authConfig); - - /* Un-marshaling device analytics configuration */ - JAXBContext ctx = JAXBContext.newInstance(AnalyticsConfiguration.class); - Unmarshaller unmarshaller = ctx.createUnmarshaller(); - config = (AnalyticsConfiguration) unmarshaller.unmarshal(doc); - } catch (JAXBException e) { - throw new DataPublisherConfigurationException("Error occurred while un-marshalling device analytics " + - "Config", e); - } - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/InvalidConfigurationStateException.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/InvalidConfigurationStateException.java deleted file mode 100644 index b9686bac42..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/config/InvalidConfigurationStateException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.analytics.data.publisher.config; - -public class InvalidConfigurationStateException extends RuntimeException { - - private static final long serialVersionUID = -3151274311329070297L; - - public InvalidConfigurationStateException(String message) { - super(message); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/exception/DataPublisherConfigurationException.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/exception/DataPublisherConfigurationException.java deleted file mode 100644 index ea93c62a31..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/exception/DataPublisherConfigurationException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.analytics.data.publisher.exception; - -public class DataPublisherConfigurationException extends Exception { - - public DataPublisherConfigurationException(String message) { - super(message); - } - - public DataPublisherConfigurationException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java deleted file mode 100644 index 7472d3800b..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/internal/DataPublisherServiceComponent.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.analytics.data.publisher.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.ComponentContext; -import org.osgi.service.component.annotations.*; -import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfiguration; -import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; -import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherServiceImpl; - -@Component( - name = "org.wso2.carbon.device.mgt.analytics.data.publisher.internal.DataPublisherServiceComponent", - immediate = true) -public class DataPublisherServiceComponent { - - private ServiceRegistration analyticsServiceRef; - private static Log log = LogFactory.getLog(DataPublisherServiceComponent.class); - - protected void activate(ComponentContext componentCtx) { - try { - if (log.isDebugEnabled()) { - log.debug("Initializing device analytics bundle"); - } - AnalyticsConfiguration.init(); - BundleContext bundleCtx = componentCtx.getBundleContext(); - this.analyticsServiceRef = - bundleCtx.registerService(EventsPublisherService.class, new EventsPublisherServiceImpl(), null); - if (log.isDebugEnabled()) { - log.debug("Device management analytics bundle has been successfully initialized"); - } - } catch (Throwable e) { - log.error("Error occurred while initializing device analytics bundle", e); - } - } - - protected void deactivate(ComponentContext componentCtx) { - if (log.isDebugEnabled()) { - log.debug("Deactivating device analytics bundle"); - } - if (analyticsServiceRef != null) { - analyticsServiceRef.unregister(); - } - if (log.isDebugEnabled()) { - log.debug("Device analytics bundle has been successfully deactivated"); - } - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherService.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherService.java deleted file mode 100644 index f75496d0e2..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherService.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.analytics.data.publisher.service; - -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; - -/** - * This service can be used to publish and retrieve data from the Analytics Server. - */ -public interface EventsPublisherService { - - /** - * This is used to publish an event to DAS. - * @param streamName is the name of the stream that the data needs to pushed - * @param version is the version of the stream - * @param metaDataArray - meta data that needs to pushed - * @param correlationDataArray - correlation data that needs to be pushed - * @param payloadDataArray - payload data that needs to be pushed - * @return if success returns true - * @throws DataPublisherConfigurationException on exception - */ - boolean publishEvent(String streamName, String version, Object[] metaDataArray, Object[] correlationDataArray, - Object[] payloadDataArray) throws DataPublisherConfigurationException; - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherServiceImpl.java deleted file mode 100644 index 6b7b81aa36..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/service/EventsPublisherServiceImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.wso2.carbon.device.mgt.analytics.data.publisher.service; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.databridge.agent.DataPublisher; -import org.wso2.carbon.databridge.commons.utils.DataBridgeCommonsUtils; -import org.wso2.carbon.device.mgt.analytics.data.publisher.DataPublisherUtil; -import org.wso2.carbon.device.mgt.analytics.data.publisher.DeviceDataPublisher; -import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfiguration; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -import java.util.ArrayList; - -/** - * This is the implementation of Osgi Service which can be used to publish and retireved - * event/records. - */ -public class EventsPublisherServiceImpl implements EventsPublisherService { - - private static Log log = LogFactory.getLog(EventsPublisherServiceImpl.class); - - /** - * @param streamName is the name of the stream that the data needs to pushed - * @param version is the version of the stream - * @param metaDataArray meta data that needs to pushed - * @param correlationDataArray correlation data that needs to be pushed - * @param payloadDataArray payload data that needs to be pushed - * @return if success returns true - * @throws DataPublisherConfigurationException on exception - */ - @Override - public boolean publishEvent(String streamName, String version, Object[] metaDataArray, - Object[] correlationDataArray, - Object[] payloadDataArray) throws DataPublisherConfigurationException { - AnalyticsConfiguration analyticsConfig = AnalyticsConfiguration.getInstance(); - if (!analyticsConfig.isEnable()) { - log.warn("Analytics data publishing not enabled."); - return false; - } - - if (metaDataArray == null || metaDataArray.length == 0) { - String msg = "meta data[0] must have the device Id field"; - log.error(msg); - throw new DataPublisherConfigurationException(msg); - } - - ArrayList receiverURLGroups = DataPublisherUtil.getEndpointGroups(analyticsConfig.getReceiverServerUrl()); - int hashId = DataPublisherUtil.obtainHashId(metaDataArray[0].toString(), receiverURLGroups.size()); - if (receiverURLGroups.size() <= hashId) { - String msg = "Invalid receiver url group size. Expected to be higher than: " + hashId + " Actual: " + - receiverURLGroups.size(); - log.error(msg); - throw new DataPublisherConfigurationException(msg); - } - - String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { - metaDataArray[0] = tenantDomain + "@" + metaDataArray[0]; - } - - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext() - .setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); - try { - DataPublisher dataPublisher = DeviceDataPublisher.getInstance() - .getDataPublisher(analyticsConfig, receiverURLGroups.get(hashId)); - if (dataPublisher != null) { - String streamId = DataBridgeCommonsUtils.generateStreamId(streamName, version); - return dataPublisher.tryPublish(streamId, System.currentTimeMillis(), metaDataArray, - correlationDataArray, - payloadDataArray); - } else { - return false; - } - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - } -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/BaseAnalyticsDataPublisherTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/BaseAnalyticsDataPublisherTest.java deleted file mode 100644 index 3d42a3020b..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/BaseAnalyticsDataPublisherTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.device.mgt.analytics.data.publisher; - -import org.testng.annotations.BeforeSuite; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.context.PrivilegedCarbonContext; - -import java.io.File; - -public class BaseAnalyticsDataPublisherTest { - - @BeforeSuite - public void init() { - setUpCarbonHome(); - } - - private void setUpCarbonHome() { - 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("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); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java deleted file mode 100644 index 0e04de8a56..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.device.mgt.analytics.data.publisher; - -import junit.framework.Assert; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfiguration; -import org.wso2.carbon.device.mgt.analytics.data.publisher.config.InvalidConfigurationStateException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; - -import java.io.File; -import java.lang.reflect.Field; -import java.net.URL; - -/** - * This test class will validate the Data publisher configuration creation. - */ -public class DataPublisherConfigTest extends BaseAnalyticsDataPublisherTest { - - @Test(description = "Validating the behaviour of getInstance config before calling the init", - expectedExceptions = InvalidConfigurationStateException.class) - public void testGetInstanceWithoutInit() throws NoSuchFieldException, IllegalAccessException { - Field configField = AnalyticsConfiguration.class.getDeclaredField("config"); - configField.setAccessible(true); - configField.set(configField, null); - AnalyticsConfiguration.getInstance(); - } - - @Test(description = "Analytics configuration initialization with invalid config", - expectedExceptions = DataPublisherConfigurationException.class, - dependsOnMethods = "testGetInstanceWithoutInit") - public void testInitWithInvalidConfig() throws DataPublisherConfigurationException { - ClassLoader classLoader = this.getClass().getClassLoader(); - URL invalidConfig = classLoader.getResource("carbon-home/repository/conf/etc/" + - "device-analytics-config-invalid.xml"); - Assert.assertTrue("No configuration - device-analytics-config-invalid.xml found in resource dir", - invalidConfig != null); - File file = new File(invalidConfig.getFile()); - AnalyticsConfiguration.init(file.getAbsolutePath()); - } - - - @Test(description = "Analytics config initialization with invalid xml", - expectedExceptions = DataPublisherConfigurationException.class, - dependsOnMethods = "testInitWithInvalidConfig") - public void testInitWithInvalidXML() throws DataPublisherConfigurationException { - ClassLoader classLoader = this.getClass().getClassLoader(); - URL invalidConfig = classLoader.getResource("carbon-home/repository/conf/etc/" + - "device-analytics-config-invalid-xml.xml"); - Assert.assertTrue("No configuration - device-analytics-config-invalid-xml.xml found in resource dir", - invalidConfig != null); - File file = new File(invalidConfig.getFile()); - AnalyticsConfiguration.init(file.getAbsolutePath()); - } - - - @Test(description = "Validating the init method with all required params", - dependsOnMethods = "testInitWithInvalidXML") - public void testInitWithValidConfig() throws DataPublisherConfigurationException { - AnalyticsConfiguration.init(); - AnalyticsConfiguration analyticsConfiguration = AnalyticsConfiguration.getInstance(); - Assert.assertEquals(analyticsConfiguration.getAdminPassword(), "testuserpwd"); - Assert.assertEquals(analyticsConfiguration.getAdminUsername(), "testuser"); - Assert.assertEquals(analyticsConfiguration.getReceiverServerUrl(), "tcp://localhost:7615"); - Assert.assertTrue(analyticsConfiguration.isEnable()); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherServiceComponentTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherServiceComponentTest.java deleted file mode 100644 index d5ffb75d48..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherServiceComponentTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.device.mgt.analytics.data.publisher; - - -import org.apache.sling.testing.mock.osgi.MockOsgi; -import org.osgi.service.component.ComponentContext; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.analytics.data.publisher.internal.DataPublisherServiceComponent; -import org.wso2.carbon.device.mgt.analytics.data.publisher.util.TestComponentContext; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * This tesclass will be validating the behaviour of {@link DataPublisherServiceComponent} - */ -public class DataPublisherServiceComponentTest extends BaseAnalyticsDataPublisherTest { - private DataPublisherServiceComponent serviceComponent; - - @BeforeClass - public void initTest() { - this.serviceComponent = new DataPublisherServiceComponent(); - } - - @Test (description = "Test bundle activation with exception thrown when service resgistration") - public void activateWithException() throws NoSuchMethodException, IllegalAccessException, - InvocationTargetException { - this.activate(new TestComponentContext()); - } - - @Test(dependsOnMethods = "activateWithException", description = "Test the bundle activation with succesful path") - public void activateWithoutException() throws NoSuchMethodException, InvocationTargetException, - IllegalAccessException { - this.activate(MockOsgi.newComponentContext()); - } - - @Test(dependsOnMethods = "activateWithoutException", description = "Test bundle deactivation") - public void deActivate() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Method method = this.serviceComponent.getClass().getDeclaredMethod("deactivate", ComponentContext.class); - method.setAccessible(true); - method.invoke(this.serviceComponent, MockOsgi.newComponentContext()); - } - - private void activate(ComponentContext componentContext) throws NoSuchMethodException, InvocationTargetException, - IllegalAccessException { - Method method = this.serviceComponent.getClass().getDeclaredMethod("activate", ComponentContext.class); - method.setAccessible(true); - method.invoke(this.serviceComponent, componentContext); - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/EventPublisherServiceTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/EventPublisherServiceTest.java deleted file mode 100644 index a7e5e8083d..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/EventPublisherServiceTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.device.mgt.analytics.data.publisher; - -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.databridge.agent.AgentHolder; -import org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfiguration; -import org.wso2.carbon.device.mgt.analytics.data.publisher.config.InvalidConfigurationStateException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService; -import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherServiceImpl; - -import java.lang.reflect.Field; - -/** - * This test class will test the methods that are exposed from {@link EventsPublisherService} - */ -public class EventPublisherServiceTest extends BaseAnalyticsDataPublisherTest { - - private static final String STREAM_NAME = "org.wso2.test.stream"; - private static final String TENANT_DOMAIN = "test.com"; - - private EventsPublisherService eventsPublisherService; - - @BeforeClass - public void initTest() { - this.eventsPublisherService = new EventsPublisherServiceImpl(); - } - - @Test(description = "Publish the event before initializing", - expectedExceptions = InvalidConfigurationStateException.class) - public void publishBeforeInit() throws DataPublisherConfigurationException, NoSuchFieldException, - IllegalAccessException, InstantiationException { - Field configField = AnalyticsConfiguration.class.getDeclaredField("config"); - configField.setAccessible(true); - configField.set(configField, null); - this.eventsPublisherService.publishEvent(STREAM_NAME, "1.0.0", getEventProps(), getEventProps(), - getEventProps()); - } - - @Test(description = "Publish with analytics config disabled", dependsOnMethods = "publishBeforeInit") - public void publishWhenAnalyticsConfigDisabled() throws DataPublisherConfigurationException { - AnalyticsConfiguration.init(); - AnalyticsConfiguration.getInstance().setEnable(false); - boolean published = this.eventsPublisherService.publishEvent(STREAM_NAME, "1.0.0", getEventProps(), - getEventProps(), getEventProps()); - Assert.assertFalse(published); - } - - @Test(description = "Publish the event after initializing", dependsOnMethods = "publishWhenAnalyticsConfigDisabled") - public void publishAfterInit() throws DataPublisherConfigurationException { - AnalyticsConfiguration.getInstance().setEnable(true); - boolean published = this.eventsPublisherService.publishEvent(STREAM_NAME, "1.0.0", getEventProps(), - getEventProps(), getEventProps()); - Assert.assertTrue(published); - } - - @Test(description = "Publish as tenant", dependsOnMethods = "publishAfterInit") - public void publishAsTenant() throws DataPublisherConfigurationException { - publishAsTenant(getEventProps()); - } - - @Test(description = "Publish the with no meta data as tenant", dependsOnMethods = "publishAsTenant", - expectedExceptions = DataPublisherConfigurationException.class) - public void publishAsTenantWithNoMetaData() throws DataPublisherConfigurationException { - publishAsTenant(null); - } - - @Test(description = "Publish the with empty meta data as tenant", dependsOnMethods = "publishAsTenant", - expectedExceptions = DataPublisherConfigurationException.class) - public void publishAsTenantWithEmptyMetaData() throws DataPublisherConfigurationException { - publishAsTenant(new Object[0]); - } - - @Test(description = "Publishing with invalid data publisher config", - dependsOnMethods = {"publishAsTenantWithEmptyMetaData", "publishAsTenantWithNoMetaData"}, - expectedExceptions = DataPublisherConfigurationException.class) - public void publishWithDataEndpointConfigException() throws DataPublisherConfigurationException, - NoSuchFieldException, IllegalAccessException { - AnalyticsConfiguration analyticsConfiguration = AnalyticsConfiguration.getInstance(); - analyticsConfiguration.setReceiverServerUrl(""); - Field dataPublisherField = DeviceDataPublisher.class.getDeclaredField("deviceDataPublisher"); - dataPublisherField.setAccessible(true); - dataPublisherField.set(dataPublisherField, null); - publishAsTenant(getEventProps()); - } - - @Test(description = "Publishing with invalid data publisher config", - dependsOnMethods = "publishWithDataEndpointConfigException", - expectedExceptions = DataPublisherConfigurationException.class) - public void publishWithDataAgentConfigException() throws DataPublisherConfigurationException, - NoSuchFieldException, IllegalAccessException, DataEndpointAgentConfigurationException { - AnalyticsConfiguration.init(); - Field defaultAgentName = AgentHolder.getInstance().getClass().getDeclaredField("defaultDataEndpointAgentName"); - defaultAgentName.setAccessible(true); - defaultAgentName.set(AgentHolder.getInstance(), "dummyAgent"); - publishAsTenant(getEventProps()); - } - - @Test(description = "Publishing with invalid data publisher config", - dependsOnMethods = "publishWithDataAgentConfigException") - public void publishWithDataEndpointException() throws DataPublisherConfigurationException, - NoSuchFieldException, IllegalAccessException, DataEndpointAgentConfigurationException { - AnalyticsConfiguration.init(); - - } - - private void publishAsTenant(Object[] metaData) throws DataPublisherConfigurationException { - PrivilegedCarbonContext.startTenantFlow(); - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(TENANT_DOMAIN, true); - try { - boolean published = this.eventsPublisherService.publishEvent(STREAM_NAME, "1.0.0", metaData, - getEventProps(), getEventProps()); - Assert.assertTrue(published); - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - } - - private Object[] getEventProps() { - return new Object[]{"123"}; - } - - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/util/TestComponentContext.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/util/TestComponentContext.java deleted file mode 100644 index adcb3cba2f..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/util/TestComponentContext.java +++ /dev/null @@ -1,81 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -*/ -package org.wso2.carbon.device.mgt.analytics.data.publisher.util; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.service.component.ComponentContext; -import org.osgi.service.component.ComponentInstance; - -import java.util.Dictionary; - -/** - * Mock implementation for component context. - */ -public class TestComponentContext implements ComponentContext { - @Override - public Dictionary getProperties() { - return null; - } - - @Override - public Object locateService(String s) { - return null; - } - - @Override - public Object locateService(String s, ServiceReference serviceReference) { - return null; - } - - @Override - public Object[] locateServices(String s) { - return new Object[0]; - } - - @Override - public BundleContext getBundleContext() { - return null; - } - - @Override - public Bundle getUsingBundle() { - return null; - } - - @Override - public ComponentInstance getComponentInstance() { - return null; - } - - @Override - public void enableComponent(String s) { - - } - - @Override - public void disableComponent(String s) { - - } - - @Override - public ServiceReference getServiceReference() { - return null; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/carbon.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/carbon.xml deleted file mode 100644 index a5518cb720..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/carbon.xml +++ /dev/null @@ -1,658 +0,0 @@ - - - - - - - - - ${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/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/data-bridge/data-agent-config-invalid.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/data-bridge/data-agent-config-invalid.xml deleted file mode 100644 index a399556257..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/data-bridge/data-agent-config-invalid.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - Thrift - org.wso2.carbon.databridge.agent.endpoint.thrift.ThriftDataEndpointNoClass - src/test/resources/client-truststore.jks - wso2carbon - 32768 - 200 - 1 - 30000 - 1 - 20 - 30 - 250 - 250 - 5500 - 5000 - 250 - 250 - 5500 - 5000 - - - - - - Binary - org.wso2.carbon.databridge.agent.endpoint.binary.BinaryDataEndpoint - src/test/resources/client-truststore.jks - wso2carbon - 32768 - 200 - 1 - 1 - 30000 - 20 - 30 - 250 - 250 - 5500 - 5000 - 250 - 250 - 5500 - 5000 - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/data-bridge/data-agent-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/data-bridge/data-agent-config.xml deleted file mode 100644 index 995b44705b..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/data-bridge/data-agent-config.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - Thrift - org.wso2.carbon.databridge.agent.endpoint.thrift.ThriftDataEndpoint - src/test/resources/client-truststore.jks - wso2carbon - 32768 - 200 - 1 - 30000 - 1 - 20 - 30 - 250 - 250 - 5500 - 5000 - 250 - 250 - 5500 - 5000 - - - - - - Binary - org.wso2.carbon.databridge.agent.endpoint.binary.BinaryDataEndpoint - src/test/resources/client-truststore.jks - wso2carbon - 32768 - 200 - 1 - 1 - 30000 - 20 - 30 - 250 - 250 - 5500 - 5000 - 250 - 250 - 5500 - 5000 - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config-invalid-xml.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config-invalid-xml.xml deleted file mode 100644 index c9298fdb34..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config-invalid-xml.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - tcp://localhost:7615 - testuser - testuserpwd diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config-invalid.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config-invalid.xml deleted file mode 100644 index 4a63c9cf5c..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config-invalid.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - tcp://localhost:7615 - testuser - testuserpwd - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config.xml deleted file mode 100644 index a4caa4fa31..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/etc/device-analytics-config.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - true - tcp://localhost:7615 - testuser - testuserpwd - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/registry.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/registry.xml deleted file mode 100644 index 331c448c87..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/carbon-home/repository/conf/registry.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - wso2registry - false - true - / - - - jdbc:h2:./target/databasetest/CARBON_TEST - - org.h2.Driver - 80 - 60000 - 5 - - - false - - - - true - true - true - true - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/client-truststore.jks b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/client-truststore.jks deleted file mode 100644 index 3b9fdfb9e84c41196f803dca9d96daa06fe60d1a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 102330 zcmdqJ1z1&EyEaTWNF!Z>NUlYPC>_#`bS=6&RJsJDyE~;sKvGf^1*D`Tr9?nNY53;? zbfbH}?>^^z`@Glp{azQc#+s8k#+>uH?95%-C>>|;a z#A)QB!7=Gq5FZE=36(KODrgTA78Vf^1_S}4gHVy+)ew;I;M7#W1Ry-<01XdA446?A zn2}1_))-6-B7%O6j)(2$=EnMCF|5XRHsBi|8t5T-Jkp=Bu+DJRXImXA>uAeeodsgT_+F>j9(vT~G@brFKn5)f)tsEIlrZaTMi422*CsAD8 z?rOnQ+5L+)Xg$&oz)2j|G^@b_>{>Yucz!tRd_?KV{Epd6hk4^8L|~Wlz=t&DcVQ)h zzB73AR84%+AnJTXhE-V;Q=tB=xjJ#Zr0{E9SJB;g!hy5wgf$fX>uw5g@USqjxyB$v z5Ek%K$*;k}o*^Irf)oV01|8!;$A}a3f0wkWMIxRD9Hc^(vN+jwr_N*MTm zxQWmr)0f!NVa8~VGvl+2!C~5phly{y<4tLdO>r1ON@rsonO|oJTQ!(VpN;L1{&c?M zpd(qSjtLp1k9A40y6_N9oGs_;_Bqti0Z`eQ*f}~Gp2J&C>IkCz6W)kZAV0)00OBt% z;VoNo@MhB3ZkBRSeoPxaDE+E*V*v2>4ZMPHNf9t9h!}V=2q<{Cl8z8VXNV(}oT06; zIm8M02*y5t>j=nr$SQ``rgn}dU=q-E=;>&9IHC%23StTXl&NGbY%H81CSWGeE$A_L zJetd6$|}NCP{yz@wJ-2;BGeN*X2?7ov2sl`n=oQtNK{WNMGRzwvyZXhEo;afXxlYB%T(+Tk6YgV-fb&vAUK<+NvkS$>|b6%J7! zzMNnlrdc1(RQm1WKRRgXEMQacPWFC&Y$od1i~%zmx@N^Zv>us6hF|(n|z zs;nwX$g~tnL!Nx`w!Z{Vz}m`NUnx;Dc}K=non~25hQ~TIUNxmj;~TR|{vD_i@-}yp z595g@9&l&~-;PjPN3YeXU^XV1(dfC`w5r>gS|Of1pR0AFrlD9}u-~raOj@($Yth+m z{nJ&RqlWrjbpC@CQ4xyJv4CE@t?|aWP=oq#2K6$0@-(z%hqZpJkAlSs*;387_bQ%a z(#XEV@%^GM@O>y}Uc0UufkrvrC)Q%+i7aF*8lJ`88SZnK8Nn?JWw^!xDKqtZz(z3;c+DFPC@!hekwkKhCk3$|_tJbAjooAhOzoqhN>{zUpSe_r7~ z0I2X#;X>OQkqD?OS8BAbmJ`N@iIq+3U3{t9pGEfs?%<>{2lE?M(rrAJGWDFw(MLEj ztE>$ftSOFF&BS8XhFm!*HH5epTH$ja?&OiIu)*(^8Mqg)Jdbi-?jyzlVHiauHzhkTUD=q*!s!_EjB!V;AJg& z3%`6^&Iem-^!CRO4ykrJKP|q)Eb5Jpsd^CjzyS^Tl0wr(iHZGMwq#)3oU@JdcHO)Q9D~F7i(t=TQe$SV=x1V9(ouZkMdXcR{_=z7_ClJViv9zPJliD zQ=gj!fXcXjc_GD%yQG4i3g{wH;q#0AFi=rp35hSC1IxvO5W09cP{R|dQuw$*fEM|w zQrN-30Q^&>{QvESeKW7VQ>g9g8v(r6P&i*-m_crC%dija+8GnR!bXw28`21BqXU~{ zr16B3o7bhd_?35=ERiAw*gmT-R0Kt25bb5uKwRMDHhWQXsFlW22h0W_7OLpIqaeqjBqk{=9V84lG{4vdktYe2S(ZN((^t?i5rt%g5IdOTa`?YB?Y|SUxWYq%(Qj!xyPt#^e46=LE8q5U1eGD1=hrqz zF@`UPCBzeMa(#Ux&l1D*_1R4YuKc*vO>-y%MO5X{TM2tYaFkBrlz3l6*oVqAKwzpdI2W7!Yyo4P5_3)k|*5NWP~;rmS*0YUl@9L7^3 zGNDS=K>}x_9v8#T=jzfuoq5mSR#$4UHQ)^}b&?$`jF$EWOEF$>xs#iPlarH$nXSDw zU=iE8*q8w#2Z$NDO6R+*pJImC1z7cM0G}6Mh#87}HH;YsyspA;_XU#vAzgs8E-Lkd z!U1Pp1v-xkFb|cmB$yUN4HYhUJd!`YR=k`aYQVElNwQx$>nc&R!tj}Oeg4=P`+Y&)NghuCNk=39ACax;YjsZTr$YWJ!q7Q zkAAm2_k?yiKkYdUHE|tJEX_;BG(WH55d<-v-kSEzn3fx3US>4&7W#{b?!&?34)z>$ zDmB3Zx1t!hQ`E#j=6U{!-k20=u4e@428l2cj|1Vq__Taxw#8P8dHZN2mt$;HdRmjQ z;ydA*j8_zU;){lK&8>Y6X#|QKT_pRD4wDBT!%|4Y`vr65`g$LHZ%oTNMD3$Bs$RvU zoOfi1%q%mfdT1w56bMH3Mt`*eSzU0)LNx=0arzzU&c03ewK3X2p+I1kPyKRQte}5l z;l7DVnO)O*xU(5WA&VGB@!2!lv*W|!5va+U6k9WCk3@gq7CStigq)#epscbp8xo}# z&U`>(ck+&n_XjioM|kFA4h&jjeIHk_@l#H1XoGE^XxZN$i9m%ZENQ9)^VswR;8SQf ziyKo}$vB5MPx526^=lDE<|l2thF0U@3ZT2Wl{GHjzI89g@r@w~lb-Cnzq8vRmy~Cq zTttdW=ZyQC#AqodaVFS3GLoG2>kVkl{)cu=5gM@q!@~uA6kAzUeWfQ%3@HkvA37W- z^Ez8~Wxsv&O0d{4_gPv_YT&LrwOwawrrL)PPpF|jqMJH3G;%z6bRBNfxMtv}Vo|_2 z+${0}*1lyR-{N0^4f_{n^B-Xc#frDc!32_ayj?Yr_tWtut21eDe+fJMwWb#7{20+gB zZ&0RcKp8^FgjSGvH`wyLIxckI2?v5=XChuN%{K>ZM=v3+5!$dX9!~oSn$)-8JLjUQ z4l&1HC*u01WOX+(C&7@<-AZP$AZuS`MhQFCXxWEt{{3vz6K)ANjxY5`Pg0me<-j=C z=ra%+>kuN)w_hA<&W}X_79I=&;=LFf@|ZJ#H5|O2p9J#;SCwOdU|oQL}U)ELQo=V z*st%nWOjPPC?LkCy7 zbS@FGDl&X0-+o3|t`zVHOQcP}jE|hg!riU_mx<7BP~%!;FAYjodC3;MHNT7;YCe`@ zx4IRzh&(MFzInMT+5-$^dy|6{w(p31^xYVd#NMKMw!7K{Y?Fq%OJ;0$QQ{5^YLdVc z&RYSo4s!ZO2Ac1WI@@eQa~i2A(;cFF*;DZZ?>vlA<|>Pc%Ne@f{@~T;3RgtJk7hU9 zACV!`Q11w#k#Zu7;k5@?KA9obYV}?tpC{pcuTvozW99Q4l>a(ntQ71^In!>+GZb4K z7~}yNJg0oTpK{`4VGY={KMB9R=-VHJ50E`#GeG$HmxQlCI?Sfp$R_ifSb-$}ON9T2 zS^Wp$tDMjNmvqn0d2UVopnK@>pPT6K$i8zc*n7wwyvO@`zav?+>D68n&$7HjgG^+; z6S5yB|8a^!9v z7CUJzE0CC0a?jrgVQcYa^Sv+sTRUM;gI9=K%V z9*e-5=4ZoQ+zB?J4Dv^3+~q=Zf34OpTq(H<%1mxCEJ6x+!QiRSJ5E~6Tj}rZ)Yc&& z#prj9I<@|75m!e5ssFP(EqU=4u>7Gg?g-M<$0CxGH zM!`dRyG{RL5aKK^NpE;WMrD1RR*M@RlG_IVR2Z})K^hoU0eL=B^@&j1-Gw~S)8>9LW2Dz~M{p>1 zvb2+Xk6^PBmowwY)*}m2#zui=y809?K}W+V)8Gw^QMq9pXLQR`bok?3HI2~Id%fk_ zM2J1x5wu_x-a!`2yM8YsP%QWKgq>|Wa2_F--7<*2%lk$H8?zb2_9}l#IBTLDF*qeF z4`MBgiV@mSKlI{d>|@Yj#A1pS0j#`P$%K*mod6Wm!A|ang?F%zLuQA47Gau8cI1(A zJuMH692Za()>5%xX}2;PA52YI<0R5mZ`T;(4>8>8 zU*8*}F;?4ivL}W(xLBAPx;sIPfvgOR7UJY&YzPKye7UHYcDF`dXMo3Y;VuNxL-T z_lG;pCBD{hbp^sxbytYzQ!9xJuMui;v)j!p8kroND5aI$7~f6zXADN89>V42w2pwW z)yf(d*&v~gKTwuc)9Sj$s~~Y`v(L&kO8#JN{%fU+PfsykSxd+!zip{LBd-x$C9czdk%K7&HnZCHG`@OF`Tn7e#+V?)Ml zjVv_zQRy9e?VsC4%6iQvzg7uE)l1RI_im9ZmX5Hn_xpYL#{JP^u0k{-J#agJ$;G{F z_9Z?)&*UmzS`8&*6%)UN#6hF6wt`fLs1AXiZamQuy?{dMV zdA^JB@4kJZRSxbXI#b zVU`Jwj93%J_vJ(5Y11;-Jcryb+;QffZh2M9SZuzY^UocFHgl}PzFwOgx_`I9u}SPk z+Je)wy$TIB5&HCE=LQ(%ZJBo}4z*Z9j#ffNawk?rJ^b-%nBR;V$(m?K>!QQOT+vo zi05f!(7M9CIZb|LNA2eYxsdAxjYy)6`hF@*vSIGUh|xe!)~*?%`z>Pfcy}00MtLe zM7&rFMwlYZjT)RGZaO-%*P*{XXpnFDuaN%{_5`X(RDYlw84n9cBs){d8d^c9M1eFg zm;yw0K@0?{<`6116>()%Wi=I5DtU;ro1LT8j|2fa-t|jqfR>v;Z{wV)&g)IM&qW7_ zZn3DT%CkT(ApyNb7SZ#2JWn|T_xd9PZD?ykB@VskOGU^7;sf)r^KwBI;dy8k7;|JQEl@A#{lFEDTWVX3fykpxfqyEX%tCO*i)Jrc>B7jLEBS|*LiaS^}B6Itw& zo`1|n@n8^){7SyY-z1&&)<}*?XJB)n5|>Awym^!tnP*;15z%%M!FKH1*Lm#mjTj1` z=AD6(B0KQWH%UnEzMKYw^C0IL zsCMJK5ePq=dF_(FUVwaSuToX_pEDGH#FRq)%pP{8)7!(y)F?_lm=-KYuzd*9yr3#2 zkOD|9OD0P?Nb(9*{UV%fe;*b_Y5&rb-yLGGN} zs%#8(3rM^ll-~OUI##ixyV3n-eIBgCgtf6@sAh+7r=M@Si&Q%9(;Ag*%~FOUtK)dY zx02jv_a@ZI3=(~&{BoY&YkmyW6QS00f1pAT|MboWwxNN^wy)$v%;~3!wOx90LPl?E zP&^MC2X2}7$5-!h!j+P$2Xdnao_^2F@Qiu~E9&Qm%sjXy$E8S5D zKC}T$-i2+hoH3IV*rkI~;J&1yP_H~Q|2l>>D!~#GH_eP0|IBb z-EQ5TeK=ut&l{!@dF`;h=@>-oW?-h}Vn>-CCt8F;C}tYlc9DM&7N zIpn^Sf}czeWJ`m5@jffsUF)&;-xg78tW{yqW(nkiU2N(!6SO|s48mmXrb@MR@Z>dc z&prqaOe7)5nP$z=Zmzg~5T*Fe{{H?=Gs)gpS;+hk-!to46Z4xse|QpY=U3H&5<7`6 zxs}87N<8ECE4K=hqS%@57XE$)+tMPO>sm0Xfn7UChq#_& zj)AE;Jnkpv5aIz#A{xM*#|7pP#H|$nT#QipE8s5kq-c1U;un`@zVLE^KF@-onY>gp5(29;n$Y6Yn3hMMy{d#S{ z^n_j;9`DBG_m{=0|GI(=TEWWB!wzES;ADq7CYM7l=n&-l|K2VA9h20?*NTc9cH1!8 zNzKH`@@XJ$ba>zhn{%&!IZc6$%;se{-outKWtF2KsUnf@e*ZE)r1JF{IE({+vd-V@ z4po5OdbK)3;r{FkAqSqWUP-J(M)Q|6@kRublH=b7n9lrUUO&AvEjtbB233B5r(zs9FkXqqK%^?xCw}AQC_h{^ zIgoIqszuC#I3V2k`?X$r*l0!TU48udSm&2`86bYeg&Kn{ zvad8^5e|}NJtVJJQ&V6J@XqWX>Ep;rlRhI*_Ij;4(V8A#VU;qLvAXq1G-4h{jK8&_ z*)|+|bd)&Cn5Y=?$@X3;e-h?f{25 z101IFXK#q{6oPj0+Y<))CjQE2|1odqhfRV<_^atDb$N4F+#X&a1PG^jodBLbggsu9F_-o4dtt#Ex zLYt#m2O_JSkRzCxQxdQnMhdKF75f4cEHbZcN4_3ylX$9^V%uv_XMT0Pb@-^x(-9BcTmzTSW!7rZ(&MY3x6xkS!tove1P=M{HdvI z)15NIX0#Bjo*BW72MDt1XnI!BqZ_Z*86ryMf(`t+m>Nuu$($UGx~3F$I}9pWG{D05LF010srUlvamR}ja4(ZBg2 zWaqvN7TMpG?q zgd%^|(}Q0fLa4h8`w2IGQJnKxm_>7cO<<&pQpQ7mUVeNj-0q`70g?zzKOrEyhZ2g%$NrF=Hbuh1th1Z5*W(;pmXEHZKyBF9 z(lq65##a^6dXHY2FZ%iRSl&Fi8NxWCsTfcBRe(&R@gY8+5mUqoEO^eQHiond;&dAUjS~mnSHon;Db9=(y{F#KM6Vt3 zqKM&_x=;4i2+Z=*li`%4Q0H0g+r(w@Va>z$ZZ@JhFM}bRXq28G*KTuUccsha*$Kz< zdcUR!SbLu#9TOZEjKLpx&ondreym)gAyUx2T&OqkyLa%X@c$oS1i__SQmLPj-%yL) zqo1~&9`ql`ynppwz?%abui(Hiix#-AZ6~|I4XDC%iTg(6QR1P5{$d>*OuSzyi`HL%DfMxaOML~0Y$nWhM3-nL7+?-fQ< zp`pdrp1>Sq?*Y?}X%x@DmM6{&c?uf)DNnGAfGo`cKf#ys#K@aRmVkyZEmF;pkG{g0 z1b5{g;Qotmm-C0{{Kw?!zcb@~AhP{ao-UvQ4~q;h0)tTB?J*Q-O^21q%12BFpI4r; z$cKzd_{O;EMbQ3ZjW&%wkwd5KJ&4E|MH@`DtrOPSE9%ATc_rfxcZ-H!^o5iEcST0E z((9>s{k)L(5t{8$3&-o*xd9_rA2+-d3`iV~8fGdcI}5L%AHH&_lR7c#5MP4@{>#Sg zA=@`a)~-!C(~WRcH;V#qa;2(w=Wa_5*4dK6!4Q?06%a&EAI5$0Lf_8}I2Q>NXuYe8 z&4vHQEGx$RQwrd*0lNnSkb>O{DFAkaQT=Z2+__@yD9ZlWRD_0yt7dEA330ZgQn6>H z@}#n3wPXER+X@tvpHB&-C85LtV!zlA$jQyY2lb_Rt_(r{r`P{G)1j}bjde)j!8^LX z>vt47!|i-5oqDvD_EQI^8ew#*vW{KgH+;W_Y|tvNE)j49MgO|XKnf@Z3k6P%{XABXmh8E6=eRb^Y&PoZA7wGlsxAYcS@vhh+>^h zf(Yu)hj@QXVVO!xtNr6^kBl5rzH~iAN6xFkJL`+?n!artJbcK+x5K*87(E9NDv^ue_=WRME~a)$dzp= z&}wa{POgvW+g!$P=-;Rmi?OcZyOR@O`?Q|gZE)DlFL;Sc*mq-oAE(avJrPd}vFi;o z1QOXb!4fk&mf?4&5U_n0X#pHsgMpWgW_ybCsWCgc)dK&^vQmM{l_6B6aBTl>&e<-e zS&~`<{F~P7ZsASUj!FIR-rjxDb3+7wRO5JwUbL8e(I=`8UX|g_-rb>nxphl4{#d+J z0eo6KLLj5MH(!55H0fb$#p#YI5>*Ja{BA@3h$;&}g} zOdRjmGI6}$%EWn~*-{WU7dsdD0!ln!08Zz_e^n;_e>&~oAuM4@+{MN*gUP8@JPf_; zo+r|KZDRJL*xkZ_Yy;6eig&w05%FlBJVlE}{;_Zs`WSarzqRePxAFS%o8h_MlS6u8zn z?+#qOa~Na`Y9DG6xVfT*QkV6#u=EW#4jvTf>pm~BVU|t2r+JFp^`L}ld^$(1=i7I7 zvLzH2mHTT`XPZt>)QPE2t%j0KWjLzBKfk<{O7mf5ak%j9Zh^#|=DR0HoDN;+0wkZ? z7rs7Ed%8w@!Y(a^gj3izQYse_nvXvdK0T`O*?|ncNN_f&;`If>fWo{hp8RvR8`R;7 zTjF-=waTs-IWC*>lmu6q6_Ap1yb*m`vMf`(w~9}X2T79e;#A6me9pF!7)t2td|87ipPa#*pUW{xg+7D4F%{P2qV4s*1*~~F zprYRV((;ytMREL#!KSQZQFzio^N7g1>xVjzRLZ|lJZyozc~|Jp_+n2CTet^T-~>l0 zZDFXo?tAzuW~3?C8TZv5IT!Ty)Pgwv)Tf1AD}K#rNDk~D6)2vW!8{n%!WA9fQh#A1 zpZMfK(_539I&@pNOS~%I7zlh^zD??#K=-ZqIFX}CEN7&s+oFLy?LoH5ZIy%^J#G)N ztWgxkdegAe z@?b7d2h?@_N?yNgDpwH)|A^}2p$nUsoQL$OghhUAZbHYy|M{(|s^X8Z{*R0#ux07z zVNvLcsK9_CJ2#xqwHXM+1;qM69K0Oo5WG74Pc7qbA(=2tEp0GwwIYm+G2J;kg-83Y zjqBCXs5}muncg=fZL53~0qt9a{L8`BoJd_wi23jj{CaO;m(PXxHjicuowBI65%ew4 zrxUPZA0b785T*-jjBC!S(#mgFxYeq6Jul5!wcr=T;_zU-yk*-2nqDMMG3lZB-GWVMeq#<`3Csl|J4<;E%MC%L+>5X(7(z3If*dan2=Jw z!~FOH_AtSilU+(Oxjb?G#F4PTNm6Tf?c?gV(IfG8oo+xeMke#{IhbvH z;DPS`w3YvLcODJ46%J&x8H!g{jPb7Jks7&Qca>|3RZ#k86^1-j!cH2=)Va4$t7{is z8%Jm$g?CTin?6NvvPurxy!&wHI{O>1?uAkliTHhbi*Yr7FXjZ~v-`|qx!sGa#Z%eF zK3ddz)cq=|UmNT~CyPqr`@s#u3csf zE?j6cc0hCAGDyXE`3HxH0331$;1K#t&3#WLoZ;%@glcZzmMi8iP~G&ek`;gKgH(Y) zsD4jaSVPPVtyzF=_BKw?2prVK2GSarxe2~sa}$6g4s5@tf);E5+vh!j)CQ1drn0lO z_5cH+W$2&6jT|J2ABoxTwFi$lF%U+bol@N4gMYVH3ZZ;PG(?O%_pyd zU<+M8v)9K9lf0fVl-G3ZKmG3K(duM~gqDAE?3wu`h?^j0Ew)Rn-ql_I-LS-6>Ew zeWdzOqvh+0ZM#P`Kf2nyViF-co(`M4dRu$kvu&+UH&ZfieCYl%kV@yb@V32EyemA> z6UmAZC$kvMR!YEbau|nLWG@oA^_z-*+MQh@<|T_Vd3ISNx6gGei;bL3#9`%WO3QVR zo~u-G&@9^Y+utTRoKH2Y_1}%iuP~C8o7F5c;lzdCuZ@T^zLDo}L4E(tAcmzQz2^YM z=EG$H3#DP}h|DNl)6(Cdan3XzndAxGwH|kAB7%p4;Smfhtx{O;hdSYuiN61acNW3N z^m4md!9Kj0?K4p)x@yKSX+jdm?V_hfIWVrJ_bqIZ$RBmS5Q|8vz#TT6L?f1v+*#W* zZWBTj${(!TeV)SIS{&jUf}n=Llosqw!gKo(OFqfiaH!s!<}yL+F`J5!9oK8`1VVUe z(ye1tIt5$(NFjF%uIZK>FIE%0dH%G!NpK)w5K)E;}Lgk46U3Oja; zSQVP>?d+c-{b5Sp>#>wwnE3Zgrny=Pd~U7CMfGgt|705Y8vx5t0X{W=ph`Z5t`>tVmjbAFkB9FJg9 zwq>QFkNB+D%%@cZ?#by#Sky0bF!&0`M_(~MiZ*C7%~AT;ClhGI5^h~fw5)44rzLwU zcOO)yL?KYYG`e9d?$tG}uQ<4%c#S_~xfTCp_SK6E4EVvK0-+5=kUdm|QzBS^05zRu zoMo7&57PZ-AO4R$zVLVmqRO)1^I~owKL|M8&~)Ih?*Y0Q__C4`>6fx(sU`CRrorm? z50YcFRM-j}Nl}@@SB#gxJd6Ro7~YRIJtPKRh2 zHg(XLeo4J1$XG}#4T}&Y;&r^?okOVn+{|o9Xi|V)vzoz8upHmbaP*MT^kx?3VWE@G zXZx)r~ z5Y9==`_az*G4%*SPvK<1rA-mh=3`V?B(U=&Uh+h`^N;K9CX>8dGc0X~6j0XHHP=NR zpV&vDXPLFY=G^ahSh{x0^{h(WL!5~+!&7x7_ZF9V9<0K(JXW4f($>|ffO^s#M zpq|$|+7rwZx=(Cx=iZq(@>~44ty7K2VfUE3ZvapJto0rSr))t7b+aOZ+FDg(`jI$= z3Bj})Y&e|j^WN;cA{I?-&E}$n>Y< zxus7(7b3T>XZv9s-Ak?tTpG|Z>bg0NQ$YxZ8ntHE9DgR`$2W6Pv*S*s z);{$s=q9mQY2n0Y&jvBRMAHX9ewH(5AIXfi_|C>$X>H;zqIVek5}uCLslL!WO;1gY ziNa{ZL#aDO78oBIgB)Hv)!!9Jr<0jD6S^#A^n(RTYha`Q9JBMCgF>DP!FL?wI|}k0 zx-61z(S(5q`F4SPV}In_;NU>MK_tHZ!nPh47NsebvpIl;tJ=dD=2`Q?ul?W`?~J*e2OdMk}Rn7`x z`MD@qLh38kzCXZ!kpnv~|2DRF`qd@-Bh#||5^vT|^v=-+n;Clom(FB;FWdmg7Wz17 z5ddoU!T+lhvZeDR{~_r5{h52t_W~~4e7SA6XR208%ek?9YobHDw$gumU|^p5 zXvd&XK-WO!W=`sN6dK0m)-1=xv>TS-swmH!lL0uPHw)afct5n31s!kb`ZpnUzjw2` zW^;p0#?!hGIpNJhK<3ksF!EBu2yIiMal+j&pTUp&)vg`Kym%!T(;^m3wmY}id~QyD zD-grX)Ka^TK7y$%)m5Ik&F0hfnO%_!H<7h%?re)TM2RN4QUonU$2x1HRZYogxi=tE8qs}t%;9We@lWJ z${JI9jFe2AljZgvlu`E9WyAklr4e7hwZ^>cU^F_G3j=9N>j{bI)*H7Yfk?x83kE_F z1U-93GU~C&xn^2z7H6TDabsdkr;ip*Mv_gl&P>&74_kyupTCso%BJbnmv3W;nZDjI z!pP8w6Gjx9lxz^EL))))Gf@v65h<33LcoH1tvJJwJd%Cl3C5`N9WT@y6R>WQodWMT z!;`4+Z~K8qqZYFmcjB)U8Pxp*6qyjyPeq0ZbZbNex;4UIc58$~MEze; zWIx(HKs6UHkZL(^_i&-efDUXN9RH9aV+YLJf8RbW<@y_$I7}Fp3iw-(zh3k0DVHS< zBuB|Cy(Jd7!{+;xogzx2H8+T!gyQrO*>!%MGy@_=erJCU&_hF2oZj`)*`>jpN8haM zuGgWVvz)Bn*+lDphP^t~EQp&-Y<_i%7IsUQC zOk}qf+G6E`zMd6MDaJwIn%L?-g46cusZLV(H>V1#nn&-3b>Ns}`R1zQ<5@(4Ka4z! z60Nhw+nWCPy>mbG?t7PSF&)t(k3$BczD(Inhqgl;62dUyPtsbo3Cm(8Kc9L$c)C`x zN7y_0j*e-O@+c*9Ug<5r3Wn4YR`cr`S0v>n9K1kBV|avF1a2lOVz?FOLdx3L>ZV^^ z=%&otunY}Cp51w0beuauUirR?R&_?q)n;9ItgV`+R)uVai+n2EjS>8b<=f)oWY6r` zqR$6(}w6o1O%TGpAF_bZ`lq{pdg7Px6U)ZVU*j`QI_hhRP21_?bPB4`E6fIG}2hkH4ktRCu9sFTbcWoog1o=l#A8LoZ z);oG@I2Fd>HYCQ*g=&NlLx??=aZ~b0fO=tnjr>Q=%6UcIpYrFwSiyf#JV}62lawq6 z9m4R&z<2mgVu|;0R=-gEU!CyJQ9L_9@xP<;oZ|1G5z1vEX&03{=&~WQnJwXo`*(7G z-+4)of%#n0M0dZ&@wG%g{Pmk^q3#b|KPPbd5K&Dn`|n2_BiB#p%dwhO2b_$H9lI&| zE@bn$DKnNTeJMG;gfC4s?F<M2M&MUGA&r9u!G?>{npDz{z@0XSvQfP)l#bOA?H+zjDGl z6y=Q^%}74_NGH%gxsn&g^KZe4Lzw#PjXxFp z_lHKUj&r%ORc$_~Xk+{u_{h~>g<|VA6g=ofZ^`_1K zmx--~s?C|`NL5C3x;A>^PGxLF$cP{I=XUTr)(eV1Z}$Ln1iA24pcH>^^MRfC9~A!) zp!jis;@d8K6>N$Oh83yp#m$Zf_b9Zko7G+=d}y@Mn{0iuUw(2l##hSpcCEx^RO?7H?ND-Sp}KmPJ(ozJ;G0J`sTvjZCyIC#P5AwlSn z3&e9i{12_-@6<)ShilY{-#iYCa6T&T~NKE*?*te`OC|;!;;k&CsOGL7z z8TFF*>~8EI88D`=%jmmi?(+#8%ZH9V=rY?Z9ely5Z^gf3!rj+i*^g)brl)u9`Me-2 z^~`7H;n@TG1lco7&7?Y_Po&C=kC0)=^(U6@#3R&Mgz#kx8_*fb#PgXOkyW81hQ8$X z!>7JmKAC;eWJhKYRI3sv{enrNO96(dHM_C*?(8cKGL4l{i~Y76%IP6$AKQajooNT~ zPZ%Y&8Vk}-;y%59oUb2b>>AixaVE`h?6WTGG1&O&M1v`Gm?fd+!XsJyVgY(lX@su| zSM6?bf`z5+{VjhZ>qfOz z!`NKGZ&ey$3bd7}i*c50GvPDwO1BKM(QkdyQPZp|I!@l8las}IHY6JvuyX6#3AQR+ zV9&u~M_B*zwab)E5Xjg6xALo?izo;+bng_fSqB-~$VUaJ3H$Nkd;`x#zhV>+640+0 z4i@=J;6#p|iY8QMXe19U+irRu*SBlyHtR2em%lvWN_z1;R}1VvWk;*dBkg_I;-?Y% z!qR(Zw~ZC&VLkC3kGi5FM;_BulJzn?0jyS|uW2(GUfC*ASi+ufs0xWlYu&#HMem3_ z#qQAAJTtiO{Vp&!Oi+r94(_(u!*A@XY@o%5`JTK3JEn}L6cHT$kL@1V7HPSp)PI=J zloFFHl0B4_M!VOJ%TpwT(a|$Epn;jl9{-9zGjT{`AANe!aVK~3?D^RJYNwBKj1JWe z(%*W?M!tFUBtJWDlXYIGX}-lnfWSa8EiPgIrJ}(d>oH>=jK|bVePT0aE16Amb9B*# zvNj{s&4P~*!>oz`HK}N2vTnL)#(_2(TEqJl;y8iius1j(`=6Z=Ia1-Z`;<^KJMdu* zMC!B+y?;XEC?QLpP_E!mHHUaB;r?!8hKpc7CJ(03Bz?GXG3|^Q((MQQ6PzM*rZo}> z)7=S4*JPwTZ?L;WXO``muQI++gY@Yd4&AgL<2lWIQIW-}UY83|S{EqAZ{)011Ko>!9N?$ZC4G z=WmKn7z~v|4AWKoo!iT|b=nEnW9|gpaWV*La@}R_A9(n1s9x`VG%oh)yN_?^7Dm>S z*;-tDWo{gZOT@jtMXi!XFJ6L2^lAB>`#fJ86K+O925Hw4);Rbg%|!mAA-cJRnfZB# zcBsn?alOz9fJz|NFm3o_hYb8{Kpg-r-{78Jssy+)9ePW2q0~rpkL_{^I=8DT0U8#z zzM>NTM?KpAXx03)N4pfTRI2kv?dR^jxcU#}@FV8+vp4%i%Bgtpj7nNF1kG4jNgdzD0phRcBpw{pQ&G%U*Yxo#_z_s(rVO32mR&qdq{@_R3sSnB$pHX&RB z0R9*tmUnbP0Pq-GM89KR>sQSG`(`j#wzB=27P_e5ruuL8g!$i```@LA8kUKo;2>3; zYPY4^l}2U?-}6MiU-oqpRyIgY&nBXGfBLFwg+7k``7}oaKilMXil>%SQm)SG(PJl4 zo#l>JAM1C;yQ54m_YRUvjB~0a;jRsTQsT$GZT(nFHNbwdtt+bEQM|Y4{>yh9>34Gz z)&e=G$?j0xF|c+0|G0Y#sH)a=eVpzt>6ETTgVGI(v~+iOBhms&mvl;(Al;y}fJh@H z4GKtzQvN0-=-y}VbMOD2bMF5-24grEbFJ^2tncmTecoh~fHz(3dKd1-@6<3&dFhV! zau%Z1-4x?Tc|R&tEKDtLxDtQ*>p#S{{}eS$as^wKfIe9V?l(&-^xK~vlb-MI`21*g@ny%C~`*e5cgv_O}K*@Kl(6PaWb` z6y+YjL^V(eUN1;8_A@zG=$>?91B!gsQc9F7BZK==#Cq4}m4J!Rh=^hK*uhjM44;=yuP6Z~u*LU}}!hkhsA zTFCv=+x7HuBr_hY3MWMMl`t9QWZExAV@)4#C!~H5gX3Qrf=A|vnf8957(Z4CFG^~N za|;sUz9O>e%t(Q~Oth6R%2YDYRkN$9rQ~h~A2&LM-WuwZ_iBKrtDm>ww&${b&wS&f z+(s26#Klv}&sAnK= zal1m25bT`0e(GbY;PM^!g(e=43z^tw(#-1m<)?Oe94k85tL;a--*QIjKUmV7KvZVW zEYPSlS6adBQTY^awWkfkEcR4&m;xti5yzUwKn*l22cB#YjGs1jE5_HBtNnIrqQt0r z&x1U(V0)5C%PFr^g5pjRhiL{`JfoAx(Sm49L))KuQ<-S^&8XPkcwA_PGb{TC$-Yih zP1Z9Nlp)mwQOP@MT0y>V84q_K{l%*O=?%ZOl?47~2hKB1EUwF)m9sT5g57qn^Ef_< z6SW2G(x?WOAs&a7^Ms2k7aIC&n&l5Ba`PT8k#H=DE_l1em}b|%PUD+re+v?Ssze|A zV(UO4!T*F~d4Q$kgL!lA7zNz?bM1C@IOqJFQWxfG-9}My^R4(F4zaCatI z(9y+`Kwt2Kcv@w7bHPSBj|;85$!%XC&1pf=LLBv`N51nMZTFHJNl|SQ;@+rr;>Dgw z>X!CXYnfC$VXNoFO$tE8p5A0Ea*nQ@01uT!%RAcV4*W8O(9!6hMIkgZ>S7Zx96%^H zS0W!$7s~Jav9^bLM<;E|S`8Uyoc>n!kf%kx4i>&-IR5>W3JJon`(pH@o079D)9_)q zd6R;nQB>%PdJb9}jVrHZXu0$@ig*}Jm~ck-!TbU;`W`#KezaJ9&v*+`OxLUmNg*!E zUpptOGMk@%qHml)qF_gKQuaIK>NZxdz^>oSV5`zX^(q3F%u`Y|NDy8ILsug@$!tlt z^qXC3W8=Ug)5sqa%Zh}kPc_Yq5U9F{+1s_`J;w5rVKO+UM}lJ-CKefywBaq`;yttY zJfnXIWMJhERBCNZO%c9!o(-yP6oZZ>C^;54zh5f3&|iW&&)~fSF%+z0=2hG;Bc9BK9s;FdpT_UJFR3$zr!iRxn4#Clp?^QZ(@B8h-Ev6m{2|r zeaZGyDMJVXZUrykR=j{fHO+mT+(qNV4^$(Rypen zyKKPc0&!gAnwTz7uWY1pPWnKN4=CxGS?Srk-AFzCVc-kE&JS>5{Ok>51)wJYllkSq zmw)*N{>stl)>KQ~AqWA-dWAL%B{;R9Qfe+H819dR_>OI20)1c;LY0K_fG$rIy5JKe ziRJb8o}+#%qR_FW<;?C5 zTzQ#D+N<~?V1=*gQR3-sF}4rR*q>1|?F{c5G5MH^<({jP-@cMF_ywB1LOwJW9xI&C z_8SX?J}*=dj8+{`zwsk@6iP}-fr z0Z-EGfrY10GwQKze^A8vLBqZpKym&BU&OE`XCMr~1@QO#dD@_u000IZ-~wP=MzOl! z@zvtF>#trVj^1NFh&a0Wd}oQx-wBqkM~z)9czNQkQIywJ>9eDCmDjwUCczEjyf~Z8 zmnceZphSH(JLBS$0PLgqKLAl)&n&xm!_U)vh5P_0(l5Xt+<>bAKrSzR4>m3Ue|bG% z;y1>q|Md^_cd>MNGd07})VRj9s|P`9CSX(H18HA=6XOH!gKRT3?$D)hi>b$NZQL#jTRweJ^ynn~@#k+yP z(x6;X2uw#i2Lxd?h;IZ~7Q(YOI&~JlnJF48(v8I6_EYy9SMNT4{D=hV6;;yQEA=7? zKINLRGAacca27%1@rm1wU+Km_kx6MLeRW@ZtjysRXAv45P2C$+zg{HRlGgUkdq8VX z{X@TFU=F_}qGC^DR6ib!{W6j!w^=9DXoF?H#@7SWM{uM!fIO&DYyR!%pTi{a z1;=BJir}MyJ9zfcmhw@I6}4Pv4sS=+uZYUecHpohY?+J7uhYYZK)SbY2p}*h;H1-w z)KW$W*ygiQT8ZJ)+@&5UXr~n>n7wvk!~FS;mlZ^hs2y0{%wVb5_-bu!bWBMG=rIZjYwOtMVk6Mvu;iX`VX%dLml zsnVo|4BmrTPg=D1UC4lMT?4~=&p&KyQD>J^pjxt5zh+sr^`tMU{s+(UL%sJ1xvw?v z>v}-DP`Njc!zwW7AJ`g9@Bm5iHn$JXw59!T7!0AbgE*~Oh6VBU**OI`z)Ok@(*Ln; zIV+k_x=Vg4{i$0Zo&lCD2>3z1)GZvxRGJh1vfX@Cd@4yLV-Ih1MgkBQ|6h&SKaj&e zs0*(DNp*2iV&?*iD(8X9MTz~a8~S?0+5e7h{(~0k%n@LULTt(x1=lC1Avn#@%d=S! zvdFLy_Xw^d^4$?_?0G-ze?hDg$H72gD;AFfa5tY;^@kvRL!Ym| z`K?2mfq{&H7V7D5b1D)VxyuOcjr-mq@f^qm!MsX=E;KzEdu}t8%iLw#Mz+r$LnyU1 z{}|8UpBMn%@;Wr;_=DomhZI*F5^OdKMTG@*7Oj+?l15BgQDkb3ycN@Aj005xCVL2# ztndu1i$Wicp^=lL128Gi(a6%s;%2>%DEUDq_RpgWnFW}{G~no7Hc^99-Bbo=*<8CD zr&UypOJpdLXCC0Ot6^#r?FT!UL07V7N?7JTJ@rSox8ME`F z$#d2K05GWn2lSfz@XQ$lF8>o-`a4@xh?vDO_mmdvC00NwFWMrH4TqL=$@IEjXspzp zjbRqPu5ot0Ai4j<@QWqaXcSZM;#wKaJN@r#@`MFv2eRsX)y$&^iU<=Y;pi!;znf7= ze3{!|a8KIDgc$T<_iRh$1yd{BpG4Yc<)tr@n;dPQ@r&unLrP#pfs=fwVSY3@uc`_z zrDHF|iwy%Frd3=}6aDIK>PGIWIimvm)SWF&C;7>#U6${gcF$Q~D`ATweNR&UTs(^l zm!1_EBDJXq9gcT@WJc93X~>*VxbV$L?tm$3+~U06b7#G-NY7Dzu#b^)Pv%n)mW$(u zh&t{(>TQ^WWFHCB0N*!LIr&a+oh?3 zx~g(P|5hmbQx>xrL$zWa!xh>M%v1IDr z-=`I$>ShD=UGY+%7_MQVXQLFO!~^@L1fm9+>UFssY8gwm&`Bs1DhV+NR&_iEG=WjO zxc=iu?*^bB8mgSzB2;}RH(Q`ub0eM-F{8yO`zgxMT0oLZ4G?Fc%On@XO;J8`X>a27 zAIM&{5+WdB3156PsgNQg56}|G$;QUYb;XJdiFE7g*Hxbw0FKf# z@?-X!m;dAI{axDY#Uw&3j@&}*j&_PO3k<7!(ib%68nDDl1zT!Zr=!p7ZmJr%#m2?_eHR^HXz$kuT)Q(rxM1^HuY-qku~!Xko}si5#kA zeEy!&gf2m)f%&{p3n!$Ei%=y+>_<=>XLEfItcT4LgRwzY^HD8Jq%RfLJRdDsn0Uab zv1YhiKH(V$Vyvdv<6s&pbmnsrp7?@3`{NSrm1zF3#RS`UxzFZ)Z&djkbm%>^vi%Ag zPED-W@(wZ~%c5B}|lKu~kdjanP8a8+($w9DIAc?-{%0M+)W%41BU$s%#ca_m3ps`K#y>Jb3#0B6{lvuT!k@elFx4c)UChozg zbE#7f!eO`!+rZ1k^K}um&ps0aJ?waISZKW4q8*pq{u)4)SUkPs_P9c7fbU~)S~}=n zKy7l&ZMX187WrbPsPuzhCJB4ZYI>yft-1yc^rv-ERSUv1fL>4I%mD)Da(}~@_jwdr zKy};C?m?7QRbMNiKUnVTw3kH9+aF6do8QVmF+V{0PFWVlYtjB!O6aO|4n|5L!~qr2 zCaABw^^xQLm_X4-_K2Dc8|OnDoNP%hhP8;c9o}yUY2!Xi^%|3u4B5HLcDGr-b|LOG zn172dDu->;Nt^2H3MptZx0#nh>th-7uCMPJ&qOg)SW%V)tJA~pYXOb$*n5Ln|) zoZpB3f_Dd}LL%jO$eZkS@1TUOP)3g*9vp+!j+RSu2o~lrCt=j~5)9XeoaKll?r=>D z0`Wi*VI6*OSVbi*qellJ4jG9`>Lj!xSk!F+sFgt;_;+KfiF9)-lUHcXRMeBA-9J2q| z{4$)mUYZ42I*@SVBPT7@{^a=U9Vfj3uM%eiX?H=R=qKNZy`Kdx1&)TJ94j*DuHxw7 zXYz}9yyekVGT+|`rUEzhlgwmW?S_ghM`uUpUmp~~BY}*LK>8uir?MwxJ>Q$&w9#$w z)~avu8)t!O%I8L{cw15ADin?n^GI6t>GCnXUN{@*%vn)lUH9!K8oCn{RK%I(1{yic z_V}>-VO}tx@_+TIi>Ys~Z#Hrr3UvD+br;_cX?w=?Q`e5nef$|;+HbAulb<)2skK+d z22%*-^Gpjx7Y3i2FMPXO|3PNVa7Vsrxu8&ejb#(2!J!#bA0e%?HvU`*W8GwAv(Yy< zGPvNQN7!fjcs|vSmyQ@<69?xTBP-ezA&R4Hn|GKPaQV40fd!7+r1@#n{5*{2NMXnxc&p|>rqYD7sMNg%daP8PHJ3GKdE z60$upim*C7lz;ubF^(P&is8Lg?uYHiHhxAQ%?qCdI$bDApHdJo#q0)*^)I=mCqElH zVkKko7EUMRH)_zxJmu{k2MGfiEub$AU}6ISOl;|Ffh_+d7u&@FJ7;1$8_Nwav5|vF zuUaf1A%Ff44hG?p$sYmoPZ_4+NEBXjiMmdm^w&NW?*-XP^}S5Ed5=|+N=4seab?LAc-^=g4GEN^qYu}Uzvj$cZCx1gkCl&@m2 z5^H_l74lGve^cZEzXf&J;GKH`h&t~-o98<9zEgj~%;SWqZeIrBlh(A2>aRo!1E5@O{ zqP5iyniR~n5mSLEkN+(gN!PhrLcc14+Fqo&FS70KO!Fc?y+cTEKp%Mmfu7-|PQop! zG(Rz`!oFi*Svq<6I^%bpq`;tuA6gOD~9Gv=?s>ftEcILoCif4YAdv;*^+ap1ciKwMerMIU~vFv z|GXt`H)jEn$6;>~pJY7OOX#LEjt^x@ECI2cqWh6E9(=Z+BWkwEq|?ep?QVF=Xasgl zgD^W|~OXJ>W&Lk~9Z+bMp=2Ki{b3BGJImcdxjPJ6t0QY=L^)T7L znzOWRwrFS%4aU}v<1ZYjf1FWd7?Bf-$9}pU&Z(y%ePl6_(9IV0+hID-D5~2&W|*#K zm)#GP&!=j-S5xrC4*7##XZkujvAYW@6vrxcxMf6hB+hMde(4AO^f)7k3Pi^wCYcao zEVBK(hmg5$DT?M3lLmLbd5^tMn1361weEUEkg-D#c58z+gOX6RPuxoWxOQ zss8@T&KpBA!QMe#O|jKLf$ei{_Ye<+?cv-@VPo2YB>B%EC2}mCi9({*#hC4H`}7Cv zJ+9)TH9(UfGCe*PIKTI{aC$7Pw$4g&3<9GwMs}o~x+jMCxm5e~jWThO3I0 z(LA*MDX0IgD30|efbJ@a1Nacnnntgpxbw^Zp(yTpy}yg%#yYhRT49G>jzq}z_V&#d zH(9}_vI0pK)sX8}oct6v)(Q2nCF_Y`d!Ch)eTYk0Z`X|q^rdk~ehBm9p5ZnU9hX$) z(g2d@<`?OD2awV32(w?6*TTwvYN77;_g_+?977fflaozvF_{A5O$>Ge8%k-)ZiC-eK!0gj=uS(=o5=0|K?6By~o zBbJpi6>M{Q8(K|k&rw;&i0<(+se>y-!tczkhmOMt8Wf-}p0;zPVkrpheeB!Oi+*=v zVlk#r(rj8ND3Y$iq3F7;_)Sk3*05vDCh0ymvO$r4Dd*En2L$AOvPQ=OnRRkjU>&(vfU^ZYYWoT3ideqGre1s;Z|GE1=Tt$xxin4P%PwQR@7?l{NQ`&CES1OkOQ zE%sVyFYPuPWEYByAg!3}m`YzS6lXOeq36E(Azki)hDMUBB2?Z|vd5q{DuEWXOD0bX z>d_4>6)zD2rjer6Vd32Y}Kg5AQocJa!;j)io@QF9S@-K}bL=DF&8AVC z1yzbH)Z`|z66UQ>L&4psDX?dvQas>g)K~6Fg4A)B5v-QO=Z5N+XFaXSd|ORo6;EY zyjpf`O>T#6PfUprPc+T?U%4n z2yh4pC&Wq}@OT@(pbD#R2 zcq~*pzOx4(RxEI8!o@q;O(pm8C4cYg0|&63@(;Uj#E;;&aO3)O=aT)kNKxF=3pk%1 z(p0%JReV~N*oE4Tpm?=jx};bGeITJlANVCVyW=iL)ey3R(AZv-(|jg^+`}hL@rWL5 z0cf=}xSMS2lIUX^krK}2!L68st@S*# zK{~4hT?}gmh>fq6SeFpHCN?(IlHks}!bF?fQSMKK)&Hau1oE#G+ZD7~!LcCr9{ICQ zzPRjDtwZL@hK+5+wTIk9@2rqB8cd&Vzwv%?oBd=b4i`NzgL9v2MM-ePkfdG5R@j1( zr!!Rnx_`yoekjylKtj&1urrjhyKEs>5hpgsTyY&YCEPXN#RdQSt9S{uAZnV*o_VG* zew0k)8gfy{g?9#JLU%Iuvl$PZiJ_DdTv-Lj=sjiXa+1s3tYMp;ecBx3Hq&TDdT5$< zy76wlE9m>q+s91-uS8A2^}h`|V);*lj{fNl{1xbE39s2I>!BWF zf~4J7lbPDkjq21uZ-hvcLvG4a@gUzNhrINp+givZeMZ(uWrGj>ai1i@B%x(E%)V0P zv9NCaianB-Cs2R^6UtKbxQu-)oZTb{{w)^z#|L5$%}87!yeB_MMAFuCb{lBEnHyt# z;*n9!TIK<&qhn?%*vvASoI01H-@cM_&KGQ29$uHMNli*fPu;^!_yk^RG}|sD_~nWx z0|*~+<2dyDnvg{n^G=;Jgb7SPfgwx&&w6@dg|W`uk#)eJ zW4&LNEog+%(J<&%)aIKq6B8Udt{gYOEM%xwfCwzk{h zEf_s8y@~S^J#6kSqu)N&elZmlmc$%tY0ECr);+Dtfj)jU4XXw*tcLsCVE=`|Tm;f1 zt#TOm-GKFtVaO6~e}0`G*q_ZBzVmR}I}Nxf$n17UFx2ubbyFw`klcPwrU{!s+t_jE z(~5QA9gBEJ1GYv}T$XLuQ0M03)G#f&z+9P#57hXV@EtLb$PJ6IlmZm+Bvku~4&jtI z13m6kLdk6ZcP&Byl2+KFjl8Kaboz9?EH$M+WaEM13F8=OAsg-1#w0B*K!WD{6%Ui5 z1`Xl6YWA?6Z6lPPIY!8>5roD!4It0aH6+T=Ktb70eOX@I9bD+LpQlY(!tM`MfIDtB zIcdX6;y)5=1uh<_k$e_++~#z;J&c5dEHU2&UhVyq z)XJ_@Po}Qy)CX`__pDBAtt{{j8V#38s{6Nh(wOQAs(0jq9HQDjF5rYFvO*Mw;ZCoi zp>KL|6h@TtgJRqV+4ypeQ1_3+QuPNUL>a)f>WL~@ha`r$nFddNKCqe-S8no-9IyBg z;kDluUN_*$KNnPV2S+_%sHBml;d$NkBH{**XoXq$DWm|$l`j-3AfyKuLi&d(ogmX2 zE*_Abzienmz$66tVJpD2ovzvCKm`;dp&QQj%WQQ) z;yw|`C_LiLN!xDEm>eFrrdNzOx}DAMzn!|O^J$4%be|?iz++~PZo8{gkvX*o8a$df z+?bFjSLRT?$^nYfc*EuKidu(s0wtEx2365*{w!4?B5Y5R*<5pNm7e7K~*(#luAU z0IDd$T!@NA0pwCRH{TjgzV+ny92E^_J^Otrt0#t`x4hY`wWYNZx{05>O2Ka#vBu<} z(4I}w;oBNLaBf@YuXjZz6gIJd8viyrY4dbPG#$JU0vs~yjI5~bhV(Y;RKM$=CJEfr zP%io~hSr9XAG8AUi8^xv0s7Stkk1outUtRa!!q0a-}lw}0tft8(zQS7l!HzY2ugX^ zjjx8JwrL{JP4GIvD|gR)b=o)wD`>&o@#bMAPlPBgdwPTJCQ9--!Yi7-O6E z?IJ|_LP-+A5T4MkDU+*$QLHauh|p?Cz)e3BGB<+BTOunEdKF6+Tl?r8dm-j%al?m? zd^~R(`JHStaMd8Y$zO#hk7(14y{H;Su=-Xlh%TN;;)bH%j2i!Gj+x|E%(?O)0BE4} zEX^FwC(-^K(rOPF*7F3r3=$<5$4@l^-3-7l0D>IItP3>)r-FbUFZ_C;@20&!Lt$9l z&?Zt!EGXw+1{5q3w2Yahp7j+%3IPdU=wfwJMJ8J&Atq)J8yg2V2P=q&lZ%BKM0sxe zk%+Hu`gLsQFUdU?5HLE4g#{R*el|}Dn0|77`S0D#-(~)CJ6^w_&1TqI!hKUFmt`Y= zHw{6(yG@cCp^Y#d_i<$9lUhN6X(Ce+IKL4_;-K_z;Sa;D5+I@?a7J|CEQ819iyBDV zUe5W+hnUHL#i`pcw}^UWp)5weRo(n>)JZHRF-=_y2cDKgMzk-)$bA2Vrg$!-nEcg4 zqp(1w@Msa*86I)hED%NA+wDh~DlJ+=eioAVUl*o%t83h8?9L?@@TO+dK&cKv0)`R6 z^;!3Y(_;T>Z!xSw~NvT$x}&d|`oakV8LlsuZhBBcm^vU>-zuoSsDD zlPf_2wUNaW1(TNWzWM#StXwkQY1|WHUZbyBxVQZR(N>iB^X@p`mh~Zfvw#ZmEjmVm zwElD$<-KX`^lNv2-vvb_x9O?mp&i&Hrm6=1&jD6jl;}J0_`-Sz(($WLU!uVt8u^rG z@(djC{=hxz_@e$)?IT2yN7Ud0ELk=EuUr&}#IxyU%uBwrZthBi^TOzE=+0WT4VQ8sU1~%? znPS`xZQfYOe$?9;YqvU?<@u)Vn`0CdL10lfxuRfI(dm8Xfuk7K7LGJ$0qdm*>+~F| z%o>KKck}@#xu#up;Pfvo9f@ijVple+J1Mup?t_(kRUtkl+-;FdrL3KUo8dJ6!S&)@ zy^?N#Sx;R^8#K0o{#4-X)og*2zERnE9Hqoe zk4{a=<$7PRAD?oddvO1H5E# zF?f$i$q0@6r_P6J1zg8QKMl z{@ep6&7<^M-o0{Ccb%Kpr@Z$|{X`^%fF!uBQ$93ZF^S!7w-O%_jJY6x1yaDKCV^X< z{_7gfFb*wnBnl`Aj)ElJ2kFLqy;KOvf*E^S&ztQEUx1m?efD!l&BUr4Ca>@=<3&=J zH)B-A4gZ{w`laM!?DAKMyip|7GF8>7c4My8q(~(;uAvx0bII=RofnfYkSGo)P?A}d zwe6Dqq2&`9PnI9hv8&JY2y&SqDUm6=Od=rl#g}-0h~bppz2b1zAtIDj@|mUQNH#z6WT5RBhW4D;3X znGbV4(i;T|2MTK;X8)zk+EfOuhRRbJXBg-CcbOr7NId>YUpV#I`sh%kAYvcFn;$QD zb#ZxGLFYGO{1Z2x4=^W%Iv-#TgLn@A@Oi?700|D_2cGsakqQBh1G;)pTL-4!7GnlD zIDdUuQ%5Vyo1WNJ-V{kFz70RHh1@gkC}I~M7$LHS`JGG$DtWT|MJTmp+>^*Ap$KsM z=oR8eI$wi3v~mUE`HG~(#6B>Ef=tWd>yFx)`|1#91zbGDAKk&Y9TpeP3yoki6hlK~ zh19|nL_RV;K!n-3Ejcy@ojcGek$RVxy~|s67_0smS?=Jl;*+pW{ByuH2MK@p$vz5cy`~V|+0IdSd3HaG5Ct;;8`Llxn z3FsiWy7`w5g3IU|5{dA-#o&TB;w$; zSkMXHW2Yx1BrgdN9BymW8qF~%b?Lr0z9lf@S&EVtqL1(4eH}_x;95DXYGb)8J&cu5+=;)hrE>^dPKAh7p36e9lC3eu@dsY`L3R?IYt4l;szvHO!H}f&rQic_xFGd#zVfXn32XwhjP`X zl8EBx)bXd_FUu6bYGf7($Q%j0S~j)K=qO7yM~Nnf+`4z;Y3Bl;%s{E3eo-4X47it2 zN(n{WEuJ4g<6BN(o0j~w)Q)A^1NsHS``R9fuRS|oSBh&T1sZUwTdnri;Y&a5R<1y& z<`9P{%8y3-^f^XXZQE7}FnCVJP`yjeKTM6qTk&W?do3;tZ6?9Al z{ino3jR9WHdqC>zFC-ofck*2-)uYvVX)@KfeHM46Z~k@9;jBG36abJg`-kn?*X=@A zecYGbLJy1_U2NtpK;=ptv2&wQI} z*N5X%!rYMRQBw+_TA~jpNZZ)Yh-_n%8W%AzSGYG6zG^Ek^DfxTqto_l#Rm+>DG#lC z58uZ%W4mOO?PXH#loCdn;4baKKy5|TE`lvi->Jm=0a3TdyE*rCgX`(1y|JR5uiJd3 z(@v3WctnJPy^go>$f75(PK)RiI>Sexq!vRBB!YO&{CZC%8tJ`c-^7-nqzu0kX)$qF zz=HEy5=e8XVM7?u5@3H47qY3iN{M};kbKHP0Cx5dJqEw4B&#c51sn-V52TZ!m97C& z1F3+Nao~YobrU0I6EkDb*~~RqU^XlYBm_PbR`}9;{J^5nFpKs9Z}VYETm}z3CJ-eK z#igeM%1Z$!LTzEAXR zX^@Woz&QSMX1?_g35<;{UthS9bANiBo9>EHtdAmQYxrg*-k9+@yq8YtXdjKy4tN0^ zzQoM;@19ZWaAu^)6Z}@zyvWw$%P^6GxV7I}KhI7H70ktvcE2^m=Jx51+068(MZ~lT zn?jnVgqX^HiYGcGGqx@ru6@U2I5W;Ec8pjvpgh-^@v# zFP#+)2{PjAr4@WCy!kzJ8??&U;}v0O)~Ws!d2O1i)PVOITQ44o3EGEMqgbH89IR`aVCD;!(4QWdU%spgKbbO5)KpU%5ghMgkx(Y((F=6~t? zT$Bm`-^WAqrzZUWh3|9G+I#8y08o*0w$%S^z7N2?4gN>&ZE)1H0t3Q%fuTTWl0awG zA#!O_b1!pQVrkb@Sr?iJBD*31at9REY(GPn*U3ZKQdwNe6KWv#g+X}D3}G_9E0p76xW40S$_lq+~G zT0!xMM`BGue-tBHyP73V82ZRLmpE&`?Rd@ojb*-_?0TlnXn z_CvD5^)UN%f$SNO##W$=d8~$rXdW6i;S#vYo9ADaVQ3-?NZ(W|Qpt;yBcjKu&bOdC zPqc)3`s~`U$JJQTVGGeVn2XS)o+q z(pS`Jm;~3S&CH>;TfRf?)oMc&YfCB(%RamQ1KWG4Zp?jL!^socomRq2FpmY(<*ne| zSMn0>Oy~;|=rbwCgHK14j1T>k*FD>4g9+AbD*8V{`*$<*y9Vf6ck8se8aS%9Na7+T z@N8uF;a9q;hhis>Vz~{@$Bj?{YEC9d0ZmN~;xQHQ zemP?Ec3ym2j3*0C9fp}<-F7bdzxzJym%fkmhwG`0kU(2Mq(AV3aOwLnd!JG~Lm@|% zG{K;Wd{R_#v&kFuFZ2btNUyw@e~;tCe(w1EB|*Ty&hh#8KkPrC8OVL;?x`?on1sTp zIj&t4#diw6j3>>91$pmKmzs3KFWBr*sUs0rTba&q2Igz1^xa}KUL(GUAgJIukX}WJ z7I?15jAwaMkC7f&V98{-$6#==43S!*(8~r1?+>Z^?ccNhx4RM*IFTotIo6AnOj6-b zTz$MhExoL~dE_rf!-I^;kZ`GV)ww+$3eV*pbNb6ik}^2Ui1588@~0Rq8ujFW>3?h1 z7=b)xDJe{ZQXmY$0+!4t$wR@TijR$r|~wv%?2fKJcD?%m98%M$V( z=>o>w@j$w1CbT~l+4BSi*pZ(PImu5W4MhxuEBJuOLO`H{C3(R}W%29Rj%-Fq+R<*Q z{N@Jz%OsYChll6iEV1VdKs-EWNsfPWsPZ3q*uV21dh3!Ej$KLciERkD92&oMTf|_1 zWVbmb_6H*o_HT8)&}+pJlsO8~i&%0dZAFK9RLEeRvyUzmcF0&vr>B-}LUn&|wLw9{ zmJ~|$oqKn-S%cp#!(!;C4TGxvq0ja=wuPk-Q{t&jSgq$vqOl2W8%SlCac81}RxJZm z(DB#27O2pbGR5MQ{dz#bs~^U*KGS&%Ja#iu;m0O5hGUM6ZZ42u&J&N{#`t*JhCnaB z?7UnpUi}d{r!TMlzM69I@~WaH;d;upJ`Q4Tw+_&}+UDF}dSJeDD3p`QhSj~~Zty-; zpKBz*C>3Q{@wOv@HW7xRMkm9HpVVFKk`U8cmH2c2;kV;{-iL#Z71vrA1$Q98++BXU zsGepxGessFn85DLsWLr?&HSeLF*XU8z61a8icbG6$SICP`l%9KcpYM$aO-+RzIAm> zVkBLg%9ctBawb^B-h9ViiF%^eu@@G7%tOK_Qq#G?1B!K%VCpo@zO&!zFp1;>eNVzb z;k4pq#C#l+-1<1U(#6YF@|H8D`WxVb#J5k~!!htNOlyve6R@zvG)q=W%x?M6t8;a0 z)9rP9%+ORy%25Iv*#6Sm`5c6QmlJ0y%XWVFD5!@fh-t*tQ_vO(v`ne)OcD2{Dvb{)mo|}Eq zn6l&gYaPN4=nxQ~LvSz6zFdsuC*1XsWSNopEvNAG;@|$TzveuFl*c7eC?Y2I*UZqeS7hHWZ??Y-GG3bvrx^kXX2ln=`-JRg$dV1u}AIPxc zFovK~WSE4vv4;u;7g7Xy3(s&*osvA1ouT}zDG`R%`w(KR$=BgIA1MMx+>sm2=hi-b zx>YYsU{XN&S@@22V>w5pWLs%2vroSS-Dn4a85x7REvP-0}y>WZ8~)z4_(HUe-dHWUfc6!6R$!>Rsz5ngvJPTuMvVzu<8BJhBZ)DtbsZUJ z49hN0U2NBuS|3GbJihKM7! z;j!E_DGFtVCdo)-65LYe2dLA~k_dy4%R&r=SZYu#BW`CWY1)O?)q4>VOqqM5k~OSN ze!uBmfqa^O&7@v;;Q|GevsEs!hSw~F|J7N}EUag> znCp)MlAix)mNQUbyhy0hUB2TIWdz`#&5X?q^c;Vo)C4|AOoZhuiU82Z0REVTgOvl| z3;@!n04w3yCCAz2|A8m`2cd&MX7^y7m5|3r%fSt09b*Xm+j|zm1faUKaJ!dHUJ>~d^oaD7Ss5V%^pAKDv%Te~ro->ydGC~)Yx_Qjf}y{LGUEj_lb4bO4nL zG+J>0X7vB-=l`7rEadvJp_?S+YPK(>S~f#sXO=_1P$Jin-w?e<+O+r@)A!-lwg@YH zPm&X4xToy=oUC&yVzHq+)}6$ZW@a2jBf|X6NnX(?iCT|rlEnp}JfXrST=$~|92sf?YOJK(6uRkOaBei3PM(52*|*p0PBSe zLY{r}wiG&AgeUH!JW}Y_ZSEX(gz5-$Os-u)F9%e>Kk){uwzwNbjlfpf{2*i;xb}IQ^WXOG)c4 zljU)hM!8U06eS1I<=P?ghB}i2&-jEiX1-^w(RoUsk$h$4^|D=?%@|=qeu*#kssZCO z&8;P#5sVLWd(7uaRHJKAn{p&8Oj%z|MC6(o#t3LdX!~f*S6h_^<>`y{K34n zAZ(o#wbtVU4aN%fPI;ZeY}OpTCso#{fkPmO_-|uoDjB#uTIPms9pGw3ye!h(oq>HFEE?@p8>(VA*JTo3_s=w!F&)rp0L(HJuDGghb&I$GJus$SewoAI+?~1lKlr8 z9@UFAWXEd$_zve)>bNZ9>G_f!A&s8r5B(f$7X$H!ScK}Bn;0?GooybhKJY;i(10XQ z$7nKEMVIb{eEo`!jxp}m9FJ0iJ;tMeuu85X*O8+zSjJH0*TslP#8`CskoJdz;FPm|GZVjx9rbI zUv8n^{hs@sa;$a0-(bhnU?5Xsr$d7+%uo=@wAH)TkWkE}bKH7AmX=p;m3_>WB(Kg& zBr-N!Ohw!4%~4M_)W&)|mlDXP9$bQz?d=DZBttX3Z%IUi!Lphr=TiUM!8+>{m6v(j zq}lr%FB!WWoX3?(2GzvYHlYJeJtkXGM#+l46j@8~sp0#v&6$UKQ93!ViO}>o-!oA2 zuF}HSq8mE)RXU^*O6E7{fp31im4mb(2zM7{Wkb|~F7b<5)RrAqJ5P~aZX~?Tq8&^{ zotg@j8`#%x$eC;)n&AS~^pq5{$dhyPh;or*IwKjdzk<^-OPXH`ivb`kI)Jc9T)4N0 zP{7;3z{yk<;WBSN(;2Yt{uL)DBId1&RL~hgz*VmY5O685U2zQ{U?N=KarGkP%@@y( zEkN7F283c)z!qTo!S&_;@M?c&y80-cBivwI$#M2u{HpwWXi`t0ozdSE2iYHsLx^;i zhonI1-0o$%H?Qj}KCe)SV-JICp2$o|!56Xt2I{pAT#vhHcfCzC#8z#Cp>$GBSCFvg_ zTh1w&;p9V3TCe#<+c|fb1^C{&HeLUPm@a(#-s3zbvD+mwa)$ft(9YHeu)NgKw-Bi0_aSgT@LaEuZ6NwI@*@wR1cjKR?dMN^Z9{C+h99Axd?rlc8dIc+_u4gqBE}vIiF@^a=00`yeF6su z=e=7AZ6xj}3yg5Z2!sqjcng(LP$RuKH`-OCn&z1pJ$0Y93&~?rr1T%KTEu|oC9E*8 zk=(gUITR?^f0rT9wOfxFt8Q~j*=E*%6B=Hok!IY!|GmDP5%ES;ydTR%MP-kKs({Xg zB)T}*0OrbG-v&U>TN(mFrlpn-II+;GOdKE{Ffd3NKoX?@No2W@L@2R)Nx#5m&O}i8 zS95hu)F>jva+#cg#YC2|ak6&QGqWarXlCTXf_xsd05fr+R1{@duNXogG2tz34D>8b zZ5+<~v{|@7Y^*@5768>bb3B1dP9W^OxcpZw`*%WF->t)N8+#Jx<3M{LWXB{;sOU%+ z)Ct7@aZw={}Uf*@Veq5l9x z(eGQ!ea>Ec?R9>5>Xc`xzz@KDCKJvZ zZ#JCEBtdr1J6YHq~FK2wqcYBkQ8RAQ@ z_hL8gwA7B9pKlhETRo8A?BAb#TBbMp%vhQLP6EvI$=E|wa+=;nS3Oz%$t8$SyhcF^ zhZ|R*yeQH7X+F;D%$PIwW-20+#%)kV8c29(+5QrNxGu4fY2|K&M}N&$WwcuWo`th< z$9U~9QXv-hL7Psw+3p*kWc`kbQO1P32R6>pouULOmQ=VNGmnQrp2x_QbSDM0N zqNoAvJ7n@EcPz-nfSk*9J_Z33Tix1%OhZjVRb5p>P5s*WV*|e9EAtZXMmzxMF}b34 zxJ=m)g7B}xpBMmFDxhq|Mbt&afcHhFCMEVgW&{kVX5;1JVQ0IF8C@*-K-?Sv(L&&V z|FfIgXipg(G}>dDStQ{<&%vRxFnVDo5;h*Z42ZFSP5>imcrlL}gO7|MwO;Z( z=Y+-SXvX1GQxy9Ni~bhn40#>2J1st{(nMQ&RZ}9q*={~M!kU_NdebibEu3Y7EcyJN zJv<%j*G{`?V6P38gYq;TxsPS%#6zAv^OPza3%Nc5o zM4=JaB|*b3h`lSC_WN72_nJ)VEAmRA9z-|!oJU{bkQjyV};YU!1 z!;xrBEe{)rvYxYnTxnNKskjw|Q;Cv=l%o7Np~wlon<*!D7UI*KGyhH%rAyW`@Y&fE zAuQ!AHkwAd6B$P!ZYcbJykCyVHP*{6HB1sY4acF>;? zzlsyakW!3!>xXLUN~}u5ON1wL4suItU!-7t_d0qb-b)@V*2Ul8{WM{u#GTL6Hpzt@ zn)0Yf2bo^+JO{}^bJNZ?-`s_b6$AzkQ;$2f_IfnNnTz2W`OEP zj`yNN4;WYZJ!5jwwjw5SRkg_n;sT6tU?d9%-(~RW#`1sq@_&*AL)d((<*JqS9Xdhn z2CAj}Vio~%UAvDOK5!>b+Pue$ktDAUeaQVuBG?Lc|J~6b_Y_qg;@Y+TAY)X;O^;91O2BhfDlsTVF8`u zb35<|HJOQb2Vq@c@GqgHzvN_Y#Fnm&1$q7)@sc`;@~#BGZbSspS@Tt*O&vS9`fwxL zUfHB4Ua_zp?n5@Kl;r143fUZ&Va+n{H4XM za7R4%d;3#QrAhIHV-nVOPH;B|6c?Z{G$s~5O`i%u`^*y?b`~@wD_QgJudpD9y?mji zZ))vRbDk4%KdZ#Fi4i`GbK4gD)nj^1fv;dZgOqkViqBrUNn+T=Z*q>Wr^SC3Z;E4c z8JB@LfLPokUGtfIq*3&3J>oc3>Km6X#51VA2)!_8`uN7&Dj?sTwy#AA21|}BEXy|x zErVF_k|!|FAnF;1VIZAPfiLYESZOrRB|@>S+$_v~&?#N{%@-B}K&pg4wD!YdfB>uo z2wk8~xD5gVJnyD?00n^b?hTLv@gzJD&V|xOz(kc&mjGI0U7Q?UE)$hE0>_un{2=Bd zQ**Stdy&e#=5hHsvgWq~uN>?jZMJ;Cz(Bxw2inc9az>ZSi=5E~(bE6YZT+*bO%iI> z%WdWKWv{LW1Jk%DEMS0t;!W~v?A zYbTDph_-)V6|l5Xku>PS)|*G z(U4~eHZ&nl(gDI4*j=7gq|mIlOj9ob_1o8X5w@{kBZOZuoK*Q>MPZW5ARz6rkmZv< zE%!4d2IR>Ub;Lt6%iXCnH5k>Ru-) z)}M^e`|MkrG{>w%CmZRNz0C>XY^N$fMomiC>Pvk0gfv4x#J=lUsS+tg^+3||`hx!B zVni?hztI*KIeY>+n2GQon-KECWCb=Mgy@yo`m46Muv3+9Y(zj?{M?9YKeYu5kS@8g z5&x-zxJ;!3O};?yHi(lQ#CfS8ZZ7`^uJ|XNP+9raf7HHw3&%$*56Rv=f>o~B{8WB3 zV*3ld&;GYfhPjoMdOdTBv@}O1ei|DU=v11iaUxsi&NN?=jAHQ@P>bwrtt{#*P5Lh3gNnx#`<Le5&o! zlaEoh62MCnz=$hq5 zqe#(NEt5Uf#Bp^fQ8=W?R(ekC#VkR)2x>9heUI5kEvk|v1sP>W-tQ*5q4tds!$18C&D zLL;1q2MjGuQMu1e@p56piQfPvpdGL-JL;hjkPt;KuXLFbylz2;M8di8=ryeZa03_4 z-bIxykQ)TZxj>gSEf$w z-n7*eGbwe7uqSGrU=-+~%*T?FgyI)Gt7fhbZNvX%+D@WI5> zI*E;i+qmdsZrg}#^NcjMkL9&WOUQ)kCA^@&G(NV$F7;I;Gi&E^=ZA&p;W_V;+Fago zCw9f&P0p?E_VSz*ea7go|Md-xQjTRH*9-A_brK>FyG6#5K!TyNqSpfdm_t9o>G23p zDHTJp79<57vdmro8oKv)n`0KHP(0cG&LGQ3=v0d|?0q4eNrJkVn$$pbkQn<{y!{?w zy@9`LgG{?*4+>@AHS#xv^RapyBl<>f>r`!-kt$*y1%Fy!Nf-mM&QKO1*9sb6rG%oF z?F?zft>2l)lT=AM;m<*}wxYPcUn2I5G)Hds6;J)M>uR7lzuG zHv6mNdL;?f`vo}-0%@c(LAK;sq^VZW8M1!1+c1a zX4kwf8|NfaK7k5x*z{$T69w6J@>zP5Sau4NppGz7hbSK-95NO0VJ9W6)dix3e$P$q zcPOou5(%%FKBwU_dV}$JiE!Ne$T9x~jle&Qsp(+IHnGlVYK~*)zVWdhEqc`%&h9Hs+W_k5 zE7|j(-n{eD*{*)i*@ zl_%DTliiBLp(E8TMLP{t=0&pW-w|xvH(RJ&An&2#TRF$Jl-wgkA5w75@s&Il+$c0M z9orE;nsd`)#LEb*YNvajn4IUdRzlnai@rVnVR|uYdz`&2cu8wMwz(<$S+gK<^%(E! z+cJHAC0pUx*Oqo>&sHXLarOd-ldw>H2a-4^M`E2^1HIGz8dFT(Nra`ub*zPgI=Py+ zzqM&R2$tJ|ehA~dTbq(lvpx`HvctQil$^q#8+~Q*UpbtYiQ22G1}xetJj)+44zdZ5 zZ}otU@$^c@eNWV)hSDq{-~3Q7Z2vzeYT2)Ivj4?IEjLgz%XP&;a1j^+Dw2LI|HW7P z6ZG>3sZg3&9O+UeMB9sn$kiVsj{4tsI>D&yYYsE&^bZ}a0O?PhKi~15T0Am-1pg3i ze@JcS)Z5SXL5b=EZ`phx<7!w~5T%RW;1#si6tz-W@`xHXSvHjcmbHq+qd5Y#8p4P0 zQEf*ZKU2d5M%|i@@B9!_1+mMPPJ|@5~@9>F!&e%i3d&i&Qu*<0d@7_X?S_ z-!;K}pr1LHfS{5bq5I}V@%Z60_-DqAQWme49qwA2!b-K#`OJ6mNEa4;cMkfYzv zgeInGsa**MGnIH*1eZ`(#36^5)_N57K=H%0Gbcfd`g=*?xlx8Pqxw&Uvh_svXBW-Im{-R6ibtN#)x58j;;%N#zNNg5=(*J_OMf%Fj zHEPQfr~DoBf;TLhzppy}nLxTKVPgLWMaLKM->U@DjiTfK=IQ^0>M7+%Ll{R~BXIY; zUaC5sJ8llvq4ybhd|Y4ggNmN$cXSogGA`jj5MPHhA_}02Uo4E*#0WZ^W8C{tYQhqZ z7JbLAz7nEwoV!DshjM;fmq(QY7h`_dSfPnk1byKEml`QD{xxB$cd91xi_MV+DXj%h z8E?*TTB`dq)GNDG<+|9_V>I-uHW?!AWFg^Lj^gL8|18j>uBuJF25Vf#Lt5DSPYiy@0Hl;%c`@p?o4T625_^S?oH zf%@PBas0m7F@LaGO%BuQLlyA2wKn152jVMK23w!88p&$X1i-%9XMTvAdb?*j5$R;` zc@avw$l9l8NA!!Ge}|V3vC4z`5dQkJ$^&**1t*M zjcO%2b_*)*0OYH5YV7)_?%`)JJ9tA0awtAQHF=V#n^a~mt0ix2KfME-C}@U<*bD1Sn@5`gdv0K&=Nof5cPbDD9YlI7WVZF_X$yM7@? zxX{`rHxLX22e2>4cL1SdByr$!7e&Kl7d?6SAl!?HG9o70MalT}om^&!0S>&2rywzL zf4t&GjQG017$6h+-k^Jdav*B(bNTPMg+EDx`CA{+U1kb%M{~5EDL;)x^oZ+unzxDZ z=8+yaJXt?@LV+TvM(t3n-3Cl6V?LTvjexBCFdtByPzxGX>nq` zpO7T^Zq`WWz`dV%;f2HpW8p7rK-z$NRNS;l_ZAqqbT3sW#M(ihl3lJ@@%6H<{en}o z2U_zP_(8~Ip*Wg0d(mCI@!_XUQuDO7dubd;GH}L`V@6f{_nWhy$;$f*4JsMgxf^E5 z@x(uwqFAzjgGCTy+xK;#63ZO7OOO5ud-Lw*$ta@eSaFRA`+KCZt)sy4SJB$S)r8A3 zbWfe$vq4QCR^aT)BPhZaZpaE6R{Q6~wY{Ldk^~ndw7-T4{%Nlr3c+EG%ZdVk_#24)24MZ|0e^$KK9?0EcwI$!Z9j4C3E=uJfNO(a3~_8Z z-L}Nvm9o|iNQ+8bV;2Dv?FyHd<&zHX%&sPEXqR6%0BhKbd@O)fwx80-v{D<+b6g3T6001aSAD;-UbMJZzwZ7FZI zvmBnSsP4x5&e@N1fnp5BTz5rQ#%&iW!ud7%cpYH`9@ywHD0CF4*V={mKRy=dT|5up z#}IgU@6p7Rn?r)Q$#8U+WW`;S&}ICHaeKS*dpJo?SGo~+*LJBem0Z;mFhlqW8%Q{- zBcY?}JR-|Kkdnn0!>c*Oz47L8t8#fyY)lC0{xWOyq&iiV^ zWJ7h2q_Tj>*>tnFJGlhcAfok1D%63YU6Us)hrKeecPzT;T z6Hve<>F7dsLGAD80yGzylL2KoWR4DYouLleU)8;W3OV>bRymjUG*xrhh*U4JZk4vt+g9&6*!q7hfZW z&4jIY+*~%8Y1j;7_glpld2^EK!7%N5S*2cUSYo0K+0Jp+_G^7M?ziNV zOgx_PQ=a^#j^lR$^HZL9>q!j0c+=-~&i0VN_T?AJH7#l7-!}ZEJn=+-Ems-;@@#v> zY7E&yqDf;pVdM>@@Wy-UGGeVh5`OnA`E_OYWpfv#+@hV@$cc%t`>)s+MbKY+Oja6a ztPze6JBW)H<%6$lm=b%`>c>dS_@v*`LN9sl$`iwSPe0CDYSP$v=?qqof(*C)5ND>^0r`6w>hp1#^T9%x;tVeLkYF`r1Zs3jc$zCAU2nOVAtz zV+lRoBinf@$?@(la)Ygzk)_tHeC2?8CDPpjaV%~|_9XC)=;(wnll!Pyy3TZL{zsH7 z7Lh}iB&orMbB-?uh$eo1@r;2|t+b%c0yG1jSbaXmPf*+5(V9`#m-6K2h@J~sVs#aJ zlad=W3;U_^KLV0u8c_KiSJLFyZ2LuGFEI93@$p@q!(qaT0O)pfFu9Jm!D1q)nK`<- zxtg2US=_AQ`Y(*~fxJ1&=Smp-5JDDY7ZW%DQR3zah!&~qaxTC^_$efS#&?dNT|xhG zcl;+&(74e8d3F$c22t*)mnl7&;W_`b2GT?muTARZ+g?E~mTy5je-ZAP3&qGrUm(%=fl_Ql7{{t?bYN>Uks2Un!V!BI6d zZU5YX#wm6-pZLK!BlM#?&t&w6Qxk`uE|}@TyH{(Pew1?~el$ii1_z}xl!Ah?G;`Lr zP8zrKe7tM7r$UJyQ*@bum?>=%pv5qb8dqdi>evdI|VHJ-KBCb*W9z418=&&#GBu-h8iQo_d7{ytacOSgD1mdmRfrq|6?E5Lb z+A+Qin{hg>=EvM_hSb^nme4HzeAq<{r^=BrAvSxLq5$oBj{TJba9R9y;9egb`co2U z1Cl@;kOTr(k^mBdQ}gD>dEv*4{wfN7a%TLPP=7hO{)T;T;dq((C%ZEAuN`%Ep!$*x zsMrO5E@JLCm;aJ${0VRG`|->`=X)zmq>I6nhD|qCgG{ z_u#!Yt0f`wy^HV%G-kTjM+|w@7WI{)n7=Aha-Uf)^~L1!;e*vALGZ;RqI~6L z8778KJ5UgEM1>`O!9)^k%r}3+t%k`rW=O;ML9h_3k$nvhl1>%Md9j#7@FVXlSnm6# z>7J`Npgp74jLXh4hP3ElUZuSIQdzv3^R_un4y zH=Z}w0=?}btATn9y>en^DgoA~*n147iBD;*o(v5V7)q_QROAj$ix5C7K9<{*b<|L; zq{`+&STlELU}5@le(P>r^NI7jEy8M}NL2hqe59#ERe6m=U{2rv%ic|@( zt~cl^6clrLt1q#o;mubKmD~=Yg}NeCkv?EoHQGO3>?~KeE?TgOdzqGpT3aVf=36RT zU7P-i_+{}@VqQyE@beG*v|%VvcH`fsvkW%ERBITqAxio3ZQWMhw|{O>;3O&1SKu&u z2+#V!(!e9Ri`X5rXnb)82OgbkyyOFwvlCN_CgLP+)$oD}qv74<@u4Xt&W%=R%Yf{@ zC5}q~qPRLbSh$#6MaM6FZv@fmoRpvN1I&6zz^sS(Zq|eUlG(oiAKwk|Ny@OH0^q!? zzl2e{JoB{+4vC3&^}rP;H!u%;grIHdZIaJ=PhlmKxHreJ8qIF!H_9! zF@+Ah?(7b91SmM!tY_NyM-2sjt!DchDCxclJH~Or){-NheEj(-4QM^VYIcHog!9EAZ{C|? zoVsFGAFjTVA=D~)#=_>h&n=8eZGn=Q_;GD}c zq9-_|*yB1as1CDaeV|-p`5bYhT&f%8y1kCPgWKp7)8SXGge$C|2-~pUAAOdgiXS4j zJu%_iy7QU*E)48Dj4E<6CsF6X_X26$P5FArwsvWx@!rSBTcY)fick8Hq7$bkCDIMo zMU~A;_YB(0F{XNN6|!Vt=|bPFS$}IbU(fXt3NC*6eMb6$Wi?(2LcTf;C&vh3%a}g_ ze+=R?c83pVO4ON?>|Kv^ol0iqznirlHm(=LgD$LE3wJYqKnGxz3Bw0tJbQP-Jz3#S(&pcys;OPk-kTFGXQq z#Y(Wwq+Y#&7KY%rw4`h(lsGlieMD7t0qlkZ83{Yf0>(@QhFbXADuxYAnuxXUwjzV7 z1ZrEU3NgE~$hirxpGHRb^Dtgx(_c zU))``q{E>el1t_-_%sMV%-x3A^!}E(c68Iu6ZktqU)Z}C!#dXu(+|Qdo^#N*vxZOB z_4PnzoZ2O-B%=|AA`%b^A3*qdk9DY+(`D?BmIMbr7)bs`#o=0RcWnES?t@XM;Bu435)a`9)g&r@tdSX>wsN3~h2w6fpDom9PAcbmcR6hm z{6=hJiDyU{x4|>e=DT=dT@Wl@zkEea{~qT_Bv+)##-g)UaJ7JQ=7LhQA4y=Q$Q8|H zPGBe~F!;BKU+7g)E;$rn00MQMu*M;7;A#*MKmPceX-bec>Ubq4^8y_NA1FjSk4UyS zNRWJK56Jk%u=v{pZb-vR%N_z8ERo+8CR0@oq(AnxT%Y>*ZH(i7n0e*~R!l8a44qu; zGw&F_s!8nw?`$rF?2L#*v&FSWzM!!MFJ{MCOo95ZewrzWU(_=P#1$O`J_=zs!_Z`W z+KziU*7^j*Lb}!E)vnyN>iu51&x@uHtV*}II)OAG{617tbhJNwLi1Q*;U_cuN%K#& z^ty1(${+8eYIqyLQ4sDorjlSCyxG%63#vpA#BXWVD}I*xZkMfbk=Jrc8@g-5jDQ6p z*(WT4u_9t&XB}_x?o0Zx&r^{EepT;!Mk8?TeCfrTBA)I0@v~U7CDhrzPn-L&!jgA? zfC!;h7VbEG$AktbvhlWDk2joF5&qzc`W#9dei{lQ2|;MoeKsGBBtUR^AlH1Dqw8VU zyrTF5e2-$QK^O|glV;Q&XtWuxoN|F(;k;+Gp3m8QNzc#lZ91mwgnb4&t6D)Mehv@c z`kT1x#;zqPG@v_>`{?kb4#6}W!`QRqI%~>OOi%=}UuF;Kvo<8d~v3(nxxVtX4n!Dr05k+k;@t290_^6pC7PhNy z-9E8xN(L4|q?5?u@9(;tZtX}}VODkz<3FIKNlW$gC;7xA?7g`&qY(Khxouq7hmdk3 zw~`pgMNE$DqmEze@^hNzr-zr?0QtI<(#_T6(yo%pnzlUup$QZOy;H{xG=K>i`@l;NLZ4+JDyF{$b{g(1Zxs zc_!VgXH(*fhI6nldiW5mWHQG3-VTm|;z;k7Y zVS=tm>xePI!M{O4gCK$be%k>ToicJO&u{~wPdyRXGCM@}G}Vh&S{IXJ@V>_PAPLc! z_hie{nin*JCulf3;41M=5l+c)q480E>wVlkXem4;PcRk;BdSXJk)|96w|>dVg-v`} zF1aT(aY zy9`xpLO-@PdlVkBgk6$i1@t%-_=_sJ4~ z1tC8X74W zHEN_?LCN{9qq~W@jq8QWa0w+k#^bMsKcECX2KWm@Kw_=-N=rcTzf_L=9Zfd}dWtGs z``bXuTjj2!=Ecd$b1^JcC8Tk31-m)%#*5y8wR`v59lAU zP^sUh;yok?nbMZ;%cT`f9?A@kX!`^MsRx#)LgEDFHs3PFU;Os@Em%D0nDgM0Rm({{ zLhFcqErOK#{S9|PpUIg-+gozDE#t9`7QFmPLxLLIinE?tYz!ptbSz}F$x{4^jr=lK zCKT3#-HN*G-fhy$hA_Zj9jh;mzPEslG~>Z|JG9>BO(r6qv(cA@`_b9r4Y4KLp*uK! zw=bmj%On}%d<>f9P9*oa1)q>UY3T}NLM$$7qW&6B2m&X#h$xUj1%aajO}xm!FZ_3M=_YM}p)>Fl z6gYN$4G0KOU>8APyQ+nqjfsQVMS_;h4IuFNM?2Ai%+!<2#KDuy$;1Un!~i2K?*f(z znTeU1g_GOW2`n#90Gz~u%*4sb4(P%+wX+}ttQml)#KoKpu$_SMl)!?_%+bNz=CTp^ zVyZ5X9cCiCs5$$Yb9Mp(Wo|$n8qg?war`g$^)owdL8j~oT*Z?GMDgQYf#cxZC;`0w z+*nNQZ}=aPa`qde^mQ=!>wJ7g+sXHB`?h95fu$Fp9VJv?J}59J0PF9L$qu}q8yNV% zjaTlg4-4?ea{XNJVkfPARH>$|9QnN3pBW0yYnLfF zrQA1JCS0(=LwR#5rJSYsZJUa;vEt1>?b$l3+A~*gNI^G;C7dT~c`WVCnzYJ{ru9v7 zL;@Q6BE(cpL1a<}W;mAYQV{m}tpzLI5++s&u*ZM(E zmsWKs!j6*nQO;NUALin;tKzMazbW5Yx*xb$UldBWE2e9Jkx@c2S-6N`Ti~A+MnAY4 zt}wRVF~8(B#7!9?>&AV2Df(}=Iy$*n*xLa6*39fu2S}LeAj|&H0RSR`z`p{&Ay+y8 z&MlcbqD$CI{U(<)NaBWf@DKYOugevYaBucGDqme4An(3pwYhF|WCyWx0-_w4CwAHB zc)9#nUFIJ!Xd{CR39&OEhq67nYWM{ndi7!x4VZpOr_qNMTvR{Fndrw@-NQ0kj=?Wx zWszPg!4tbzGQ`u?STVq~BsEX4WL7K4!g{Y=>BAmsuC=^|%bg@*MLf}@d;L5D@$-)@ z80jw=w0~w2fMO`G*XUeaG%6slHruba$4e&!{wltH-_Qs!a15c+Zv>$rA-^+dz4( zV_|0wuoSsph@lIs;b;2%AV3U{O#4A`J424%C8&dUz(E1AlTKe z@A>DPi{EUC|MNWhf9|dS$}iNrq`p&)<#eD{y$n zo!4xV+qm$tp*~nZ1*?w#LD(_1SmHxRmBM>Z}AOwcz*n-LTrMo$%wemaB)RT|j1P)6`vOjVPn}I-)5es=~=laTg)kLJEXH0!IjJ1oRf~G%HN8LK} ztciiOU4!WEZDZUJ2o1hSf9NYi<8SGDe}~ymn5G+n%{~Kv3u5Gb@U+%mHhmX8KKP~$ ze4S92%=%$dg1T?E#X!w#VzA5acr&WH`p zb5=rSkkXGg9~pL!w=`}(bYyqijSpgN3=;Kv&QL?vGUOuk+_f0-@m(Z)iJF+il1Dt%SwpedQYZ_{!PBwlTO!~d{j^1~^oZ$_PYZe0UfcRIZrQDbjxRYB5SxALyg5hBtGS%F5&`90ZLi>z{V zIbHpwkU#`XFh_Go6O*f;6T&`Khv^To0MJndK>>ppAql>Vh2P1eK;Ac`f|TfWMJyZ= zhLnqi31BIaDF8N=^<}_`?Yqc;MS=yW*MJcc=4=EYybIVPAfbz0-o-^`;oA53&bJ1M zgeM{*awFXIGevRfM*!;PW>5(zul-p-^S^p?e}Z(FNRH9O*^=?X>bq$?YV+>;A>D|;|-fO3msq?d$a?)KL3J# zD=5!@2$Wm(Th#t<>U6y?Y+h0*H;@a6H;X%qGnDYGr(TDVR&EH zgkHAH0k6wq4+Z_@m6yGB|KxRlW3a+$o741rolP{s_{g$GM*BRBKX2mS>9%IgPXcY^Z6M@ZI_bnUbr!|zi|z;?3aU`*5>v) zx6qf&zIXaZzDQ29cFx(hwQ)i+`97M~ZAB?SNNs_REJkAeqR&5Q$D;usHludiPJ8R@ zWwC_=)B)j?z??32=ab1D9cd7`1*F~j3c2h0W610|p66NEc(Et-5N`^YiqJ5b#unjd ziYbzfkKzp7#-66BHSQK!&pmZ$eQQ^qgZiX-&HA(EZt3m`%re;Et+^DKUFhcDC@|9MV)R+z2Aypyt-y75 z3?#pl-OD>b5%pT|C+r{EuAw_;Sbb7iRtNR${Gh9{ZV`X9-%fZp%6OVDdh1z^2}rcvJlJHQNMh=G-?dowNH1 zlVLvcz!dMyVP^CrJbwNe>dC{=+Z(ws811({#Tr zu@~LJxFhB$=bU)LNxXsS&>P^N!fID%@owe2xh zV*M!vzXlcmQl1+a|J_#(2L*-(VEx@0vhU>D{M)|ypuZoQg04GKoK+4xv7$6JBjF5U z_a|h5KWK+EGFT>8Xga2r(qO)ho0Gy77Spx&|Ybg%%TDK|r(V{QdLq?zcyGPG0}e@5`sJ4S@V6}GEf1wziXVj$%|p`awf#ogOh?VBpN>@|3wRiqF>pLQ8wf&v ztezCMU%eJJpf}tLV(ob#Sv`P^UWFICIh-wIfW1sNINKKY*sgyVNy4L&e=Q=8c;$t; zZMb)lpqSgqCo78V(Z+aqV~(O}?<|PsN7M+0Jx282Rk(qX_JR0AlfnAX zu_87EHevypg)in-qT(ZI8K2S^51{Vm=0F6;;03ngMu=e_+kYWO%hgR6H=!i=dUrZ} z)4agAfca&j3=RYXB+4Mbq5fi1XkD2Q${e#bcM1uwi{d5NK~hCH9Ftiw`q&q9_ApRzAiwpE-5lXI z7wzUsbHF$0i?-UfE*PSMUTVXwmniiSs}8sasX*omeI|yM!DSWiSWI;}?IhZwmnCA7?8e+IHYx)fB`B z#lSCb3w)d#?wVy8EWjd3uT!@}lI?v%xrOoVarDQ|al$HliiPqI{^aH_LL0Ow7$&3w zwZwxo)fz*wz!A^<-EwtHck0orA8YFdRPo${=kQ^dg4A!%3zpu~(sT&qro~fQe@xdp zR`u2gNeGE?wioJcXUwX$VqtC`9+90yN{+}d^GKI{H2%(W&zeBtMwlR4W;AW+>U+?2 ztRIl>#Krkx>F~Zvq{3Vr&cK=-4N{QY4&YN|M_ssI;U%_fIAbJCJiSmsn3c^y3F*KB zjvc0-fA?-zvPsiS=+v0>hen2GS&jG0zRIUn0l2k^&ESHo@9TZ$w5@RKwC5g#N?O@v zph;=74{`Z;GQ>UAMMJ0Ldd}MaNmj3*n|3#N#_*M)$LHld2eVdW1Cybs5j$OSlwP`= zHw-IDUDAV(9El%NcXxKSv>-v3(6o=-9r?&$^;%FbFKunmo1icQOJWfMa~ljfNkS~Sg$eLQTbImWMuo`-X?o7Rev!?+-2>)T6qoX`(~X2PeO z^`>9)2+b<**TPcMEH+es6@aL$IcgGX2}4hOLTQH^Q5!*vq%O5xRQWm}DvNfF7=Hma z#>1(XanIL%?%vgGl$?uh=D*lSKSh^`^PeJ>(`Xfa1FXh@whAL+j$=%k&&pqO&3lwtHNp|BwqyQB}+%;HSXXrK6YpF;xe{F4@mAWdZ@a@xMZ_Ybi~cf zDAsS0*M(kzejnI%Cr@&_$G8o=1dsiq}NoG~M!0u8CeZLzt^+(O2b2 zV~+YRWf+P6RDDKSNu|vP+~A(W8KefdsrV;_LvOKpT=TeU&-^;XZ^N{$9Z>}6OTB?u zK+hEacAm!G?`y7tvZh7j&c8rHA<&x7J&nIraE9@P=Cux6h$7i4M~gaafOwgcEQg*HY5G~%8QCeKkmGIUB3F@_2<#J z6}pFs-qzm93v7c`0?{zKf1|xf=to5uW_)pfi*%_gFJ)YWnhIeR;9PJUSsWDD-opXfV`To>{Ai49g-2+xTyoy{rbo4Pgm(Q&cKA zP}G(um6NUY^i65fyg{jZ&9`LP@Q<5g$T_fj0Zn-N<}}vX|J)Ei3so+@wq3merc5H1 zCjM#6*P=^Nj&bcNTHFJ)tiyK#M}&P^H?^ORB0u0L0^uk~l7A%99dC&Af9RjlfT%7+ zIU*+U4^L3y`$fradW;kxvMZ5~|JURG&SB)`xTt{r;V@n-LI3s}`jbsqb4b9kvmf!9{yz-HBxSMBRWg8Ltm4 zN$0h_%{;u!Btr2b&z&^8wv~jJ*`K)ecE_o&bQ+=F%SgK|fKp=e%n&Q~Nm#b6^3>Zj z#TU?(`Ob;y&Xvl>2wj*Nys)7Vg)4aFP8JK~?Z zo^RTV7`f;=!|_ylTIA|vCGs4Cu_CuVba_9->+%7sP@>&{!MCPrqJ6Vu08_lChjCgA zjQYf+&c;@o61}E?BUbaS&i(-XTge&(MvIrDqK?=Vwce*&D+X%goVwqM8v>_5fs;2J z$LEbHUYu1lhbQec>RXVFb5wom1b=cIQ-RHKkz|br1;zwm{oNU|U2~oP?K|KfIFMzJ z=R&AkCn)DpAHh7#5J^d&yzdz}Nuq}ZOUZ2!TlUW5Rf&k5lyR_1*)hA|=d%ME%&q{O zyk_0Au)%wt;pA!a@~{Y@Tn)Q3D(xeWYNq@YH=WLj_|}jhRIr$18gb@YW+m@_rh2}< zCt4Mf;DlyXp8>-qi#N*X)vqF&?PWH+^eVf9v6Z_C6M3o8%+J%i03P{vvF&thMBBkZ z6oDwT%9zA{W`QZWH8z=;KpOW-8E%3JiU?7-)Nu z$o=8F{?@Pl|ED+mCo%Z~0l9UY>4Q}r^I{_HbY9b3nL=!(iKf7WPut#rP-x%N2lF4_ z<=S*q&o{T^ODP*l@M@%a<~!2KQ3#&M=S))DF@Z1z$RMP( zLjhDW;wcx&%{+*1y|x}r8~F~rmUwT(aZIqs4O?x}LXyU0Aq?YjF9#yC`q`&z&Tnf} zC=+Rx_D6dtbdf0(u(@wpKa7YYfeX~Ecy5!UI@CwhPAN#5`c-}z$1J83F6MykVB}=c zeY%?HVUEne0Qi9QK#@&-&KfatdM;UhOIF9Qq&%+uNQtHJqo}$2W8B{;bUKdFjSG#S ze0K>BsQMUuB085m%-fJmyz|K_w|prhasx^7Yo5-04K@Id0Tl*%j5X) z;tP(%0u_glym>4F@LXl~?oKi(w9A0kDpf^1sxPiFsox5>I@|isQ;8N1i|S0^#U>*X z3MW*9&_Rqk=Ym0!8X3I}s{h<+V`ydJ@>R!P=;fz&@8z~mW+zgTry2oX7|%SL*Nr8s z{64c&%q5N$&qHmh>XlK&2M?!y+UzxYr zPyYc9%sat>c_-NapLypu8TjAxPM{bC7f=%(C=LIAl6Nuz`6s0J*AVC(mj@XH_&yvM z5T`(j7`O8*pui=%c4(4saB}QZdlhPY^Ow!#@Vt>5lFWVR3!WzJ7(W@vJ<5L4u5Xeq zqZ0O7vPYV$9ew?=>LyN|bAKHqmo{epS|a2MYQ^KHIV|QH_yrRfjWb!(3l62esqJae zEXbr^i5T8PvmY69^(?+=ra&iKLg?k=9S(%qGUcCBr@kG`73MvM+#xUjc6(f7~kdi86H6Q5lr`MR3YBNtCRA z147`Lsl5m8xP0!&@rZbp3^M;>m|;_7F)THYXJ67P;pS;pM@I#DcK?f6nKV@c~LQ>>5=n^jb27d<=NBEdrCEs$vJj3Ju0mf zt$G#xPjB8gY<7`P?g5N?0~617gnayxLVKp&O1c97W`3HVF* zKp!lu+4XfA9G+X=B%idhsz|+PXgx|0|C8#Y)@)0pX-UwBZz%HQRuSk?UF1PFIc6LfFnRkYXB;Z z7=2vv!EO7pvOL{aXkB$#(aihRxejGp1JS=_yvUzB<-lb~-0RMi(XCzF@3!~8HIv`6 zW9~{+(nmxesD2r>Inbz$fkrL+E%N|_Z@Ry*Z=3G!i^j{U{uuKIhlVKY;{L5h<-}mX z@S{ovj)wm8{qOzcKMGJxx3pN`9uXVUx7pJ75C4a*@^^Mw<5wv7fpiezY_IzG4N{`I zpi5=80RQlQ3A6eZPPLgxvZj@HZPS%|dPzZWjXs{g(6G^4A}pAcyiZ5`sC}|k>Z#i9 zg6?0$qUN5NEpRKov~k*MOWTAQ)KjI!H-Byw|?Iocl4j~(eS-^Jo#d&$E zu5xCro(jeJan5T~I&-+y(kCe>5tn zKUg6aMo2g;BYCKu00G{{$LAhFl4!&CGK@bx{U`gnnji2-Clp46e7Bl1e7fvMb=hxh zqdggyBvB?=8F(ATUaL?Pu67b~1T`d7G>A!p?H9-0%`mpBcpgD?2NA+mgYr@0Jg%`=3en1q{0k`uxP zHtkRPF1Y5Rqr|*@a<8NdzVwAR?fEC3&{Y-neMs^n58+2APtCJ7Y~KW?3=GjMD8DAM z4=N==R;!b|S%xO9jl3i%fLNvnXMee9cg+-LdSh)P%32BI#!vaq@${91T0C#E(JITU z6tcMbAdhW=EVFXMsqm?@FH}p+RBwXk+(JlRppyJ)oPMYF0*upLrqq6!Bs9<@!GR`e z4Tb{pl2LysEbE1*IBb)ay>&$8edD}qg!*@fD+AS6|DQwX|JDK0|3T0A&zi0Z!$3)# z>E7dle@I?U;zcHbIZmHX+DZNL8UhNfO;4$Rh>#9djjjpQf^H~gPHJ|N|MX0jgGvP+?Y{z-+|C;sH><&y!G zk2T$u6XN)q0~mlCMC(uVNH)WMZhsmQ1N*BS87}?CjvYRCXP))wDns2=ZtK4l! zimha1CT6Uy5&OA>lcfqNt1*28X4+$|I>pD_weaYtsLN*Ar{&DXy4B*2RFSA&J)(6L zcNT;8LlfnvSg{#Us{uHGfsw`Ir^!G7S;62yRxsGsHxzq-QD&QfQ{y2cbVgO&g^f&f z-)wF%E#NoSnZS!WpaE6pWSy@!#t=dT+;?d&lN(qTCPN7=U=RbCrwX4g;f ze+3ly(8BUv7EB;4MSM*{Z69_sMQLrV4?*!r)z{~!JwbA*kzmn23Q{jDKkeh|!`(4K zAsa(Z0yU@}a0x|XoG)Gv;E@a~Tvglk+}il1K$ZEDDZpLHH3{nG!*@M48)|t3nq{el z{GiG#qdP~>APIc7grBVEPfC14-+z(t+3hhH{o)Zg0sey3Jd;)ezW~6G{wIoyg!;-PSAz5D12{g9@*;HCQ*!(gxVy1Y&_1jOu;(Q`Swx32V{tD z@>C5Pl@FOJML~3aos+b4S4Bk(=!7}F%+)R)}5#zpot;J-&LO~>m zM1l^te5iKrc)Ey@?#5=SUW%qX6WuA;GmVC+>Dbq30ov_Z9RzCb6D9N_0lSkz`^$&x zAh1wxM8pvW7;R}mME?B%gDvv;!4)KW=o)^tg{V(LA<&X(2=H&D1bp@zzXHp$;kcy- zuLyHNU|_Il0=1cR#3SgDpQJg@ihZ6CtoAH1r+-qDLb}>X+n0WEqE{4%x`%^8|5x7P zwt!0EDIWW)fC^Rv^b{4q7u$Dl!CP}G2?w%vy+_WYtIywM^@m=9f7?}X{4cwTZyIYH zz^EE1n11^QxJS@4AZr{agQwo(GKT?XTb%BAaD3{@|=>Y#erUMq_l_0*zCtdlf z`#$3~a=hOoBO>{ugB~dNeW!?WCk-qlaj*CN*V_`nivu}9zjXfCnEXyv zD1~2=zt3uevv_N&F98-uo6B zYE)9N<_q=lwIC`Cf`cQ&Xc8qlxf`}uI-*-31ldI98@1EtrqeuLJ4GN6#|Kd_(v!QOw_w-$xh^E?wp-zKh;4tG=CZSMCU4*!t+{^?6^+6uZftK|D!@Igp#LoChIRdFzY_Zsjp7Hc;G{%r zTf8pXZfAWDiYhp&Tq9yW!ZORXbc8*^;XRlHfD)~K{5_83Y` zxa1>tOk@f~k@7KQUCu&A_^L(di~K8!3M0pO05znzs=$z$pf{w(E%Z$klPWn)P`l-E zdF0uhPwJ)7EG0%5;MEdU-VCSCThjL7%oetW=Nz7PQDBaHy-W)rl^mTE z;-t{Y+tJDDO>h|%`wB=BiHR+R>wDs)FKt1;l&l@kBm}H8^WucY?!D0w({oz zYTM1ZZDf@dU+utGz<2C-J|6X3`~tygv~=;?Vgdxz-D8uBefxfQ z^Hv1`{I^9lcyx~20S@1P>s_s{-SrH=ac$`8NS>X?~XnK;-0Y)rSb17HpY zJY;2JV`A3)Z+)!4%Z$q9WQtLr)a>RGLt|hX)6mL{wZluxMIZRP=9@LT3wAgO_nUXj zE7LCOHn}FV#XrT(@J8cCBGPIk9N8pCC#()Aj`C?5vXTKm218gV%@-sG@pDdikpc6t zHVpn#s9T2W+l?;YX-nhM5cDUBT1m_bc6|NKrU>g_TAQRgUBjhtzIGI~hUc0w_GYy> z;OIBe@6Zjzx|(_=tW~;CnJDYtV=RlbkqqrJ@3;IC zMpZuq@bJ=0GSA}4I-3CD6CF=ajMgKNXbe&nERa~r_!cB7^JncB65|<(!ktKR%XX9_ zUDzasrXu!JlO52jzcQoWW3hkYyj3>>#!&p*X2M^>lYp&euABdKG z)lfdC!*@Jvdxn9M5QuOnkXVUQiagD@L4Q94}A2V^-qLv5t}nATf2)ph4_Y>#&k8;XhIolikEGIy~x zGj}sEvA44LSqu<)#wz)%Uj-53b&%90IP$_lps$m{^+tiNwJ1u?%#?vd+c~Of&%MJO6_~Vxk};_4jioS($*+ zvw+*iH;&uj^8Vrf`t|=V>RhEjK8%_VV{tKiTTbM|{m3R`oDu!R$oUN@i6zHwumZFU zr53D+HA$vr|0MV)eT$f(52PDJ@6RnsnHuRZKCWDYSc=?)n)KG=b{5LoklK?(FnvsN z4u?gh#Lpa@Ma@a%o!c>MhsicxpAv2qJ4!k|`!roIjRB_NldK`5-|}`EF%^wPdCcI_ zb8_0fHkIWZE=G7a-b!ik?W82 zOrOAoy{t00P8Lhy0BBWDe}HOEcLm=4loxKfMrjv5FtPZf}gHs!PW_p2AYxlHeh zuSt}QdkV}xxIjZCpa-b-Qf+|7V0BtLOt;B=PSEi2MPaEHJ~y<+o*IEQ=l8QdBaAUD z&o`QfEhHip79zAuiQu2U6cF_EsLBV8dzZlngOUFLl)jePwI~s>)-&}p^aFPkyVaP! zW@HLnXPQm?WTBL0lF;o$C`-6nO9@w#GwzWXLo6IGIO?~!?}7+P`smu*ZVb#D&G25i z%S8>FZEkc%HLG*(=M82bSK}yQ#X3~E7~BMerE`9(ws1i~n9)Fk zeA5#F27LfnC`ei)a4=k8S_TaTX+{H_{|tdHR`t3MPR;vJ%N-%{5?i^m0DtDeZw7c5 zGQ!pdDL)3~Pn3Fj9MF8}N=#NyrSCjpnZl}T4Wc}o^|7Fu99q zM%N=P3y#LDfIsKNAI>TOOlO4{SedI6L83wE98s3<|=P@LT( zst&$7E@TQXa|LJBbcDw~ntVbD6iP5F5_A|$IFs$rs=cpJ>yu9PfHb7?cN~_?qfH%|^BxaAP z{LFqx4@xJHk&21sCw(?M#0uEg<=k%(24VUSx4S$hYk1c#OS1-D88Y!fush=W8{v^z~P z1qI0|9V$kJp^#cvlq*z?o})EHG+`A%hAzD;E`-(K4RTYOw20C*E4NS6&cg-Q;(ovd zx`Tf&A-kkAsgQPP;5N3yQ=xFt_r4lhMNLs?JB8L=5(l-o8HN>6fx8Kri;o|4l`pQz ztusyb?Qegqx{f2ngv0$ZdvZb5FwjO&XKftoce>H7HO)~WjI@}CYv&!N(t~Nc>S@k! z!QGCS#~aS$Uiio;2!aI0Eb3#R)Tq|i>bJ;2!4v$%A?MP3wCP`I;9%u;11?a~@7z0< zkpYm~e>*PRz{uRd#t=BJ7`RPv7d#TE=o>Zt3?8B70D;g_KtIp)&Bw!n47?rRne-tW z{%vgm0?O`rcQI8a5rELG1@Dx${~cEs3ft6mGLkvn#~%DnL)zvL<*waN0hzVVW?FT)@gD!MD*sFI>oXs zd$j$Swu1=4?A(#|yU%#7-1TqDbB9C=5i3YA1YUY-#ktJnp>l@fL^S%pTVu9UOMf;M z_5i-t**MNw|Kw~0TVB70Y_yMO*gz&F<~72oU`_G@V$q}Amv9yO+2vwNM$M+J<|~(N zxJ3c42!-5T#yhV;RI5T&wy9#-2xM8xlfEP|BnP+C4dk|uC8MAp7+nk|hiPD?9EgD@ z`SLy?42x|0_$)Zagmnf))~AsPOY@;895y*1m!saZ7}SSy>JlmX@$pwYmimW0SUf@v zB#RRreEC^fL?Q|UuUf17%|YIQuYZ`I{ZbtD zEM$WCO{{wHG2=2WqSci*6226<2i1&tiQU7;N@4b>yNi6E(v(%~R`qj=U|;Uy_1y@@fnjC3>VU=y|19XrogC`aIrHVH6xgfi(?{el%!E_ zFPVB=ye?a3)Fs?GU4|k4S-JOO0TW?Eb)Rnt?oe2#+1cM+?0;7i|C81hI+wp5wMH5Yq?pAmQTpK!X z(n>-n{g_V&j3cy z5alrjf?EnD=`R3eZZqOC9yVu@2i$)8DDI~_X%&+y9nSt^@WNT0ci@ZuYn}W6-|xt4 zN;35ed6j|4D-T3ojvvUIJ16X$S6wmp+rk3Moc$*t??V99H{>N2`3||aLU2GW6CgkX zrReV31OE|wnYr%N1%6=f-Qj=V1N|NPR)V~-=b-i1l;*Z}Pw>h0!zDUnn{1tbgDC3A zPgxVI)NI5yPc5KFpRX*~~bPuZf;c z^XWecA-7vcsdeKge$GZ>RSPp~&tQBW9H%^mR23T$u^t))HQpMFw3hM$?+MaeD%>l0 z0|h9h<4ix-{Wr*?goq<406zR~u?HGuQ{&syo4Y-r&~8(TTi|{XlKFDxE-!alG9TeM zd}5YKx6#Le|2&l8vd~WXHYVPk%fm^R0%=ft&kYs&jj@n~V|=MX*B-2^G3z_7MpqPA zL|3uy;tD>?%6cCY#srNA``X@>zH1HGv!iK`G^Lh{P2q=ld)>VY(+Spxqm|nrm-LaX zHgV?#)>lae9(Eq@L8mL>fr={fdQnVwZz`$iP(Tl25;v7^2pxLDT&LIt6+8p0vSwGc zeDCw=`PN{-RMK%m(9S_swH2xbVcBP$;-2K4IxP*)HohEDZllK&@DxjU@~xYonQz}c zoXo<)fwOBzh#iO3n_Z7!8}iVU!{LZ)?CvbDJoO+?tpSCvuGD^h;?Mk9n=kn|TR?iL ztuldORy7sNRzJhYy2)suB0w9PZ6)?q8?QVE=}X_ekxVy|0zS@w&ysUYe6;J~pGNCj zeODB^QNwG=QXepd%vabQak5~$qWnN#YasfX{|)+Hl9wUZ)L(dXTr!2#vlF9KJy}=E-#?^zs`1m`1{kZ{qN&%ENUew+v{Ae4-88?^*ip~l5GM$ zVsW}VbJaLsFnP1;v`jNC-*>EM_4A0b0tqTtpYlF#p~r!OOarvbf`Ghz{}&$9gh z5v`bPG-NZ{t00rl5zUe1Q;AQn5fRMkHK-r?2rZoo?9v*oO;@v|y+PX0UFh3etBAH6+5g zbAlfp4(!7rXs?Yn4@r)5zzw0oMR-*4f%{p=oU#)8)UxhI%NT#+|5{6ChJgst^ntz; zR*|>H8skGg*>sTe#wNqSbuyK3Z)tC4)uZFc$6_X#Lk#drs>)d}LFIYT~ z>=6TeVSL}$)P9=MqnXh2&OvSIZMgps<^7UAARz1>`T~2OfNJEoI0%CV_sGPJSQ?mF zn|S=FtpJtfzr8^$0-SvJW2^`q8ioo`rBzi~Oi4vaRaxbyRL?Ih;k$FUHJ)3c$-g3m z-R88wrX?Wx>#qnN|2en%7laPnG8N6@OLMaKo|EKu%DtL1GNrwf4P#qQ4i$^(QwRoM z=d;7Xn;_Bm)rSvt1lCAuhtDS>JXUgpeCd-$4Z4q07AT$>mHGj4>+IM1Ua+K}v@>Wc zSL@aKF#AQYu6ua=CSu9G3j1VY1n2d0S7#~Lg%!45Bcs&6uLs{3u`~w(n1BJ;&0b)_ zENmo!2oXGLTQve5;VBVDG0x6N-~vPO(Dov@GJbi8DO}qg@fx;!f1_Fsj0t3i#y}!c zNm}L+w*A?Z=#=fJpk^D5R`OXj$=##w9PxlKOK$P8;xxGdgSjysbxZ8Km5Xd5eQ0rKT`hI zbc1-?bOUqObhDH(y{nEb^+IcJT2J!HZrkF`#*rERsfl^5xQvy7=8oalz|}tr#t7t9!zHyI&DjbJ>vvOg-o5->@Qo2RkW$+-?&fnW05jKWymd&51shMI#$KNDT4hsu`? z0}0choo~VkA(ldztFQ0eBb4uGh-cVCWT%HK+yze)}T_?mtx7O4%kK~qWXtNv)#KmllUQsVNenV=#W+7;0jS&=IPUoJBn|h1b zm|*AKB)m#6Q1IN}CFkCCSG{{SA&cTrYw(8e#r0y5<-|H5AnJSY5dsJZ^hf`*&%7|p zGx?)47b2`K;@dYENSY6khAeL?Mg0Ua6bmdyf%t{qE=eGXH=2ZwVR z>W^Y;vGE)WaKrk{$dU7K2p=?;Ab~oM>CCfRW%_KBNdr7*XxMN*LCmSXU2K57elifO zoXo=_s;NP4ctm!Pg=`x?tR&;9kS*o_@n(4DTb?=lbKew7VssUXQd_5xtu&GhIO{;9 zqKnrER}ToSpC5%Hb|V`+Ek6vRO}vPX3wGq%Bi;=<2zr}j3)8aqh_bcz&`bHf$6xl_RVMNgaD;o^eAaQa`u;zj6VRzXBk%Ih8xXDDrRK$_6z#e9V4caWR zEyOJ9^y-&1n(E~o$dv?s^Q~FmvP=Wh+x^`;ocpeke3xa48ETAd{d5?R(!dN;99Y9+ z_~tNRY$DOcs|(-`@0$(+&~FI+5#?@Y1Oc4_90L43HRK=CG2jSj_ud6|-QFoQe}^Zg zTg?|>FAqDgJoiH%`R?$4;u3$Ch;^eb7wcUMEiQh_ida7@Tjh06ZJGJt=b6nyvk*nB zRY7m}K7N+n-qL&|S}`|7%M2p>0lA$Hbzo(9-`i-u2^;oX?`42LLF(_WPr2Fcbz zc>?+$wjV&rCB4M&W}=5RLXzFG_!UWAgA(ess@$iJ!A+o-i3tGzU%Mn9d zEMyctqnp=}NIToB)R{}CLb{Km>W9>iDD`4u&0!gvE*7A67*hEa3&%*i;R-n=t!poD zd`h3FuQyMHxVtrr>`MBb&9sr(5Vnu8TWe?^ALikx;C=#s=eo5T*~(ixE-ACtf8iHb zObVtxPpa>`tpm>8 zeNaMPNi`|hK3NWs%rK-5r&T-C9Y+ZO|AS3<@PSle5bK@(NETzCa!jlpWS z=g_h2Rr~dBNzui^S&c_TgW0!4?3Pmfi`13TVOD@ZI!pOUthB&H359A#tjy>i^Oc*GocHCgjIem^kK8c@k%t1MR=QD<6JG$P@q}3Djh-Fm%)Tm zTUj2Y#@+V?VhVj!6G3!Nchy&YponO6KZId%_W|3IXVL)@r*0f$ynTLgx?Q0U8i8*w zjAXU0*`6W{#m*LmmD0m!>F>ClVAPjVpz5?T9zdq znK-yg{(R5-EFSXJfzuBCmYDe6ph>4(zE;Lia>`cQ{> zWY+=uWVjNBA^Af%tp0YjWw`5EAG{>XCqZY;8j2m`cj-;*YnnFrcx#SiBX{?p+e_I} zRiCtA7t|N&)&*HxSqP42EgW}QSiM}efjvDgQE-Lx^zp=cq551ng$Z_1A0-MB;JXzq z4irtA>%-cBd>+|NUXM3|4qYR7k((*>qy=Ks>UlqnKkL`_BdFX(jh+xb{+R2`hbs+D zu;w`U*do6r7mnX&SIJ3!d7%2s;jRH4?h?@9_I^(;K)>1mzT^%n7U8uRBe8-1fvkV) zc>j;{3nk_I0>gi3IQdV@FaFuB{v8nbqnco`BX!Ng)Q*;^Bf1{Er5cwlR|qm#Dufa*@U6-yk9QVaTvB`EGcixHQI+zbg#1wqUebY#a;9`up8avF>Nc|w~qN34^`33He7 z(R|6Z^COEst4RI$rS3k2Y8hSBw=BNSn8 zgPW=a^0<&^!7}$yWfQ$mtRRbZF@uJh%+|KiGKRDQ$7O2|v~HF*oyy2~=t0`qRGnd^ zW~4N5{o>fS6yuOiD1Gqduv!N8MJPwxh4ciAMMY0j-m8aZDiEow6!Cv`He#$+FoE6D z5M~g;m96_gA@TSMf-ru9Qe0Xgpk}Gfz440~#_E82Fd?$h)Q(~El%6WXu68dq3J{$ZKAkd!h zMjSZ@^$|)jL2&9(%6fA#k^<$2Hz$ITl?kS*{v7>SiI*xgf%<@m8H)N6$Wc^p$Wv`~X=o4O z<+A+FK{*r96Gfn5KkFAC;+LXEW~b^FCR;wXc`5+&xqnQo5*x!f78TivnxSWn{LvSU z{ST*N*QB+3jM49A#S9=jlkAFI9b=wGvRAevLJm7bZ57xNSr<4M_RNe1IU*dJp@bu( zqscn5F1JiNESESeuD-O6SH$mWoP zL6v|%Vz5s6$}ZQ8f<$L)kpP~-9FHfkazDr{WFlG7x%y>_fB21`JC3%8v_323Izpd-6Ae@x*LeV=)&Ya-^A4`fuWEoJHKN3<(FXRpORAR+2*>; zszRlUsWZuExMc1DQuT7*&Q`eN2$1b)&p&J} zSMA4Bi8MOfF4*nkK-JEDNC-ANPsCF7*cve!Fi#=yvVuPZ% z+HPW%_1txg?=C9;ZMol3aZ633rfZw~QX95ZMXAZwL^OiROyLlF(;?#G;e*T1he^gig z1|`c8YN`qMSQe4eWKGncurF(UaT{)KKcCp&!u*B2@2b@Zw9r*hbPMNV6$47ORgLga zYRjc0sfRQUat%H|vGc5DSKCKwcQiE*c^idYysCQjY7SEkvXcemWw_ApqbHD)oap)~ zxiU*o&mHJK&NmR{9SIzMizuCLDX}K5-&nY}LOZxJFrKzQod|dU(1G{>_xw!$YR^yq zUhXcf@Pm*KhlZ~#CL%9K{7scZ*#kHU6*$aGM4o|8Rz>s|^A?Rn*#t=20&ZB}RdZcz zfs(MdgT9D?)30xE%WyNA>e=i4*t%@TKx9a)5uq@)0>4o zio+tV{8v6fKNQ)GhGS)q!oMo4=W@SEaye(*D6xVF79A{DGmrkNs$htm=YTW}%}FmD zqEOEJ-0taQ4${byR5;(1F$3o&p>@4_MCOqs(pygp%uvz#*bS(RiWd+`8XiZ)(t%cy zr0x4e$UDIf2ggVoP1tBdYV0~=sf3DFT(2>NM>Wlu7y$iWaNceUv?@_q4IF@p!7xZK2=I-hGFoTVkg}I z8O98CV<`n%z4+=Aup7$A?yxulwQC%+kE$E~xmM|=ZmWt8h{W>`Qs-M;J)qrEsLNAz z=c?sJ>DZ$4pZ9$Y`k>M4F_r9H6m|WC9~v`m)$2XMK8vfbFoSf+<+E_}VDNzawA8kB zjvkd#H6Cnwp*(~O;rW#86-T>QI;)uS%5cV)k51bkskFLVhwZkfqmjS1x5)8B?&mFs z8K_DY%%yoB7Ifeix&q>L?j)Zo{N+3Yr*vhuq@IG?*|$5Fe=q)-r2{Yp29+ z>!JpyI=(CtN`hh%;TzLRvSh_9fEUb~2$>%Dc3}nEoZ|Sb-n;xMvI4a_ zisicy`^?(t-pm%gr3W@_Vr23-?)mO%)5C^NS=s1&Z&vigk|AhIk5*Reob)xo&97j@ zBQAos^tndVFUohNp}91Hc5Dr3S>-o{FO=miIvzZFaW3BiHNM+#?CkYAQ7GNSN#i&+ zmDjR5d7wMAWkk$IY|WNb;JO8wNqhU_?47}UAGdU`2n&Pt(^9~qfL0O?d?A0|Cn1uk zEHMPJS5T1!%}g^&q4{GGHsl_}-J89H_RnT7q5Z?`B{UQu9?FZ#-?l6Nn7u>`czC*5Q)w4^(#8Hd{Wt^DfZP>3Um(~^;~DE-Fpvk(U$*ND0ZhL6LfE(0@(upkD~*B3| zzgM5VBisEd&i?CD0{*no~`28zAwd5vs&|q{&Irp;?Je%wRy?b;QXjK zDiCd>L7*5s=qjfz0>jd83BIcV2OV;7x2p&ufk)h%8SwjKQB>1%%Vbj8{9 z651Q(2fh*FV@X$y474bvu~k(5m)lvII~-Z18_U+UAy^rFv*hv~&)BB)Aol!&N>jn; z>mQuX#P&fr2_867WEW@cXO^0yrl|MEpmM|JwTga)!rCk85+yrMbryn`M~p1EXyDdG-5Y`J(PL zX%(m*Kc7h$(YHPJTh^IiN;?|sv)cHv=$ Rh!iM9rnBJ3075NF{~tu`p4$Kb diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/testng.xml deleted file mode 100644 index fffc1f8f85..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/resources/testng.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml deleted file mode 100644 index c6411d46ce..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - device-mgt - io.entgra.device.mgt.core - 5.0.0-SNAPSHOT - - 4.0.0 - - org.wso2.carbon.device.mgt.analytics.wsproxy - war - WSO2 - Webapp for Web Socket Proxy - https://entgra.io - - - - io.entgra.device.mgt.core - org.wso2.carbon.device.mgt.analytics.data.publisher - provided - - - javax.ws.rs - javax.ws.rs-api - - - org.apache.cxf - cxf-rt-frontend-jaxrs - - - - - secured-websocket-proxy - - - 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 - - - - - - - - \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/exception/WSProxyException.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/exception/WSProxyException.java deleted file mode 100644 index 7937ada371..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/exception/WSProxyException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.analytics.wsproxy.exception; - -/** - * Indicates an error with deployment tinkerer - * - * @since 1.0.0 - */ -public class WSProxyException extends Exception { - - /** - * Constructs a new exception with the message provided and the cause. - * - * @param message the detailed message of the exception - * @param cause the cause of the exception - */ - public WSProxyException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SubscriptionEndpoint.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SubscriptionEndpoint.java deleted file mode 100644 index b556949ae1..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SubscriptionEndpoint.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.analytics.wsproxy.inbound; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.databridge.agent.exception.DataEndpointConfigurationException; -import org.wso2.carbon.device.mgt.analytics.data.publisher.DataPublisherUtil; -import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfiguration; -import org.wso2.carbon.device.mgt.analytics.wsproxy.exception.WSProxyException; -import org.wso2.carbon.device.mgt.analytics.wsproxy.outbound.AnalyticsClient; - -import javax.websocket.CloseReason; -import javax.websocket.Session; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Interface for subscription and un-subscription for web socket - */ - -public class SubscriptionEndpoint { - - private static final Log log = LogFactory.getLog(SubscriptionEndpoint.class); - private Map> analyticsClientsMap = new HashMap<>(); - - /** - * Web socket onOpen - When client sends a message - * - * @param session - Users registered session. - */ - void onOpen(Session session) { - if (log.isDebugEnabled()) { - log.debug("WebSocket opened, for Session id: " + session.getId()); - } - - AnalyticsConfiguration analyticsConfig = AnalyticsConfiguration.getInstance(); - ArrayList publisherGroups = - DataPublisherUtil.getEndpointGroups(analyticsConfig.getAnalyticsPublisherUrl()); - List analyticsClients = new ArrayList<>(); - for (String publisherURLGroup : publisherGroups) { - try { - String[] endpoints = DataPublisherUtil.getEndpoints(publisherURLGroup); - for (String endpoint : endpoints) { - try { - endpoint = endpoint.trim(); - if (!endpoint.endsWith("/")) { - endpoint += "/"; - } - endpoint += session.getRequestURI().getSchemeSpecificPart().replace("secured-websocket-proxy",""); - AnalyticsClient analyticsClient = new AnalyticsClient(session, new URI(endpoint)); - analyticsClients.add(analyticsClient); - } catch (URISyntaxException e) { - log.error("Unable to create URL from: " + endpoint, e); - } catch (WSProxyException e) { - log.error("Unable to create WS client for: " + endpoint, e); - } - } - } catch (DataEndpointConfigurationException e) { - log.error("Unable to obtain endpoints from receiverURLGroup: " + publisherURLGroup, e); - } - } - if (log.isDebugEnabled()) { - log.debug("Configured " + analyticsClients.size() + " analytics clients for Session id: " + - session.getId()); - } - analyticsClientsMap.put(session.getId(), analyticsClients); - } - - /** - * Web socket onClose - Remove the registered sessions - * - * @param session - Users registered session. - * @param reason - Status code for web-socket close. - * @param streamName - StreamName extracted from the ws url. - * @param version - Version extracted from the ws url. - * @param tenantDomain - Domain of the tenant. - */ - public void onClose(Session session, CloseReason reason, String streamName, String version, String tenantDomain) { - if (log.isDebugEnabled()) { - log.debug("Closing a WebSocket due to " + reason.getReasonPhrase() + ", for session ID:" + - session.getId() + ", for request URI - " + session.getRequestURI()); - } - for (AnalyticsClient analyticsClient : analyticsClientsMap.get(session.getId())) { - if (analyticsClient != null) { - try { - analyticsClient.closeConnection(reason); - } catch (WSProxyException e) { - log.error("Error occurred while closing ws connection due to " + reason.getReasonPhrase() + - ", for session ID:" + session.getId() + ", for request URI - " + session.getRequestURI(), e); - } - } - } - analyticsClientsMap.remove(session.getId()); - } - - /** - * Web socket onMessage - When client sens a message - * - * @param session - Users registered session. - * @param message - Status code for web-socket close. - */ - void onMessage(Session session, String message) { - for (AnalyticsClient analyticsClient : analyticsClientsMap.get(session.getId())) { - if (analyticsClient != null) { - analyticsClient.sendMessage(message); - } - } - } - - /** - * Web socket onError - * - * @param session - Users registered session. - * @param throwable - Status code for web-socket close. - * @param streamName - StreamName extracted from the ws url. - * @param version - Version extracted from the ws url. - * @param tenantDomain - Domain of the tenant. - */ - public void onError(Session session, Throwable throwable, String streamName, String version, String tenantDomain) { - log.error("Error occurred in session ID: " + session.getId() + ", for request URI - " + - session.getRequestURI() + ", " + throwable.getMessage(), throwable); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SuperTenantSubscriptionEndpoint.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SuperTenantSubscriptionEndpoint.java deleted file mode 100644 index 0e4bc3684d..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/SuperTenantSubscriptionEndpoint.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.analytics.wsproxy.inbound; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.MultitenantConstants; - -import javax.websocket.CloseReason; -import javax.websocket.EndpointConfig; -import javax.websocket.OnClose; -import javax.websocket.OnError; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; -import javax.websocket.server.PathParam; -import javax.websocket.server.ServerEndpoint; - -/** - * Connect to web socket with Super tenant - */ - -@ServerEndpoint(value = "/{destination}/{streamname}/{version}") -public class SuperTenantSubscriptionEndpoint extends SubscriptionEndpoint { - - private static final Log log = LogFactory.getLog(SuperTenantSubscriptionEndpoint.class); - - /** - * Web socket onOpen - When client sends a message - * - * @param session - Users registered session. - * @param streamName - StreamName extracted from the ws url. - * @param version - Version extracted from the ws url. - */ - @OnOpen - public void onOpen(Session session, EndpointConfig config, @PathParam("streamname") String streamName, - @PathParam("version") String version) { - if (log.isDebugEnabled()) { - log.debug("WebSocket opened, for Session id: " + session.getId() + ", for the Stream:" + streamName); - } - super.onOpen(session); - } - - /** - * Web socket onMessage - When client sens a message - * - * @param session - Users registered session. - * @param message - Status code for web-socket close. - * @param streamName - StreamName extracted from the ws url. - */ - @OnMessage - public void onMessage(Session session, String message, @PathParam("streamname") String streamName) { - if (log.isDebugEnabled()) { - log.debug("Received message from client. Message: " + message + ", " + - "for Session id: " + session.getId() + ", for the Stream:" + streamName); - } - super.onMessage(session, message); - } - - /** - * Web socket onClose - Remove the registered sessions - * - * @param session - Users registered session. - * @param reason - Status code for web-socket close. - * @param streamName - StreamName extracted from the ws url. - * @param version - Version extracted from the ws url. - */ - @OnClose - public void onClose(Session session, CloseReason reason, @PathParam("streamname") String streamName, - @PathParam("version") String version) { - super.onClose(session, reason, streamName, version, MultitenantConstants.SUPER_TENANT_NAME); - } - - /** - * Web socket onError - Remove the registered sessions - * - * @param session - Users registered session. - * @param throwable - Status code for web-socket close. - * @param streamName - StreamName extracted from the ws url. - * @param version - Version extracted from the ws url. - */ - @OnError - public void onError(Session session, Throwable throwable, @PathParam("streamname") String streamName, - @PathParam("version") String version) { - super.onError(session, throwable, streamName, version, MultitenantConstants.SUPER_TENANT_NAME); - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/TenantSubscriptionEndpoint.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/TenantSubscriptionEndpoint.java deleted file mode 100644 index 02e55cfed6..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/inbound/TenantSubscriptionEndpoint.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.analytics.wsproxy.inbound; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.websocket.CloseReason; -import javax.websocket.EndpointConfig; -import javax.websocket.OnClose; -import javax.websocket.OnError; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; -import javax.websocket.server.PathParam; -import javax.websocket.server.ServerEndpoint; - -/** - * Connect to web socket with a tenant - */ - -@ServerEndpoint(value = "/{destination}/t/{tdomain}/{streamname}/{version}") -public class TenantSubscriptionEndpoint extends SubscriptionEndpoint { - - private static final Log log = LogFactory.getLog(TenantSubscriptionEndpoint.class); - - /** - * Web socket onOpen - When client sends a message - * - * @param session - Users registered session. - * @param streamName - StreamName extracted from the ws url. - * @param version - Version extracted from the ws url. - * @param tdomain - Tenant domain extracted from ws url. - */ - @OnOpen - public void onOpen(Session session, EndpointConfig config, @PathParam("streamname") String streamName, - @PathParam("version") String version, @PathParam("tdomain") String tdomain) { - if (log.isDebugEnabled()) { - log.debug("WebSocket opened, for Session id: " + session.getId() + ", for the Stream:" + streamName); - } - super.onOpen(session); - } - - /** - * Web socket onMessage - When client sens a message - * - * @param session - Users registered session. - * @param message - Status code for web-socket close. - * @param streamName - StreamName extracted from the ws url. - */ - @OnMessage - public void onMessage(Session session, String message, @PathParam("streamname") String streamName, @PathParam("tdomain") String tdomain) { - if (log.isDebugEnabled()) { - log.debug("Received message from client. Message: " + message + ", for Session id: " + - session.getId() + ", for tenant domain" + tdomain + ", for the Adaptor:" + streamName); - } - super.onMessage(session, message); - } - - /** - * Web socket onClose - Remove the registered sessions - * - * @param session - Users registered session. - * @param reason - Status code for web-socket close. - * @param streamName - StreamName extracted from the ws url. - * @param version - Version extracted from the ws url. - */ - @OnClose - public void onClose(Session session, CloseReason reason, @PathParam("streamname") String streamName, - @PathParam("version") String version, @PathParam("tdomain") String tdomain) { - super.onClose(session, reason, streamName, version, tdomain); - } - - /** - * Web socket onError - Remove the registered sessions - * - * @param session - Users registered session. - * @param throwable - Status code for web-socket close. - * @param streamName - StreamName extracted from the ws url. - * @param version - Version extracted from the ws url. - */ - @OnError - public void onError(Session session, Throwable throwable, @PathParam("streamname") String streamName, - @PathParam("version") String version, @PathParam("tdomain") String tdomain) { - super.onError(session, throwable, streamName, version, tdomain); - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/outbound/AnalyticsClient.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/outbound/AnalyticsClient.java deleted file mode 100644 index 96e6d6974a..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/java/org/wso2/carbon/device/mgt/analytics/wsproxy/outbound/AnalyticsClient.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.analytics.wsproxy.outbound; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.analytics.wsproxy.exception.WSProxyException; - -import javax.websocket.CloseReason; -import javax.websocket.ContainerProvider; -import javax.websocket.DeploymentException; -import javax.websocket.OnClose; -import javax.websocket.OnMessage; -import javax.websocket.Session; -import javax.websocket.WebSocketContainer; -import java.io.IOException; -import java.net.URI; - -/** - * This class holds web socket client implementation - * - * @since 1.0.0 - */ -@javax.websocket.ClientEndpoint -public class AnalyticsClient { - - private static final Log log = LogFactory.getLog(AnalyticsClient.class); - - private final Session analyticsSession; - private final Session clientSession; - - /** - * Create {@link AnalyticsClient} instance. - */ - public AnalyticsClient(Session clientSession, URI endpointURI) throws WSProxyException { - WebSocketContainer container = ContainerProvider.getWebSocketContainer(); - this.clientSession = clientSession; - - try { - this.analyticsSession = container.connectToServer(this, endpointURI); - } catch (DeploymentException | IOException e) { - String msg = "Error occurred while connecting to remote endpoint " + endpointURI.toString(); - log.error(msg, e); - throw new WSProxyException(msg, e); - } - } - - /** - * Callback hook for Connection close events. - * - * @param userSession the analyticsSession which is getting closed. - * @param reason the reason for connection close - */ - @OnClose - public void onClose(Session userSession, CloseReason reason) { - if (log.isDebugEnabled()) { - log.debug("Closing web socket session: '" + userSession.getId() + "'. Code: " + - reason.getCloseCode().toString() + " Reason: " + reason.getReasonPhrase()); - } - } - - /** - * Callback hook for Message Events. - * - *

This method will be invoked when a client send a message. - * - * @param message The text message. - */ - @OnMessage - public void onMessage(String message) { - synchronized (this.clientSession) { - try { - this.clientSession.getBasicRemote().sendText(message); - } catch (IOException e) { - log.warn("Sending message to client failed due to " + e.getMessage()); - if (log.isDebugEnabled()) { - log.debug("Full stack trace:", e); - } - } - } - } - - /** - * Send a message. - * - * @param message the message which is going to send. - */ - public void sendMessage(String message) { - synchronized (this.analyticsSession) { - try { - this.analyticsSession.getBasicRemote().sendText(message); - } catch (IOException e) { - log.warn("Sending message to analytics failed due to " + e.getMessage()); - if (log.isDebugEnabled()) { - log.debug("Full stack trace:", e); - } - } - } - } - - /** - * Close current connection. - */ - public void closeConnection(CloseReason closeReason) throws WSProxyException { - if (this.analyticsSession.isOpen()) { - try { - this.analyticsSession.close(closeReason); - } catch (IOException e) { - String msg = "Error on closing WS connection."; - log.error(msg, e); - throw new WSProxyException(msg, e); - } - } else { - log.warn("Analytics session '" + this.analyticsSession.getId() + "' is already closed"); - } - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/webapp/WEB-INF/web.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 933cf86531..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - Output WebSocket Proxy - - - ContentTypeBasedCachePreventionFilter - org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter - - patterns - text/html" ,application/json" ,text/plain - - - filterAction - enforce - - - httpHeaders - Cache-Control: no-store, no-cache, must-revalidate, private - - - - - ContentTypeBasedCachePreventionFilter - /* - - diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml deleted file mode 100644 index 9c784d0af3..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/pom.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - identity-extensions - io.entgra.device.mgt.core - 5.0.0-SNAPSHOT - - - 4.0.0 - bundle - WSO2 Carbon - OAuth Back End Authenticator - org.wso2.carbon.identity.authenticator.backend.oauth - - - - org.apache.felix - org.apache.felix.scr.ds-annotations - provided - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.base - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.core - - - org.wso2.carbon - org.wso2.carbon.core - - - org.ops4j.pax.logging - pax-logging-api - provided - - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.application.authentication.framework - - - org.wso2.carbon - org.wso2.carbon.core.services - - - org.wso2.carbon.identity.inbound.auth.oauth2 - org.wso2.carbon.identity.oauth - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.application.common - - - org.wso2.carbon.identity.inbound.auth.oauth2 - org.wso2.carbon.identity.oauth.stub - - - commons-codec.wso2 - commons-codec - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${io.entgra.device.mgt.core.version} - OAuth Authenticator Bundle - - org.wso2.carbon.identity.authenticator.backend.oauth.internal - - - !org.wso2.carbon.identity.authenticator.backend.oauth.internal, - org.wso2.carbon.identity.authenticator.backend.oauth.* - - - org.wso2.carbon.identity.oauth2.*, - javax.servlet.http, - org.apache.axis2.client, - org.apache.axis2.context, - org.apache.axis2.transport.http, - org.apache.commons.httpclient, - org.apache.commons.logging, - org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.wso2.carbon.core.security, - org.wso2.carbon.core.services.authentication, - org.wso2.carbon.utils.multitenancy, - org.wso2.carbon.base, - 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 - - - - - - - - diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/AuthenticatorException.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/AuthenticatorException.java deleted file mode 100755 index 38cf6b178a..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/AuthenticatorException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.carbon.identity.authenticator.backend.oauth; - -/** - * Custom exception for backend OAuth authentication - */ -@SuppressWarnings("unused") -public class AuthenticatorException extends Exception { - - private static final long serialVersionUID = 1L; - - public AuthenticatorException(String message) { - super(message); - } - - public AuthenticatorException(Throwable e) { - super(e); - } - - public AuthenticatorException(String message, Throwable e) { - super(message, e); - } -} diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticator.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticator.java deleted file mode 100755 index b1d41dd9e6..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticator.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.identity.authenticator.backend.oauth; - -import org.apache.axis2.context.MessageContext; -import org.apache.axis2.transport.http.HTTPConstants; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.MultitenantConstants; -import org.wso2.carbon.core.security.AuthenticatorsConfiguration; -import org.wso2.carbon.core.services.authentication.CarbonServerAuthenticator; -import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuthValidationResponse; -import org.wso2.carbon.utils.ServerConstants; -import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuth2TokenValidator; -import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuthValidatorFactory; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import java.rmi.RemoteException; - -/** - * This is a custom back end authenticator for enable OAuth token authentication for admin services - */ -public class OauthAuthenticator implements CarbonServerAuthenticator { - - private static final Log log = LogFactory.getLog(OauthAuthenticator.class); - private static final int PRIORITY = 5; - private static final int ACCESS_TOKEN_INDEX = 1; - private OAuth2TokenValidator tokenValidator; - - public OauthAuthenticator() { - try { - tokenValidator = OAuthValidatorFactory.getValidator(); - } catch (IllegalArgumentException e) { - log.error("Failed to initialise Authenticator", e); - } - } - - /** - * Checks whether the authentication of the context can be handled using this authenticator. - * - * @param messageContext containing the request need to be authenticated. - * @return boolean indicating whether the request can be authenticated by this Authenticator. - */ - public boolean isHandle(MessageContext messageContext) { - HttpServletRequest httpServletRequest = getHttpRequest(messageContext); - if (httpServletRequest != null) { - String headerValue = httpServletRequest.getHeader(HTTPConstants.HEADER_AUTHORIZATION); - if (headerValue != null && !headerValue.trim().isEmpty()) { - String[] headerPart = headerValue.trim().split(OauthAuthenticatorConstants.SPLITING_CHARACTOR); - if (OauthAuthenticatorConstants.AUTHORIZATION_HEADER_PREFIX_BEARER.equals(headerPart[0])) { - return true; - } - } else if (httpServletRequest.getParameter(OauthAuthenticatorConstants.BEARER_TOKEN_IDENTIFIER) != null) { - return true; - } - } - return false; - } - - /** - * Authenticates the user using the provided OAuth token and returns the status as a boolean. - * Sets the tenant domain and tenant friendly username to the session as attributes. - * - * @param messageContext containing the request need to be authenticated. - * @return boolean indicating the authentication status. - */ - public boolean isAuthenticated(MessageContext messageContext) { - HttpServletRequest httpServletRequest = getHttpRequest(messageContext); - String headerValue = httpServletRequest.getHeader(HTTPConstants.HEADER_AUTHORIZATION); - String[] headerPart = headerValue.trim().split(OauthAuthenticatorConstants.SPLITING_CHARACTOR); - String accessToken = headerPart[ACCESS_TOKEN_INDEX]; - OAuthValidationResponse response = null; - try { - response = tokenValidator.validateToken(accessToken); - } catch (RemoteException e) { - log.error("Failed to validate the OAuth token provided.", e); - } - if (response != null && response.isValid()) { - HttpSession session; - if ((session = httpServletRequest.getSession(false)) != null) { - session.setAttribute(MultitenantConstants.TENANT_DOMAIN, response.getTenantDomain()); - session.setAttribute(ServerConstants.USER_LOGGED_IN, response.getUserName()); - if (log.isDebugEnabled()) { - log.debug("Authentication successful for " + session.getAttribute(ServerConstants.USER_LOGGED_IN)); - } - } - return true; - } - if (log.isDebugEnabled()) { - log.debug("Authentication failed.Illegal attempt from session " + httpServletRequest.getSession().getId()); - } - return false; - } - - /** - * this method is currently not implemented. - * - * @param messageContext containing the request need to be authenticated. - * @return boolean - */ - public boolean authenticateWithRememberMe(MessageContext messageContext) { - throw new UnsupportedOperationException(); - } - - /** - * @return string Authenticator name. - */ - public String getAuthenticatorName() { - return OauthAuthenticatorConstants.AUTHENTICATOR_NAME; - } - - /** - * @return int priority of the authenticator. - */ - public int getPriority() { - return PRIORITY; - } - - /** - * @return boolean true for enable or otherwise for disable status. - */ - public boolean isDisabled() { - AuthenticatorsConfiguration authenticatorsConfiguration = AuthenticatorsConfiguration.getInstance(); - AuthenticatorsConfiguration.AuthenticatorConfig authenticatorConfig = authenticatorsConfiguration. - getAuthenticatorConfig(OauthAuthenticatorConstants.AUTHENTICATOR_NAME); - return authenticatorConfig.isDisabled(); - } - - /** - * Retrieve HTTP Servlet Request form thr Message Context. - * - * @param messageContext Containing the Servlet Request for backend authentication. - * @return HTTPServletRequest. - */ - private HttpServletRequest getHttpRequest(MessageContext messageContext) { - return (HttpServletRequest) messageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); - } - -} diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticatorConstants.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticatorConstants.java deleted file mode 100755 index 66e96101a8..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/OauthAuthenticatorConstants.java +++ /dev/null @@ -1,29 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.carbon.identity.authenticator.backend.oauth; - -public class OauthAuthenticatorConstants { - public static final String AUTHORIZATION_HEADER_PREFIX_BEARER = "Bearer"; - public static final String AUTHORIZATION_HEADER_PREFIX_BASIC = "Basic"; - public static final String BEARER_TOKEN_TYPE = "bearer"; - public static final String BEARER_TOKEN_IDENTIFIER = "token"; - public static final String AUTHENTICATOR_NAME = "OAuthAuthenticator"; - public static final String SPLITING_CHARACTOR = " "; - public static final String OAUTH_ENDPOINT_POSTFIX = - "/services/OAuth2TokenValidationService.OAuth2TokenValidationServiceHttpsSoap12Endpoint/"; -} diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorDataHolder.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorDataHolder.java deleted file mode 100644 index 202568c4a5..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorDataHolder.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.identity.authenticator.backend.oauth.internal; - -import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; - -/** - * DataHolder of Backend OAuth Authenticator component. - */ -public class OAuthAuthenticatorDataHolder { - - private OAuth2TokenValidationService oAuth2TokenValidationService; - - private static OAuthAuthenticatorDataHolder thisInstance = new OAuthAuthenticatorDataHolder(); - - private OAuthAuthenticatorDataHolder() {} - - public static OAuthAuthenticatorDataHolder getInstance() { - return thisInstance; - } - - public OAuth2TokenValidationService getOAuth2TokenValidationService() { - if (oAuth2TokenValidationService == null) { - throw new IllegalStateException("OAuth2TokenValidation service is not initialized properly"); - } - return oAuth2TokenValidationService; - } - - public void setOAuth2TokenValidationService( - OAuth2TokenValidationService oAuth2TokenValidationService) { - this.oAuth2TokenValidationService = oAuth2TokenValidationService; - } -} \ No newline at end of file diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java deleted file mode 100755 index 30de0c2522..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/internal/OAuthAuthenticatorServiceComponent.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - -package org.wso2.carbon.identity.authenticator.backend.oauth.internal; - -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.services.authentication.CarbonServerAuthenticator; -import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticator; -import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; -import org.osgi.service.component.annotations.*; - -@Component( - name = "org.wso2.carbon.identity.backend.oauth.authenticator", - immediate = true) -public class OAuthAuthenticatorServiceComponent { - - private static final Log log = LogFactory.getLog(OAuthAuthenticatorServiceComponent.class); - - @SuppressWarnings("unused") - @Activate - protected void activate(ComponentContext componentContext) { - if (log.isDebugEnabled()) { - log.debug("Starting Backend OAuthAuthenticator Framework Bundle"); - } - } - - @SuppressWarnings("unused") - @Deactivate - protected void deactivate(ComponentContext componentContext) { - //do nothing - } - - /** - * Sets OAuth2TokenValidation Service. - * - * @param tokenValidationService An instance of OAuth2TokenValidationService. - */ - @SuppressWarnings("unused") - @Reference( - name = "identity.oauth2.validation.service", - service = org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService.class, - cardinality = ReferenceCardinality.MANDATORY, - policy = ReferencePolicy.DYNAMIC, - bind = "setOAuth2ValidationService", - unbind = "unsetOAuth2ValidationService") - protected void setOAuth2ValidationService(OAuth2TokenValidationService tokenValidationService) { - if (log.isDebugEnabled()) { - log.debug("Setting OAuth2TokenValidationService Service"); - } - OAuthAuthenticatorDataHolder.getInstance().setOAuth2TokenValidationService(tokenValidationService); - } - - /** - * Unsets OAuth2TokenValidation Service. - * - * @param tokenValidationService An instance of OAuth2TokenValidationService - */ - @SuppressWarnings("unused") - protected void unsetOAuth2ValidationService(OAuth2TokenValidationService tokenValidationService) { - if (log.isDebugEnabled()) { - log.debug("Unsetting OAuth2TokenValidationService Service"); - } - OAuthAuthenticatorDataHolder.getInstance().setOAuth2TokenValidationService(null); - } -} \ No newline at end of file diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuth2TokenValidator.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuth2TokenValidator.java deleted file mode 100755 index 1dbbd0fb68..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuth2TokenValidator.java +++ /dev/null @@ -1,35 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.carbon.identity.authenticator.backend.oauth.validator; - -import java.rmi.RemoteException; - -/** - * Declares the contract for OAuth2TokenValidator implementations. - */ -public interface OAuth2TokenValidator { - - /** - * This method gets a string accessToken and validates it and generate the OAuth2ClientApplicationDTO - * containing the validity and user details if valid. - * - * @param accessToken which need to be validated. - * @return OAuthValidationResponse with the validated results. - */ - OAuthValidationResponse validateToken(String accessToken) throws RemoteException; -} diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuthValidationResponse.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuthValidationResponse.java deleted file mode 100755 index 8804924a4c..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuthValidationResponse.java +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.carbon.identity.authenticator.backend.oauth.validator; - -/** - * This class holds the authenticated user information after the OAuth2 token is validated. - */ -@SuppressWarnings("unused") -public class OAuthValidationResponse { - - private String userName; - private String tenantDomain; - private boolean isValid; - - public OAuthValidationResponse(String userName, String tenantDomain, boolean isValid) { - this.userName = userName; - this.tenantDomain = tenantDomain; - this.isValid = isValid; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public void setTenantDomain(String tenantDomain) { - this.tenantDomain = tenantDomain; - } - - public boolean isValid() { - return isValid; - } - - public void setIsValid(boolean isValid) { - this.isValid = isValid; - } -} \ No newline at end of file diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuthValidatorFactory.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuthValidatorFactory.java deleted file mode 100755 index 8e0697e9db..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/OAuthValidatorFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.carbon.identity.authenticator.backend.oauth.validator; - -import org.wso2.carbon.core.security.AuthenticatorsConfiguration; -import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticatorConstants; -import org.wso2.carbon.identity.authenticator.backend.oauth.validator.impl.ExternalOAuthValidator; -import org.wso2.carbon.identity.authenticator.backend.oauth.validator.impl.LocalOAuthValidator; - -/** - * The class validate the configurations and provide the most suitable implementation according to the configuration. - * Factory class for OAuthValidator. - */ -public class OAuthValidatorFactory { - - private static final String AUTHENTICATOR_CONFIG_IS_REMOTE = "isRemote"; - private static final String AUTHENTICATOR_CONFIG_HOST_URL = "hostURL"; - private static final String AUTHENTICATOR_CONFIG_ADMIN_USERNAME = "adminUsername"; - private static final String AUTHENTICATOR_CONFIG_ADMIN_PASSWORD = "adminPassword"; - - /** - * The method check the configuration and provide the appropriate implementation for OAuth2TokenValidator - * - * @return OAuth2TokenValidator - */ - public static OAuth2TokenValidator getValidator() throws IllegalArgumentException { - AuthenticatorsConfiguration authenticatorsConfiguration = AuthenticatorsConfiguration.getInstance(); - AuthenticatorsConfiguration.AuthenticatorConfig authenticatorConfig = authenticatorsConfiguration. - getAuthenticatorConfig(OauthAuthenticatorConstants.AUTHENTICATOR_NAME); - boolean isRemote; - String hostUrl; - String adminUserName; - String adminPassword; - if (authenticatorConfig != null && authenticatorConfig.getParameters() != null) { - isRemote = Boolean.parseBoolean(authenticatorConfig.getParameters().get( - AUTHENTICATOR_CONFIG_IS_REMOTE)); - hostUrl = authenticatorConfig.getParameters().get(AUTHENTICATOR_CONFIG_HOST_URL); - adminUserName = authenticatorConfig.getParameters().get(AUTHENTICATOR_CONFIG_ADMIN_USERNAME); - adminPassword = authenticatorConfig.getParameters().get(AUTHENTICATOR_CONFIG_ADMIN_PASSWORD); - } else { - throw new IllegalArgumentException("Configuration parameters need to be defined in Authenticators.xml"); - } - if (isRemote) { - if (!(hostUrl == null || hostUrl.trim().isEmpty())) { - hostUrl = hostUrl + OauthAuthenticatorConstants.OAUTH_ENDPOINT_POSTFIX; - return new ExternalOAuthValidator(hostUrl, adminUserName, adminPassword); - } else { - throw new IllegalArgumentException("Remote server name and ip both can't be empty"); - } - } - return new LocalOAuthValidator(); - } -} diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/ExternalOAuthValidator.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/ExternalOAuthValidator.java deleted file mode 100755 index c3d246bb16..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/ExternalOAuthValidator.java +++ /dev/null @@ -1,95 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.carbon.identity.authenticator.backend.oauth.validator.impl; - -import org.apache.axis2.client.Options; -import org.apache.axis2.client.ServiceClient; -import org.apache.axis2.transport.http.HTTPConstants; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.httpclient.Header; -import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticatorConstants; -import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuth2TokenValidator; -import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuthValidationResponse; -import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; -import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; -import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken; -import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; - -import java.rmi.RemoteException; -import java.util.ArrayList; -import java.util.List; - -/** - * Handles the Authentication form external IDP servers. Currently supports WSO2 IS only. - */ -public class ExternalOAuthValidator implements OAuth2TokenValidator{ - - private String hostURL; - private String adminUserName; - private String adminPassword; - - public ExternalOAuthValidator(String hostURL, String adminUserName, String adminPassword) { - this.hostURL = hostURL; - this.adminUserName = adminUserName; - this.adminPassword = adminPassword; - } - /** - * This method gets a string accessToken and validates it and generate the OAuth2ClientApplicationDTO - * containing the validity and user details if valid. - * - * @param token which need to be validated. - * @return OAuthValidationResponse with the validated results. - */ - public OAuthValidationResponse validateToken(String token) throws RemoteException { - OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO(); - OAuth2TokenValidationRequestDTO_OAuth2AccessToken accessToken = - new OAuth2TokenValidationRequestDTO_OAuth2AccessToken(); - accessToken.setTokenType(OauthAuthenticatorConstants.BEARER_TOKEN_TYPE); - accessToken.setIdentifier(token); - validationRequest.setAccessToken(accessToken); - OAuth2TokenValidationServiceStub tokenValidationService = - new OAuth2TokenValidationServiceStub(hostURL); - ServiceClient client = tokenValidationService._getServiceClient(); - Options options = client.getOptions(); - List

headerList = new ArrayList<>(); - Header header = new Header(); - header.setName(HTTPConstants.HEADER_AUTHORIZATION); - header.setValue(OauthAuthenticatorConstants.AUTHORIZATION_HEADER_PREFIX_BASIC + " " + getBasicAuthCredentials()); - headerList.add(header); - options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS, headerList); - client.setOptions(options); - OAuth2TokenValidationResponseDTO tokenValidationResponse = tokenValidationService. - findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse(); - boolean isValid = tokenValidationResponse.getValid(); - String userName = null; - String tenantDomain = null; - if (isValid) { - userName = MultitenantUtils.getTenantAwareUsername( - tokenValidationResponse.getAuthorizedUser()); - tenantDomain = MultitenantUtils. - getTenantDomain(tokenValidationResponse.getAuthorizedUser()); - } - return new OAuthValidationResponse(userName,tenantDomain,isValid); - } - - private String getBasicAuthCredentials() { - byte[] bytesEncoded = Base64.encodeBase64((adminUserName + ":" + adminPassword).getBytes()); - return new String(bytesEncoded); - } -} diff --git a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/LocalOAuthValidator.java b/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/LocalOAuthValidator.java deleted file mode 100755 index 4182917f30..0000000000 --- a/components/identity-extensions/org.wso2.carbon.identity.authenticator.backend.oauth/src/main/java/org/wso2/carbon/identity/authenticator/backend/oauth/validator/impl/LocalOAuthValidator.java +++ /dev/null @@ -1,60 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.carbon.identity.authenticator.backend.oauth.validator.impl; - -import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticatorConstants; -import org.wso2.carbon.identity.authenticator.backend.oauth.internal.OAuthAuthenticatorDataHolder; -import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuth2TokenValidator; -import org.wso2.carbon.identity.authenticator.backend.oauth.validator.OAuthValidationResponse; -import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService; -import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationRequestDTO; -import org.wso2.carbon.identity.oauth2.dto.OAuth2TokenValidationResponseDTO; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; - -/** - * Handles the authentication using the inbuilt IS features. - */ -public class LocalOAuthValidator implements OAuth2TokenValidator { - /** - * This method gets a string accessToken and validates it and generate the OAuth2ClientApplicationDTO - * containing the validity and user details if valid. - * - * @param token which need to be validated. - * @return OAuthValidationResponse with the validated results. - */ - public OAuthValidationResponse validateToken(String token) { - OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO(); - OAuth2TokenValidationRequestDTO.OAuth2AccessToken accessToken = - validationRequest.new OAuth2AccessToken(); - accessToken.setTokenType(OauthAuthenticatorConstants.BEARER_TOKEN_TYPE); - accessToken.setIdentifier(token); - validationRequest.setAccessToken(accessToken); - OAuth2TokenValidationResponseDTO tokenValidationResponse = OAuthAuthenticatorDataHolder.getInstance(). - getOAuth2TokenValidationService().findOAuthConsumerIfTokenIsValid(validationRequest).getAccessTokenValidationResponse(); - boolean isValid = tokenValidationResponse.isValid(); - String userName = null; - String tenantDomain = null; - if (isValid) { - userName = MultitenantUtils.getTenantAwareUsername( - tokenValidationResponse.getAuthorizedUser()); - tenantDomain = - MultitenantUtils.getTenantDomain(tokenValidationResponse.getAuthorizedUser()); - } - return new OAuthValidationResponse(userName, tenantDomain, isValid); - } -} diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 9c115b8376..4df6c47019 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -54,7 +54,7 @@ IOT Operation Template Bundle io.entgra.device.mgt.core.operation.template.internal - com.google.common.cache;version="[31.0,32)", + com.google.common.cache;version="[32.1,33)";resolution:=optional, com.google.gson;version="[2.9,3)", io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", @@ -298,7 +298,7 @@ com.google.guava guava - ${guava.version} + ${google.guava.version} provided diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml deleted file mode 100644 index 2a0aec705c..0000000000 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/pom.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - io.entgra.device.mgt.core - policy-mgt - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - io.entgra.device.mgt.core - org.wso2.carbon.complex.policy.decision.point - bundle - WSO2 Carbon - Policy Decision Point - WSO2 Carbon - Policy Decision Point - https://entgra.io - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.artifactId} - ${io.entgra.device.mgt.core.version} - Complex Policy Decision Point Bundle - org.wso2.carbon.complex.policy.decision.point.internal - - org.wso2.carbon.complex.policy.decision.point.* - - - - - - 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.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.equinox - org.eclipse.equinox.common - - - org.ops4j.pax.logging - pax-logging-api - provided - - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.policy.mgt.common - - - - - diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java deleted file mode 100644 index 50fb7a54a4..0000000000 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java +++ /dev/null @@ -1,48 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - - -package org.wso2.carbon.policy.evaluator; - -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; - -import java.util.List; - -public interface FeatureFilter { - - List evaluate(List policyList, List featureRulesList); - - List extractFeatures(List policyList); - - List evaluateFeatures(List featureList, List featureRulesList); - - void getDenyOverridesFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getPermitOverridesFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getFirstApplicableFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getLastApplicableFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getAllApplicableFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getHighestApplicableFeatures(String featureName, List featureList, List effectiveFeatureList); - - void getLowestApplicableFeatures(String featureName, List featureList, List effectiveFeatureList); -} diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java deleted file mode 100644 index e6eb914312..0000000000 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java +++ /dev/null @@ -1,250 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - -package org.wso2.carbon.policy.evaluator; - -import org.wso2.carbon.policy.evaluator.utils.Constants; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.ProfileFeature; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class is responsible for evaluating the policy (Configurations sets) and returning - * the effective features set. - */ - -public class FeatureFilterImpl implements FeatureFilter { - - /** - * This method returns the effective feature list when policy list and feature aggregation rules are supplied. - * @param policyList - * @param featureRulesList - * @return - */ - @Override - public List evaluate(List policyList, List featureRulesList) { - return evaluateFeatures(extractFeatures(policyList), featureRulesList); - } - - /** - * This method extract the features from the given policy list in the order they are provided in the list. - * @param policyList - * @return - */ - public List extractFeatures(List policyList) { - List featureList = new ArrayList(); - for (Policy policy : policyList) { - featureList.addAll(policy.getProfile().getProfileFeaturesList()); - } - return featureList; - } - - /** - * This method is responsible for supplying tasks to other methods to evaluate given features. - * @param featureList - * @param featureRulesList - * @return - */ - public List evaluateFeatures(List featureList, List featureRulesList) { - List effectiveFeatureList = new ArrayList(); - for (FeatureRules rule : featureRulesList) { - String ruleName = rule.getEvaluationCriteria(); - String featureName = rule.getName(); - if (Constants.DENY_OVERRIDES.equalsIgnoreCase(ruleName)) { - getDenyOverridesFeatures(featureName, featureList, effectiveFeatureList); - } - if (Constants.PERMIT_OVERRIDES.equalsIgnoreCase(ruleName)) { - getPermitOverridesFeatures(featureName, featureList, effectiveFeatureList); - } - if (Constants.FIRST_APPLICABLE.equalsIgnoreCase(ruleName)) { - getFirstApplicableFeatures(featureName, featureList, effectiveFeatureList); - } - if (Constants.LAST_APPLICABLE.equalsIgnoreCase(ruleName)) { - getLastApplicableFeatures(featureName, featureList, effectiveFeatureList); - } - if (Constants.ALL_APPLICABLE.equalsIgnoreCase(ruleName)) { - getAllApplicableFeatures(featureName, featureList, effectiveFeatureList); - } - if (Constants.HIGHEST_APPLICABLE.equalsIgnoreCase(ruleName)) { - getHighestApplicableFeatures(featureName, featureList, effectiveFeatureList); - } - if (Constants.LOWEST_APPLICABLE.equalsIgnoreCase(ruleName)) { - getLowestApplicableFeatures(featureName, featureList, effectiveFeatureList); - } - } - return effectiveFeatureList; - } - - /** - * This method picks up denied features, if there is no denied features it will add to the list, the final permitted feature. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getDenyOverridesFeatures(String featureName, List featureList, List effectiveFeatureList) { - ProfileFeature evaluatedFeature = null; -// for (ProfileFeature feature : featureList) { -// if (feature.getFeature().getName().equalsIgnoreCase(featureName)) { -// if (feature.getFeature().getRuleValue().equalsIgnoreCase("Deny")) { -// evaluatedFeature = feature; -// effectiveFeatureList.add(evaluatedFeature); -// return; -// } else { -// evaluatedFeature = feature; -// } -// } -// } - if (evaluatedFeature != null) { - effectiveFeatureList.add(evaluatedFeature); - } - - } - - /** - * This method picks up permitted features, if there is no permitted features it will add to the list, the final denied feature. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getPermitOverridesFeatures(String featureName, List featureList, List effectiveFeatureList) { - ProfileFeature evaluatedFeature = null; -// for (ProfileFeature feature : featureList) { -// if (feature.getFeature().getName().equalsIgnoreCase(featureName)) { -// if (feature.getFeature().getRuleValue().equalsIgnoreCase("Permit")) { -// evaluatedFeature = feature; -// effectiveFeatureList.add(evaluatedFeature); -// return; -// } else { -// evaluatedFeature = feature; -// } -// } -// } - if (evaluatedFeature != null) { - effectiveFeatureList.add(evaluatedFeature); - } - - } - - /** - * This method picks the first features of the give type. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getFirstApplicableFeatures(String featureName, List featureList, List effectiveFeatureList) { - for (ProfileFeature feature : featureList) { -// if (feature.getFeature().getName().equalsIgnoreCase(featureName)) { -// effectiveFeatureList.add(feature); -// return; -// -// } - } - } - - /** - * This method picks the last features of the give type. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getLastApplicableFeatures(String featureName, List featureList, List effectiveFeatureList) { - ProfileFeature evaluatedFeature = null; -// for (ProfileFeature feature : featureList) { -// if (feature.getFeature().getName().equalsIgnoreCase(featureName)) { -// evaluatedFeature = feature; -// } -// } - if (evaluatedFeature != null) { - effectiveFeatureList.add(evaluatedFeature); - } - } - - /** - * This method picks the all features of the give type. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getAllApplicableFeatures(String featureName, List featureList, List effectiveFeatureList) { - for (ProfileFeature feature : featureList) { -// if (feature.getFeature().getName().equalsIgnoreCase(featureName)) { -// effectiveFeatureList.add(feature); -// } - } - } - - /** - * This method picks the feature with the highest value of given type. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getHighestApplicableFeatures(String featureName, List featureList, List effectiveFeatureList) { - ProfileFeature evaluatedFeature = null; - int intValve = 0; -// for (ProfileFeature feature : featureList) { -// if (feature.getFeature().getName().equalsIgnoreCase(featureName)) { -// if (Integer.parseInt(feature.getFeature().getRuleValue()) > intValve) { -// intValve = Integer.parseInt(feature.getFeature().getRuleValue()); -// evaluatedFeature = feature; -// } -// } -// } - if (evaluatedFeature != null) { - effectiveFeatureList.add(evaluatedFeature); - } - } - - /** - * This method picks the feature with the lowest value of given type. - * But if given policies do not have features of given type, it will not add anything. - * - * @param featureName - * @param featureList - * @param effectiveFeatureList - */ - public void getLowestApplicableFeatures(String featureName, List featureList, List effectiveFeatureList) { - ProfileFeature evaluatedFeature = null; -// int intValve = 0; -// for (ProfileFeature feature : featureList) { -// if (feature.getFeature().getName().equalsIgnoreCase(featureName)) { -// if (Integer.parseInt(feature.getFeature().getRuleValue()) < intValve) { -// intValve = Integer.parseInt(feature.getFeature().getRuleValue()); -// evaluatedFeature = feature; -// } -// } -// } - if (evaluatedFeature != null) { - effectiveFeatureList.add(evaluatedFeature); - } - } -} diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java deleted file mode 100644 index f706cf947f..0000000000 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureRules.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - -package org.wso2.carbon.policy.evaluator; - -public class FeatureRules { - - private String name; - private String evaluationCriteria; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getEvaluationCriteria() { - return evaluationCriteria; - } - - public void setEvaluationCriteria(String evaluationCriteria) { - this.evaluationCriteria = evaluationCriteria; - } -} diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java deleted file mode 100644 index 571f9c6848..0000000000 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.policy.evaluator; - -public class PDPException extends Exception { - - private String pdpErrorMessage; - - public String getPdpErrorMessage() { - return pdpErrorMessage; - } - - public void setPdpErrorMessage(String pdpErrorMessage) { - this.pdpErrorMessage = pdpErrorMessage; - } - - public PDPException(String message) { - setPdpErrorMessage(message); - } - - public PDPException(String message, Exception ex) { - super(message, ex); - setPdpErrorMessage(message); - } - - public PDPException(String message, Throwable cause) { - super(message, cause); - setPdpErrorMessage(message); - } - - public PDPException(Throwable cause) { - super(cause); - } - - public PDPException(){ - super(); - } -} diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java deleted file mode 100644 index 82421c9f03..0000000000 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.policy.evaluator; - -import org.wso2.carbon.policy.evaluator.spi.PDPService; -import io.entgra.device.mgt.core.policy.mgt.common.Feature; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; - -import java.util.List; - -public class PDPServiceImpl implements PDPService { - @Override - public List getEffectivePolicyList(List policies, List roles, String deviceType) { - return null; - } - - @Override - public List getEffectiveFeatureList(List policies, List featureRulesList) { - return null; - } -} diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java deleted file mode 100644 index 84b6cac51e..0000000000 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - - -package org.wso2.carbon.policy.evaluator; - -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; - -import java.util.List; - -public interface PolicyFilter { - - /** - * This method will extract the policies related a given roles list from the policy list available. - * @param policyList - * @param roles - * @return - */ - public List extractPoliciesRelatedToRoles(List policyList, List roles); - - /** - * This mehtod extract the policies related to a given device type from policy list. - * @param policyList - * @param deviceType - * @return - */ - public List extractPoliciesRelatedToDeviceType(List policyList, String deviceType); -} diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java deleted file mode 100644 index 37818b7461..0000000000 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * you may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.policy.evaluator; - -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; - -import java.util.ArrayList; -import java.util.List; - -public class PolicyFilterImpl implements PolicyFilter { - - - /** - * This method will extract the policies related a given roles list from the policy list available. - * - * @param policyList - * @param roles - * @return - */ - @Override - public List extractPoliciesRelatedToRoles(List policyList, List roles) { - - List policies = new ArrayList<>(); - - for (Policy policy : policyList) { - List roleList = policy.getRoles(); - - for (String role : roleList) { - if (roles.contains(role)) { - policies.add(policy); - break; - } - } - } - return policies; - } - - /** - * This mehtod extract the policies related to a given device type from policy list. - * - * @param policyList - * @param deviceType - * @return - */ - @Override - public List extractPoliciesRelatedToDeviceType(List policyList, String deviceType) { - List policies = new ArrayList<>(); - - for (Policy policy : policyList) { - if (policy.getProfile().getDeviceType().equalsIgnoreCase(deviceType)) { - policies.add(policy); - } - } - return policies; - } -} diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java deleted file mode 100644 index ea43abb397..0000000000 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java +++ /dev/null @@ -1,34 +0,0 @@ -/* -* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - -package org.wso2.carbon.policy.evaluator.spi; - - -import org.wso2.carbon.policy.evaluator.FeatureRules; -import io.entgra.device.mgt.core.policy.mgt.common.Feature; -import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; - -import java.util.List; - -public interface PDPService { - - List getEffectivePolicyList(List policies, List roles, String deviceType); - - List getEffectiveFeatureList(List policies, List featureRulesList); - -} diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java deleted file mode 100644 index 790fa7f246..0000000000 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/utils/Constants.java +++ /dev/null @@ -1,30 +0,0 @@ -/* -* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - -package org.wso2.carbon.policy.evaluator.utils; - -public class Constants { - - public static final String DENY_OVERRIDES = "deny_overrides"; - public static final String PERMIT_OVERRIDES = "permit_overrides"; - public static final String FIRST_APPLICABLE = "first_applicable"; - public static final String LAST_APPLICABLE = "last_applicable"; - public static final String ALL_APPLICABLE = "all_applicable"; - public static final String HIGHEST_APPLICABLE = "highest_applicable"; - public static final String LOWEST_APPLICABLE = "lowest_applicable"; -} diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 1c2e2c8aec..fcf802e885 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -54,7 +54,7 @@ io.entgra.device.mgt.core.subtype.mgt.internal com.fasterxml.jackson.core;version="[2.14,3)", - com.google.common.cache;version="[31.0,32)", + com.google.common.cache;version="[32.1,33)";resolution:=optional, io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.config.datasource;version="[5.0,6)", diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml deleted file mode 100644 index d8f8e0e32f..0000000000 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - io.entgra.device.mgt.core - apimgt-extensions-feature - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.apimgt.handler.server.feature - pom - WSO2 Carbon - Device Management - APIM handler Server Feature - https://entgra.io - This feature contains the handler for the api authentications - - - - - io.entgra.device.mgt.core - org.wso2.carbon.apimgt.handlers - - - - - - - maven-resources-plugin - - - 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 - - - org.wso2.carbon.apimgt.handler.server - ../../../features/etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - org.eclipse.equinox.p2.type.group:false - - - - - io.entgra.device.mgt.core:org.wso2.carbon.apimgt.handlers:${io.entgra.device.mgt.core.version} - - - - - - - - - - - - diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/build.properties b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/build.properties deleted file mode 100644 index 89aee3ff76..0000000000 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/build.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (c) 2018 - 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 = true diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/conf/iot-api-config.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/conf/iot-api-config.xml deleted file mode 100644 index 7b1462746b..0000000000 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/conf/iot-api-config.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - https://${iot.core.host}:${iot.core.https.port}/ - - - https://${iot.core.host}:${iot.core.https.port}/api/certificate-mgt/v1.0/admin/certificates/verify/ - - - admin - admin - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token - - - /services - - \ No newline at end of file diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/p2.inf b/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/p2.inf deleted file mode 100644 index e7c6acf89f..0000000000 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.handler.server.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,2 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.handler.server_${feature.version}/conf/iot-api-config.xml,target:${installFolder}/../../conf/iot-api-config.xml,overwrite:true);\ diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml deleted file mode 100644 index 37c5189f98..0000000000 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/pom.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - io.entgra.device.mgt.core - apimgt-extensions-feature - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.apimgt.integration.client.feature - pom - WSO2 Carbon - APIM Integration Client Feature - https://entgra.io - This feature contains a http client implementation to communicate with WSO2-APIM server - - - - io.entgra.device.mgt.core - org.wso2.carbon.apimgt.integration.client - - - io.entgra.device.mgt.core - org.wso2.carbon.apimgt.integration.generated.client - - - - - - - maven-resources-plugin - - - 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 - - - org.wso2.carbon.apimgt.integration.client - ../../../features/etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - org.eclipse.equinox.p2.type.group:false - - - - - io.github.openfeign:feign-jackson:${io.github.openfeign.version} - - - io.github.openfeign:feign-core:${io.github.openfeign.version} - - - io.github.openfeign:feign-gson:${io.github.openfeign.version} - - - io.github.openfeign:feign-slf4j:${io.github.openfeign.version} - - - io.entgra.device.mgt.core:org.wso2.carbon.apimgt.integration.client:${project.version} - - - io.entgra.device.mgt.core:org.wso2.carbon.apimgt.integration.generated.client:${project.version} - - - - - - - - - diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/build.properties b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/build.properties deleted file mode 100644 index 89aee3ff76..0000000000 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/build.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (c) 2018 - 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 = true diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml deleted file mode 100644 index ec89b619c1..0000000000 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/conf/apim-integration.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - https://${iot.keymanager.host}:${iot.keymanager.https.port}/client-registration/v0.12/register - https://${iot.gateway.host}:${iot.gateway.https.port}/token - https://${iot.apimpublisher.host}:${iot.apimpublisher.https.port}/api/am/publisher/v0.12 - https://${iot.apimstore.host}:${iot.apimstore.https.port}/api/am/store/v0.12 - admin - admin - \ No newline at end of file diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf b/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf deleted file mode 100644 index 3dca52fc59..0000000000 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.integration.client.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,2 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.apimgt.integration.client_${feature.version}/conf/apim-integration.xml,target:${installFolder}/../../conf/apim-integration.xml,overwrite:true);\ diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml deleted file mode 100644 index cbb89240a5..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/pom.xml +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - io.entgra.device.mgt.core - device-mgt-feature - 5.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.analytics.feature - pom - WSO2 Carbon - Device Management Server Feature - https://entgra.io - This feature contains bundles related to device analytics data publisher and ws proxy - - - - io.entgra.device.mgt.core - org.wso2.carbon.device.mgt.analytics.data.publisher - - - org.wso2.carbon.registry - org.wso2.carbon.registry.indexing - - - org.wso2.carbon.registry - org.wso2.carbon.registry.common - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy - package - - copy - - - - - io.entgra.device.mgt.core - org.wso2.carbon.device.mgt.analytics.wsproxy - ${project.version} - war - true - - ${project.build.directory}/maven-shared-archive-resources/webapps - - secured-websocket-proxy.war - - - - - - - - maven-resources-plugin - - - 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 - - - org.wso2.carbon.device.mgt.analytics - ../../../features/etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - org.eclipse.equinox.p2.type.group:false - - - - - io.entgra.device.mgt.core:org.wso2.carbon.device.mgt.analytics.data.publisher:${io.entgra.device.mgt.core.version} - - - - org.wso2.carbon.core.server:${carbon.kernel.version} - - - org.wso2.carbon.registry:org.wso2.carbon.registry.indexing:${carbon.registry.version} - org.wso2.carbon.registry:org.wso2.carbon.registry.common:${carbon.registry.version} - - - - - - - - - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/build.properties b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/build.properties deleted file mode 100644 index 89aee3ff76..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/build.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (c) 2018 - 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 = true diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/conf/device-analytics-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/conf/device-analytics-config.xml deleted file mode 100644 index 8a39b21a21..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/conf/device-analytics-config.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - true - - tcp://${iot.analytics.host}:${iot.analytics.thrift.port} - - wss://${iot.analytics.host}:${iot.analytics.https.port} - admin - admin - diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/p2.inf b/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/p2.inf deleted file mode 100644 index a0a1b3d005..0000000000 --- a/features/device-mgt/org.wso2.carbon.device.mgt.analytics.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,4 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.analytics_${feature.version}/conf/device-analytics-config.xml,target:${installFolder}/../../conf/etc/device-analytics-config.xml,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.analytics_${feature.version}/webapps/secured-websocket-proxy.war,target:${installFolder}/../../deployment/server/webapps/secured-websocket-proxy.war,overwrite:true);\ \ No newline at end of file diff --git a/pom.xml b/pom.xml index dcbac2b442..c81630de6c 100644 --- a/pom.xml +++ b/pom.xml @@ -2117,7 +2117,6 @@ 20220924 2.4.5 - 27.0.1-jre 1.70.0.wso2v1 @@ -2130,7 +2129,7 @@ 3.0.0.wso2v1 1.3 2.9.1 - 31.0.1-jre + 32.1.3-jre 4.12.0 3.6.0 11.0 @@ -2178,7 +2177,6 @@ 2.1.1 1.6.9 - 1.6.9 4.0.1 @@ -2205,7 +2203,7 @@ 1.7 - 2.1.7-wso2v227 + 4.0.0.wso2v20_25 1.5.11-wso2v18 From 63a3c3eab3fe59fee26e41779b4033b0d58c2f5c Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Mon, 6 May 2024 10:07:00 +0530 Subject: [PATCH 175/343] Fix build failure --- .../pom.xml | 1 - .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 10 +++++++--- pom.xml | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 6e431bb444..2a088248d7 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -65,7 +65,6 @@ org.wso2.carbon.commons org.wso2.carbon.tenant.common - ${carbon.commons.version} diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index b6902e627e..2ffc7f6807 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -107,7 +107,6 @@ org.wso2.carbon.commons org.wso2.carbon.tenant.common - ${carbon.commons.version} org.wso2.carbon @@ -124,22 +123,27 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.core + provided io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.common + provided io.entgra.device.mgt.core io.entgra.device.mgt.core.application.mgt.core + provided io.entgra.device.mgt.core io.entgra.device.mgt.core.application.mgt.common + provided - io.entgra.device.mgt.core - io.entgra.device.mgt.core.tenant.mgt.common + io.entgra.device.mgt.core + io.entgra.device.mgt.core.tenant.mgt.common + provided org.wso2.carbon diff --git a/pom.xml b/pom.xml index c81630de6c..6de6b55efc 100644 --- a/pom.xml +++ b/pom.xml @@ -1874,6 +1874,11 @@ slf4j-ext ${slf4j.ext.version} + + org.wso2.carbon.commons + org.wso2.carbon.tenant.common + ${carbon.commons.version} + From 6ac477400110cd9b04d0dac503779a4d876aa791 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 7 May 2024 08:32:25 +0530 Subject: [PATCH 176/343] Fix build failure --- .../pom.xml | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 2ffc7f6807..20da34386b 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -60,33 +60,22 @@ io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.common.roles.config;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.dao;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.metadata.mgt;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", io.entgra.device.mgt.core.tenant.mgt.common.exception;version="[5.0,6)", io.entgra.device.mgt.core.tenant.mgt.common.spi;version="[5.0,6)", io.entgra.device.mgt.core.tenant.mgt.core, org.apache.commons.logging;version="[1.2,2)", - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.osgi.framework;version="[1.9,2)", + org.osgi.service.component;version="[1.2,2)", org.wso2.carbon.context;version="[4.8,5)", org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", org.wso2.carbon.stratos.common.beans;version="[4.9,5)", org.wso2.carbon.stratos.common.exception;version="[4.9,5)", org.wso2.carbon.stratos.common.listeners;version="[4.9,5)", org.wso2.carbon.user.api;version="[1.0,2)", - org.wso2.carbon.user.core.service;version="[4.8,5)", - org.apache.commons.logging, - io.entgra.device.mgt.core.application.mgt.common.*, - io.entgra.device.mgt.core.application.mgt.core.config, - io.entgra.device.mgt.core.device.mgt.core, - io.entgra.device.mgt.core.tenant.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.common.metadata.mgt, - io.entgra.device.mgt.core.device.mgt.common.exceptions, - io.entgra.device.mgt.core.device.mgt.common.permission.mgt, - io.entgra.device.mgt.core.device.mgt.common.roles.config, - io.entgra.device.mgt.core.device.mgt.core.metadata.mgt, - io.entgra.device.mgt.core.device.mgt.core.config, - io.entgra.device.mgt.core.device.mgt.core.dao.* + org.wso2.carbon.user.core.service;version="[4.8,5)" !io.entgra.device.mgt.core.tenant.mgt.core.internal, @@ -150,5 +139,4 @@ org.wso2.carbon.utils - \ No newline at end of file From ce2e57c6d0f78c753bd17feb4c373052e204c299 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Tue, 7 May 2024 09:24:45 +0530 Subject: [PATCH 177/343] Fix tenant-mgt build failure --- .../pom.xml | 52 +++++++------------ 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 2ffc7f6807..9b5b3387e3 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -52,41 +52,25 @@ Tenant Management Core Bundle io.entgra.device.mgt.core.tenant.mgt.core.internal - io.entgra.device.mgt.core.application.mgt.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common.services;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.roles.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.metadata.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.tenant.mgt.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.tenant.mgt.common.spi;version="[5.0,6)", - io.entgra.device.mgt.core.tenant.mgt.core, - org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", - org.osgi.service.*;version="${imp.package.version.osgi.service}", - org.wso2.carbon.context;version="[4.8,5)", - org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", - org.wso2.carbon.stratos.common.beans;version="[4.9,5)", - org.wso2.carbon.stratos.common.exception;version="[4.9,5)", - org.wso2.carbon.stratos.common.listeners;version="[4.9,5)", - org.wso2.carbon.user.api;version="[1.0,2)", - org.wso2.carbon.user.core.service;version="[4.8,5)", - org.apache.commons.logging, - io.entgra.device.mgt.core.application.mgt.common.*, - io.entgra.device.mgt.core.application.mgt.core.config, - io.entgra.device.mgt.core.device.mgt.core, - io.entgra.device.mgt.core.tenant.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.common.metadata.mgt, - io.entgra.device.mgt.core.device.mgt.common.exceptions, - io.entgra.device.mgt.core.device.mgt.common.permission.mgt, - io.entgra.device.mgt.core.device.mgt.common.roles.config, - io.entgra.device.mgt.core.device.mgt.core.metadata.mgt, - io.entgra.device.mgt.core.device.mgt.core.config, - io.entgra.device.mgt.core.device.mgt.core.dao.* + org.osgi.service.component;version="${imp.package.version.osgi.service}", + io.entgra.device.mgt.core.application.mgt.common.exception.*;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.services.*;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.core.config.*;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions.*;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt.*;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.permission.mgt.*;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.roles.config.*;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.dao.*;version="[5.0,6)", + io.entgra.device.mgt.core.tenant.mgt.common.exception.*;version="[5.0,6)", + io.entgra.device.mgt.core.tenant.mgt.common.spi.*;version="[5.0,6)", + org.wso2.carbon.user.api.*, + org.wso2.carbon.user.core.service.*, + org.apache.commons.logging.*, + org.wso2.carbon.context.*, + org.wso2.carbon.stratos.common, + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.*;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.*;version="[5.0,6)" !io.entgra.device.mgt.core.tenant.mgt.core.internal, From faab9c863279e13eb1ce3765a1d74acfd0882e56 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Tue, 7 May 2024 13:50:23 +0530 Subject: [PATCH 178/343] Update dependency list --- .../pom.xml | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 80e7d66c43..9426325890 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -52,25 +52,30 @@ Tenant Management Core Bundle io.entgra.device.mgt.core.tenant.mgt.core.internal - org.osgi.framework.*;version="${imp.package.version.osgi.framework}", + io.entgra.device.mgt.core.application.mgt.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.services;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.roles.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.dao;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.metadata.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.tenant.mgt.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.tenant.mgt.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.tenant.mgt.core, + org.apache.commons.logging;version="[1.2,2)", + org.osgi.framework;version="${imp.package.version.osgi.framework}", org.osgi.service.component;version="${imp.package.version.osgi.service}", - io.entgra.device.mgt.core.application.mgt.common.exception.*;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common.services.*;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.core.config.*;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions.*;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.permission.mgt.*;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.permission.mgt.*;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.roles.config.*;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.dao.*;version="[5.0,6)", - io.entgra.device.mgt.core.tenant.mgt.common.exception.*;version="[5.0,6)", - io.entgra.device.mgt.core.tenant.mgt.common.spi.*;version="[5.0,6)", - org.wso2.carbon.user.api.*, - org.wso2.carbon.user.core.service.*, - org.apache.commons.logging.*, - org.wso2.carbon.context.*, - org.wso2.carbon.stratos.common, - io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.*;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.*;version="[5.0,6)" + org.wso2.carbon.context;version="[4.8,5)", + org.wso2.carbon.registry.core.exceptions;version="[1.0,2)", + org.wso2.carbon.stratos.common.beans;version="[4.9,5)", + org.wso2.carbon.stratos.common.exception;version="[4.9,5)", + org.wso2.carbon.stratos.common.listeners;version="[4.9,5)", + org.wso2.carbon.user.api;version="[1.0,2)", + org.wso2.carbon.user.core.service;version="[4.8,5)" !io.entgra.device.mgt.core.tenant.mgt.core.internal, From 8fd032c33619be2ec860261676b636ab743a6501 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Wed, 8 May 2024 17:22:10 +0530 Subject: [PATCH 179/343] Fix issue in operation log not loading --- .../core/device/mgt/core/dto/operation/mgt/ConfigOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/operation/mgt/ConfigOperation.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/operation/mgt/ConfigOperation.java index e6681e0e00..a556c216e7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/operation/mgt/ConfigOperation.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/operation/mgt/ConfigOperation.java @@ -22,7 +22,7 @@ import java.util.List; public class ConfigOperation extends Operation { - private final List properties; + private final transient List properties; public ConfigOperation() { properties = new ArrayList<>(); From 1171086eb77ea4c28a19b28519494a358d503570 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Wed, 8 May 2024 18:08:41 +0530 Subject: [PATCH 180/343] Remove duplicate properties field --- .../mgt/core/dto/operation/mgt/ConfigOperation.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/operation/mgt/ConfigOperation.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/operation/mgt/ConfigOperation.java index a556c216e7..4bc28b19fa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/operation/mgt/ConfigOperation.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/operation/mgt/ConfigOperation.java @@ -22,21 +22,10 @@ import java.util.List; public class ConfigOperation extends Operation { - private final transient List properties; - public ConfigOperation() { - properties = new ArrayList<>(); setControl(Control.REPEAT); } - public List getConfigProperties() { - return properties; - } - - public void addConfigProperty(String name, Object value, Class type) { - properties.add(new Property(name, value, type)); - } - public Type getType() { return Type.CONFIG; } From 2169c6937a672af88cd0104bc3ab3758f1423a11 Mon Sep 17 00:00:00 2001 From: ashvini Date: Thu, 9 May 2024 07:43:39 +0530 Subject: [PATCH 181/343] Fix unknown application type error when installing web apps --- .../mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java index 61c34fcd4d..42889367b4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java @@ -70,7 +70,7 @@ public class MDMAndroidOperationUtil { webApplication.setName(application.getName()); // webApplication.setType(application.getType().toString()); // Hard-corded "type" to "webapp". Some agent versions accept only "webapp" as the type. - webApplication.setType("webapp"); +// webApplication.setType("webapp"); webApplication.setProperties(application.getProperties()); operation.setPayLoad(webApplication.toJSON()); break; From 2ab1cf767a0f39f9259a014421287020d4ebdec9 Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Fri, 10 May 2024 12:30:10 +0530 Subject: [PATCH 182/343] Refactor SQL query to filter out 'REMOVED' and 'DELETED' statuses --- .../mgt/core/dao/impl/device/GenericDeviceDAOImpl.java | 3 ++- .../device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java | 5 ++++- .../mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java | 5 ++++- .../mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index df408422b6..7d7fe4bf5b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -1297,7 +1297,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } query = query.concat("WHERE DM_DEVICE.ID IN ("); StringJoiner joiner = new StringJoiner(",", query , - ") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ?"); + ") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ? AND e.STATUS != ?"); deviceIds.stream().map(ignored -> "?").forEach(joiner::add); query = joiner.toString(); @@ -1341,6 +1341,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } ps.setInt(index++, tenantId); ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); + ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); if (isDeviceNameProvided) { ps.setString(index++, name + "%"); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index cecf4e510b..25b05520b6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -25,6 +25,7 @@ import io.entgra.device.mgt.core.device.mgt.common.Count; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceBilling; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; @@ -1078,7 +1079,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " + "WHERE DM_DEVICE.ID IN (", - ") AND DM_DEVICE.TENANT_ID = ?"); + ") AND DM_DEVICE.TENANT_ID AND e.STATUS NOT IN (?, ?)"); deviceIds.stream().map(ignored -> "?").forEach(joiner::add); String query = joiner.toString(); @@ -1120,6 +1121,8 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { } ps.setInt(index++, tenantId); + ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); + ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); if (isDeviceNameProvided) { ps.setString(index++, name + "%"); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index c467165851..4f602afc9f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -25,6 +25,7 @@ import io.entgra.device.mgt.core.device.mgt.common.Count; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceBilling; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; @@ -1057,7 +1058,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " + "WHERE DM_DEVICE.ID IN (", - ") AND DM_DEVICE.TENANT_ID = ?"); + ") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS NOT IN (?, ?)"); deviceIds.stream().map(ignored -> "?").forEach(joiner::add); String query = joiner.toString(); @@ -1099,6 +1100,8 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { } ps.setInt(index++, tenantId); + ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); + ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); if (isDeviceNameProvided) { ps.setString(index++, name + "%"); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index a09185533c..d98b2af00a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -926,7 +926,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " + "WHERE DM_DEVICE.ID IN (", - ") AND DM_DEVICE.TENANT_ID = ?"); + ") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ? AND e.STATUS != ?"); deviceIds.stream().map(ignored -> "?").forEach(joiner::add); String query = joiner.toString(); @@ -968,6 +968,8 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { } ps.setInt(index++, tenantId); + ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); + ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); if (isDeviceNameProvided) { ps.setString(index++, name + "%"); } From 3fd61636030b0c37f05c6113ff8d829917607c27 Mon Sep 17 00:00:00 2001 From: ashvini Date: Mon, 13 May 2024 07:18:18 +0530 Subject: [PATCH 183/343] Remove comments --- .../core/device/mgt/core/util/MDMAndroidOperationUtil.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java index 42889367b4..4485df61a1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMAndroidOperationUtil.java @@ -68,9 +68,7 @@ public class MDMAndroidOperationUtil { WebApplication webApplication = new WebApplication(); webApplication.setUrl(application.getLocation()); webApplication.setName(application.getName()); -// webApplication.setType(application.getType().toString()); -// Hard-corded "type" to "webapp". Some agent versions accept only "webapp" as the type. -// webApplication.setType("webapp"); + webApplication.setType(application.getType().toString()); webApplication.setProperties(application.getProperties()); operation.setPayLoad(webApplication.toJSON()); break; From 60eac79c746c0e4ed9de54142dc20f7c74d682fd Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Wed, 15 May 2024 11:01:06 +0530 Subject: [PATCH 184/343] Add EVENT_UPDATE operation code and refactor geo fence update --- .../mgt/core/DeviceManagementConstants.java | 1 + .../event/config/EventOperationExecutor.java | 25 +++++++++++++++++ ...GroupAssignmentEventOperationExecutor.java | 27 +++++++++++++++++++ .../GeoLocationProviderServiceImpl.java | 6 ++--- .../operation/mgt/OperationManagerImpl.java | 2 ++ .../operation/mgt/OperationMgtConstants.java | 1 + 6 files changed, 59 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConstants.java index 6fae7901d5..9f6f24db08 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConstants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConstants.java @@ -89,6 +89,7 @@ public final class DeviceManagementConstants { public static final String POLICY_OPERATION_CODE = PolicyOperation.POLICY_OPERATION_CODE; public static final String POLICY_REVOKE_OPERATION_CODE = OperationMgtConstants.OperationCodes.POLICY_REVOKE; public static final String EVENT_CONFIG_OPERATION_CODE = OperationMgtConstants.OperationCodes.EVENT_CONFIG; + public static final String EVENT_UPDATE_OPERATION_CODE = OperationMgtConstants.OperationCodes.EVENT_UPDATE; public static final String EVENT_REVOKE_OPERATION_CODE = OperationMgtConstants.OperationCodes.EVENT_REVOKE; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventOperationExecutor.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventOperationExecutor.java index 54a7efd9dc..7151eaeef7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventOperationExecutor.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/EventOperationExecutor.java @@ -84,6 +84,16 @@ public class EventOperationExecutor implements Runnable { } //extend with another cases to handle other types of events } + /** + * Build operation to create EVENT_UPDATE operation. + * @param operation Operation object to build + */ + private void buildEventUpdateOperation(ProfileOperation operation) { + if (eventSource.equalsIgnoreCase(DeviceManagementConstants.EventServices.GEOFENCE)) { + createGeoFenceUpdateOperation(operation); + } //extend with another cases to handle other types of events + } + /** * Build operation to create EVENT_CONFIG operation. * @param operation Operation object to build @@ -128,6 +138,18 @@ public class EventOperationExecutor implements Runnable { * @param operation operation object to set the payload */ private void createGeoFenceRevokeOperation(ProfileOperation operation) { + changeGeoFenceOperation(operation); + } + + /** + * Create EVENT_UPDATE operation object and attach payload to configure geo fence events + * @param operation operation object to set the payload + */ + private void createGeoFenceUpdateOperation(ProfileOperation operation) { + changeGeoFenceOperation(operation); + } + + private void changeGeoFenceOperation(ProfileOperation operation) { GeoFenceEventMeta geoFenceMeta = (GeoFenceEventMeta) eventMetaData; EventRevokeOperation eventRevokeOperation = new EventRevokeOperation(); eventRevokeOperation.setEventSource(eventSource); @@ -188,6 +210,9 @@ public class EventOperationExecutor implements Runnable { if (operationCode.equalsIgnoreCase(OperationMgtConstants.OperationCodes.EVENT_CONFIG)) { operation.setCode(OperationMgtConstants.OperationCodes.EVENT_CONFIG); buildEventConfigOperation(operation); + } else if (operationCode.equalsIgnoreCase(OperationMgtConstants.OperationCodes.EVENT_UPDATE)){ + operation.setCode(OperationMgtConstants.OperationCodes.EVENT_UPDATE); + buildEventUpdateOperation(operation); } else if (operationCode.equalsIgnoreCase(OperationMgtConstants.OperationCodes.EVENT_REVOKE)){ operation.setCode(OperationMgtConstants.OperationCodes.EVENT_REVOKE); buildEventRevokeOperation(operation); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/GroupAssignmentEventOperationExecutor.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/GroupAssignmentEventOperationExecutor.java index 48c77e555b..37a80ef7e5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/GroupAssignmentEventOperationExecutor.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/event/config/GroupAssignmentEventOperationExecutor.java @@ -106,6 +106,8 @@ public class GroupAssignmentEventOperationExecutor implements Runnable { operation.setType(Operation.Type.PROFILE); if (operationCode.equalsIgnoreCase(OperationMgtConstants.OperationCodes.EVENT_CONFIG)) { buildEventConfigOperationObject(operation); + } else if (operationCode.equalsIgnoreCase(OperationMgtConstants.OperationCodes.EVENT_UPDATE)) { + buildEventUpdateOperation(operation); } else if (operationCode.equalsIgnoreCase(OperationMgtConstants.OperationCodes.EVENT_REVOKE)) { buildEventRevokeOperation(operation); } @@ -162,6 +164,19 @@ public class GroupAssignmentEventOperationExecutor implements Runnable { } } + /** + * Build EVENT_UPDATE operation attaching event payload + * @param operation operation object to build + * @throws EventConfigurationException if not events found for the specific group + */ + private void buildEventUpdateOperation(ProfileOperation operation) throws EventConfigurationException { + for (String eventSource : this.eventSources) { + if (eventSource.equalsIgnoreCase(DeviceManagementConstants.EventServices.GEOFENCE)) { + setGeoFenceUpdateOperationContent(operation); + } //add other cases to handle other types of events + } + } + /** * Build EVENT_CONFIG operation attaching event payload * @param operation operation object to build @@ -217,6 +232,18 @@ public class GroupAssignmentEventOperationExecutor implements Runnable { * @param operation operation object to attach payload */ private void setGeoFenceRevokeOperationContent(ProfileOperation operation){ + changeGeoFenceOperation(operation); + } + + /** + * Set operation payload GeoFence for EVENT_UPDATE operation + * @param operation operation object to attach payload + */ + private void setGeoFenceUpdateOperationContent(ProfileOperation operation){ + changeGeoFenceOperation(operation); + } + + private void changeGeoFenceOperation(ProfileOperation operation) { List revokeOperationList = new ArrayList<>(); for (GeofenceData geofenceData : this.geoFencesOfGroup) { EventRevokeOperation eventRevokeOperation = new EventRevokeOperation(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java index edac4eaa09..9b380f14ee 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java @@ -1323,7 +1323,7 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic DeviceManagementConstants.EventServices.GEOFENCE, new GeoFenceEventMeta(geofenceData), tenantId, geofenceData.getGroupIds()); } catch (EventConfigurationException e) { - String msg = "Failed while creating EVENT_REVOKE operation creation task entry while updating geo fence " + String msg = "Failed while creating EVENT_CONFIG operation creation task entry while updating geo fence " + geofenceData.getFenceName() + " of the tenant " + tenantId; log.error(msg, e); throw new GeoLocationBasedServiceException(msg, e); @@ -1650,11 +1650,11 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic log.debug("Update geofence event completed."); } try { - eventConfigService.createEventOperationTask(OperationMgtConstants.OperationCodes.EVENT_REVOKE, + eventConfigService.createEventOperationTask(OperationMgtConstants.OperationCodes.EVENT_UPDATE, DeviceManagementConstants.EventServices.GEOFENCE, new GeoFenceEventMeta(geofenceData), tenantId, geofenceData.getGroupIds()); } catch (EventConfigurationException e) { - String msg = "Failed while creating EVENT_REVOKE operation creation task entry while updating geo fence " + String msg = "Failed while creating EVENT_UPDATE operation creation task entry while updating geo fence " + geofenceData.getFenceName() + " of the tenant " + tenantId; log.error(msg, e); throw new GeoLocationBasedServiceException(msg, e); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java index 8cf4630f0a..658dc64545 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -198,6 +198,7 @@ public class OperationManagerImpl implements OperationManager { String initiatedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (initiatedBy == null && (isScheduledOperation || operation.getCode().equalsIgnoreCase(OperationMgtConstants.OperationCodes.EVENT_CONFIG) + || operation.getCode().equalsIgnoreCase(OperationMgtConstants.OperationCodes.EVENT_UPDATE) || operation.getCode().equalsIgnoreCase(OperationMgtConstants.OperationCodes.EVENT_REVOKE))) { operation.setInitiatedBy(SYSTEM); } else if (StringUtils.isEmpty(operation.getInitiatedBy())) { @@ -1445,6 +1446,7 @@ public class OperationManagerImpl implements OperationManager { case DeviceManagementConstants.AuthorizationSkippedOperationCodes.POLICY_OPERATION_CODE: case DeviceManagementConstants.AuthorizationSkippedOperationCodes.EVENT_CONFIG_OPERATION_CODE: case DeviceManagementConstants.AuthorizationSkippedOperationCodes.EVENT_REVOKE_OPERATION_CODE: + case DeviceManagementConstants.AuthorizationSkippedOperationCodes.EVENT_UPDATE_OPERATION_CODE: case DeviceManagementConstants.AuthorizationSkippedOperationCodes.POLICY_REVOKE_OPERATION_CODE: case DeviceManagementConstants.AuthorizationSkippedOperationCodes.MONITOR_OPERATION_CODE: status = true; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationMgtConstants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationMgtConstants.java index 920da1526f..f0bfa8a330 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationMgtConstants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationMgtConstants.java @@ -26,6 +26,7 @@ public class OperationMgtConstants { public static final String POLICY_REVOKE = "POLICY_REVOKE"; public static final String EVENT_CONFIG = "EVENT_CONFIG"; + public static final String EVENT_UPDATE = "EVENT_UPDATE"; public static final String EVENT_REVOKE = "EVENT_REVOKE"; } } From 14580b5f5fe6a1cfaa93b652f07d15cf1d1e3a7d Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Thu, 16 May 2024 08:05:43 +0530 Subject: [PATCH 185/343] Fix EVENT_REVOKE operation is not being sent after geofence delete --- .../mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java | 3 +++ .../mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java index 191852ced3..67c8bf26f7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/GenericGeofenceDAOImpl.java @@ -626,6 +626,9 @@ public class GenericGeofenceDAOImpl extends AbstractGeofenceDAOImpl { geofenceData.setGroupData(groupMap); } } + if (geofenceData != null) { + geofenceData.setGroupIds(new ArrayList<>(groupMap.keySet())); + } return geofenceData; } } catch (SQLException e) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java index c1a719f446..db15476b48 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/geofence/SQLServerGeofenceDAOImpl.java @@ -157,6 +157,9 @@ public class SQLServerGeofenceDAOImpl extends AbstractGeofenceDAOImpl { geofenceData.setFenceShape(rst.getString("FENCE_SHAPE")); geofenceData.setGroupData(groupMap); } + if (geofenceData != null) { + geofenceData.setGroupIds(new ArrayList<>(groupMap.keySet())); + } return geofenceData; } } From f4fe3b8d825fe652a836ea73667664b76035e818 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 22 May 2024 12:08:57 +0530 Subject: [PATCH 186/343] Fix SQL issue in app uninstall feature --- .../core/dao/impl/subscription/GenericSubscriptionDAOImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 243ce17bf4..0aa4656866 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -1034,11 +1034,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc "AP_DEVICE_SUBSCRIPTION.AP_APP_RELEASE_ID = AP_APP_RELEASE.AP_APP_ID " + "WHERE PACKAGE_NAME = ? " + "AND DM_DEVICE_ID = ? " + - "AND UNSUBSCRIBED = 'FALSE' " + + "AND UNSUBSCRIBED = ? " + "AND STATUS = 'COMPLETED';"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, packageName); stmt.setInt(2, id); + stmt.setBoolean(3, false); try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { return rs.getString("UUID"); From fb79d61b60d833fc1072669412724355c508054a Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Tue, 7 May 2024 19:17:30 +0530 Subject: [PATCH 187/343] Add DEVICE_TYPE and DEVICE_IDENTIFICATION fields to DM_ENROLLMENT table --- .../carbon-home/dbscripts/dm-db-h2.sql | 2 + .../src/test/resources/sql/h2.sql | 2 + .../core/device/mgt/core/dao/DeviceDAO.java | 1 + .../device/mgt/core/dao/EnrollmentDAO.java | 4 +- .../core/dao/impl/AbstractDeviceDAOImpl.java | 670 ++++++++---------- .../dao/impl/AbstractEnrollmentDAOImpl.java | 77 +- .../core/dao/impl/AbstractEventConfigDAO.java | 4 - .../enrolment/GenericEnrollmentDAOImpl.java | 524 -------------- .../enrolment/SQLServerEnrollmentDAOImpl.java | 456 +----------- .../mgt/dao/impl/GenericOperationDAOImpl.java | 32 +- .../DeviceManagementProviderServiceImpl.java | 5 +- .../dao/DeviceStatusPersistenceTests.java | 4 +- .../core/dao/EnrolmentPersistenceTests.java | 4 +- .../src/test/resources/sql/h2.sql | 2 + .../src/test/resources/sql-files/h2.sql | 2 + .../policy/mgt/core/PolicyDAOTestCase.java | 3 +- .../src/test/resources/sql/CreateH2TestDB.sql | 2 + .../carbon-home/dbscripts/dm-db-h2.sql | 2 + .../src/main/resources/dbscripts/cdm/h2.sql | 2 + .../main/resources/dbscripts/cdm/mssql.sql | 2 + .../main/resources/dbscripts/cdm/mysql.sql | 14 +- .../main/resources/dbscripts/cdm/oracle.sql | 2 + .../resources/dbscripts/cdm/postgresql.sql | 2 + 23 files changed, 400 insertions(+), 1418 deletions(-) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 046e93de83..13ac69dfc6 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -125,6 +125,8 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, OWNER VARCHAR(255) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql index c079d1e214..a842fdf2ab 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql @@ -149,6 +149,8 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION ( CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, OWNER VARCHAR(50) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java index 2e7e69e358..0fd55c870d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java @@ -477,6 +477,7 @@ public interface DeviceDAO { * @return returns list of device types. * @throws DeviceManagementDAOException */ + @Deprecated List getDeviceTypes() throws DeviceManagementDAOException; /** diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java index 1bce2627d9..e42d5c1524 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo.Status; @@ -26,7 +27,8 @@ import java.util.List; public interface EnrollmentDAO { - EnrolmentInfo addEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, int tenantId) throws DeviceManagementDAOException; + EnrolmentInfo addEnrollment(int deviceId, DeviceIdentifier deviceIdentifier, + EnrolmentInfo enrolmentInfo, int tenantId) throws DeviceManagementDAOException; int updateEnrollment(EnrolmentInfo enrolmentInfo, int tenantId) throws DeviceManagementDAOException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 8c17c204a8..ba1cb3cf7f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -136,8 +136,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "d1.ID AS DEVICE_ID, " + "d1.DESCRIPTION, " + "d1.NAME AS DEVICE_NAME, " - + "d1.DEVICE_TYPE, " - + "d1.DEVICE_IDENTIFICATION, " + + "e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.STATUS, " @@ -149,12 +149,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "(SELECT " + "d.ID, " + "d.DESCRIPTION, " - + "d.NAME, " - + "t.NAME AS DEVICE_TYPE, " - + "d.DEVICE_IDENTIFICATION " - + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " - + "t.NAME = ? AND " - + "t.ID = d.DEVICE_TYPE_ID AND " + + "d.NAME " + + "FROM DM_DEVICE d" + "d.DEVICE_IDENTIFICATION = ? AND " + "d.TENANT_ID = ?"; @@ -212,23 +208,23 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + - "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " + - "t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + - "AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC, e.STATUS ASC"; - // Status adeed as an orderby clause to fix a bug : when an existing device is + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME " + + "FROM DM_DEVICE d WHERE " + + "d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + + "AND e.DEVICE_TYPE = ? AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC, e.STATUS ASC"; + // Status added as an order-by clause to fix a bug : when an existing device is // re-enrolled, earlier enrollment is marked as removed and a new enrollment is added. // However, both enrollments share the same time stamp. When retrieving the device - // due to same timestamp, enrollment information is incorrect, intermittently. Hence + // due to same timestamp, enrollment information is incorrect, intermittently. Hence, // status also should be taken into consideration when ordering. This should not present a // problem for other status transitions, as there would be an intermediary removed // state in between. stmt = conn.prepareStatement(sql); - stmt.setString(1, deviceIdentifier.getType()); - stmt.setString(2, deviceIdentifier.getId()); - stmt.setInt(3, tenantId); + stmt.setString(1, deviceIdentifier.getId()); + stmt.setInt(2, tenantId); + stmt.setString(3, deviceIdentifier.getType()); stmt.setInt(4, tenantId); rs = stmt.executeQuery(); if (rs.next()) { @@ -252,16 +248,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try { conn = this.getConnection(); String sql = "SELECT " + - "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " + "FROM " + "DM_ENROLMENT e," + - " (SELECT d.ID, d.DESCRIPTION, d.NAME, t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION " + - "FROM " + - "DM_DEVICE d, DM_DEVICE_TYPE t " + - "WHERE " + - "t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 " + + " (SELECT d.ID, d.DESCRIPTION, d.NAME " + + "FROM DM_DEVICE d " + + "WHERE d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 " + "WHERE " + "d1.ID = e.DEVICE_ID " + "AND TENANT_ID = ? " + @@ -299,16 +293,17 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + - "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " + - "t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME " + + "FROM DM_DEVICE d WHERE d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 " + + "WHERE e.DEVICE_TYPE = ? AND d1.ID = e.DEVICE_ID " + "AND TENANT_ID = ? AND e.OWNER = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); - stmt.setString(1, deviceIdentifier.getType()); - stmt.setString(2, deviceIdentifier.getId()); - stmt.setInt(3, tenantId); + stmt.setString(1, deviceIdentifier.getId()); + stmt.setInt(2, tenantId); + stmt.setString(3, deviceIdentifier.getType()); stmt.setInt(4, tenantId); stmt.setString(5, owner); rs = stmt.executeQuery(); @@ -333,18 +328,18 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + - "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t " + - "WHERE t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? " + - "AND d.LAST_UPDATED_TIMESTAMP > ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME " + + "FROM DM_DEVICE d WHERE d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? " + + "AND d.LAST_UPDATED_TIMESTAMP > ?) d1 WHERE e.DEVICE_TYPE = ? " + + "AND d1.ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); int paramIdx = 1; - stmt.setString(paramIdx++, deviceIdentifier.getType()); stmt.setString(paramIdx++, deviceIdentifier.getId()); stmt.setInt(paramIdx++, tenantId); stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); + stmt.setString(paramIdx++, deviceIdentifier.getType()); stmt.setInt(paramIdx, tenantId); rs = stmt.executeQuery(); if (rs.next()) { @@ -412,7 +407,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List deviceProperties = new ArrayList<>(); try { conn = this.getConnection(); - List> outputLists = new ArrayList<>(); String sql = "SELECT " + "p.DEVICE_IDENTIFICATION, " + "p.DEVICE_TYPE_NAME, " + @@ -426,7 +420,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int iterationCount = 0; StringBuilder propertyQuery = new StringBuilder(" "); - for (Map.Entry stringStringEntry : deviceProps.entrySet()) { + for (Map.Entry ignored : deviceProps.entrySet()) { String tempTableId = "t".concat(Integer.toString(iterationCount++)); propertyQuery.append("JOIN DM_DEVICE_PROPERTIES ") .append(tempTableId).append(" ").append("ON p.DEVICE_IDENTIFICATION = ") @@ -526,17 +520,16 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " + "FROM" + " DM_ENROLMENT e, " + - "(SELECT d.ID, d.DESCRIPTION, d.NAME, " + - "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME " + "FROM" + - " DM_DEVICE d, DM_DEVICE_TYPE t " + + " DM_DEVICE d " + "WHERE " + - "t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? AND" + + "d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? AND" + " d.LAST_UPDATED_TIMESTAMP > ?) d1 " + "WHERE" + " d1.ID = e.DEVICE_ID AND TENANT_ID = ? " + @@ -570,20 +563,20 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + - "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t " + - "WHERE t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME " + + "FROM DM_DEVICE d WHERE " + + "d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? " + "AND d.LAST_UPDATED_TIMESTAMP > ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ? AND e.OWNER = ? " + - "ORDER BY e.DATE_OF_LAST_UPDATE DESC"; + "AND e.DEVICE_TYPE = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); - stmt.setString(1, deviceIdentifier.getType()); - stmt.setString(2, deviceIdentifier.getId()); - stmt.setInt(3, tenantId); - stmt.setTimestamp(4, new Timestamp(since.getTime())); - stmt.setInt(5, tenantId); - stmt.setString(6, owner); + stmt.setString(1, deviceIdentifier.getId()); + stmt.setInt(2, tenantId); + stmt.setTimestamp(3, new Timestamp(since.getTime())); + stmt.setInt(4, tenantId); + stmt.setString(5, owner); + stmt.setString(6, deviceIdentifier.getType()); rs = stmt.executeQuery(); if (rs.next()) { device = DeviceManagementDAOUtil.loadMatchingDevice(rs, false); @@ -606,16 +599,16 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + - "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " + - "t.NAME = ? AND t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME " + + "FROM DM_DEVICE d WHERE " + + "d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND e.DEVICE_TYPE = ? AND e.DEVICE_IDENTIFICATION = ? " + "AND TENANT_ID = ? AND e.STATUS = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); - stmt.setString(1, deviceIdentifier.getType()); - stmt.setString(2, deviceIdentifier.getId()); - stmt.setInt(3, tenantId); + stmt.setInt(1, tenantId); + stmt.setString(2, deviceIdentifier.getType()); + stmt.setString(3, deviceIdentifier.getId()); stmt.setInt(4, tenantId); stmt.setString(5, status.toString()); rs = stmt.executeQuery(); @@ -639,7 +632,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { String sql = "SELECT d1.ID AS DEVICE_ID, " + "d1.DESCRIPTION, " + "d1.NAME AS DEVICE_NAME, " + - "d1.DEVICE_TYPE, " + + "e.DEVICE_TYPE, " + "e.TENANT_ID, " + "d1.DEVICE_IDENTIFICATION, " + "e.OWNER, " + @@ -653,19 +646,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "(SELECT d.ID, " + "d.DESCRIPTION, " + "d.NAME, " + - "t.NAME AS DEVICE_TYPE, " + "d.DEVICE_IDENTIFICATION " + - "FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t " + - "WHERE t.NAME = ? " + - "AND t.ID = d.DEVICE_TYPE_ID " + - "AND d.DEVICE_IDENTIFICATION = ?) d1 " + - "WHERE d1.ID = e.DEVICE_ID " + + "FROM DM_DEVICE d " + + "WHERE d.DEVICE_IDENTIFICATION = ?) d1 " + + "WHERE d1.ID = e.DEVICE_ID AND e.DEVICE_TYPE = ? " + "ORDER BY e.DATE_OF_LAST_UPDATE DESC"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, deviceIdentifier.getType()); - stmt.setString(2, deviceIdentifier.getId()); + stmt.setString(1, deviceIdentifier.getId()); + stmt.setString(2, deviceIdentifier.getType()); try (ResultSet rs = stmt.executeQuery()) { SingletonMap deviceMap = null; @@ -695,11 +684,10 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + - "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " + - "d.ID = ? AND t.ID = d.DEVICE_TYPE_ID AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME " + + "FROM DM_DEVICE d WHERE d.ID = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + "AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); stmt.setInt(1, deviceId); @@ -726,11 +714,10 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List devices; try { conn = this.getConnection(); - String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID, " + - "d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?) d1 " + + "d.DESCRIPTION, d.NAME FROM DM_DEVICE d WHERE d.TENANT_ID = ?) d1 " + "WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); @@ -758,24 +745,20 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List devices = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " + - "d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND t.NAME = ? " + - "AND t.ID = d.DEVICE_TYPE_ID AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?" + - " ORDER BY e.DATE_OF_LAST_UPDATE DESC"; + "d.NAME FROM DM_DEVICE d WHERE d.TENANT_ID = ?) d1 WHERE e.DEVICE_TYPE = ? AND d1.ID = e.DEVICE_ID " + + "AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); - stmt.setString(1, type); - stmt.setInt(2, tenantId); + stmt.setInt(1, tenantId); + stmt.setString(2, type); stmt.setInt(3, tenantId); rs = stmt.executeQuery(); devices = new ArrayList<>(); while (rs.next()) { Device device = DeviceManagementDAOUtil.loadActiveDevice(rs, false); - if (device != null) { - devices.add(device); - } + devices.add(device); } } catch (SQLException e) { String msg = "Error occurred while listing devices for type '" + type + "'"; @@ -791,40 +774,36 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { @Override public List getAllocatedDevices(String type, int tenantId, int activeServerCount, int serverIndex) throws DeviceManagementDAOException { - List devices = null; + List devices; try { Connection conn = this.getConnection(); String sql = "SELECT d1.ID AS DEVICE_ID," + - " d1.DESCRIPTION," + - " d1.NAME AS DEVICE_NAME," + - " d1.DEVICE_TYPE," + - " d1.DEVICE_IDENTIFICATION," + - " e.OWNER," + - " e.OWNERSHIP," + - " e.STATUS," + - " e.IS_TRANSFERRED," + - " e.DATE_OF_LAST_UPDATE," + - " e.DATE_OF_ENROLMENT," + - " e.ID AS ENROLMENT_ID " + - "FROM DM_ENROLMENT e," + - " (SELECT d.ID," + - " d.DESCRIPTION," + - " d.NAME," + - " d.DEVICE_IDENTIFICATION," + - " t.NAME AS DEVICE_TYPE" + - " FROM DM_DEVICE d, DM_DEVICE_TYPE t" + - " WHERE DEVICE_TYPE_ID = t.ID" + - " AND t.NAME = ?" + - " AND t.ID = d.DEVICE_TYPE_ID" + - " AND d.TENANT_ID = ?) d1 " + - "WHERE d1.ID = e.DEVICE_ID" + - " AND TENANT_ID = ?" + - " AND MOD(d1.ID, ?) = ? " + - "ORDER BY e.DATE_OF_LAST_UPDATE DESC"; + " d1.DESCRIPTION," + + " d1.NAME AS DEVICE_NAME," + + " e.DEVICE_TYPE," + + " e.DEVICE_IDENTIFICATION," + + " e.OWNER," + + " e.OWNERSHIP," + + " e.STATUS," + + " e.IS_TRANSFERRED," + + " e.DATE_OF_LAST_UPDATE," + + " e.DATE_OF_ENROLMENT," + + " e.ID AS ENROLMENT_ID " + + "FROM DM_ENROLMENT e," + + " (SELECT d.ID," + + " d.DESCRIPTION," + + " d.NAME" + + " FROM DM_DEVICE d" + + " WHERE d.TENANT_ID = ?) d1 " + + "WHERE d1.ID = e.DEVICE_ID" + + " AND e.DEVICE_TYPE = ?" + + " AND e.TENANT_ID = ?" + + " AND MOD(d1.ID, ?) = ? " + + "ORDER BY e.DATE_OF_LAST_UPDATE DESC"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, type); - stmt.setInt(2, tenantId); + stmt.setInt(1, tenantId); + stmt.setString(2, type); stmt.setInt(3, tenantId); stmt.setInt(4, activeServerCount); stmt.setInt(5, serverIndex); @@ -833,20 +812,18 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { Device device = DeviceManagementDAOUtil.loadActiveDevice(rs, false); - if (device != null) { - devices.add(device); - } + devices.add(device); } } catch (Exception e) { String msg = "Error encountered while populating allocated active devices for server with index : " + serverIndex + - " active-server-count " + activeServerCount + " device-type " + type + " tenant-id " + tenantId; + " active-server-count " + activeServerCount + " device-type " + type + " tenant-id " + tenantId; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } } } catch (SQLException e) { String msg = "Error encountered while retrieving allocated devices for server with index : " + serverIndex + - " active-server-count " + activeServerCount + " device-type " + type + " tenant-id " + tenantId; + " active-server-count " + activeServerCount + " device-type " + type + " tenant-id " + tenantId; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -861,12 +838,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List devices = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.IS_TRANSFERRED, e1.DATE_OF_LAST_UPDATE," + - " e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.DEVICE_IDENTIFICATION, t.NAME " + - "AS DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, " + - "e.DEVICE_ID, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " + - "e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?)) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " + - "AND t.ID = d.DEVICE_TYPE_ID ORDER BY e1.DATE_OF_LAST_UPDATE DESC"; + String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.IS_TRANSFERRED, " + + "e1.DATE_OF_LAST_UPDATE, e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, " + + "d.DEVICE_IDENTIFICATION, e1.DEVICE_TYPE FROM DM_DEVICE d, " + + "(SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, e.DEVICE_TYPE, " + + "e.DEVICE_ID, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT " + + "FROM DM_ENROLMENT e WHERE e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?)) e1 " + + "WHERE d.ID = e1.DEVICE_ID ORDER BY e1.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setString(2, username); @@ -894,12 +872,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List devices = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.IS_TRANSFERRED, e1.DATE_OF_LAST_UPDATE," + - " e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.DEVICE_IDENTIFICATION, t.NAME " + - "AS DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, " + - "e.DEVICE_ID, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " + - "e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?) ORDER BY e.DATE_OF_LAST_UPDATE DESC) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " + - "AND t.ID = d.DEVICE_TYPE_ID AND t.NAME= ?"; + String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.IS_TRANSFERRED, " + + "e1.DATE_OF_LAST_UPDATE, e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, " + + "d.DEVICE_IDENTIFICATION, e1.DEVICE_TYPE FROM DM_DEVICE d, " + + "(SELECT e.OWNER, e.DEVICE_TYPE, e.OWNERSHIP, e.ID AS ENROLMENT_ID, e.DEVICE_ID, e.STATUS, " + + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " + + "e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?) ORDER BY e.DATE_OF_LAST_UPDATE DESC) e1 " + + "WHERE d.ID = e1.DEVICE_ID AND e1.DEVICE_TYPE = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setString(2, username); @@ -928,7 +907,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { return devices; } Connection conn = this.getConnection(); - StringJoiner joiner = new StringJoiner(",","SELECT " + StringJoiner joiner = new StringJoiner(",", "SELECT " + "e1.OWNER, " + "e1.OWNERSHIP, " + "e1.ENROLMENT_ID, " @@ -940,40 +919,37 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "d.DESCRIPTION, " + "d.NAME AS DEVICE_NAME, " + "d.DEVICE_IDENTIFICATION, " - + "t.NAME AS DEVICE_TYPE " + + "e.DEVICE_TYPE " + "FROM " + "DM_DEVICE d, " + "(SELECT " - + "e.OWNER, " - + "e.OWNERSHIP, " - + "e.ID AS ENROLMENT_ID, " - + "e.DEVICE_ID, " - + "e.STATUS, " - + "e.IS_TRANSFERRED, " - + "e.DATE_OF_LAST_UPDATE, " - + "e.DATE_OF_ENROLMENT " - + "FROM " - + "DM_ENROLMENT e " - + "WHERE " - + "e.TENANT_ID = ? AND " - + "LOWER(e.OWNER) = LOWER(?) AND " - + "e.STATUS IN (", - ")) e1, " - + "DM_DEVICE_TYPE t " - + "WHERE d.ID = e1.DEVICE_ID AND " - + "t.ID = d.DEVICE_TYPE_ID " - + "ORDER BY e1.DATE_OF_LAST_UPDATE DESC"); + + "e.OWNER, " + + "e.DEVICE_TYPE " + + "e.OWNERSHIP, " + + "e.ID AS ENROLMENT_ID, " + + "e.DEVICE_ID, " + + "e.STATUS, " + + "e.IS_TRANSFERRED, " + + "e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT " + + "FROM " + + "DM_ENROLMENT e " + + "WHERE " + + "e.TENANT_ID = ? AND " + + "LOWER(e.OWNER) = LOWER(?) AND " + + "e.STATUS IN (", + ")) e1 ORDER BY e1.DATE_OF_LAST_UPDATE DESC"); deviceStatuses.stream().map(ignored -> "?").forEach(joiner::add); - String query = joiner.toString(); + String query = joiner.toString(); try (PreparedStatement stmt = conn.prepareStatement(query)) { int index = 1; stmt.setInt(index++, tenantId); stmt.setString(index++, username); - for (String deviceId : deviceStatuses) { - stmt.setObject(index++, deviceId); - } + for (String status : deviceStatuses) { + stmt.setObject(index++, status); + } try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { Device device = DeviceManagementDAOUtil.loadDevice(rs); @@ -1017,13 +993,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "gd.DESCRIPTION, " + "gd.NAME, " + "gd.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE " + "FROM " + "(SELECT d.ID AS DEVICE_ID, " + "d.DESCRIPTION, " + "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + - "d.DEVICE_TYPE_ID " + "FROM DM_DEVICE d, " + "(SELECT dgm.DEVICE_ID " + "FROM DM_DEVICE_GROUP_MAP dgm " + @@ -1035,18 +1009,18 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { sql = sql + " AND d.NAME LIKE ?"; isDeviceNameProvided = true; } - sql = sql + ") gd, DM_DEVICE_TYPE t WHERE gd.DEVICE_TYPE_ID = t.ID"; + sql = sql + ") gd WHERE 1=1"; //Add query for last updated timestamp if (since != null) { sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; isSinceProvided = true; } + sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? "; //Add the query for device-type if (deviceType != null && !deviceType.isEmpty()) { - sql = sql + " AND t.NAME = ?"; + sql = sql + " AND e.DEVICE_TYPE = ?"; isDeviceTypeProvided = true; } - sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? "; //Add the query for ownership if (ownership != null && !ownership.isEmpty()) { sql = sql + " AND e.OWNERSHIP = ?"; @@ -1075,10 +1049,10 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); } + stmt.setInt(paramIdx++, tenantId); if (isDeviceTypeProvided) { stmt.setString(paramIdx++, deviceType); } - stmt.setInt(paramIdx++, tenantId); if (isOwnershipProvided) { stmt.setString(paramIdx++, ownership); } @@ -1116,7 +1090,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { * Get device count of user. * * @return device count - * @throws DeviceManagementDAOException */ @Override public int getDeviceCount(String username, int tenantId) throws DeviceManagementDAOException { @@ -1126,13 +1099,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int deviceCount = 0; try { conn = this.getConnection(); - String sql = "SELECT COUNT(d1.DEVICE_ID) AS DEVICE_COUNT FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID FROM " + - "DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?) d1 WHERE " + - "d1.DEVICE_ID = e.DEVICE_ID AND LOWER(e.OWNER) = LOWER(?) AND TENANT_ID = ?"; + String sql = "SELECT COUNT(ID) AS DEVICE_COUNT FROM DM_ENROLMENT WHERE " + + "LOWER(OWNER) = LOWER(?) AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); - stmt.setInt(1, tenantId); - stmt.setString(2, username); - stmt.setInt(3, tenantId); + stmt.setString(1, username); + stmt.setInt(2, tenantId); rs = stmt.executeQuery(); if (rs.next()) { deviceCount = rs.getInt("DEVICE_COUNT"); @@ -1149,7 +1120,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { * Get device count of user. * * @return device count - * @throws DeviceManagementDAOException */ @Override public int getDeviceCount(String type, String status, int tenantId) throws DeviceManagementDAOException { @@ -1159,14 +1129,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int deviceCount = 0; try { conn = this.getConnection(); - String sql = "SELECT COUNT(d.ID) AS DEVICE_COUNT FROM (SELECT e.DEVICE_ID FROM DM_ENROLMENT e WHERE " + - "TENANT_ID = ? AND STATUS = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.ID = e.DEVICE_ID AND " + - "d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? AND t.NAME=?"; + String sql = "SELECT COUNT(ID) AS DEVICE_COUNT FROM DM_ENROLMENT WHERE " + + "DEVICE_TYPE = ? AND STATUS = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); - stmt.setInt(1, tenantId); + stmt.setString(1, type); stmt.setString(2, status); stmt.setInt(3, tenantId); - stmt.setString(4, type); rs = stmt.executeQuery(); if (rs.next()) { deviceCount = rs.getInt("DEVICE_COUNT"); @@ -1187,17 +1155,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List deviceIDs = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT d.DEVICE_IDENTIFICATION AS DEVICE_IDS FROM (SELECT e.DEVICE_ID FROM DM_ENROLMENT e WHERE " + - "TENANT_ID = ? AND STATUS = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.ID = e.DEVICE_ID AND " + - "d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? AND t.NAME=?"; + String sql = "SELECT DEVICE_IDENTIFICATION FROM DM_ENROLMENT WHERE " + + "DEVICE_TYPE = ? AND STATUS = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); - stmt.setInt(1, tenantId); + stmt.setString(1, type); stmt.setString(2, status); stmt.setInt(3, tenantId); - stmt.setString(4, type); rs = stmt.executeQuery(); while (rs.next()) { - deviceIDs.add(rs.getString("DEVICE_IDS")); + deviceIDs.add(rs.getString("DEVICE_IDENTIFICATION")); } } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while retrieving tenants which have " + @@ -1218,13 +1184,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { return false; } conn = this.getConnection(); - StringBuilder sql = new StringBuilder("UPDATE DM_ENROLMENT SET STATUS = ? WHERE DEVICE_ID IN " + - "(SELECT d.ID FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION IN ("); + StringBuilder sql = new StringBuilder("UPDATE DM_ENROLMENT SET STATUS = ? " + + "WHERE DEVICE_IDENTIFICATION IN ("); for (int i = 0; i < devices.size(); i++) { sql.append("?,"); } sql.deleteCharAt(sql.length() - 1); - sql.append(") AND t.NAME = ? AND d.TENANT_ID = ?) AND TENANT_ID = ?"); + sql.append(") AND DEVICE_TYPE = ? AND TENANT_ID = ?"); stmt = conn.prepareStatement(sql.toString()); stmt.setString(1, status); int index = 1; @@ -1233,7 +1199,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } stmt.setString(++index, deviceType); stmt.setInt(++index, tenantId); - stmt.setInt(++index, tenantId); stmt.executeUpdate(); } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while updating enrollment status in bulk", e); @@ -1247,7 +1212,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { * Get device count of all devices. * * @return device count - * @throws DeviceManagementDAOException */ @Override public int getDeviceCount(int tenantId) throws DeviceManagementDAOException { @@ -1257,12 +1221,10 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int deviceCount = 0; try { conn = this.getConnection(); - String sql = "SELECT COUNT(d1.DEVICE_ID) AS DEVICE_COUNT FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID FROM " + - "DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?) d1 WHERE " + - "d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?"; + String sql = "SELECT COUNT(ID) AS DEVICE_COUNT FROM DM_ENROLMENT WHERE " + + "TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); - stmt.setInt(2, tenantId); rs = stmt.executeQuery(); if (rs.next()) { deviceCount = rs.getInt("DEVICE_COUNT"); @@ -1300,25 +1262,24 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "(SELECT " + "d.ID, " + "d.NAME, " + - "d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE " + + "d.DEVICE_IDENTIFICATION " + "FROM " + - "DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + "DM_DEVICE d " + + "WHERE 1=1 "; //Add query for last updated timestamp if (since != null) { sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; isSinceProvided = true; } - if (deviceType != null && !deviceType.isEmpty()) { - sql = sql + " AND t.NAME = ?"; - isDeviceTypeProvided = true; - } if (deviceName != null && !deviceName.isEmpty()) { sql = sql + " AND d.NAME LIKE ?"; isDeviceNameProvided = true; } sql = sql + ") d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?"; + if (deviceType != null && !deviceType.isEmpty()) { + sql = sql + " AND e.DEVICE_TYPE = ?"; + isDeviceTypeProvided = true; + } if (ownership != null && !ownership.isEmpty()) { sql = sql + " AND e.OWNERSHIP = ?"; isOwnershipProvided = true; @@ -1338,17 +1299,16 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; - stmt.setInt(paramIdx++, tenantId); if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); } - if (isDeviceTypeProvided) { - stmt.setString(paramIdx++, request.getDeviceType()); - } if (isDeviceNameProvided) { stmt.setString(paramIdx++, "%" + request.getDeviceName() + "%"); } stmt.setInt(paramIdx++, tenantId); + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, request.getDeviceType()); + } if (isOwnershipProvided) { stmt.setString(paramIdx++, request.getOwnership()); } @@ -1384,13 +1344,10 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int deviceCount = 0; try { conn = this.getConnection(); - String sql = "SELECT COUNT(d1.ID) AS DEVICE_COUNT FROM DM_ENROLMENT e, (SELECT d.ID FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND t.NAME = ? " + - "AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?"; + String sql = "SELECT COUNT(ID) AS DEVICE_COUNT FROM DM_ENROLMENT WHERE DEVICE_TYPE = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, type); stmt.setInt(2, tenantId); - stmt.setInt(3, tenantId); rs = stmt.executeQuery(); if (rs.next()) { deviceCount = rs.getInt("DEVICE_COUNT"); @@ -1410,12 +1367,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int deviceCount = 0; try { conn = this.getConnection(); - String sql = "SELECT COUNT(e1.DEVICE_ID) AS DEVICE_COUNT FROM DM_DEVICE d, (SELECT e.DEVICE_ID " + - "FROM DM_ENROLMENT e WHERE e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?)) " + - "e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID AND t.ID = d.DEVICE_TYPE_ID"; + String sql = "SELECT COUNT(ID) AS DEVICE_COUNT FROM DM_ENROLMENT WHERE LOWER(OWNER) = LOWER(?)" + + " AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); - stmt.setInt(1, tenantId); - stmt.setString(2, username); + stmt.setString(1, username); + stmt.setInt(2, tenantId); ResultSet rs = stmt.executeQuery(); if (rs.next()) { @@ -1437,8 +1393,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int deviceCount = 0; try { conn = this.getConnection(); - String sql = "SELECT COUNT(d1.ID) AS DEVICE_COUNT FROM DM_ENROLMENT e, (SELECT d.ID FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.NAME LIKE ? AND d.TENANT_ID = ?) d1 " + + String sql = "SELECT COUNT(d1.ID) AS DEVICE_COUNT FROM DM_ENROLMENT e, (SELECT d.ID FROM DM_DEVICE d " + + "WHERE d.NAME LIKE ? AND d.TENANT_ID = ?) d1 " + "WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, deviceName + "%"); @@ -1465,13 +1421,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int deviceCount = 0; try { conn = this.getConnection(); - String sql = "SELECT COUNT(d.ID) AS DEVICE_COUNT FROM (SELECT e.DEVICE_ID FROM DM_ENROLMENT e WHERE " + - "TENANT_ID = ? AND OWNERSHIP = ?) e, DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE d.ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + String sql = "SELECT COUNT(ID) AS DEVICE_COUNT FROM DM_ENROLMENT WHERE " + + "TENANT_ID = ? AND OWNERSHIP = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setString(2, ownerShip); - stmt.setInt(3, tenantId); ResultSet rs = stmt.executeQuery(); if (rs.next()) { @@ -1493,13 +1447,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int deviceCount = 0; try { conn = this.getConnection(); - String sql = "SELECT COUNT(d.ID) AS DEVICE_COUNT FROM (SELECT e.DEVICE_ID FROM DM_ENROLMENT e WHERE " + - "TENANT_ID = ? AND STATUS = ?) e, DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE d.ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + String sql = "SELECT COUNT(ID) AS DEVICE_COUNT FROM DM_ENROLMENT WHERE " + + "TENANT_ID = ? AND STATUS = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setString(2, status); - stmt.setInt(3, tenantId); ResultSet rs = stmt.executeQuery(); if (rs.next()) { @@ -1521,14 +1473,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int deviceCount = 0; try { conn = this.getConnection(); - String sql = "SELECT COUNT(d.ID) AS DEVICE_COUNT FROM (SELECT e.DEVICE_ID FROM DM_ENROLMENT e WHERE " + - "TENANT_ID = ? AND STATUS = ?) e, DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE t.NAME = ? AND d.ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + String sql = "SELECT COUNT(ID) AS DEVICE_COUNT FROM DM_ENROLMENT WHERE " + + "TENANT_ID = ? AND STATUS = ? AND DEVICE_TYPE = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setString(2, status); stmt.setString(3, deviceType); - stmt.setInt(4, tenantId); ResultSet rs = stmt.executeQuery(); if (rs.next()) { @@ -1551,17 +1501,20 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int enrolmentId = -1; try { conn = this.getConnection(); - String sql = "INSERT INTO DM_ENROLMENT(DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, " + - "DATE_OF_ENROLMENT, DATE_OF_LAST_UPDATE, TENANT_ID) VALUES(?, ?, ?, ?, ?, ?, ?, ?)"; + String sql = "INSERT INTO DM_ENROLMENT(DEVICE_ID, DEVICE_TYPE, DEVICE_IDENTIFICATION, OWNER, OWNERSHIP, " + + "STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, DATE_OF_LAST_UPDATE, TENANT_ID) " + + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; stmt = conn.prepareStatement(sql, new String[]{"id"}); stmt.setInt(1, device.getId()); - stmt.setString(2, device.getEnrolmentInfo().getOwner()); - stmt.setString(3, device.getEnrolmentInfo().getOwnership().toString()); - stmt.setString(4, device.getEnrolmentInfo().getStatus().toString()); - stmt.setBoolean(5, device.getEnrolmentInfo().isTransferred()); - stmt.setTimestamp(6, new Timestamp(new Date().getTime())); - stmt.setTimestamp(7, new Timestamp(new Date().getTime())); - stmt.setInt(8, tenantId); + stmt.setString(2, device.getType()); + stmt.setString(3, device.getDeviceIdentifier()); + stmt.setString(4, device.getEnrolmentInfo().getOwner()); + stmt.setString(5, device.getEnrolmentInfo().getOwnership().toString()); + stmt.setString(6, device.getEnrolmentInfo().getStatus().toString()); + stmt.setBoolean(7, device.getEnrolmentInfo().isTransferred()); + stmt.setTimestamp(8, new Timestamp(new Date().getTime())); + stmt.setTimestamp(9, new Timestamp(new Date().getTime())); + stmt.setInt(10, tenantId); stmt.execute(); rs = stmt.getGeneratedKeys(); @@ -1583,16 +1536,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { PreparedStatement stmt = null; try { conn = this.getConnection(); - String sql = "UPDATE DM_ENROLMENT SET STATUS = ? WHERE DEVICE_ID = (SELECT d.ID FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION = ? " + - "AND t.NAME = ? AND d.TENANT_ID = ?) AND OWNER = ? AND TENANT_ID = ?"; + String sql = "UPDATE DM_ENROLMENT SET STATUS = ? WHERE DEVICE_IDENTIFICATION = ? " + + "AND DEVICE_TYPE = ? AND OWNER = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, status.toString()); stmt.setString(2, deviceId.getId()); stmt.setString(3, deviceId.getType()); - stmt.setInt(4, tenantId); - stmt.setString(5, currentOwner); - stmt.setInt(6, tenantId); + stmt.setString(4, currentOwner); + stmt.setInt(5, tenantId); stmt.executeUpdate(); } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment", e); @@ -1611,15 +1562,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Status status = null; try { conn = this.getConnection(); - String sql = "SELECT STATUS FROM DM_ENROLMENT WHERE DEVICE_ID = (SELECT d.ID FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION = ? " + - "AND t.NAME = ? AND d.TENANT_ID = ?) AND OWNER = ? AND TENANT_ID = ?"; + String sql = "SELECT STATUS FROM DM_ENROLMENT WHERE DEVICE_IDENTIFICATION = ? " + + "AND DEVICE_TYPE = ? AND OWNER = ? AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, deviceId.getId()); stmt.setString(2, deviceId.getType()); - stmt.setInt(3, tenantId); - stmt.setString(4, currentOwner); - stmt.setInt(5, tenantId); + stmt.setString(3, currentOwner); + stmt.setInt(4, tenantId); rs = stmt.executeQuery(); if (rs.next()) { @@ -1651,9 +1600,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "TENANT_ID " + "FROM DM_ENROLMENT " + "WHERE " - + "DEVICE_ID = (SELECT d.ID " + - "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID " + - "AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) " + + "DEVICE_IDENTIFICATION = ? AND DEVICE_TYPE = ? " + "AND OWNER = ? "; if (!StringUtils.isBlank(request.getOwnership())) { @@ -1664,7 +1611,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(paramIdx++, deviceId.getId()); stmt.setString(paramIdx++, deviceId.getType()); - stmt.setInt(paramIdx++, tenantId); stmt.setString(paramIdx++, request.getOwner()); if (!StringUtils.isBlank(request.getOwnership())) { stmt.setString(paramIdx++, request.getOwnership()); @@ -1686,23 +1632,21 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } @Override - public EnrolmentInfo getActiveEnrolment(DeviceIdentifier deviceId, int tenantId) throws DeviceManagementDAOException { + public EnrolmentInfo getActiveEnrolment(DeviceIdentifier deviceId, int tenantId) + throws DeviceManagementDAOException { Connection conn; PreparedStatement stmt = null; ResultSet rs = null; EnrolmentInfo enrolmentInfo = null; try { conn = this.getConnection(); - String sql = "SELECT ID AS ENROLMENT_ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, " + - "DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = (SELECT d.ID " + - "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID " + - "AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) " + - "AND TENANT_ID = ? AND STATUS != 'REMOVED'"; + String sql = "SELECT ID AS ENROLMENT_ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, " + + "DATE_OF_ENROLMENT, DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT " + + "WHERE DEVICE_IDENTIFICATION = ? AND DEVICE_TYPE = ? AND TENANT_ID = ? AND STATUS != 'REMOVED'"; stmt = conn.prepareStatement(sql); stmt.setString(1, deviceId.getId()); stmt.setString(2, deviceId.getType()); stmt.setInt(3, tenantId); - stmt.setInt(4, tenantId); rs = stmt.executeQuery(); if (rs.next()) { enrolmentInfo = DeviceManagementDAOUtil.loadEnrolment(rs); @@ -1725,12 +1669,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List devices = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, t.NAME AS DEVICE_TYPE, " + - "d.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ENROLMENT_ID FROM (SELECT e.ID, e.DEVICE_ID, e.OWNER, e" + - ".OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS " + - "ENROLMENT_ID FROM DM_ENROLMENT e WHERE TENANT_ID = ? AND STATUS = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t " + - "WHERE DEVICE_ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + String sql = "SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ENROLMENT_ID FROM (SELECT e.ID, e.DEVICE_ID, e.DEVICE_TYPE, e.OWNER, " + + "e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS " + + "ENROLMENT_ID FROM DM_ENROLMENT e WHERE TENANT_ID = ? AND STATUS = ?) e, " + + "DM_DEVICE d WHERE d.ID = e.DEVICE_ID AND d.TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setString(2, status.toString()); @@ -1751,6 +1695,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } @Override + @Deprecated public List getDeviceTypes() throws DeviceManagementDAOException { Connection conn; @@ -1779,9 +1724,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { * Returns the collection of devices that has been updated after the time given in the timestamp passed in. * * @param timestamp Timestamp in long, after which the devices have been updated. - * @param tenantId Tenant id of the currently logged in user. + * @param tenantId Tenant id of the currently logged-in user. * @return A collection of devices that have been updated after the provided timestamp - * @throws DeviceManagementDAOException */ public List getDevices(long timestamp, int tenantId) throws DeviceManagementDAOException { Connection conn; @@ -1790,11 +1734,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List devices = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + + String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID, " + - "d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE, d.LAST_UPDATED_TIMESTAMP FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? AND d.LAST_UPDATED_TIMESTAMP < CURRENT_TIMESTAMP) d1 " + + "d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP FROM DM_DEVICE d " + + "WHERE d.TENANT_ID = ? AND d.LAST_UPDATED_TIMESTAMP < CURRENT_TIMESTAMP) d1 " + "WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); @@ -1854,7 +1798,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "MIN(DEVICE.ID) AS DEVICE_ID, " + "MIN(DEVICE.NAME) AS DEVICE_NAME, " + "MIN(DEVICE.DESCRIPTION) AS DESCRIPTION, " + - "MIN(DEVICE_TYPE.NAME) AS DEVICE_TYPE, " + + "MIN(ENROLMENT.DEVICE_TYPE) AS DEVICE_TYPE, " + "MIN(DEVICE.DEVICE_IDENTIFICATION) AS DEVICE_IDENTIFICATION, " + "MIN(ENROLMENT.ID) AS ENROLMENT_ID, " + "MIN(ENROLMENT.OWNER) AS OWNER, " + @@ -1864,11 +1808,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "MIN(ENROLMENT.DATE_OF_LAST_UPDATE) AS DATE_OF_LAST_UPDATE, " + "MIN(ENROLMENT.STATUS) AS STATUS " + "FROM DM_DEVICE_LOCATION AS DEVICE_LOCATION, DM_DEVICE AS DEVICE, " + - "DM_DEVICE_TYPE AS DEVICE_TYPE, DM_ENROLMENT AS ENROLMENT " + + "DM_ENROLMENT AS ENROLMENT " + "WHERE DEVICE_LOCATION.LATITUDE BETWEEN ? AND ? " + "AND DEVICE_LOCATION.LONGITUDE BETWEEN ? AND ? "; if (geoQuery.getDeviceTypes() != null && !geoQuery.getDeviceTypes().isEmpty()) { - sql += "AND DEVICE_TYPE.NAME IN ("; + sql += "AND ENROLMENT.DEVICE_TYPE IN ("; sql += String.join(", ", Collections.nCopies(geoQuery.getDeviceTypes().size(), "?")); sql += ") "; @@ -1905,7 +1849,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { if (geoQuery.getUpdatedBefore() != 0 || geoQuery.getUpdatedAfter() != 0) { sql += "AND ENROLMENT.DATE_OF_LAST_UPDATE BETWEEN ? AND ? "; } - sql += "AND DEVICE.ID = DEVICE_LOCATION.DEVICE_ID AND DEVICE.DEVICE_TYPE_ID = DEVICE_TYPE.ID " + + sql += "AND DEVICE.ID = DEVICE_LOCATION.DEVICE_ID " + "AND DEVICE.ID = ENROLMENT.DEVICE_ID " + "AND DEVICE.TENANT_ID = ? AND DEVICE.TENANT_ID = ENROLMENT.TENANT_ID GROUP BY GEOHASH_PREFIX"; stmt = conn.prepareStatement(sql); @@ -1917,27 +1861,27 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { stmt.setDouble(index++, geoQuery.getSouthWest().getLongitude()); stmt.setDouble(index++, geoQuery.getNorthEast().getLongitude()); if (geoQuery.getDeviceTypes() != null) { - for (String s: geoQuery.getDeviceTypes()) { + for (String s : geoQuery.getDeviceTypes()) { stmt.setString(index++, s); } } if (geoQuery.getDeviceIdentifiers() != null) { - for (String s: geoQuery.getDeviceIdentifiers()) { + for (String s : geoQuery.getDeviceIdentifiers()) { stmt.setString(index++, s); } } if (geoQuery.getOwners() != null) { - for (String s: geoQuery.getOwners()) { + for (String s : geoQuery.getOwners()) { stmt.setString(index++, s); } } if (geoQuery.getOwnerships() != null) { - for (String s: geoQuery.getOwnerships()) { + for (String s : geoQuery.getOwnerships()) { stmt.setString(index++, s); } } if (geoQuery.getStatuses() != null) { - for (Status s: geoQuery.getStatuses()) { + for (Status s : geoQuery.getStatuses()) { stmt.setString(index++, s.toString()); } } @@ -2013,15 +1957,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { StringJoiner joiner = new StringJoiner(",", "SELECT " - + "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " - + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " + + "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " + "e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " + "FROM " + "DM_ENROLMENT e, " - + "(SELECT d.ID, d.DESCRIPTION, d.NAME, t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION " - + "FROM DM_DEVICE d, DM_DEVICE_TYPE t " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME " + + "FROM DM_DEVICE d " + "WHERE " - + "t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION IN (", + + "d.DEVICE_IDENTIFICATION IN (", ") AND d.TENANT_ID = ?) d1 " + "WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ? " + "ORDER BY e.DATE_OF_LAST_UPDATE DESC, e.STATUS ASC"); @@ -2071,15 +2015,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { StringJoiner joiner = new StringJoiner(",", "SELECT " - + "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + + "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " + "e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " + "FROM " + "DM_ENROLMENT e, " - + "(SELECT d.ID, d.DESCRIPTION, d.NAME, t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION " - + "FROM DM_DEVICE d, DM_DEVICE_TYPE t " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION " + + "FROM DM_DEVICE d " + "WHERE " - + "t.ID = d.DEVICE_TYPE_ID AND d.DEVICE_IDENTIFICATION IN (", + + " d.DEVICE_IDENTIFICATION IN (", ") AND d.TENANT_ID = ?) d1 " + "WHERE d1.ID = e.DEVICE_ID AND " + statusJoiner.toString() + "AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC, e.STATUS ASC"); @@ -2113,7 +2057,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } public List getDeviceLocationInfo(DeviceIdentifier deviceIdentifier, long from, - long to) throws DeviceManagementDAOException { + long to) throws DeviceManagementDAOException { List deviceLocationHistories = new ArrayList<>(); String sql = "SELECT " + "DEVICE_ID, " @@ -2245,7 +2189,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "d.ID AS DEVICE_ID, " + "d.DESCRIPTION, " + "d.NAME AS DEVICE_NAME, " + - "t.NAME AS DEVICE_TYPE, " + + "e.DEVICE_TYPE, " + "d.DEVICE_IDENTIFICATION, " + "e.OWNER, " + "e.OWNERSHIP, " + @@ -2256,9 +2200,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "e.ID AS ENROLMENT_ID " + "FROM DM_DEVICE AS d " + "INNER JOIN DM_ENROLMENT AS e ON d.ID = e.DEVICE_ID " + - "INNER JOIN DM_DEVICE_TYPE AS t ON d.DEVICE_TYPE_ID = t.ID " + "WHERE " + - "t.NAME = ? AND e.TENANT_ID = ? AND d.ID " + + "e.DEVICE_TYPE = ? AND e.TENANT_ID = ? AND d.ID " + "NOT IN " + "(SELECT a.DEVICE_ID FROM DM_APPLICATION AS a WHERE a.APP_IDENTIFIER = ?"; @@ -2310,9 +2253,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "COUNT(d.ID) AS DEVICE_COUNT " + "FROM DM_DEVICE AS d " + "INNER JOIN DM_ENROLMENT AS e ON d.ID = e.DEVICE_ID " + - "INNER JOIN DM_DEVICE_TYPE AS t ON d.DEVICE_TYPE_ID = t.ID " + "WHERE " + - "t.NAME = ? AND e.TENANT_ID = ? AND d.ID " + + "e.DEVICE_TYPE = ? AND e.TENANT_ID = ? AND d.ID " + "NOT IN " + "(SELECT a.DEVICE_ID FROM DM_APPLICATION AS a WHERE a.APP_IDENTIFIER = ?"; @@ -2354,40 +2296,39 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { try { Connection conn = getConnection(); - String sql = "" + + String sql = "SELECT e1.owner," + - "e1.ownership," + - "e1.enrolment_id," + - "e1.device_id," + - "e1.status," + - "e1.date_of_last_update," + - "e1.date_of_enrolment," + - "d.description," + - "d.NAME AS DEVICE_NAME," + - "d.device_identification," + - "t.NAME AS DEVICE_TYPE " + - "FROM dm_device d," + - "(SELECT e.owner," + - "e.ownership," + - "e.id AS ENROLMENT_ID," + - "e.device_id," + - "e.status, " + - "e.date_of_last_update, " + - "e.date_of_enrolment " + - "FROM dm_enrolment e " + - "INNER JOIN " + - "(SELECT DEVICE_ID " + - "FROM DM_DEVICE_INFO " + - "WHERE " + - "KEY_FIELD = 'encryptionEnabled' " + - "AND VALUE_FIELD = ?) AS di " + - "ON di.DEVICE_ID = e.DEVICE_ID " + - "WHERE e.tenant_id = ?) e1, " + - "dm_device_type t " + - "WHERE d.id = e1.device_id " + - "AND t.id = d.device_type_id " + - "ORDER BY e1.date_of_last_update DESC " + - "LIMIT ? OFFSET ?"; + "e1.ownership," + + "e1.enrolment_id," + + "e1.device_id," + + "e1.status," + + "e1.date_of_last_update," + + "e1.date_of_enrolment," + + "d.description," + + "d.NAME AS DEVICE_NAME," + + "d.device_identification," + + "e1.DEVICE_TYPE " + + "FROM dm_device d," + + "(SELECT e.owner," + + "e.ownership," + + "e.id AS ENROLMENT_ID," + + "e.device_id," + + "e.status, " + + "e.date_of_last_update, " + + "e.date_of_enrolment " + + "e.DEVICE_TYPE " + + "FROM dm_enrolment e " + + "INNER JOIN " + + "(SELECT DEVICE_ID " + + "FROM DM_DEVICE_INFO " + + "WHERE " + + "KEY_FIELD = 'encryptionEnabled' " + + "AND VALUE_FIELD = ?) AS di " + + "ON di.DEVICE_ID = e.DEVICE_ID " + + "WHERE e.tenant_id = ?) e1, " + + "WHERE d.id = e1.device_id " + + "ORDER BY e1.date_of_last_update DESC " + + "LIMIT ? OFFSET ?"; try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setBoolean(1, isEncrypted); @@ -2417,23 +2358,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { try { Connection conn = getConnection(); - String sql = "" + - "SELECT " + - "COUNT(e1.DEVICE_ID) AS DEVICE_COUNT " + - "FROM dm_device d," + - "(SELECT e.id AS ENROLMENT_ID, " + - "e.device_id " + - "FROM dm_enrolment e " + - "INNER JOIN " + - "(SELECT DEVICE_ID " + - "FROM DM_DEVICE_INFO " + - "WHERE KEY_FIELD = 'encryptionEnabled' " + - "AND VALUE_FIELD = ?) AS di " + - "ON di.DEVICE_ID = e.DEVICE_ID " + - "WHERE e.tenant_id = ?) e1, " + - "dm_device_type t " + - "WHERE d.id = e1.device_id " + - "AND t.id = d.device_type_id "; + String sql = + "SELECT COUNT(DEVICE_ID) " + + "FROM DM_DEVICE_INFO " + + "WHERE KEY_FIELD = 'encryptionEnabled' " + + "AND VALUE_FIELD = ?"; + //TODO: Add tenant column to DM_DEVICE_INFO table try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setBoolean(1, isEncrypted); @@ -3092,16 +3022,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "DM_DEVICE.ID AS DEVICE_ID, " + "DM_DEVICE.NAME AS DEVICE_NAME, " + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " - + "DM_DEVICE.DEVICE_TYPE_ID, " - + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + + "e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + "e.ID AS ENROLMENT_ID, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.DATE_OF_ENROLMENT, " + "e.DATE_OF_LAST_UPDATE, " + "e.STATUS, " - + "e.IS_TRANSFERRED, " - + "device_types.NAME AS DEVICE_TYPE " + + "e.IS_TRANSFERRED " + "FROM DM_DEVICE_GROUP_MAP " + "INNER JOIN DM_DEVICE ON " + "DM_DEVICE_GROUP_MAP.DEVICE_ID = DM_DEVICE.ID " @@ -3110,8 +3039,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "INNER JOIN DM_ENROLMENT e ON " + "DM_DEVICE.ID = e.DEVICE_ID AND " + "DM_DEVICE.TENANT_ID = e.TENANT_ID " - + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " - + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " + "WHERE DM_DEVICE.ID IN (", ") AND DM_DEVICE.TENANT_ID = ?"); @@ -3289,10 +3216,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); List devices = new ArrayList<>(); String query = "SELECT e.ID AS ENROLMENT_ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.DATE_OF_ENROLMENT, " + - "e.DATE_OF_LAST_UPDATE, e.IS_TRANSFERRED, e.STATUS,d.DEVICE_NAME, d.DESCRIPTION, d.DEVICE_TYPE, d.DEVICE_IDENTIFICATION " + - "FROM DM_ENROLMENT e,(SELECT d1.ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_IDENTIFICATION, " + - "t1.NAME AS DEVICE_TYPE FROM DM_DEVICE d1, DM_DEVICE_TYPE t1 WHERE d1.DEVICE_TYPE_ID = t1.ID " + - "AND d1.TENANT_ID = ?) d WHERE e.STATUS NOT IN ('DELETED', 'REMOVED') AND e.DATE_OF_ENROLMENT > ? AND e.TENANT_ID = ?"; + "e.DATE_OF_LAST_UPDATE, e.IS_TRANSFERRED, e.STATUS,d.DEVICE_NAME, d.DESCRIPTION, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION " + + "FROM DM_ENROLMENT e, (SELECT d1.ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME FROM DM_DEVICE d1 " + + "WHERE d1.TENANT_ID = ?) d WHERE e.STATUS NOT IN ('DELETED', 'REMOVED') " + + "AND e.DATE_OF_ENROLMENT > ? AND e.TENANT_ID = ?"; try { Connection connection = DeviceManagementDAOFactory.getConnection(); try (PreparedStatement preparedStatement = connection.prepareStatement(query)) { @@ -3314,14 +3242,16 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } return devices; } + public List getDevicesEnrolledPriorTo(Date priorTo) throws DeviceManagementDAOException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); List devices = new ArrayList<>(); String query = "SELECT e.ID AS ENROLMENT_ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.DATE_OF_ENROLMENT, " + - "e.DATE_OF_LAST_UPDATE, e.IS_TRANSFERRED, e.STATUS, d.DEVICE_NAME, d.DESCRIPTION, d.DEVICE_TYPE, d.DEVICE_IDENTIFICATION " + - "FROM DM_ENROLMENT e,(SELECT d1.ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_IDENTIFICATION, " + - "t1.NAME AS DEVICE_TYPE FROM DM_DEVICE d1, DM_DEVICE_TYPE t1 WHERE d1.DEVICE_TYPE_ID = t1.ID " + - "AND d1.TENANT_ID = ?) d WHERE e.STATUS NOT IN ('DELETED', 'REMOVED') AND e.DATE_OF_ENROLMENT < ? AND e.TENANT_ID = ?"; + "e.DATE_OF_LAST_UPDATE, e.IS_TRANSFERRED, e.STATUS, d.DEVICE_NAME, d.DESCRIPTION, e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION " + + "FROM DM_ENROLMENT e, (SELECT d1.ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME FROM DM_DEVICE d1 " + + "WHERE d1.TENANT_ID = ?) d WHERE e.STATUS NOT IN ('DELETED', 'REMOVED') " + + "AND e.DATE_OF_ENROLMENT < ? AND e.TENANT_ID = ?"; try { Connection connection = DeviceManagementDAOFactory.getConnection(); try (PreparedStatement preparedStatement = connection.prepareStatement(query)) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index 98050fe318..8bde335227 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; @@ -39,24 +40,29 @@ import java.util.List; public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { @Override - public EnrolmentInfo addEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, + public EnrolmentInfo addEnrollment(int deviceId, DeviceIdentifier deviceIdentifier, EnrolmentInfo enrolmentInfo, int tenantId) throws DeviceManagementDAOException { Connection conn; PreparedStatement stmt = null; ResultSet rs = null; try { conn = this.getConnection(); - String sql = "INSERT INTO DM_ENROLMENT(DEVICE_ID, OWNER, OWNERSHIP, STATUS, " + - "DATE_OF_ENROLMENT, DATE_OF_LAST_UPDATE, TENANT_ID) VALUES(?, ?, ?, ?, ?, ?, ?)"; - stmt = conn.prepareStatement(sql, new String[] {"id"}); + String sql = "INSERT INTO DM_ENROLMENT(DEVICE_ID, DEVICE_TYPE, DEVICE_IDENTIFICATION, OWNER, OWNERSHIP, " + + "STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, DATE_OF_LAST_UPDATE, TENANT_ID) " + + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; Timestamp enrollmentTime = new Timestamp(new Date().getTime()); + + stmt = conn.prepareStatement(sql, new String[]{"id"}); stmt.setInt(1, deviceId); - stmt.setString(2, enrolmentInfo.getOwner()); - stmt.setString(3, enrolmentInfo.getOwnership().toString()); - stmt.setString(4, enrolmentInfo.getStatus().toString()); - stmt.setTimestamp(5, enrollmentTime); - stmt.setTimestamp(6, enrollmentTime); - stmt.setInt(7, tenantId); + stmt.setString(2, deviceIdentifier.getType()); + stmt.setString(3, deviceIdentifier.getId()); + stmt.setString(4, enrolmentInfo.getOwner()); + stmt.setString(5, enrolmentInfo.getOwnership().toString()); + stmt.setString(6, enrolmentInfo.getStatus().toString()); + stmt.setBoolean(7, enrolmentInfo.isTransferred()); + stmt.setTimestamp(8, enrollmentTime); + stmt.setTimestamp(9, enrollmentTime); + stmt.setInt(10, tenantId); stmt.execute(); rs = stmt.getGeneratedKeys(); @@ -70,7 +76,6 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } return null; } catch (SQLException e) { - e.printStackTrace(); throw new DeviceManagementDAOException("Error occurred while adding enrolment configuration", e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); @@ -81,7 +86,6 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { public int updateEnrollment(EnrolmentInfo enrolmentInfo, int tenantId) throws DeviceManagementDAOException { Connection conn; PreparedStatement stmt = null; - ResultSet rs = null; try { conn = this.getConnection(); String sql = "UPDATE DM_ENROLMENT SET OWNERSHIP = ?, STATUS = ?, DATE_OF_LAST_UPDATE = ? " + @@ -92,12 +96,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { stmt.setTimestamp(3, new Timestamp(new Date().getTime())); stmt.setInt(4, enrolmentInfo.getId()); stmt.setInt(5, tenantId); - int updatedCount = stmt.executeUpdate(); - return updatedCount; + return stmt.executeUpdate(); } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e); } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); + DeviceManagementDAOUtil.cleanupResources(stmt, null); } } @@ -105,7 +108,6 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { public boolean updateEnrollmentStatus(List enrolmentInfos) throws DeviceManagementDAOException { Connection conn; PreparedStatement stmt = null; - ResultSet rs = null; boolean status = false; int updateStatus = -1; try { @@ -132,7 +134,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while updating enrolment status of given device-list.", e); } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); + DeviceManagementDAOUtil.cleanupResources(stmt, null); } return status; } @@ -147,7 +149,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { try { conn = this.getConnection(); String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql, new String[] {"id"}); + stmt = conn.prepareStatement(sql, new String[]{"id"}); stmt.setInt(1, deviceId); stmt.setString(2, currentOwner); stmt.setInt(3, tenantId); @@ -177,12 +179,12 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { stmt.setString(1, owner); stmt.setInt(2, tenantID); rs = stmt.executeQuery(); - if(rs.next()){ + if (rs.next()) { count = rs.getInt("COUNT"); } } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while trying to get device " + - "count of Owner : "+owner, e); + "count of Owner : " + owner, e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } @@ -197,11 +199,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { @Override public boolean setStatusAllDevices(String currentOwner, EnrolmentInfo.Status status, int tenantId) - throws DeviceManagementDAOException{ + throws DeviceManagementDAOException { Connection conn; PreparedStatement stmt = null; Timestamp updateTime = new Timestamp(new Date().getTime()); - if(getCountOfDevicesOfOwner(currentOwner, tenantId) > 0){ + if (getCountOfDevicesOfOwner(currentOwner, tenantId) > 0) { try { conn = this.getConnection(); String sql = "UPDATE DM_ENROLMENT SET STATUS = ?, DATE_OF_LAST_UPDATE = ? WHERE OWNER = ? AND TENANT_ID = ?"; @@ -236,8 +238,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { stmt.setInt(3, enrolmentID); stmt.setInt(4, tenantId); int updatedRowCount = stmt.executeUpdate(); - if (updatedRowCount != 1){ - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment: "+ + if (updatedRowCount != 1) { + throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment: " + updatedRowCount + " rows were updated instead of one row!!!"); } // save the device status history @@ -254,10 +256,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { return addDeviceStatus(config.getId(), config.getStatus()); } - public boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException { + public boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) + throws DeviceManagementDAOException { Connection conn; String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - if (changedBy == null){ + if (changedBy == null) { changedBy = DeviceManagementConstants.MaintenanceProperties.MAINTENANCE_USER; } PreparedStatement stmt = null; @@ -281,7 +284,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { sql = "INSERT INTO DM_DEVICE_STATUS (ENROLMENT_ID, DEVICE_ID, STATUS, UPDATE_TIME, CHANGED_BY) VALUES(?, ?, ?, ?, ?)"; try (PreparedStatement ps = conn.prepareStatement(sql)) { if (conn.getMetaData().supportsBatchUpdates()) { - for(int[] info: enrolmentInfoList){ + for (int[] info : enrolmentInfoList) { ps.setInt(1, info[0]); ps.setInt(2, info[1]); ps.setString(3, status.toString()); @@ -296,7 +299,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } } } else { - for(int[] info: enrolmentInfoList){ + for (int[] info : enrolmentInfoList) { ps.setInt(1, info[0]); ps.setInt(2, info[1]); ps.setString(3, status.toString()); @@ -320,14 +323,15 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { public boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException { Connection conn; String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - if (changedBy == null){ + if (changedBy == null) { changedBy = DeviceManagementConstants.MaintenanceProperties.MAINTENANCE_USER; } PreparedStatement stmt = null; try { conn = this.getConnection(); - // get the device id and last udpated status from the device status table - String sql = "SELECT DEVICE_ID, STATUS FROM DM_DEVICE_STATUS WHERE ENROLMENT_ID = ? ORDER BY UPDATE_TIME DESC LIMIT 1"; + // get the device id and last updated status from the device status table + String sql = "SELECT DEVICE_ID, STATUS FROM DM_DEVICE_STATUS " + + "WHERE ENROLMENT_ID = ? ORDER BY UPDATE_TIME DESC LIMIT 1"; stmt = conn.prepareStatement(sql); stmt.setInt(1, enrolmentId); ResultSet rs = stmt.executeQuery(); @@ -353,12 +357,14 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } else { // if there were no records corresponding to the enrolment id this is a problem. i.e. enrolment // id is invalid - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment: no record for enrolment id " + enrolmentId); + throw new DeviceManagementDAOException("Error occurred while setting the status of " + + "device enrolment: no record for enrolment id " + enrolmentId); } DeviceManagementDAOUtil.cleanupResources(stmt, null); } - sql = "INSERT INTO DM_DEVICE_STATUS (ENROLMENT_ID, DEVICE_ID, STATUS, UPDATE_TIME, CHANGED_BY) VALUES(?, ?, ?, ?, ?)"; + sql = "INSERT INTO DM_DEVICE_STATUS (ENROLMENT_ID, DEVICE_ID, STATUS, UPDATE_TIME, CHANGED_BY) " + + "VALUES(?, ?, ?, ?, ?)"; stmt = conn.prepareStatement(sql); Timestamp updateTime = new Timestamp(new Date().getTime()); stmt.setInt(1, enrolmentId); @@ -377,6 +383,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } return true; } + @Override public EnrolmentInfo.Status getStatus(int deviceId, String currentOwner, int tenantId) throws DeviceManagementDAOException { @@ -534,11 +541,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } } - private Connection getConnection() throws SQLException { + protected Connection getConnection() throws SQLException { return DeviceManagementDAOFactory.getConnection(); } - private EnrolmentInfo loadEnrolment(ResultSet rs) throws SQLException { + protected EnrolmentInfo loadEnrolment(ResultSet rs) throws SQLException { EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); enrolmentInfo.setOwner(rs.getString("OWNER")); enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.valueOf(rs.getString("OWNERSHIP"))); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEventConfigDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEventConfigDAO.java index e5780003d1..dfe882ed44 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEventConfigDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEventConfigDAO.java @@ -21,7 +21,6 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.event.config.EventConfig; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.EventConfigDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.EventManagementDAOFactory; @@ -30,12 +29,9 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.Timestamp; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; public abstract class AbstractEventConfigDAO implements EventConfigDAO { private static final Log log = LogFactory.getLog(AbstractEventConfigDAO.class); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/GenericEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/GenericEnrollmentDAOImpl.java index 188af00f88..831e058ad9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/GenericEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/GenericEnrollmentDAOImpl.java @@ -17,532 +17,8 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.enrolment; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractEnrollmentDAOImpl; -import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; - -import java.sql.*; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; public class GenericEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl { - @Override - public EnrolmentInfo addEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, - int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - try { - conn = this.getConnection(); - String sql = "INSERT INTO DM_ENROLMENT(DEVICE_ID, OWNER, OWNERSHIP, STATUS, " + - "DATE_OF_ENROLMENT, DATE_OF_LAST_UPDATE, TENANT_ID) VALUES(?, ?, ?, ?, ?, ?, ?)"; - stmt = conn.prepareStatement(sql, new String[] {"id"}); - Timestamp enrollmentTime = new Timestamp(new Date().getTime()); - stmt.setInt(1, deviceId); - stmt.setString(2, enrolmentInfo.getOwner()); - stmt.setString(3, enrolmentInfo.getOwnership().toString()); - stmt.setString(4, enrolmentInfo.getStatus().toString()); - stmt.setTimestamp(5, enrollmentTime); - stmt.setTimestamp(6, enrollmentTime); - stmt.setInt(7, tenantId); - stmt.execute(); - - rs = stmt.getGeneratedKeys(); - if (rs.next()) { - int enrolmentId = rs.getInt(1); - enrolmentInfo.setId(enrolmentId); - enrolmentInfo.setDateOfEnrolment(enrollmentTime.getTime()); - enrolmentInfo.setDateOfLastUpdate(enrollmentTime.getTime()); - addDeviceStatus(enrolmentId, enrolmentInfo.getStatus()); - return enrolmentInfo; - } - return null; - } catch (SQLException e) { - e.printStackTrace(); - throw new DeviceManagementDAOException("Error occurred while adding enrolment configuration", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public int updateEnrollment(EnrolmentInfo enrolmentInfo, int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - try { - conn = this.getConnection(); - String sql = "UPDATE DM_ENROLMENT SET OWNERSHIP = ?, STATUS = ?, DATE_OF_LAST_UPDATE = ? " + - "WHERE ID = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, enrolmentInfo.getOwnership().toString()); - stmt.setString(2, enrolmentInfo.getStatus().toString()); - stmt.setTimestamp(3, new Timestamp(new Date().getTime())); - stmt.setInt(4, enrolmentInfo.getId()); - stmt.setInt(5, tenantId); - int updatedCount = stmt.executeUpdate(); - return updatedCount; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public boolean updateEnrollmentStatus(List enrolmentInfos) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - boolean status = false; - int updateStatus = -1; - try { - conn = this.getConnection(); - String sql = "UPDATE DM_ENROLMENT SET STATUS = ? WHERE ID = ?"; - stmt = conn.prepareStatement(sql); - if (conn.getMetaData().supportsBatchUpdates()) { - for (EnrolmentInfo enrolmentInfo : enrolmentInfos) { - stmt.setString(1, enrolmentInfo.getStatus().toString()); - stmt.setInt(2, enrolmentInfo.getId()); - stmt.addBatch(); - } - updateStatus = stmt.executeBatch().length; - } else { - for (EnrolmentInfo enrolmentInfo : enrolmentInfos) { - stmt.setString(1, enrolmentInfo.getStatus().toString()); - stmt.setInt(2, enrolmentInfo.getId()); - updateStatus = stmt.executeUpdate(); - } - } - if (updateStatus > 0) { - status = true; - } - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while updating enrolment status of given device-list.", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - return status; - } - - @Override - public int removeEnrollment(int deviceId, String currentOwner, - int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - int status = -1; - try { - conn = this.getConnection(); - String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql, new String[] {"id"}); - stmt.setInt(1, deviceId); - stmt.setString(2, currentOwner); - stmt.setInt(3, tenantId); - stmt.executeUpdate(); - - rs = stmt.getGeneratedKeys(); - if (rs.next()) { - status = 1; - } - return status; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while removing device enrolment", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - private int getCountOfDevicesOfOwner(String owner, int tenantID) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - int count = 0; - try { - conn = this.getConnection(); - String checkQuery = "SELECT COUNT(ID) AS COUNT FROM DM_ENROLMENT WHERE OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(checkQuery); - stmt.setString(1, owner); - stmt.setInt(2, tenantID); - rs = stmt.executeQuery(); - if(rs.next()){ - count = rs.getInt("COUNT"); - } - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while trying to get device " + - "count of Owner : "+owner, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - return count; - } - - @Override - public boolean setStatus(String currentOwner, EnrolmentInfo.Status status, - int tenantId) throws DeviceManagementDAOException { - return setStatusAllDevices(currentOwner, status, tenantId); - } - - @Override - public boolean setStatusAllDevices(String currentOwner, EnrolmentInfo.Status status, int tenantId) - throws DeviceManagementDAOException{ - Connection conn; - PreparedStatement stmt = null; - Timestamp updateTime = new Timestamp(new Date().getTime()); - if(getCountOfDevicesOfOwner(currentOwner, tenantId) > 0){ - try { - conn = this.getConnection(); - String sql = "UPDATE DM_ENROLMENT SET STATUS = ?, DATE_OF_LAST_UPDATE = ? WHERE OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, status.toString()); - stmt.setTimestamp(2, updateTime); - stmt.setString(3, currentOwner); - stmt.setInt(4, tenantId); - stmt.executeUpdate(); - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return addDeviceStatus(currentOwner, status, tenantId); - } else { - return false; - } - } - - @Override - public boolean setStatus(int enrolmentID, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - Timestamp updateTime = new Timestamp(new Date().getTime()); - try { - conn = this.getConnection(); - String sql = "UPDATE DM_ENROLMENT SET STATUS = ?, DATE_OF_LAST_UPDATE = ? WHERE ID = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, status.toString()); - stmt.setTimestamp(2, updateTime); - stmt.setInt(3, enrolmentID); - stmt.setInt(4, tenantId); - int updatedRowCount = stmt.executeUpdate(); - if (updatedRowCount != 1){ - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment: "+ - updatedRowCount + " rows were updated instead of one row!!!"); - } - // save the device status history - addDeviceStatus(enrolmentID, status); - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return true; - } - - public boolean addDeviceStatus(EnrolmentInfo config) throws DeviceManagementDAOException { - return addDeviceStatus(config.getId(), config.getStatus()); - } - - public boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException { - Connection conn; - String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - if (changedBy == null){ - changedBy = DeviceManagementConstants.MaintenanceProperties.MAINTENANCE_USER; - } - PreparedStatement stmt = null; - ResultSet rs = null; - List enrolmentInfoList = new ArrayList<>(); - try { - conn = this.getConnection(); - String sql = "SELECT ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, " + - "DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT WHERE OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, currentOwner); - stmt.setInt(2, tenantId); - rs = stmt.executeQuery(); - while (rs.next()) { - int enrolmentId = rs.getInt("ID"); - int deviceId = rs.getInt("DEVICE_ID"); - enrolmentInfoList.add(new int[]{enrolmentId, deviceId}); - } - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - Timestamp updateTime = new Timestamp(new Date().getTime()); - sql = "INSERT INTO DM_DEVICE_STATUS (ENROLMENT_ID, DEVICE_ID, STATUS, UPDATE_TIME, CHANGED_BY) VALUES(?, ?, ?, ?, ?)"; - try (PreparedStatement ps = conn.prepareStatement(sql)) { - if (conn.getMetaData().supportsBatchUpdates()) { - for(int[] info: enrolmentInfoList){ - ps.setInt(1, info[0]); - ps.setInt(2, info[1]); - ps.setString(3, status.toString()); - ps.setTimestamp(4, updateTime); - ps.setString(5, changedBy); - ps.addBatch(); - } - int[] batchResult = ps.executeBatch(); - for (int i : batchResult) { - if (i == 0 || i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { - return false; - } - } - } else { - for(int[] info: enrolmentInfoList){ - ps.setInt(1, info[0]); - ps.setInt(2, info[1]); - ps.setString(3, status.toString()); - ps.setTimestamp(4, updateTime); - ps.setString(5, changedBy); - ps.execute(); - } - - } - } - - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while retrieving the enrolments " + - "information of owner '" + currentOwner + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - return true; - } - - public boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException { - Connection conn; - String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - if (changedBy == null){ - changedBy = DeviceManagementConstants.MaintenanceProperties.MAINTENANCE_USER; - } - PreparedStatement stmt = null; - try { - conn = this.getConnection(); - // get the device id and last udpated status from the device status table - String sql = "SELECT DEVICE_ID, STATUS FROM DM_DEVICE_STATUS WHERE ENROLMENT_ID = ? ORDER BY UPDATE_TIME DESC LIMIT 1"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, enrolmentId); - ResultSet rs = stmt.executeQuery(); - int deviceId = -1; - EnrolmentInfo.Status previousStatus = null; - if (rs.next()) { - // if there is a record corresponding to the enrolment we save the status and the device id - previousStatus = EnrolmentInfo.Status.valueOf(rs.getString("STATUS")); - deviceId = rs.getInt("DEVICE_ID"); - } - DeviceManagementDAOUtil.cleanupResources(stmt, null); - // if there was no record for the enrolment or the previous status is not the same as the current status - // we'll add a record - if (previousStatus == null || previousStatus != status){ - if (deviceId == -1) { - // we need the device id in order to add a new record, therefore we get it from the enrolment table - sql = "SELECT DEVICE_ID FROM DM_ENROLMENT WHERE ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, enrolmentId); - rs = stmt.executeQuery(); - if (rs.next()) { - deviceId = rs.getInt("DEVICE_ID"); - } else { - // if there were no records corresponding to the enrolment id this is a problem. i.e. enrolment - // id is invalid - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment: no record for enrolment id " + enrolmentId); - } - DeviceManagementDAOUtil.cleanupResources(stmt, null); - } - - sql = "INSERT INTO DM_DEVICE_STATUS (ENROLMENT_ID, DEVICE_ID, STATUS, UPDATE_TIME, CHANGED_BY) VALUES(?, ?, ?, ?, ?)"; - stmt = conn.prepareStatement(sql); - Timestamp updateTime = new Timestamp(new Date().getTime()); - stmt.setInt(1, enrolmentId); - stmt.setInt(2, deviceId); - stmt.setString(3, status.toString()); - stmt.setTimestamp(4, updateTime); - stmt.setString(5, changedBy); - stmt.execute(); - } else { - // no need to update status since the last recorded status is the same as the current status - } - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while setting the status of device", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return true; - } - @Override - public EnrolmentInfo.Status getStatus(int deviceId, String currentOwner, - int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - EnrolmentInfo.Status status = null; - try { - conn = this.getConnection(); - String sql = "SELECT STATUS FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, deviceId); - stmt.setString(2, currentOwner); - stmt.setInt(3, tenantId); - rs = stmt.executeQuery(); - if (rs.next()) { - status = EnrolmentInfo.Status.valueOf(rs.getString("STATUS")); - } - return status; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public EnrolmentInfo getEnrollment(int deviceId, String currentOwner, - int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - EnrolmentInfo enrolmentInfo = null; - try { - conn = this.getConnection(); - String sql = "SELECT ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, " + - "DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, deviceId); - stmt.setString(2, currentOwner); - stmt.setInt(3, tenantId); - rs = stmt.executeQuery(); - if (rs.next()) { - enrolmentInfo = this.loadEnrolment(rs); - } - return enrolmentInfo; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while retrieving the enrolment " + - "information of user '" + currentOwner + "' upon device '" + deviceId + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public EnrolmentInfo getEnrollment(int deviceId, int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - EnrolmentInfo enrolmentInfo = null; - try { - conn = this.getConnection(); - String sql = "SELECT ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, " + - "DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ? " + - "ORDER BY DATE_OF_LAST_UPDATE DESC"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, deviceId); - stmt.setInt(2, tenantId); - rs = stmt.executeQuery(); - if (rs.next()) { - enrolmentInfo = this.loadEnrolment(rs); - } - return enrolmentInfo; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while retrieving the enrolment " + - "information of device '" + deviceId + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public List getEnrollmentsOfUser(int deviceId, String user, int tenantId) - throws DeviceManagementDAOException { - List enrolmentInfos = new ArrayList<>(); - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - EnrolmentInfo enrolmentInfo = null; - try { - conn = this.getConnection(); - String sql = "SELECT ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, " + - "DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, deviceId); - stmt.setString(2, user); - stmt.setInt(3, tenantId); - rs = stmt.executeQuery(); - while (rs.next()) { - enrolmentInfo = this.loadEnrolment(rs); - enrolmentInfos.add(enrolmentInfo); - } - return enrolmentInfos; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while retrieving the enrolments " + - "information of user '" + user + "' upon device '" + deviceId + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public boolean updateOwnerOfEnrollment(List devices, String owner, int tenantId) - throws DeviceManagementDAOException { - try { - Connection conn = this.getConnection(); - boolean updateStatus = true; - String sql = "UPDATE DM_ENROLMENT " - + "SET OWNER = ?, IS_TRANSFERRED = ?, DATE_OF_LAST_UPDATE = ? " - + "WHERE ID = ? AND TENANT_ID = ?"; - try (PreparedStatement ps = conn.prepareStatement(sql)) { - if (conn.getMetaData().supportsBatchUpdates()) { - for (Device device : devices) { - ps.setString(1, owner); - ps.setBoolean(2, device.getEnrolmentInfo().isTransferred()); - ps.setTimestamp(3, new Timestamp(new Date().getTime())); - ps.setInt(4, device.getEnrolmentInfo().getId()); - ps.setInt(5, tenantId); - ps.addBatch(); - } - int[] batchResult = ps.executeBatch(); - for (int i : batchResult) { - if (i == 0 || i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { - updateStatus = false; - break; - } - } - } else { - for (Device device : devices) { - ps.setString(1, owner); - ps.setBoolean(2, device.getEnrolmentInfo().isTransferred()); - ps.setInt(3, device.getId()); - ps.setInt(4, tenantId); - if (ps.executeUpdate() == 0) { - updateStatus = false; - break; - } - } - } - } - return updateStatus; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while obtaining the DB connection to update the " - + "owner of the device enrollment.", e); - } - } - - private Connection getConnection() throws SQLException { - return DeviceManagementDAOFactory.getConnection(); - } - - private EnrolmentInfo loadEnrolment(ResultSet rs) throws SQLException { - EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); - enrolmentInfo.setOwner(rs.getString("OWNER")); - enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.valueOf(rs.getString("OWNERSHIP"))); - enrolmentInfo.setTransferred(rs.getBoolean("IS_TRANSFERRED")); - enrolmentInfo.setDateOfEnrolment(rs.getTimestamp("DATE_OF_ENROLMENT").getTime()); - enrolmentInfo.setDateOfLastUpdate(rs.getTimestamp("DATE_OF_LAST_UPDATE").getTime()); - enrolmentInfo.setStatus(EnrolmentInfo.Status.valueOf(rs.getString("STATUS"))); - enrolmentInfo.setId(rs.getInt("ID")); - return enrolmentInfo; - } - } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/SQLServerEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/SQLServerEnrollmentDAOImpl.java index 18074e0841..73903d15f1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/SQLServerEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/enrolment/SQLServerEnrollmentDAOImpl.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.enrolment; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; @@ -32,285 +33,6 @@ import java.util.List; public class SQLServerEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl { - @Override - public EnrolmentInfo addEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, - int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - try { - conn = this.getConnection(); - String sql = "INSERT INTO DM_ENROLMENT(DEVICE_ID, OWNER, OWNERSHIP, STATUS, " + - "DATE_OF_ENROLMENT, DATE_OF_LAST_UPDATE, TENANT_ID) VALUES(?, ?, ?, ?, ?, ?, ?)"; - stmt = conn.prepareStatement(sql, new String[] {"id"}); - Timestamp enrollmentTime = new Timestamp(new Date().getTime()); - stmt.setInt(1, deviceId); - stmt.setString(2, enrolmentInfo.getOwner()); - stmt.setString(3, enrolmentInfo.getOwnership().toString()); - stmt.setString(4, enrolmentInfo.getStatus().toString()); - stmt.setTimestamp(5, enrollmentTime); - stmt.setTimestamp(6, enrollmentTime); - stmt.setInt(7, tenantId); - stmt.execute(); - - rs = stmt.getGeneratedKeys(); - if (rs.next()) { - int enrolmentId = rs.getInt(1); - enrolmentInfo.setId(enrolmentId); - enrolmentInfo.setDateOfEnrolment(enrollmentTime.getTime()); - enrolmentInfo.setDateOfLastUpdate(enrollmentTime.getTime()); - addDeviceStatus(enrolmentId, enrolmentInfo.getStatus()); - return enrolmentInfo; - } - return null; - } catch (SQLException e) { - e.printStackTrace(); - throw new DeviceManagementDAOException("Error occurred while adding enrolment configuration", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public int updateEnrollment(EnrolmentInfo enrolmentInfo, int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - try { - conn = this.getConnection(); - String sql = "UPDATE DM_ENROLMENT SET OWNERSHIP = ?, STATUS = ?, DATE_OF_LAST_UPDATE = ? " + - "WHERE ID = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, enrolmentInfo.getOwnership().toString()); - stmt.setString(2, enrolmentInfo.getStatus().toString()); - stmt.setTimestamp(3, new Timestamp(new Date().getTime())); - stmt.setInt(4, enrolmentInfo.getId()); - stmt.setInt(5, tenantId); - int updatedCount = stmt.executeUpdate(); - return updatedCount; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public boolean updateEnrollmentStatus(List enrolmentInfos) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - boolean status = false; - int updateStatus = -1; - try { - conn = this.getConnection(); - String sql = "UPDATE DM_ENROLMENT SET STATUS = ? WHERE ID = ?"; - stmt = conn.prepareStatement(sql); - if (conn.getMetaData().supportsBatchUpdates()) { - for (EnrolmentInfo enrolmentInfo : enrolmentInfos) { - stmt.setString(1, enrolmentInfo.getStatus().toString()); - stmt.setInt(2, enrolmentInfo.getId()); - stmt.addBatch(); - } - updateStatus = stmt.executeBatch().length; - } else { - for (EnrolmentInfo enrolmentInfo : enrolmentInfos) { - stmt.setString(1, enrolmentInfo.getStatus().toString()); - stmt.setInt(2, enrolmentInfo.getId()); - updateStatus = stmt.executeUpdate(); - } - } - if (updateStatus > 0) { - status = true; - } - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while updating enrolment status of given device-list.", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - return status; - } - - @Override - public int removeEnrollment(int deviceId, String currentOwner, - int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - int status = -1; - try { - conn = this.getConnection(); - String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql, new String[] {"id"}); - stmt.setInt(1, deviceId); - stmt.setString(2, currentOwner); - stmt.setInt(3, tenantId); - stmt.executeUpdate(); - - rs = stmt.getGeneratedKeys(); - if (rs.next()) { - status = 1; - } - return status; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while removing device enrolment", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - private int getCountOfDevicesOfOwner(String owner, int tenantID) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - int count = 0; - try { - conn = this.getConnection(); - String checkQuery = "SELECT COUNT(ID) AS COUNT FROM DM_ENROLMENT WHERE OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(checkQuery); - stmt.setString(1, owner); - stmt.setInt(2, tenantID); - rs = stmt.executeQuery(); - if(rs.next()){ - count = rs.getInt("COUNT"); - } - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while trying to get device " + - "count of Owner : "+owner, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - return count; - } - - @Override - public boolean setStatus(String currentOwner, EnrolmentInfo.Status status, - int tenantId) throws DeviceManagementDAOException { - return setStatusAllDevices(currentOwner, status, tenantId); - } - - @Override - public boolean setStatusAllDevices(String currentOwner, EnrolmentInfo.Status status, int tenantId) - throws DeviceManagementDAOException{ - Connection conn; - PreparedStatement stmt = null; - Timestamp updateTime = new Timestamp(new Date().getTime()); - if(getCountOfDevicesOfOwner(currentOwner, tenantId) > 0){ - try { - conn = this.getConnection(); - String sql = "UPDATE DM_ENROLMENT SET STATUS = ?, DATE_OF_LAST_UPDATE = ? WHERE OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, status.toString()); - stmt.setTimestamp(2, updateTime); - stmt.setString(3, currentOwner); - stmt.setInt(4, tenantId); - stmt.executeUpdate(); - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return addDeviceStatus(currentOwner, status, tenantId); - } else { - return false; - } - } - - @Override - public boolean setStatus(int enrolmentID, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - Timestamp updateTime = new Timestamp(new Date().getTime()); - try { - conn = this.getConnection(); - String sql = "UPDATE DM_ENROLMENT SET STATUS = ?, DATE_OF_LAST_UPDATE = ? WHERE ID = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, status.toString()); - stmt.setTimestamp(2, updateTime); - stmt.setInt(3, enrolmentID); - stmt.setInt(4, tenantId); - int updatedRowCount = stmt.executeUpdate(); - if (updatedRowCount != 1){ - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment: "+ - updatedRowCount + " rows were updated instead of one row!!!"); - } - // save the device status history - addDeviceStatus(enrolmentID, status); - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return true; - } - - public boolean addDeviceStatus(EnrolmentInfo config) throws DeviceManagementDAOException { - return addDeviceStatus(config.getId(), config.getStatus()); - } - - public boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException { - Connection conn; - String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - if (changedBy == null){ - changedBy = DeviceManagementConstants.MaintenanceProperties.MAINTENANCE_USER; - } - PreparedStatement stmt = null; - ResultSet rs = null; - List enrolmentInfoList = new ArrayList<>(); - try { - conn = this.getConnection(); - String sql = "SELECT ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, " + - "DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT WHERE OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, currentOwner); - stmt.setInt(2, tenantId); - rs = stmt.executeQuery(); - while (rs.next()) { - int enrolmentId = rs.getInt("ID"); - int deviceId = rs.getInt("DEVICE_ID"); - enrolmentInfoList.add(new int[]{enrolmentId, deviceId}); - } - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - Timestamp updateTime = new Timestamp(new Date().getTime()); - sql = "INSERT INTO DM_DEVICE_STATUS (ENROLMENT_ID, DEVICE_ID, STATUS, UPDATE_TIME, CHANGED_BY) VALUES(?, ?, ?, ?, ?)"; - try (PreparedStatement ps = conn.prepareStatement(sql)) { - if (conn.getMetaData().supportsBatchUpdates()) { - for(int[] info: enrolmentInfoList){ - ps.setInt(1, info[0]); - ps.setInt(2, info[1]); - ps.setString(3, status.toString()); - ps.setTimestamp(4, updateTime); - ps.setString(5, changedBy); - ps.addBatch(); - } - int[] batchResult = ps.executeBatch(); - for (int i : batchResult) { - if (i == 0 || i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { - return false; - } - } - } else { - for(int[] info: enrolmentInfoList){ - ps.setInt(1, info[0]); - ps.setInt(2, info[1]); - ps.setString(3, status.toString()); - ps.setTimestamp(4, updateTime); - ps.setString(5, changedBy); - ps.execute(); - } - - } - } - - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while retrieving the enrolments " + - "information of owner '" + currentOwner + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - return true; - } - public boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException { Connection conn; String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); @@ -319,8 +41,8 @@ public class SQLServerEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl { } PreparedStatement stmt = null; try { - conn = this.getConnection(); - // get the device id and last udpated status from the device status table + conn = getConnection(); + // get the device id and last updated status from the device status table String sql = "SELECT TOP 1 DEVICE_ID, STATUS FROM DM_DEVICE_STATUS WHERE ENROLMENT_ID = ? ORDER BY UPDATE_TIME DESC"; stmt = conn.prepareStatement(sql); stmt.setInt(1, enrolmentId); @@ -371,177 +93,5 @@ public class SQLServerEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl { } return true; } - @Override - public EnrolmentInfo.Status getStatus(int deviceId, String currentOwner, - int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - EnrolmentInfo.Status status = null; - try { - conn = this.getConnection(); - String sql = "SELECT STATUS FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, deviceId); - stmt.setString(2, currentOwner); - stmt.setInt(3, tenantId); - rs = stmt.executeQuery(); - if (rs.next()) { - status = EnrolmentInfo.Status.valueOf(rs.getString("STATUS")); - } - return status; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while setting the status of device enrolment", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public EnrolmentInfo getEnrollment(int deviceId, String currentOwner, - int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - EnrolmentInfo enrolmentInfo = null; - try { - conn = this.getConnection(); - String sql = "SELECT ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, " + - "DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, deviceId); - stmt.setString(2, currentOwner); - stmt.setInt(3, tenantId); - rs = stmt.executeQuery(); - if (rs.next()) { - enrolmentInfo = this.loadEnrolment(rs); - } - return enrolmentInfo; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while retrieving the enrolment " + - "information of user '" + currentOwner + "' upon device '" + deviceId + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public EnrolmentInfo getEnrollment(int deviceId, int tenantId) throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - EnrolmentInfo enrolmentInfo = null; - try { - conn = this.getConnection(); - String sql = "SELECT ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, " + - "DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ? " + - "ORDER BY DATE_OF_LAST_UPDATE DESC"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, deviceId); - stmt.setInt(2, tenantId); - rs = stmt.executeQuery(); - if (rs.next()) { - enrolmentInfo = this.loadEnrolment(rs); - } - return enrolmentInfo; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while retrieving the enrolment " + - "information of device '" + deviceId + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public List getEnrollmentsOfUser(int deviceId, String user, int tenantId) - throws DeviceManagementDAOException { - List enrolmentInfos = new ArrayList<>(); - Connection conn; - PreparedStatement stmt = null; - ResultSet rs = null; - EnrolmentInfo enrolmentInfo = null; - try { - conn = this.getConnection(); - String sql = "SELECT ID, DEVICE_ID, OWNER, OWNERSHIP, STATUS, IS_TRANSFERRED, DATE_OF_ENROLMENT, " + - "DATE_OF_LAST_UPDATE, TENANT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, deviceId); - stmt.setString(2, user); - stmt.setInt(3, tenantId); - rs = stmt.executeQuery(); - while (rs.next()) { - enrolmentInfo = this.loadEnrolment(rs); - enrolmentInfos.add(enrolmentInfo); - } - return enrolmentInfos; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while retrieving the enrolments " + - "information of user '" + user + "' upon device '" + deviceId + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - } - - @Override - public boolean updateOwnerOfEnrollment(List devices, String owner, int tenantId) - throws DeviceManagementDAOException { - try { - Connection conn = this.getConnection(); - boolean updateStatus = true; - String sql = "UPDATE DM_ENROLMENT " - + "SET OWNER = ?, IS_TRANSFERRED = ?, DATE_OF_LAST_UPDATE = ? " - + "WHERE ID = ? AND TENANT_ID = ?"; - try (PreparedStatement ps = conn.prepareStatement(sql)) { - if (conn.getMetaData().supportsBatchUpdates()) { - for (Device device : devices) { - ps.setString(1, owner); - ps.setBoolean(2, device.getEnrolmentInfo().isTransferred()); - ps.setTimestamp(3, new Timestamp(new Date().getTime())); - ps.setInt(4, device.getEnrolmentInfo().getId()); - ps.setInt(5, tenantId); - ps.addBatch(); - } - int[] batchResult = ps.executeBatch(); - for (int i : batchResult) { - if (i == 0 || i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { - updateStatus = false; - break; - } - } - } else { - for (Device device : devices) { - ps.setString(1, owner); - ps.setBoolean(2, device.getEnrolmentInfo().isTransferred()); - ps.setInt(3, device.getId()); - ps.setInt(4, tenantId); - if (ps.executeUpdate() == 0) { - updateStatus = false; - break; - } - } - } - } - return updateStatus; - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while obtaining the DB connection to update the " - + "owner of the device enrollment.", e); - } - } - - private Connection getConnection() throws SQLException { - return DeviceManagementDAOFactory.getConnection(); - } - - private EnrolmentInfo loadEnrolment(ResultSet rs) throws SQLException { - EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); - enrolmentInfo.setOwner(rs.getString("OWNER")); - enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.valueOf(rs.getString("OWNERSHIP"))); - enrolmentInfo.setTransferred(rs.getBoolean("IS_TRANSFERRED")); - enrolmentInfo.setDateOfEnrolment(rs.getTimestamp("DATE_OF_ENROLMENT").getTime()); - enrolmentInfo.setDateOfLastUpdate(rs.getTimestamp("DATE_OF_LAST_UPDATE").getTime()); - enrolmentInfo.setStatus(EnrolmentInfo.Status.valueOf(rs.getString("STATUS"))); - enrolmentInfo.setId(rs.getInt("ID")); - return enrolmentInfo; - } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index ddb77a24a4..8322905a5e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -17,7 +17,6 @@ */ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; -import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ProfileOperation; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -44,8 +43,6 @@ import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util.Operatio import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; -import java.io.ObjectInputStream; -import java.io.ByteArrayInputStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -59,7 +56,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Properties; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -575,14 +571,12 @@ public class GenericOperationDAOImpl implements OperationDAO { Connection conn = OperationManagementDAOFactory.getConnection(); String sql = "SELECT eom.ENROLMENT_ID, eom.OPERATION_ID, eom.ID AS EOM_MAPPING_ID, " - + "dor.ID AS OP_RES_ID, de.DEVICE_ID, d.DEVICE_IDENTIFICATION, d.DEVICE_TYPE_ID, " - + "dt.NAME AS DEVICE_TYPE_NAME, eom.STATUS, eom.CREATED_TIMESTAMP, " + + "dor.ID AS OP_RES_ID, de.DEVICE_ID, de.DEVICE_IDENTIFICATION, de.DEVICE_TYPE, " + + "eom.STATUS, eom.CREATED_TIMESTAMP, " + "eom.UPDATED_TIMESTAMP, op.OPERATION_CODE, op.TYPE AS OPERATION_TYPE, " + "dor.OPERATION_RESPONSE, op.INITIATED_BY, dor.RECEIVED_TIMESTAMP, dor.IS_LARGE_RESPONSE FROM " + "DM_ENROLMENT_OP_MAPPING eom INNER JOIN DM_OPERATION op " - + "ON op.ID=eom.OPERATION_ID INNER JOIN DM_ENROLMENT de " - + "ON de.ID=eom.ENROLMENT_ID INNER JOIN DM_DEVICE d ON d.ID=de.DEVICE_ID " - + "INNER JOIN DM_DEVICE_TYPE dt ON dt.ID=d.DEVICE_TYPE_ID " + + "ON op.ID=eom.OPERATION_ID INNER JOIN DM_ENROLMENT de ON de.ID=eom.ENROLMENT_ID " + "LEFT JOIN DM_DEVICE_OPERATION_RESPONSE dor ON dor.ENROLMENT_ID=de.id " + "AND dor.OPERATION_ID = eom.OPERATION_ID WHERE eom.OPERATION_ID " + "IN (SELECT * FROM TABLE(x INT = ?)) AND de.TENANT_ID = ?"; @@ -617,7 +611,7 @@ public class GenericOperationDAOImpl implements OperationDAO { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION")); - deviceIdentifier.setType(rs.getString("DEVICE_TYPE_NAME")); + deviceIdentifier.setType(rs.getString("DEVICE_TYPE")); activityStatus.setDeviceIdentifier(deviceIdentifier); @@ -655,7 +649,7 @@ public class GenericOperationDAOImpl implements OperationDAO { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION")); - deviceIdentifier.setType(rs.getString("DEVICE_TYPE_NAME")); + deviceIdentifier.setType(rs.getString("DEVICE_TYPE")); activityStatus.setDeviceIdentifier(deviceIdentifier); activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS"))); @@ -715,8 +709,8 @@ public class GenericOperationDAOImpl implements OperationDAO { + "eom.OPERATION_ID, eom.ID AS EOM_MAPPING_ID, " + "dor.ID AS OP_RES_ID, " + "de.DEVICE_ID, " - + "d.DEVICE_IDENTIFICATION, " - + "d.DEVICE_TYPE_ID, dt.NAME AS DEVICE_TYPE_NAME, " + + "de.DEVICE_IDENTIFICATION, " + + "de.DEVICE_TYPE, " + "eom.STATUS, eom.CREATED_TIMESTAMP, " + "eom.UPDATED_TIMESTAMP, " + "op.OPERATION_CODE, " @@ -727,11 +721,9 @@ public class GenericOperationDAOImpl implements OperationDAO { + "op.INITIATED_BY FROM DM_ENROLMENT_OP_MAPPING AS eom " + "INNER JOIN DM_OPERATION AS op ON op.ID=eom.OPERATION_ID " + "INNER JOIN DM_ENROLMENT AS de ON de.ID=eom.ENROLMENT_ID " - + "INNER JOIN DM_DEVICE AS d ON d.ID=de.DEVICE_ID " - + "INNER JOIN DM_DEVICE_TYPE AS dt ON dt.ID=d.DEVICE_TYPE_ID " + "LEFT JOIN DM_DEVICE_OPERATION_RESPONSE AS dor ON dor.ENROLMENT_ID=de.id " + "AND dor.OPERATION_ID = eom.OPERATION_ID " - + "WHERE eom.OPERATION_ID = ? AND de.device_id = ? AND de.TENANT_ID = ?"; + + "WHERE eom.OPERATION_ID = ? AND de.DEVICE_ID = ? AND de.TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, operationId); @@ -756,7 +748,7 @@ public class GenericOperationDAOImpl implements OperationDAO { if (enrolmentId != rs.getInt("ENROLMENT_ID")) { activityStatus = new ActivityStatus(); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"), - rs.getString("DEVICE_TYPE_NAME")); + rs.getString("DEVICE_TYPE")); activityStatus.setDeviceIdentifier(deviceIdentifier); activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS"))); @@ -850,15 +842,13 @@ public class GenericOperationDAOImpl implements OperationDAO { " op.TYPE AS OPERATION_TYPE, " + " opm.STATUS, " + " en.DEVICE_ID, " + - " de.DEVICE_IDENTIFICATION, " + - " dt.NAME AS DEVICE_TYPE, " + + " en.DEVICE_IDENTIFICATION, " + + " en.DEVICE_TYPE, " + " de.TENANT_ID " + " FROM" + " DM_ENROLMENT_OP_MAPPING opm " + " INNER JOIN DM_OPERATION op ON opm.OPERATION_ID = op.ID " + " INNER JOIN DM_ENROLMENT en ON opm.ENROLMENT_ID = en.ID " + - " INNER JOIN DM_DEVICE de ON en.DEVICE_ID = de.ID " + - " INNER JOIN DM_DEVICE_TYPE dt ON dt.ID = de.DEVICE_TYPE_ID " + " WHERE " + " op.OPERATION_CODE = ? " + " AND de.TENANT_ID = ? " + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 7aad6f8f2e..a62aaada9e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -329,7 +329,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if ((updateStatus > 0) || EnrolmentInfo.Status.REMOVED. equals(existingEnrolmentInfo.getStatus())) { enrollment = enrollmentDAO - .addEnrollment(existingDevice.getId(), newEnrolmentInfo, tenantId); + .addEnrollment(existingDevice.getId(), deviceIdentifier, + newEnrolmentInfo, tenantId); if (enrollment == null) { DeviceManagementDAOFactory.rollbackTransaction(); throw new DeviceManagementException( @@ -375,7 +376,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (type != null) { int deviceId = deviceDAO.addDevice(type.getId(), device, tenantId); device.setId(deviceId); - enrollment = enrollmentDAO.addEnrollment(deviceId, device.getEnrolmentInfo(), tenantId); + enrollment = enrollmentDAO.addEnrollment(deviceId, deviceIdentifier, device.getEnrolmentInfo(), tenantId); if (enrollment == null) { DeviceManagementDAOFactory.rollbackTransaction(); throw new DeviceManagementException( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusPersistenceTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusPersistenceTests.java index 3019e94c4e..6375f5b9da 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusPersistenceTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceStatusPersistenceTests.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.Assert; @@ -215,7 +216,8 @@ public class DeviceStatusPersistenceTests extends BaseDeviceManagementTest { EnrolmentInfo source = new EnrolmentInfo(owner, EnrolmentInfo.OwnerShip.BYOD, initialStatus); try { DeviceManagementDAOFactory.openConnection(); - EnrolmentInfo config = enrollmentDAO.addEnrollment(deviceId, source, tenantId); + EnrolmentInfo config = enrollmentDAO.addEnrollment(deviceId, + new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()), source, tenantId); device.setEnrolmentInfo(config); return config.getId(); } catch (DeviceManagementDAOException | SQLException e) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrolmentPersistenceTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrolmentPersistenceTests.java index c46f525c14..c7b8de10b1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrolmentPersistenceTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrolmentPersistenceTests.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.Assert; @@ -58,7 +59,8 @@ public class EnrolmentPersistenceTests extends BaseDeviceManagementTest { DeviceDAO deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); deviceId = deviceDAO.addDevice(TestDataHolder.initialTestDeviceType.getId(), device, TestDataHolder.SUPER_TENANT_ID); device.setId(deviceId); - enrollmentDAO.addEnrollment(deviceId, source, TestDataHolder.SUPER_TENANT_ID); + enrollmentDAO.addEnrollment(deviceId, new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()), + source, TestDataHolder.SUPER_TENANT_ID); } catch (DeviceManagementDAOException | SQLException e) { log.error("Error occurred while adding enrollment", e); } finally { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index 00c3c804a2..aea2602f2e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -149,6 +149,8 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION ( CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, OWNER VARCHAR(50) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql index 3dae0cb261..d69d5e354b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql @@ -79,6 +79,8 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION ( CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, OWNER VARCHAR(50) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyDAOTestCase.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyDAOTestCase.java index d31916cf74..c6a7e0f03d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyDAOTestCase.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/PolicyDAOTestCase.java @@ -102,7 +102,8 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest { DeviceManagementDAOFactory.beginTransaction(); for (Device device : devices) { int id = deviceDAO.addDevice(type.getId(), device, -1234); - enrollmentDAO.addEnrollment(id, device.getEnrolmentInfo(), -1234); + enrollmentDAO.addEnrollment(id, new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()), + device.getEnrolmentInfo(), -1234); } } catch (TransactionManagementException e) { log.error("Error occurred while adding device enrolment", e); diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index 2a2d497eb8..a9fa35a6fb 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -99,6 +99,8 @@ DROP TABLE IF EXISTS DM_ENROLMENT; CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, OWNER VARCHAR(50) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 295433b55c..046cfbec1d 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -97,6 +97,8 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION ( CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, OWNER VARCHAR(255) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 072ce0a81d..f34d6183e2 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -100,6 +100,8 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION ( CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, OWNER VARCHAR(255) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 6c7aa649fd..dc05a39464 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -142,6 +142,8 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[D CREATE TABLE DM_ENROLMENT ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, OWNER VARCHAR(255) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 065862a36b..9d3751e5d7 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -52,8 +52,8 @@ 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, + DEVICE_TYPE_ID INT(11) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), @@ -119,6 +119,8 @@ CREATE INDEX IDX_OP_INITIATED_BY ON DM_OPERATION (INITIATED_BY ASC); CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, OWNER VARCHAR(255) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, @@ -130,6 +132,11 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( CONSTRAINT FK_DM_DEVICE_ENROLMENT FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION )ENGINE = InnoDB; +CREATE INDEX IDX_ENROLMENT_FK_DEVICE_ID ON DM_ENROLMENT(DEVICE_ID); +CREATE INDEX IDX_ENROLMENT_DEVICE_TYPE_ID ON DM_ENROLMENT(DEVICE_TYPE_ID); +CREATE INDEX IDX_ENROLMENT_DEVICE_IDENTIFICATION ON DM_ENROLMENT(DEVICE_IDENTIFICATION); +CREATE INDEX IDX_ENROLMENT_STATUS ON DM_ENROLMENT(STATUS); + CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( ID INTEGER AUTO_INCREMENT NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -143,9 +150,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( CONSTRAINT FK_DM_DEVICE_STATUS_ENROLMENT FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE CASCADE ON UPDATE CASCADE )ENGINE = InnoDB; -CREATE INDEX IDX_ENROLMENT_FK_DEVICE_ID ON DM_ENROLMENT(DEVICE_ID); -CREATE INDEX IDX_ENROLMENT_DEVICE_ID_TENANT_ID ON DM_ENROLMENT(DEVICE_ID, TENANT_ID); -CREATE INDEX IDX_ENROLMENT_DEVICE_ID_TENANT_ID_STATUS ON DM_ENROLMENT(DEVICE_ID, TENANT_ID, STATUS); CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index eccc831141..e500c55046 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -205,6 +205,8 @@ WHEN (NEW.ID IS NULL) CREATE TABLE DM_ENROLMENT ( ID NUMBER(10) NOT NULL, DEVICE_ID NUMBER(10) NOT NULL, + DEVICE_TYPE VARCHAR2(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR2(300) NOT NULL, OWNER VARCHAR2(255) NOT NULL, OWNERSHIP VARCHAR2(45) DEFAULT NULL, STATUS VARCHAR2(50) NULL, diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 371baa0763..c0368f5826 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -114,6 +114,8 @@ CREATE SEQUENCE DM_ENROLMENT_seq; CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER DEFAULT NEXTVAL ('DM_ENROLMENT_seq') NOT NULL, DEVICE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) NOT NULL, OWNER VARCHAR(50) NOT NULL, OWNERSHIP VARCHAR(45) DEFAULT NULL, STATUS VARCHAR(50) NULL, From d1fe1baad0e11198bb9d780aabc54729c27ad8d9 Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Fri, 10 May 2024 14:43:41 +0530 Subject: [PATCH 188/343] Fix issues with caching --- .../device/mgt/common/DeviceIdentifier.java | 19 ++++++++--- .../device/mgt/core/cache/DeviceCacheKey.java | 33 ++++++++----------- .../beacon/dao/HeartBeatBeaconDAOFactory.java | 9 ++--- .../cache/OperationTemplateCacheLoader.java | 5 ++- .../dto/OperationTemplateCacheKey.java | 19 +++++++++++ .../mgt/dto/DeviceSubTypeCacheKey.java | 8 +++++ .../mgt/impl/DeviceSubTypeServiceImpl.java | 4 ++- .../main/resources/dbscripts/cdm/mysql.sql | 2 +- 8 files changed, 63 insertions(+), 36 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceIdentifier.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceIdentifier.java index a1bb3fe51e..d02f844071 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceIdentifier.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/DeviceIdentifier.java @@ -69,9 +69,20 @@ public class DeviceIdentifier implements Serializable{ @Override public String toString() { - return "deviceId {" + - "id='" + id + '\'' + - ", type='" + type + '\'' + - '}'; + return type + "|" + id; } + + @Override + public int hashCode() { + return toString().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof DeviceIdentifier) { + return (this.hashCode() == obj.hashCode()); + } + return false; + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheKey.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheKey.java index a5931f408e..d25cd2673a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheKey.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/cache/DeviceCacheKey.java @@ -28,7 +28,6 @@ public class DeviceCacheKey { private String deviceId; private String deviceType; private int tenantId; - private volatile int hashCode; public String getDeviceId() { return deviceId; @@ -55,27 +54,21 @@ public class DeviceCacheKey { } @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (!DeviceCacheKey.class.isAssignableFrom(obj.getClass())) { - return false; - } - final DeviceCacheKey other = (DeviceCacheKey) obj; - String thisId = this.deviceId + "-" + this.deviceType + "_" + this.tenantId; - String otherId = other.deviceId + "-" + other.deviceType + "_" + other.tenantId; - if (!thisId.equals(otherId)) { - return false; - } - return true; + public int hashCode() { + return toString().hashCode(); } @Override - public int hashCode() { - if (hashCode == 0) { - hashCode = Objects.hash(deviceId, deviceType, tenantId); - } - return hashCode; + public String toString() { + return tenantId + "|" + deviceType + "|" + deviceId; } + + @Override + public boolean equals(Object obj) { + if (obj instanceof DeviceCacheKey) { + return (this.hashCode() == obj.hashCode()); + } + return false; + } + } diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/HeartBeatBeaconDAOFactory.java b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/HeartBeatBeaconDAOFactory.java index 7130f07cbf..e3c3dd3381 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/HeartBeatBeaconDAOFactory.java +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/src/main/java/io/entgra/device/mgt/core/server/bootup/heartbeat/beacon/dao/HeartBeatBeaconDAOFactory.java @@ -24,10 +24,8 @@ import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.config.datasourc import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.dao.impl.GenericHeartBeatDAOImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.IllegalTransactionStateException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnsupportedDatabaseEngineException; import javax.sql.DataSource; import java.sql.Connection; @@ -42,7 +40,7 @@ public class HeartBeatBeaconDAOFactory { private static final Log log = LogFactory.getLog(HeartBeatBeaconDAOFactory.class); private static DataSource dataSource; - private static ThreadLocal currentConnection = new ThreadLocal<>(); + private static final ThreadLocal currentConnection = new ThreadLocal<>(); /** * Get instance of GroupDAO @@ -64,7 +62,6 @@ public class HeartBeatBeaconDAOFactory { /** * Begin transaction with datasource for write data * - * @throws TransactionManagementException */ public static void beginTransaction() throws TransactionManagementException { Connection conn = currentConnection.get(); @@ -85,7 +82,6 @@ public class HeartBeatBeaconDAOFactory { /** * Open connection to the datasource for read data * - * @throws SQLException */ public static void openConnection() throws SQLException { Connection conn = currentConnection.get(); @@ -102,7 +98,6 @@ public class HeartBeatBeaconDAOFactory { * Get current connection to datasource * * @return current connection - * @throws SQLException */ public static Connection getConnection() throws SQLException { Connection conn = currentConnection.get(); @@ -189,7 +184,7 @@ public class HeartBeatBeaconDAOFactory { List jndiPropertyList = jndiConfig.getJndiProperties(); if (jndiPropertyList != null) { - Hashtable jndiProperties = new Hashtable(); + Hashtable jndiProperties = new Hashtable<>(); for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { jndiProperties.put(prop.getName(), prop.getValue()); } diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/cache/OperationTemplateCacheLoader.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/cache/OperationTemplateCacheLoader.java index e92ffbadcc..4b9316fad9 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/cache/OperationTemplateCacheLoader.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/cache/OperationTemplateCacheLoader.java @@ -59,9 +59,8 @@ public class OperationTemplateCacheLoader extends CacheLoader deviceSubTypeCache = CacheBuilder.newBuilder() .expireAfterWrite(15, TimeUnit.MINUTES) @@ -143,7 +145,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { } @Override - public DeviceSubType getDeviceSubType(String subTypeId, int tenantId, String deviceType) + public synchronized DeviceSubType getDeviceSubType(String subTypeId, int tenantId, String deviceType) throws SubTypeMgtPluginException { try { DeviceSubTypeCacheKey key = DeviceSubTypeMgtUtil.getDeviceSubTypeCacheKey(tenantId, subTypeId, deviceType); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 9d3751e5d7..7000513833 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -133,7 +133,7 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION )ENGINE = InnoDB; CREATE INDEX IDX_ENROLMENT_FK_DEVICE_ID ON DM_ENROLMENT(DEVICE_ID); -CREATE INDEX IDX_ENROLMENT_DEVICE_TYPE_ID ON DM_ENROLMENT(DEVICE_TYPE_ID); +CREATE INDEX IDX_ENROLMENT_DEVICE_TYPE ON DM_ENROLMENT(DEVICE_TYPE); CREATE INDEX IDX_ENROLMENT_DEVICE_IDENTIFICATION ON DM_ENROLMENT(DEVICE_IDENTIFICATION); CREATE INDEX IDX_ENROLMENT_STATUS ON DM_ENROLMENT(STATUS); From 7dea32d2e34631994a0c0d7488b53a467f4f3aba Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Wed, 15 May 2024 10:19:00 +0530 Subject: [PATCH 189/343] Performance improvements --- .../mgt/core/device/mgt/common/Device.java | 11 + .../pom.xml | 8 +- .../core/device/mgt/core/dao/DeviceDAO.java | 3 + .../core/dao/impl/AbstractDeviceDAOImpl.java | 301 ++-- .../core/dao/impl/AbstractGroupDAOImpl.java | 27 +- .../dao/impl/device/GenericDeviceDAOImpl.java | 393 +++-- .../dao/impl/device/OracleDeviceDAOImpl.java | 1440 +---------------- .../dao/impl/group/GenericGroupDAOImpl.java | 17 +- .../dao/impl/group/OracleGroupDAOImpl.java | 15 +- .../impl/group/PostgreSQLGroupDAOImpl.java | 15 +- .../dao/impl/group/SQLServerGroupDAOImpl.java | 13 +- .../dao/util/DeviceManagementDAOUtil.java | 1 + .../impl/DeviceInformationManagerImpl.java | 7 +- .../DeviceManagementProviderService.java | 2 + .../DeviceManagementProviderServiceImpl.java | 68 +- .../mgt/core/dao/DevicePersistTests.java | 59 + 16 files changed, 574 insertions(+), 1806 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java index ffd31e1f33..b75f557077 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java @@ -57,6 +57,9 @@ public class Device implements Serializable { required = true) private String deviceIdentifier; + @ApiModelProperty(name = "updatedTimeStamp", value = "Last updated timestamp of the device.") + private long lastUpdatedTimeStamp; + @ApiModelProperty(name = "enrolmentInfo", value = "This defines the device registration related information. " + "It is mandatory to define this information.", required = true) private EnrolmentInfo enrolmentInfo; @@ -221,6 +224,14 @@ public class Device implements Serializable { this.historySnapshot = historySnapshot; } + public long getLastUpdatedTimeStamp() { + return lastUpdatedTimeStamp; + } + + public void setLastUpdatedTimeStamp(long lastUpdatedTimeStamp) { + this.lastUpdatedTimeStamp = lastUpdatedTimeStamp; + } + public static class Property { private String name; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 9827ec7084..fe7df106e3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -137,10 +137,10 @@ src/test/resources/testng.xml - src/test/resources/mysql-testng.xml - src/test/resources/mssql-testng.xml - src/test/resources/oracle-testng.xml - src/test/resources/postgre-testng.xml + + + + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java index 0fd55c870d..731bb11d59 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java @@ -122,6 +122,9 @@ public interface DeviceDAO { */ boolean updateDevice(Device device, int tenantId) throws DeviceManagementDAOException; + boolean recordDeviceUpdate(DeviceIdentifier deviceIdentifier, int tenantId) + throws DeviceManagementDAOException; + Device getDevice(DeviceData deviceData, int tenantId) throws DeviceManagementDAOException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index ba1cb3cf7f..7ab1cdb6e3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -108,7 +108,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "WHERE DEVICE_TYPE_ID = (SELECT ID FROM DM_DEVICE_TYPE " + "WHERE NAME = ? AND (PROVIDER_TENANT_ID = ? OR SHARED_WITH_ALL_TENANTS = ?)) " + "AND DEVICE_IDENTIFICATION = ? AND TENANT_ID = ?"; - stmt = conn.prepareStatement(sql, new String[]{"id"}); + stmt = conn.prepareStatement(sql); stmt.setString(1, device.getName()); stmt.setString(2, device.getDescription()); stmt.setTimestamp(3, new Timestamp(new Date().getTime())); @@ -127,6 +127,30 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } } + @Override + public boolean recordDeviceUpdate(DeviceIdentifier deviceIdentifier, int tenantId) + throws DeviceManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + int rows; + try { + conn = this.getConnection(); + String sql = "UPDATE DM_DEVICE SET LAST_UPDATED_TIMESTAMP = ? " + + "WHERE DEVICE_IDENTIFICATION = ? AND TENANT_ID = ?"; + stmt = conn.prepareStatement(sql); + stmt.setTimestamp(1, new Timestamp(new Date().getTime())); + stmt.setString(2, deviceIdentifier.getId()); + stmt.setInt(3, tenantId); + rows = stmt.executeUpdate(); + return (rows > 0); + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while updating device update timestamp of " + + " device '" + deviceIdentifier + "'", e); + } finally { + DeviceManagementDAOUtil.cleanupResources(stmt, null); + } + } + @Override public Device getDevice(DeviceData deviceData, int tenantId) throws DeviceManagementDAOException { Device device = null; @@ -136,6 +160,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "d1.ID AS DEVICE_ID, " + "d1.DESCRIPTION, " + "d1.NAME AS DEVICE_NAME, " + + "d1.LAST_UPDATED_TIMESTAMP, " + "e.DEVICE_TYPE, " + "e.DEVICE_IDENTIFICATION, " + "e.OWNER, " @@ -149,7 +174,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "(SELECT " + "d.ID, " + "d.DESCRIPTION, " - + "d.NAME " + + "d.NAME, " + + "d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d" + "d.DEVICE_IDENTIFICATION = ? AND " + "d.TENANT_ID = ?"; @@ -208,9 +234,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, " + + "d1.LAST_UPDATED_TIMESTAMP, e.DEVICE_TYPE, " + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d WHERE " + "d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + "AND e.DEVICE_TYPE = ? AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC, e.STATUS ASC"; @@ -248,12 +276,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try { conn = this.getConnection(); String sql = "SELECT " + - "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " + + "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.LAST_UPDATED_TIMESTAMP, " + + "e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " + + "e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " + "FROM " + "DM_ENROLMENT e," + - " (SELECT d.ID, d.DESCRIPTION, d.NAME " + + " (SELECT d.ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d " + "WHERE d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 " + "WHERE " + @@ -293,10 +321,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, " + + "d1.LAST_UPDATED_TIMESTAMP, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, " + + "e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + - "(SELECT d.ID, d.DESCRIPTION, d.NAME " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d WHERE d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 " + "WHERE e.DEVICE_TYPE = ? AND d1.ID = e.DEVICE_ID " + "AND TENANT_ID = ? AND e.OWNER = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; @@ -328,9 +357,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, " + + "d1.LAST_UPDATED_TIMESTAMP, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, " + + "e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d WHERE d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? " + "AND d.LAST_UPDATED_TIMESTAMP > ?) d1 WHERE e.DEVICE_TYPE = ? " + "AND d1.ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; @@ -520,12 +551,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, " + + "d1.LAST_UPDATED_TIMESTAMP, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, " + + "e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " + "FROM" + " DM_ENROLMENT e, " + - "(SELECT d.ID, d.DESCRIPTION, d.NAME " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP " + "FROM" + " DM_DEVICE d " + "WHERE " + @@ -563,9 +595,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, " + + "d1.LAST_UPDATED_TIMESTAMP, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, " + + "e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d WHERE " + "d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ? " + "AND d.LAST_UPDATED_TIMESTAMP > ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ? AND e.OWNER = ? " + @@ -599,9 +633,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, " + + "d1.LAST_UPDATED_TIMESTAMP, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, " + + "e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d WHERE " + "d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND e.DEVICE_TYPE = ? AND e.DEVICE_IDENTIFICATION = ? " + "AND TENANT_ID = ? AND e.STATUS = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; @@ -632,9 +668,10 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { String sql = "SELECT d1.ID AS DEVICE_ID, " + "d1.DESCRIPTION, " + "d1.NAME AS DEVICE_NAME, " + + "d1.LAST_UPDATED_TIMESTAMP, " + "e.DEVICE_TYPE, " + "e.TENANT_ID, " + - "d1.DEVICE_IDENTIFICATION, " + + "e.DEVICE_IDENTIFICATION, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.STATUS, " + @@ -646,7 +683,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "(SELECT d.ID, " + "d.DESCRIPTION, " + "d.NAME, " + - "d.DEVICE_IDENTIFICATION " + + "d.DEVICE_IDENTIFICATION, " + + "d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d " + "WHERE d.DEVICE_IDENTIFICATION = ?) d1 " + "WHERE d1.ID = e.DEVICE_ID AND e.DEVICE_TYPE = ? " + @@ -684,9 +722,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Device device = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, " + + "d1.LAST_UPDATED_TIMESTAMP, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, " + + "e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, " + + "e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d WHERE d.ID = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID " + "AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); @@ -714,10 +754,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List devices; try { conn = this.getConnection(); - String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID, " + - "d.DESCRIPTION, d.NAME FROM DM_DEVICE d WHERE d.TENANT_ID = ?) d1 " + + String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.LAST_UPDATED_TIMESTAMP, " + + "e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " + + "e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + + "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP FROM DM_DEVICE d " + + "WHERE d.TENANT_ID = ?) d1 " + "WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); @@ -745,10 +786,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List devices = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " + - "d.NAME FROM DM_DEVICE d WHERE d.TENANT_ID = ?) d1 WHERE e.DEVICE_TYPE = ? AND d1.ID = e.DEVICE_ID " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.LAST_UPDATED_TIMESTAMP, " + + "e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " + + "e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP FROM DM_DEVICE d " + + "WHERE d.TENANT_ID = ?) d1 WHERE e.DEVICE_TYPE = ? AND d1.ID = e.DEVICE_ID " + "AND TENANT_ID = ? ORDER BY e.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); @@ -780,6 +822,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { String sql = "SELECT d1.ID AS DEVICE_ID," + " d1.DESCRIPTION," + " d1.NAME AS DEVICE_NAME," + + " d1.LAST_UPDATED_TIMESTAMP, " + " e.DEVICE_TYPE," + " e.DEVICE_IDENTIFICATION," + " e.OWNER," + @@ -792,7 +835,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "FROM DM_ENROLMENT e," + " (SELECT d.ID," + " d.DESCRIPTION," + - " d.NAME" + + " d.NAME," + + " d.LAST_UPDATED_TIMESTAMP" + " FROM DM_DEVICE d" + " WHERE d.TENANT_ID = ?) d1 " + "WHERE d1.ID = e.DEVICE_ID" + @@ -840,7 +884,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { conn = this.getConnection(); String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.IS_TRANSFERRED, " + "e1.DATE_OF_LAST_UPDATE, e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, " + - "d.DEVICE_IDENTIFICATION, e1.DEVICE_TYPE FROM DM_DEVICE d, " + + "d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP, e1.DEVICE_TYPE FROM DM_DEVICE d, " + "(SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, e.DEVICE_TYPE, " + "e.DEVICE_ID, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT " + "FROM DM_ENROLMENT e WHERE e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?)) e1 " + @@ -874,7 +918,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { conn = this.getConnection(); String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.IS_TRANSFERRED, " + "e1.DATE_OF_LAST_UPDATE, e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, " + - "d.DEVICE_IDENTIFICATION, e1.DEVICE_TYPE FROM DM_DEVICE d, " + + "d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP, e1.DEVICE_TYPE FROM DM_DEVICE d, " + "(SELECT e.OWNER, e.DEVICE_TYPE, e.OWNERSHIP, e.ID AS ENROLMENT_ID, e.DEVICE_ID, e.STATUS, " + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " + "e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?) ORDER BY e.DATE_OF_LAST_UPDATE DESC) e1 " + @@ -919,6 +963,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "d.DESCRIPTION, " + "d.NAME AS DEVICE_NAME, " + "d.DEVICE_IDENTIFICATION, " + + "d.LAST_UPDATED_TIMESTAMP, " + "e.DEVICE_TYPE " + "FROM " + "DM_DEVICE d, " @@ -1082,7 +1127,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } } - private Connection getConnection() throws SQLException { + protected Connection getConnection() throws SQLException { return DeviceManagementDAOFactory.getConnection(); } @@ -1669,9 +1714,10 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List devices = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ENROLMENT_ID FROM (SELECT e.ID, e.DEVICE_ID, e.DEVICE_TYPE, e.OWNER, " + + String sql = "SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.LAST_UPDATED_TIMESTAMP, " + + "e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " + + "e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ENROLMENT_ID FROM " + + "(SELECT e.ID, e.DEVICE_ID, e.DEVICE_TYPE, e.OWNER, " + "e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS " + "ENROLMENT_ID FROM DM_ENROLMENT e WHERE TENANT_ID = ? AND STATUS = ?) e, " + "DM_DEVICE d WHERE d.ID = e.DEVICE_ID AND d.TENANT_ID = ?"; @@ -1735,8 +1781,9 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try { conn = this.getConnection(); String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID, " + + "d1.DEVICE_IDENTIFICATION, d1.LAST_UPDATED_TIMESTAMP, e.OWNER, e.OWNERSHIP, e.STATUS, " + + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, " + + "e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID, " + "d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP FROM DM_DEVICE d " + "WHERE d.TENANT_ID = ? AND d.LAST_UPDATED_TIMESTAMP < CURRENT_TIMESTAMP) d1 " + "WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?"; @@ -1798,6 +1845,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "MIN(DEVICE.ID) AS DEVICE_ID, " + "MIN(DEVICE.NAME) AS DEVICE_NAME, " + "MIN(DEVICE.DESCRIPTION) AS DESCRIPTION, " + + "MAX(DEVICE.LAST_UPDATED_TIMESTAMP) AS LAST_UPDATED_TIMESTAMP, " + "MIN(ENROLMENT.DEVICE_TYPE) AS DEVICE_TYPE, " + "MIN(DEVICE.DEVICE_IDENTIFICATION) AS DEVICE_IDENTIFICATION, " + "MIN(ENROLMENT.ID) AS ENROLMENT_ID, " + @@ -1957,12 +2005,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { StringJoiner joiner = new StringJoiner(",", "SELECT " - + "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " - + "e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " - + "e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " + + "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.LAST_UPDATED_TIMESTAMP, " + + "e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, " + + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " + "FROM " + "DM_ENROLMENT e, " - + "(SELECT d.ID, d.DESCRIPTION, d.NAME " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d " + "WHERE " + "d.DEVICE_IDENTIFICATION IN (", @@ -2016,11 +2064,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { StringJoiner joiner = new StringJoiner(",", "SELECT " + "d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " - + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " + + "d1.DEVICE_IDENTIFICATION, d1.LAST_UPDATED_TIMESTAMP, e.OWNER, e.OWNERSHIP, " + + "e.STATUS, e.IS_TRANSFERRED, " + "e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID " + "FROM " + "DM_ENROLMENT e, " - + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION " + + "(SELECT d.ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d " + "WHERE " + " d.DEVICE_IDENTIFICATION IN (", @@ -2191,6 +2240,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "d.NAME AS DEVICE_NAME, " + "e.DEVICE_TYPE, " + "d.DEVICE_IDENTIFICATION, " + + "d.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.STATUS, " + @@ -2307,6 +2357,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "d.description," + "d.NAME AS DEVICE_NAME," + "d.device_identification," + + "d.LAST_UPDATED_TIMESTAMP, " + "e1.DEVICE_TYPE " + "FROM dm_device d," + "(SELECT e.owner," + @@ -2763,42 +2814,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } } - /*** - * This method updates the status of a given list of devices to DELETED state in the DM_DEVICE_STATUS table - * @param conn Connection object - * @param validDevices list of devices - * @throws DeviceManagementDAOException if updating fails - */ - public void refactorDeviceStatus(Connection conn, List validDevices) throws DeviceManagementDAOException { - String updateQuery = "UPDATE DM_DEVICE_STATUS SET STATUS = ? WHERE ID = ?"; - String selectLastMatchingRecordQuery = "SELECT ID FROM DM_DEVICE_STATUS WHERE ENROLMENT_ID = ? AND DEVICE_ID = ? ORDER BY ID DESC LIMIT 1"; - - try (PreparedStatement selectStatement = conn.prepareStatement(selectLastMatchingRecordQuery); - PreparedStatement updateStatement = conn.prepareStatement(updateQuery)) { - - for (Device device : validDevices) { - - selectStatement.setInt(1, device.getEnrolmentInfo().getId()); - selectStatement.setInt(2, device.getId()); - - ResultSet resultSet = selectStatement.executeQuery(); - int lastRecordId = 0; - if (resultSet.next()) { - lastRecordId = resultSet.getInt("ID"); - } - - updateStatement.setString(1, String.valueOf(Status.DELETED)); - updateStatement.setInt(2, lastRecordId); - updateStatement.execute(); - } - - } catch (SQLException e) { - String msg = "SQL error occurred while updating device status properties."; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - private String generateRandomString(int length) { String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; StringBuilder randomString = new StringBuilder(); @@ -3001,107 +3016,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } } - @Override - public List getGroupedDevicesDetails(PaginationRequest request, List deviceIds, String groupName, - int tenantId) throws DeviceManagementDAOException { - int limitValue = request.getRowCount(); - int offsetValue = request.getStartIndex(); - List status = request.getStatusList(); - String name = request.getDeviceName(); - String user = request.getOwner(); - String ownership = request.getOwnership(); - try { - List devices = new ArrayList<>(); - if (deviceIds.isEmpty()) { - return devices; - } - Connection conn = this.getConnection(); - int index = 1; - StringJoiner joiner = new StringJoiner(",", - "SELECT " - + "DM_DEVICE.ID AS DEVICE_ID, " - + "DM_DEVICE.NAME AS DEVICE_NAME, " - + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " - + "e.DEVICE_TYPE, " - + "e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " - + "e.ID AS ENROLMENT_ID, " - + "e.OWNER, " - + "e.OWNERSHIP, " - + "e.DATE_OF_ENROLMENT, " - + "e.DATE_OF_LAST_UPDATE, " - + "e.STATUS, " - + "e.IS_TRANSFERRED " - + "FROM DM_DEVICE_GROUP_MAP " - + "INNER JOIN DM_DEVICE ON " - + "DM_DEVICE_GROUP_MAP.DEVICE_ID = DM_DEVICE.ID " - + "INNER JOIN DM_GROUP ON " - + "DM_DEVICE_GROUP_MAP.GROUP_ID = DM_GROUP.ID " - + "INNER JOIN DM_ENROLMENT e ON " - + "DM_DEVICE.ID = e.DEVICE_ID AND " - + "DM_DEVICE.TENANT_ID = e.TENANT_ID " - + "WHERE DM_DEVICE.ID IN (", - ") AND DM_DEVICE.TENANT_ID = ?"); - - deviceIds.stream().map(ignored -> "?").forEach(joiner::add); - String query = joiner.toString(); - if (StringUtils.isNotBlank(groupName)) { - query += " AND DM_GROUP.GROUP_NAME = ?"; - } - if (StringUtils.isNotBlank(name)) { - query += " AND DM_DEVICE.NAME LIKE ?"; - } - if (StringUtils.isNotBlank(user)) { - query += " AND e.OWNER = ?"; - } - if (StringUtils.isNotBlank(ownership)) { - query += " AND e.OWNERSHIP = ?"; - } - if (status != null && !status.isEmpty()) { - query += buildStatusQuery(status); - } - - query += "LIMIT ? OFFSET ?"; - - try (PreparedStatement ps = conn.prepareStatement(query)) { - for (Integer deviceId : deviceIds) { - ps.setInt(index++, deviceId); - } - ps.setInt(index++, tenantId); - if (StringUtils.isNotBlank(groupName)) { - ps.setString(index++, groupName); - } - if (StringUtils.isNotBlank(name)) { - ps.setString(index++, name); - } - if (StringUtils.isNotBlank(user)) { - ps.setString(index++, user); - } - if (StringUtils.isNotBlank(ownership)) { - ps.setString(index++, ownership); - } - if (status != null && !status.isEmpty()) { - for (String deviceStatus : status) { - ps.setString(index++, deviceStatus); - } - } - ps.setInt(index++, limitValue); - ps.setInt(index, offsetValue); - - try (ResultSet rs = ps.executeQuery()) { - while (rs.next()) { - devices.add(DeviceManagementDAOUtil.loadDevice(rs)); - } - return devices; - } - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving information of all registered devices " + - "according to device ids and the limit area."; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - @Override public int getGroupedDevicesCount(PaginationRequest request, List deviceIds, String groupName, int tenantId) throws DeviceManagementDAOException { @@ -3216,7 +3130,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); List devices = new ArrayList<>(); String query = "SELECT e.ID AS ENROLMENT_ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.DATE_OF_ENROLMENT, " + - "e.DATE_OF_LAST_UPDATE, e.IS_TRANSFERRED, e.STATUS,d.DEVICE_NAME, d.DESCRIPTION, e.DEVICE_TYPE, " + + "e.DATE_OF_LAST_UPDATE, e.IS_TRANSFERRED, e.STATUS, d.DEVICE_NAME, d.DESCRIPTION, " + + "d.LAST_UPDATED_TIMESTAMP, e.DEVICE_TYPE, " + "e.DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e, (SELECT d1.ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME FROM DM_DEVICE d1 " + "WHERE d1.TENANT_ID = ?) d WHERE e.STATUS NOT IN ('DELETED', 'REMOVED') " + @@ -3247,8 +3162,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); List devices = new ArrayList<>(); String query = "SELECT e.ID AS ENROLMENT_ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.DATE_OF_ENROLMENT, " + - "e.DATE_OF_LAST_UPDATE, e.IS_TRANSFERRED, e.STATUS, d.DEVICE_NAME, d.DESCRIPTION, e.DEVICE_TYPE, " + - "e.DEVICE_IDENTIFICATION " + + "e.DATE_OF_LAST_UPDATE, e.IS_TRANSFERRED, e.STATUS, d.DEVICE_NAME, d.DESCRIPTION, " + + "d.LAST_UPDATED_TIMESTAMP, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e, (SELECT d1.ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME FROM DM_DEVICE d1 " + "WHERE d1.TENANT_ID = ?) d WHERE e.STATUS NOT IN ('DELETED', 'REMOVED') " + "AND e.DATE_OF_ENROLMENT < ? AND e.TENANT_ID = ?"; @@ -3273,4 +3188,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } return devices; } + + public abstract void refactorDeviceStatus (Connection conn, List validDevices) + throws DeviceManagementDAOException; + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index b9c655c4ba..374c1ca0aa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1282,9 +1282,10 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { StringJoiner joiner = new StringJoiner(",","SELECT " + "d1.DEVICE_ID, " + "d1.DESCRIPTION, " - + "d1.NAME AS DEVICE_NAME, " + + "e.DEVICE_NAME, " + "d1.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, " + + "d1.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.STATUS, " @@ -1294,15 +1295,14 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { + "e.ID AS ENROLMENT_ID " + "FROM " + "DM_ENROLMENT e, " - + "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " + + "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, gd.LAST_UPDATED_TIMESTAMP " + "FROM " - + "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.DEVICE_TYPE_ID " + + "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d, " + "(SELECT dgm.DEVICE_ID " + "FROM DM_DEVICE_GROUP_MAP dgm " + "WHERE dgm.GROUP_ID = (SELECT ID FROM DM_GROUP WHERE GROUP_NAME = ? AND TENANT_ID = ?)) dgm1 " - + "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd, DM_DEVICE_TYPE t " - + "WHERE gd.DEVICE_TYPE_ID = t.ID) d1 " + + "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd) d1 " + "WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? AND e.STATUS IN (", ")"); @@ -1343,9 +1343,10 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { String sql = "SELECT " + "d1.DEVICE_ID, " + "d1.DESCRIPTION, " - + "d1.NAME AS DEVICE_NAME, " + + "e.DEVICE_NAME, " + "d1.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, " + + "d1.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.STATUS, " @@ -1355,15 +1356,14 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { + "e.ID AS ENROLMENT_ID " + "FROM " + "DM_ENROLMENT e, " - + "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " + + "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, gd.LAST_UPDATED_TIMESTAMP " + "FROM " - + "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.DEVICE_TYPE_ID " + + "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d, " + "(SELECT dgm.DEVICE_ID " + "FROM DM_DEVICE_GROUP_MAP dgm " + "WHERE dgm.GROUP_ID = (SELECT ID FROM DM_GROUP WHERE GROUP_NAME = ? AND TENANT_ID = ?)) dgm1 " - + "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd, DM_DEVICE_TYPE t " - + "WHERE gd.DEVICE_TYPE_ID = t.ID) d1 " + + "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd) d1 " + "WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -1396,9 +1396,10 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { StringJoiner sql = new StringJoiner(",", "SELECT DEVICE.ID AS DEVICE_ID, " + "DEVICE.NAME AS DEVICE_NAME, " + - "DEVICE_TYPE.NAME AS DEVICE_TYPE, " + + "ENROLMENT.DEVICE_TYPE, " + "DEVICE.DESCRIPTION, " + "DEVICE.DEVICE_IDENTIFICATION, " + + "DEVICE.LAST_UPDATED_TIMESTAMP, " + "ENROLMENT.ID AS ENROLMENT_ID, " + "ENROLMENT.OWNER, " + "ENROLMENT.OWNERSHIP, " + @@ -1406,9 +1407,9 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { "ENROLMENT.DATE_OF_LAST_UPDATE, " + "ENROLMENT.STATUS, " + "ENROLMENT.IS_TRANSFERRED " + - "FROM DM_DEVICE AS DEVICE, DM_DEVICE_TYPE AS DEVICE_TYPE, DM_ENROLMENT " + + "FROM DM_DEVICE AS DEVICE, DM_ENROLMENT " + "AS ENROLMENT " + - "WHERE DEVICE_TYPE.NAME = ? AND DEVICE.ID " + + "WHERE ENROLMENT.DEVICE_TYPE = ? AND DEVICE.ID " + "NOT IN " + "(SELECT DEVICE_ID " + "FROM DM_DEVICE_GROUP_MAP " + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 7d7fe4bf5b..efe07d1335 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.device; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Count; @@ -27,7 +28,6 @@ import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; @@ -71,14 +71,14 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { String serial = request.getSerialNumber(); boolean isSerialProvided = false; - try { Connection conn = getConnection(); String sql = "SELECT d1.ID AS DEVICE_ID, " + "d1.DESCRIPTION, " + "d1.NAME AS DEVICE_NAME, " + - "d1.DEVICE_TYPE, " + + "e.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, " + + "d1.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.STATUS, " + @@ -90,15 +90,13 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "(SELECT d.ID, " + "d.DESCRIPTION, " + "d.NAME, " + - "d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE "; + "d.LAST_UPDATED_TIMESTAMP, " + + "d.DEVICE_IDENTIFICATION "; //Filter by serial number or any Custom Property in DM_DEVICE_INFO if ((serial != null) || (request.getCustomProperty() != null && !request.getCustomProperty().isEmpty())) { sql = sql + - "FROM DM_DEVICE d " + - "INNER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID " + - "WHERE "; + "FROM DM_DEVICE d WHERE "; if (serial != null) { sql += "EXISTS (" + "SELECT VALUE_FIELD " + @@ -128,24 +126,24 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } sql += "AND d.TENANT_ID = ? "; } else { - sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? "; + sql = sql + "FROM DM_DEVICE d WHERE d.TENANT_ID = ? "; } //Add query for last updated timestamp if (since != null) { sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; isSinceProvided = true; } - //Add the query for device-type - if (deviceType != null && !deviceType.isEmpty()) { - sql = sql + " AND t.NAME = ?"; - isDeviceTypeProvided = true; - } //Add the query for device-name if (deviceName != null && !deviceName.isEmpty()) { sql = sql + " AND d.NAME LIKE ?"; isDeviceNameProvided = true; } sql = sql + ") d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?"; + //Add the query for device-type + if (deviceType != null && !deviceType.isEmpty()) { + sql = sql + " AND e.DEVICE_TYPE = ?"; + isDeviceTypeProvided = true; + } //Add the query for ownership if (ownership != null && !ownership.isEmpty()) { sql = sql + " AND e.OWNERSHIP = ?"; @@ -163,7 +161,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { sql += buildStatusQuery(statusList); isStatusProvided = true; } - sql = sql + " LIMIT ?,?"; + sql = sql + " LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; @@ -179,13 +177,13 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); } - if (isDeviceTypeProvided) { - stmt.setString(paramIdx++, deviceType); - } if (isDeviceNameProvided) { stmt.setString(paramIdx++, "%" + deviceName + "%"); } stmt.setInt(paramIdx++, tenantId); + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, deviceType); + } if (isOwnershipProvided) { stmt.setString(paramIdx++, ownership); } @@ -199,8 +197,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, status); } } - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); + stmt.setInt(paramIdx++, request.getRowCount()); + stmt.setInt(paramIdx, request.getStartIndex()); try (ResultSet rs = stmt.executeQuery()) { devices = new ArrayList<>(); @@ -230,6 +228,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "DESCRIPTION, " + "NAME, " + "DATE_OF_ENROLMENT, " + + "LAST_UPDATED_TIMESTAMP, " + "STATUS, " + "DATE_OF_LAST_UPDATE, " + "TIMESTAMPDIFF(DAY, ?, DATE_OF_ENROLMENT) as DAYS_SINCE_ENROLLED " + @@ -271,6 +270,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "NAME, " + "DATE_OF_ENROLMENT, " + "DATE_OF_LAST_UPDATE, " + + "d1.LAST_UPDATED_TIMESTAMP, " + "STATUS, " + "TIMESTAMPDIFF(DAY, DATE_OF_LAST_UPDATE, DATE_OF_ENROLMENT) AS DAYS_USED " + "from DM_DEVICE d, DM_ENROLMENT e " + @@ -314,6 +314,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "DESCRIPTION, " + "NAME, " + "DATE_OF_ENROLMENT, " + + "LAST_UPDATED_TIMESTAMP, " + "STATUS, " + "DATE_OF_LAST_UPDATE, " + "TIMESTAMPDIFF(DAY, ?, ?) as DAYS_SINCE_ENROLLED " + @@ -355,6 +356,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "NAME, " + "DATE_OF_ENROLMENT, " + "DATE_OF_LAST_UPDATE, " + + "LAST_UPDATED_TIMESTAMP, " + "STATUS, " + "TIMESTAMPDIFF(DAY, DATE_OF_LAST_UPDATE, ?) AS DAYS_USED " + "from DM_DEVICE d, DM_ENROLMENT e " + @@ -399,8 +401,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "DM_DEVICE.ID AS DEVICE_ID, " + "DEVICE_IDENTIFICATION, " + "DESCRIPTION, " + + "LAST_UPDATED_TIMESTAMP, " + "DM_DEVICE.NAME AS DEVICE_NAME, " + - "DM_DEVICE_TYPE.NAME AS DEVICE_TYPE, " + + "DEVICE_TYPE, " + "DM_ENROLMENT.ID AS ENROLMENT_ID, " + "DATE_OF_ENROLMENT, " + "OWNER, " + @@ -412,7 +415,6 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "FROM " + "DM_DEVICE " + "JOIN DM_ENROLMENT ON (DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID) " + - "JOIN DM_DEVICE_TYPE ON (DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID) " + "WHERE " + "DM_ENROLMENT.TENANT_ID = ? "; stmt = conn.prepareStatement(sql); @@ -448,6 +450,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { String sql = "SELECT " + "d1.ID AS DEVICE_ID, " + "d1.DEVICE_IDENTIFICATION, " + + "d1.LAST_UPDATED_TIMESTAMP, " + "e.STATUS, " + "e.OWNER, " + "e.IS_TRANSFERRED, " + @@ -531,8 +534,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { String sql = "SELECT d1.ID AS DEVICE_ID, " + "d1.DESCRIPTION, " + "d1.NAME AS DEVICE_NAME, " + - "d1.DEVICE_TYPE, " + + "e.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, " + + "d1.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.STATUS, " + @@ -545,29 +549,29 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "d.DESCRIPTION, " + "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE " + - "FROM DM_DEVICE d, DM_DEVICE_TYPE t "; + "d.LAST_UPDATED_TIMESTAMP " + + "FROM DM_DEVICE d "; //Add the query to filter active devices on timestamp if (since != null) { sql = sql + ", DM_DEVICE_DETAIL dt"; isSinceProvided = true; } - sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + sql = sql + " WHERE d.TENANT_ID = ?"; //Add query for last updated timestamp if (isSinceProvided) { sql = sql + " AND dt.DEVICE_ID = d.ID AND dt.UPDATE_TIMESTAMP > ?"; } - //Add the query for device-type - if (deviceType != null && !deviceType.isEmpty()) { - sql = sql + " AND t.NAME = ?"; - isDeviceTypeProvided = true; - } //Add the query for device-name if (deviceName != null && !deviceName.isEmpty()) { sql = sql + " AND d.NAME LIKE ?"; isDeviceNameProvided = true; } sql = sql + ") d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?"; + //Add the query for device-type + if (deviceType != null && !deviceType.isEmpty()) { + sql = sql + " AND e.DEVICE_TYPE = ?"; + isDeviceTypeProvided = true; + } //Add the query for ownership if (ownership != null && !ownership.isEmpty()) { sql = sql + " AND e.OWNERSHIP = ?"; @@ -589,7 +593,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { sql = sql + " AND MOD(d1.ID, ?) = ?"; isPartitionedTask = true; } - sql = sql + " LIMIT ?,?"; + sql = sql + " LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; @@ -597,13 +601,13 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { if (isSinceProvided) { stmt.setLong(paramIdx++, since.getTime()); } - if (isDeviceTypeProvided) { - stmt.setString(paramIdx++, deviceType); - } if (isDeviceNameProvided) { stmt.setString(paramIdx++, deviceName + "%"); } stmt.setInt(paramIdx++, tenantId); + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, deviceType); + } if (isOwnershipProvided) { stmt.setString(paramIdx++, ownership); } @@ -621,8 +625,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setInt(paramIdx++, activeServerCount); stmt.setInt(paramIdx++, serverIndex); } - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); + stmt.setInt(paramIdx++, request.getRowCount()); + stmt.setInt(paramIdx, request.getStartIndex()); try (ResultSet rs = stmt.executeQuery()) { devices = new ArrayList<>(); @@ -668,8 +672,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { String sql = "SELECT d1.DEVICE_ID, " + "d1.DESCRIPTION, " + "d1.NAME AS DEVICE_NAME, " + - "d1.DEVICE_TYPE, " + + "e.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, " + + "d1.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.STATUS, " + @@ -682,13 +687,12 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "gd.DESCRIPTION, " + "gd.NAME, " + "gd.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE " + "FROM " + "(SELECT d.ID AS DEVICE_ID, " + "d.DESCRIPTION, " + "d.NAME, " + "d.DEVICE_IDENTIFICATION, " + - "d.DEVICE_TYPE_ID " + + "d.LAST_UPDATED_TIMESTAMP " + "FROM DM_DEVICE d, " + "(SELECT dgm.DEVICE_ID " + "FROM DM_DEVICE_GROUP_MAP dgm " + @@ -700,19 +704,19 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { sql = sql + " AND d.NAME LIKE ?"; isDeviceNameProvided = true; } - sql = sql + ") gd, DM_DEVICE_TYPE t"; - sql = sql + " WHERE gd.DEVICE_TYPE_ID = t.ID"; + sql = sql + ") gd"; + sql = sql + " WHERE 1 = 1"; //Add query for last updated timestamp if (since != null) { sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; isSinceProvided = true; } + sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? "; //Add the query for device-type if (deviceType != null && !deviceType.isEmpty()) { - sql = sql + " AND t.NAME = ?"; + sql = sql + " AND e.DEVICE_TYPE = ?"; isDeviceTypeProvided = true; } - sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? "; //Add the query for ownership if (ownership != null && !ownership.isEmpty()) { sql = sql + " AND e.OWNERSHIP = ?"; @@ -752,7 +756,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } } } - sql = sql + " LIMIT ?,?"; + sql = sql + " LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; @@ -764,10 +768,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { if (isSinceProvided) { stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); } + stmt.setInt(paramIdx++, tenantId); if (isDeviceTypeProvided) { stmt.setString(paramIdx++, deviceType); } - stmt.setInt(paramIdx++, tenantId); if (isOwnershipProvided) { stmt.setString(paramIdx++, ownership); } @@ -789,8 +793,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, "%" + entry.getValue() + "%"); } } - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); + stmt.setInt(paramIdx++, request.getRowCount()); + stmt.setInt(paramIdx, request.getStartIndex()); try (ResultSet rs = stmt.executeQuery()) { devices = new ArrayList<>(); @@ -817,17 +821,17 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { List devices = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.IS_TRANSFERRED, e1.DATE_OF_LAST_UPDATE," + - " e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.DEVICE_IDENTIFICATION, t.NAME " + - "AS DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, " + + String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.IS_TRANSFERRED, " + + "e1.DATE_OF_LAST_UPDATE, d.LAST_UPDATED_TIMESTAMP, " + + "e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.DEVICE_IDENTIFICATION, " + + "e1.DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, e.DEVICE_TYPE, " + "e.DEVICE_ID, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " + - "e.TENANT_ID = ? AND e.OWNER = ?) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " + - "AND t.ID = d.DEVICE_TYPE_ID LIMIT ?,?"; + "e.TENANT_ID = ? AND e.OWNER = ?) e1 WHERE d.ID = e1.DEVICE_ID LIMIT ? OFFSET ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setString(2, request.getOwner()); - stmt.setInt(3, request.getStartIndex()); - stmt.setInt(4, request.getRowCount()); + stmt.setInt(3, request.getRowCount()); + stmt.setInt(4, request.getStartIndex()); ResultSet rs = stmt.executeQuery(); while (rs.next()) { @@ -851,18 +855,19 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { List devices = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "d1.DEVICE_IDENTIFICATION, d1.LAST_UPDATED_TIMESTAMP, e.OWNER, e.OWNERSHIP, e.STATUS, " + + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " + - "d.DESCRIPTION, t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.NAME LIKE ? AND d.TENANT_ID = ?) d1 " + - "WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? LIMIT ?,?"; + "d.DESCRIPTION, d.LAST_UPDATED_TIMESTAMP, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d " + + "WHERE d.NAME LIKE ? AND d.TENANT_ID = ?) d1 " + + "WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? LIMIT ? OFFSET ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, request.getDeviceName() + "%"); stmt.setInt(2, tenantId); stmt.setInt(3, tenantId); - stmt.setInt(4, request.getStartIndex()); - stmt.setInt(5, request.getRowCount()); + stmt.setInt(4, request.getRowCount()); + stmt.setInt(5, request.getStartIndex()); ResultSet rs = stmt.executeQuery(); while (rs.next()) { @@ -886,18 +891,20 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { List devices = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, t.NAME AS DEVICE_TYPE, " + - "d.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM (SELECT e.ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " + + String sql = "SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP, e.OWNER, e.OWNERSHIP, e.STATUS, " + + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM (SELECT e.ID, e.DEVICE_ID, e.OWNER, " + + "e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DEVICE_TYPE, " + "e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e " + - "WHERE TENANT_ID = ? AND OWNERSHIP = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t " + - "WHERE DEVICE_ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? LIMIT ?,?"; + "WHERE TENANT_ID = ? AND OWNERSHIP = ?) e, DM_DEVICE d " + + "WHERE DEVICE_ID = e.DEVICE_ID AND d.TENANT_ID = ? LIMIT ? OFFSET ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setString(2, request.getOwnership()); stmt.setInt(3, tenantId); - stmt.setInt(4, request.getStartIndex()); - stmt.setInt(5, request.getRowCount()); + stmt.setInt(4, request.getRowCount()); + stmt.setInt(5, request.getStartIndex()); ResultSet rs = stmt.executeQuery(); while (rs.next()) { @@ -924,8 +931,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { String sql = "SELECT d.ID AS DEVICE_ID, " + "d.DESCRIPTION, " + "d.NAME AS DEVICE_NAME, " + - "t.NAME AS DEVICE_TYPE, " + + "e.DEVICE_TYPE, " + "d.DEVICE_IDENTIFICATION, " + + "d.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.STATUS, " + @@ -942,6 +950,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "e.IS_TRANSFERRED, " + "e.DATE_OF_ENROLMENT, " + "e.DATE_OF_LAST_UPDATE, " + + "e.DEVICE_TYPE, " + "e.ID AS ENROLMENT_ID " + "FROM DM_ENROLMENT e " + "WHERE TENANT_ID = ?"; @@ -953,12 +962,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } sql += buildStatusQuery(statusList); sql += ") e, " + - "DM_DEVICE d, " + - "DM_DEVICE_TYPE t " + + "DM_DEVICE d " + "WHERE DEVICE_ID = e.DEVICE_ID " + - "AND d.DEVICE_TYPE_ID = t.ID " + "AND d.TENANT_ID = ? " + - "LIMIT ?,?"; + "LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; @@ -967,8 +974,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, status); } stmt.setInt(paramIdx++, tenantId); - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); + stmt.setInt(paramIdx++, request.getRowCount()); + stmt.setInt(paramIdx, request.getStartIndex()); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { @@ -998,8 +1005,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { String sql = "SELECT " + "d.ID AS DEVICE_ID, " + "d.DESCRIPTION,d.NAME AS DEVICE_NAME, " + - "t.NAME AS DEVICE_TYPE, " + - "d.DEVICE_IDENTIFICATION, " + + "d.LAST_UPDATED_TIMESTAMP, " + + "e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION, " + "e.OWNER, " + "e.OWNERSHIP, " + "e.STATUS, " + @@ -1007,9 +1015,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "e.DATE_OF_LAST_UPDATE," + "e.DATE_OF_ENROLMENT, " + "e.ID AS ENROLMENT_ID " + - "FROM DM_DEVICE AS d , DM_ENROLMENT AS e , DM_DEVICE_TYPE AS t " + + "FROM DM_DEVICE AS d, DM_ENROLMENT AS e " + "WHERE d.ID = e.DEVICE_ID AND " + - "d.DEVICE_TYPE_ID = t.ID AND " + "e.TENANT_ID = ? AND " + "e.DATE_OF_ENROLMENT BETWEEN ? AND ?"; if (statusList != null && !statusList.isEmpty()) { @@ -1019,7 +1026,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { if (ownership != null) { sql = sql + " AND e.OWNERSHIP = ?"; } - sql = sql + " LIMIT ?,?"; + sql = sql + " LIMIT ? OFFSET ?"; try (Connection conn = this.getConnection(); PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -1035,8 +1042,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { if (ownership != null) { stmt.setString(paramIdx++, ownership); } - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); + stmt.setInt(paramIdx++, request.getRowCount()); + stmt.setInt(paramIdx, request.getStartIndex()); try (ResultSet rs = stmt.executeQuery()) { devices = new ArrayList<>(); @@ -1063,11 +1070,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { String sql = "SELECT " + "COUNT(d.ID) AS DEVICE_COUNT " + - "FROM DM_DEVICE AS d , " + - "DM_ENROLMENT AS e , " + - "DM_DEVICE_TYPE AS t " + + "FROM DM_DEVICE AS d, " + + "DM_ENROLMENT AS e " + "WHERE d.ID = e.DEVICE_ID " + - "AND d.DEVICE_TYPE_ID = t.ID " + "AND e.TENANT_ID = ? " + "AND e.DATE_OF_ENROLMENT BETWEEN ? AND ?"; if (statusList != null && !statusList.isEmpty()) { @@ -1121,7 +1126,6 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "COUNT(SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10)) AS ENROLMENT_COUNT " + "FROM DM_DEVICE AS d " + "INNER JOIN DM_ENROLMENT AS e ON d.ID = e.DEVICE_ID " + - "INNER JOIN DM_DEVICE_TYPE AS t ON d.DEVICE_TYPE_ID = t.ID " + "AND e.TENANT_ID = ? " + "AND e.DATE_OF_ENROLMENT " + "BETWEEN ? AND ? "; @@ -1136,7 +1140,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { sql = sql + " AND e.OWNERSHIP = ?"; } - sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) LIMIT ? OFFSET ?"; + sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) LIMIT ?, ?"; try { Connection conn = this.getConnection(); @@ -1187,27 +1191,27 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { public List getDevicesByNameAndType(String deviceName, String type, int tenantId, int offset, int limit) throws DeviceManagementDAOException { - String filteringString = ""; - if (deviceName != null && !deviceName.isEmpty()) { - filteringString = filteringString + " AND d.NAME LIKE ?"; - } - - if (type != null && !type.isEmpty()) { - filteringString = filteringString + " AND t.NAME = ?"; - } - Connection conn; PreparedStatement stmt = null; List devices = new ArrayList<>(); ResultSet rs = null; try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "d1.DEVICE_IDENTIFICATION, d1.LAST_UPDATED_TIMESTAMP, e.OWNER, e.OWNERSHIP, e.STATUS, " + + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " + - "d.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?" + filteringString + - ") d1 WHERE d1.ID = e.DEVICE_ID LIMIT ?, ?"; + "d.DESCRIPTION, d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP FROM DM_DEVICE d " + + "WHERE d.TENANT_ID = ?"; + + if (deviceName != null && !deviceName.isEmpty()) { + sql += " AND d.NAME LIKE ? "; + } + sql += ") d1 WHERE d1.ID = e.DEVICE_ID"; + if (type != null && !type.isEmpty()) { + sql += " AND e.DEVICE_TYPE = ?"; + } + sql+=" LIMIT ? OFFSET ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); @@ -1222,8 +1226,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(++i, type); } - stmt.setInt(++i, offset); stmt.setInt(++i, limit); + stmt.setInt(++i, offset); rs = stmt.executeQuery(); @@ -1272,7 +1276,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { + "DM_DEVICE.ID AS DEVICE_ID, " + "DM_DEVICE.NAME AS DEVICE_NAME, " + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " - + "DM_DEVICE.DEVICE_TYPE_ID, " + + "DM_DEVICE.LAST_UPDATED_TIMESTAMP, " + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + "e.ID AS ENROLMENT_ID, " + "e.OWNER, " @@ -1280,14 +1284,12 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { + "e.DATE_OF_ENROLMENT, " + "e.DATE_OF_LAST_UPDATE, " + "e.STATUS, " - + "e.IS_TRANSFERRED, " - + "device_types.NAME AS DEVICE_TYPE " + + "e.DEVICE_TYPE, " + + "e.IS_TRANSFERRED " + "FROM DM_DEVICE " + "INNER JOIN DM_ENROLMENT e ON " + "DM_DEVICE.ID = e.DEVICE_ID AND " - + "DM_DEVICE.TENANT_ID = e.TENANT_ID " - + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " - + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID "; + + "DM_DEVICE.TENANT_ID = e.TENANT_ID "; if (null != serial && !serial.isEmpty()) { // Only if serial is provided, join with device info table query = query.concat("INNER JOIN DM_DEVICE_INFO i ON " @@ -1332,7 +1334,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } } - query = query + " LIMIT ?,?"; + query = query + " LIMIT ? OFFSET ?"; try (PreparedStatement ps = conn.prepareStatement(query)) { @@ -1365,8 +1367,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { ps.setString(index++, "%" + entry.getValue() + "%"); } } - ps.setInt(index++, offsetValue); - ps.setInt(index, limitValue); + ps.setInt(index++, limitValue); + ps.setInt(index, offsetValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { @@ -1444,11 +1446,12 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { convert function performed in the query which will depend on the datasource */ String dataSourceType = conn.getMetaData().getDatabaseProductName(); String sql = "SELECT " + - "d1.DEVICE_TYPE, " + + "e.DEVICE_TYPE, " + "d1.DEVICE_ID, " + "d1.DEVICE_NAME, " + "d1.DESCRIPTION, " + "d1.DEVICE_IDENTIFICATION, " + + "d1.LAST_UPDATED_TIMESTAMP, " + "ddd.OS_VERSION, " + "e.ID AS ENROLMENT_ID, " + "e.OWNER, " + @@ -1458,20 +1461,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT " + "FROM DM_DEVICE_INFO ddi," + - "DM_DEVICE_DETAIL ddd, " + - "DM_ENROLMENT e, " + - "(SELECT dt.NAME AS DEVICE_TYPE, " + - "d.ID AS DEVICE_ID, " + - "d.NAME AS DEVICE_NAME, " + - "DESCRIPTION, " + - "DEVICE_IDENTIFICATION " + - "FROM DM_DEVICE_TYPE dt, " + - "DM_DEVICE d " + - "WHERE dt.NAME = ? " + - "AND PROVIDER_TENANT_ID = ? " + - "AND dt.ID = d.DEVICE_TYPE_ID " + - ") d1 " + - "WHERE d1.DEVICE_ID = e.DEVICE_ID " + + "DM_DEVICE_DETAIL ddd, DM_ENROLMENT e, DM_DEVICE d1 " + + "WHERE e.DEVICE_TYPE = ? " + + "AND e.TENANT_ID = ? " + + "AND d1.DEVICE_ID = e.DEVICE_ID " + "AND d1.DEVICE_ID = ddi.DEVICE_ID " + "AND d1.DEVICE_ID = ddd.DEVICE_ID " + "AND ddi.KEY_FIELD = ? "; @@ -1487,8 +1480,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { ps.setInt(2, tenantId); ps.setString(3, Constants.OS_VALUE); ps.setLong(4, osValue); - ps.setInt(5, request.getRowCount()); - ps.setInt(6, request.getStartIndex()); + ps.setInt(5, request.getStartIndex()); + ps.setInt(6, request.getRowCount()); try (ResultSet rs = ps.executeQuery()) { List devices = new ArrayList<>(); @@ -1557,7 +1550,143 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } } - private Connection getConnection() throws SQLException { - return DeviceManagementDAOFactory.getConnection(); + @Override + public List getGroupedDevicesDetails(PaginationRequest request, List deviceIds, String groupName, + int tenantId) throws DeviceManagementDAOException { + int limitValue = request.getRowCount(); + int offsetValue = request.getStartIndex(); + List status = request.getStatusList(); + String name = request.getDeviceName(); + String user = request.getOwner(); + String ownership = request.getOwnership(); + try { + List devices = new ArrayList<>(); + if (deviceIds.isEmpty()) { + return devices; + } + Connection conn = this.getConnection(); + int index = 1; + StringJoiner joiner = new StringJoiner(",", + "SELECT " + + "DM_DEVICE.ID AS DEVICE_ID, " + + "DM_DEVICE.NAME AS DEVICE_NAME, " + + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " + + "DM_DEVICE.LAST_UPDATED_TIMESTAMP, " + + "e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + + "e.ID AS ENROLMENT_ID, " + + "e.OWNER, " + + "e.OWNERSHIP, " + + "e.DATE_OF_ENROLMENT, " + + "e.DATE_OF_LAST_UPDATE, " + + "e.STATUS, " + + "e.IS_TRANSFERRED " + + "FROM DM_DEVICE_GROUP_MAP " + + "INNER JOIN DM_DEVICE ON " + + "DM_DEVICE_GROUP_MAP.DEVICE_ID = DM_DEVICE.ID " + + "INNER JOIN DM_GROUP ON " + + "DM_DEVICE_GROUP_MAP.GROUP_ID = DM_GROUP.ID " + + "INNER JOIN DM_ENROLMENT e ON " + + "DM_DEVICE.ID = e.DEVICE_ID AND " + + "DM_DEVICE.TENANT_ID = e.TENANT_ID " + + "WHERE DM_DEVICE.ID IN (", + ") AND DM_DEVICE.TENANT_ID = ?"); + + deviceIds.stream().map(ignored -> "?").forEach(joiner::add); + String query = joiner.toString(); + if (StringUtils.isNotBlank(groupName)) { + query += " AND DM_GROUP.GROUP_NAME = ?"; + } + if (StringUtils.isNotBlank(name)) { + query += " AND DM_DEVICE.NAME LIKE ?"; + } + if (StringUtils.isNotBlank(user)) { + query += " AND e.OWNER = ?"; + } + if (StringUtils.isNotBlank(ownership)) { + query += " AND e.OWNERSHIP = ?"; + } + if (status != null && !status.isEmpty()) { + query += buildStatusQuery(status); + } + + query += "LIMIT ? OFFSET ?"; + + try (PreparedStatement ps = conn.prepareStatement(query)) { + for (Integer deviceId : deviceIds) { + ps.setInt(index++, deviceId); + } + ps.setInt(index++, tenantId); + if (StringUtils.isNotBlank(groupName)) { + ps.setString(index++, groupName); + } + if (StringUtils.isNotBlank(name)) { + ps.setString(index++, name); + } + if (StringUtils.isNotBlank(user)) { + ps.setString(index++, user); + } + if (StringUtils.isNotBlank(ownership)) { + ps.setString(index++, ownership); + } + if (status != null && !status.isEmpty()) { + for (String deviceStatus : status) { + ps.setString(index++, deviceStatus); + } + } + ps.setInt(index++, limitValue); + ps.setInt(index, offsetValue); + + try (ResultSet rs = ps.executeQuery()) { + while (rs.next()) { + devices.add(DeviceManagementDAOUtil.loadDevice(rs)); + } + return devices; + } + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving information of all registered devices " + + "according to device ids and the limit area."; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } } + + /*** + * This method updates the status of a given list of devices to DELETED state in the DM_DEVICE_STATUS table + * @param conn Connection object + * @param validDevices list of devices + * @throws DeviceManagementDAOException if updating fails + */ + public void refactorDeviceStatus(Connection conn, List validDevices) throws DeviceManagementDAOException { + String updateQuery = "UPDATE DM_DEVICE_STATUS SET STATUS = ? WHERE ID = ?"; + String selectLastMatchingRecordQuery = "SELECT ID FROM DM_DEVICE_STATUS WHERE ENROLMENT_ID = ? " + + "AND DEVICE_ID = ? ORDER BY ID DESC LIMIT 1"; + + try (PreparedStatement selectStatement = conn.prepareStatement(selectLastMatchingRecordQuery); + PreparedStatement updateStatement = conn.prepareStatement(updateQuery)) { + + for (Device device : validDevices) { + + selectStatement.setInt(1, device.getEnrolmentInfo().getId()); + selectStatement.setInt(2, device.getId()); + + ResultSet resultSet = selectStatement.executeQuery(); + int lastRecordId = 0; + if (resultSet.next()) { + lastRecordId = resultSet.getInt("ID"); + } + + updateStatement.setString(1, String.valueOf(EnrolmentInfo.Status.DELETED)); + updateStatement.setInt(2, lastRecordId); + updateStatement.execute(); + } + + } catch (SQLException e) { + String msg = "SQL error occurred while updating device status properties."; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index 25b05520b6..3effd783c1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -18,1449 +18,55 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.device; -import org.apache.commons.lang.StringUtils; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.device.mgt.core.device.mgt.common.Count; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceBilling; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; -import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractDeviceDAOImpl; -import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; - import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Date; import java.util.List; -import java.util.StringJoiner; -import java.util.Map; /** * This class holds the generic implementation of DeviceDAO which can be used to support ANSI db syntax. */ -public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { +public class OracleDeviceDAOImpl extends SQLServerDeviceDAOImpl { private static final Log log = LogFactory.getLog(OracleDeviceDAOImpl.class); @Override - public List getDevices(PaginationRequest request, int tenantId) - throws DeviceManagementDAOException { - Connection conn; - List devices = null; - String deviceType = request.getDeviceType(); - boolean isDeviceTypeProvided = false; - String deviceName = request.getDeviceName(); - boolean isDeviceNameProvided = false; - String owner = request.getOwner(); - boolean isOwnerProvided = false; - String ownerPattern = request.getOwnerPattern(); - boolean isOwnerPatternProvided = false; - String ownership = request.getOwnership(); - boolean isOwnershipProvided = false; - List statusList = request.getStatusList(); - boolean isStatusProvided = false; - Date since = request.getSince(); - boolean isSinceProvided = false; - String serial = request.getSerialNumber(); - boolean isSerialProvided = false; + public void refactorDeviceStatus(Connection conn, List validDevices) throws DeviceManagementDAOException { + String updateQuery = "UPDATE DM_DEVICE_STATUS SET STATUS = ? WHERE ID = ?"; + String selectLastMatchingRecordQuery = "SELECT ID FROM DM_DEVICE_STATUS " + + "WHERE ENROLMENT_ID = ? AND DEVICE_ID = ? ORDER BY ID DESC ROWNUMBER = 1"; - try { - conn = getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, " + - "d1.DESCRIPTION, " + - "d1.NAME AS DEVICE_NAME, " + - "d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, " + - "e.OWNER, " + - "e.OWNERSHIP, " + - "e.STATUS, " + - "e.IS_TRANSFERRED, " + - "e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + - "FROM DM_ENROLMENT e, " + - "(SELECT d.ID, " + - "d.DESCRIPTION, " + - "d.NAME, " + - "d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE "; + try (PreparedStatement selectStatement = conn.prepareStatement(selectLastMatchingRecordQuery); + PreparedStatement updateStatement = conn.prepareStatement(updateQuery)) { - //Filter by serial number or any Custom Property in DM_DEVICE_INFO - if (serial != null || !request.getCustomProperty().isEmpty()) { - sql = sql + - "FROM DM_DEVICE d " + - "INNER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID " + - "WHERE "; - if (serial != null) { - sql += "EXISTS (" + - "SELECT VALUE_FIELD " + - "FROM DM_DEVICE_INFO di " + - "WHERE di.DEVICE_ID = d.ID " + - "AND di.KEY_FIELD = 'serial' " + - "AND di.VALUE_FIELD LIKE ? ) "; - isSerialProvided = true; - } - if (!request.getCustomProperty().isEmpty()) { - if (serial != null) { - sql += "AND "; - } - boolean firstCondition = true; - for (Map.Entry entry : request.getCustomProperty().entrySet()) { - if (!firstCondition) { - sql += "AND "; - } - sql += "EXISTS (" + - "SELECT VALUE_FIELD " + - "FROM DM_DEVICE_INFO di " + - "WHERE di.DEVICE_ID = d.ID " + - "AND di.KEY_FIELD = '" + entry.getKey() + "' " + - "AND di.VALUE_FIELD LIKE ? ) "; - firstCondition = false; - } - } - sql += "AND d.TENANT_ID = ? "; - } else { - sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? "; - } - //Add query for last updated timestamp - if (since != null) { - sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; - isSinceProvided = true; - } - //Add the query for device-type - if (deviceType != null && !deviceType.isEmpty()) { - sql = sql + " AND t.NAME = ?"; - isDeviceTypeProvided = true; - } - //Add the query for device-name - if (deviceName != null && !deviceName.isEmpty()) { - sql = sql + " AND d.NAME LIKE ?"; - isDeviceNameProvided = true; - } - sql = sql + ") d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?"; - //Add the query for ownership - if (ownership != null && !ownership.isEmpty()) { - sql = sql + " AND e.OWNERSHIP = ?"; - isOwnershipProvided = true; - } - //Add the query for owner - if (owner != null && !owner.isEmpty()) { - sql = sql + " AND e.OWNER = ?"; - isOwnerProvided = true; - } else if (ownerPattern != null && !ownerPattern.isEmpty()) { - sql = sql + " AND e.OWNER LIKE ?"; - isOwnerPatternProvided = true; - } - if (statusList != null && !statusList.isEmpty()) { - sql += buildStatusQuery(statusList); - isStatusProvided = true; - } - sql = sql + " ORDER BY ENROLMENT_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + for (Device device : validDevices) { - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - int paramIdx = 1; - if (isSerialProvided) { - stmt.setString(paramIdx++, "%" + serial + "%"); - } - if (!request.getCustomProperty().isEmpty()) { - for (Map.Entry entry : request.getCustomProperty().entrySet()) { - stmt.setString(paramIdx++, "%" + entry.getValue() + "%"); - } - } - stmt.setInt(paramIdx++, tenantId); - if (isSinceProvided) { - stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); - } - if (isDeviceTypeProvided) { - stmt.setString(paramIdx++, deviceType); - } - if (isDeviceNameProvided) { - stmt.setString(paramIdx++, "%" + deviceName + "%"); - } - stmt.setInt(paramIdx++, tenantId); - if (isOwnershipProvided) { - stmt.setString(paramIdx++, ownership); - } - if (isOwnerProvided) { - stmt.setString(paramIdx++, owner); - } else if (isOwnerPatternProvided) { - stmt.setString(paramIdx++, ownerPattern + "%"); - } - if (isStatusProvided) { - for (String status : statusList) { - stmt.setString(paramIdx++, status); - } - } - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); + selectStatement.setInt(1, device.getEnrolmentInfo().getId()); + selectStatement.setInt(2, device.getId()); - try (ResultSet rs = stmt.executeQuery()) { - devices = new ArrayList<>(); - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - devices.add(device); - } - return devices; + ResultSet resultSet = selectStatement.executeQuery(); + int lastRecordId = 0; + if (resultSet.next()) { + lastRecordId = resultSet.getInt("ID"); } + + updateStatement.setString(1, String.valueOf(EnrolmentInfo.Status.DELETED)); + updateStatement.setInt(2, lastRecordId); + updateStatement.execute(); } + } catch (SQLException e) { - String msg = "Error occurred while retrieving information of all " + - "registered devices"; + String msg = "SQL error occurred while updating device status properties."; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } } - //Return only not removed id list - @Override - public List getDevicesIds(PaginationRequest request, int tenantId) - throws DeviceManagementDAOException { - Connection conn; - List devices = null; - String owner = request.getOwner(); - boolean isOwnerProvided = false; - String ownership = request.getOwnership(); - boolean isOwnershipProvided = false; - List statusList = request.getStatusList(); - boolean isStatusProvided = false; - - try { - conn = getConnection(); - String sql = "SELECT " + - "d1.ID AS DEVICE_ID, " + - "d1.DEVICE_IDENTIFICATION, " + - "e.STATUS, " + - "e.OWNER, " + - "e.IS_TRANSFERRED, " + - "e.ID AS ENROLMENT_ID " + - "FROM DM_ENROLMENT e, " + - "(SELECT d.ID, " + - "d.DEVICE_IDENTIFICATION " + - "FROM DM_DEVICE d WHERE d.TENANT_ID = ?) d1 " + - "WHERE d1.ID = e.DEVICE_ID AND e.TENANT_ID = ? "; - //Add the query for ownership - if (ownership != null && !ownership.isEmpty()) { - sql = sql + " AND e.OWNERSHIP = ?"; - isOwnershipProvided = true; - } - //Add the query for owner - if (owner != null && !owner.isEmpty()) { - sql = sql + " AND e.OWNER = ?"; - isOwnerProvided = true; - } - if (statusList != null && !statusList.isEmpty()) { - sql += buildStatusQuery(statusList); - isStatusProvided = true; - } - - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - int paramIdx = 1; - stmt.setInt(paramIdx++, tenantId); - stmt.setInt(paramIdx++, tenantId); - if (isOwnershipProvided) { - stmt.setString(paramIdx++, ownership); - } - if (isOwnerProvided) { - stmt.setString(paramIdx++, owner); - } - if (isStatusProvided) { - for (String status : statusList) { - stmt.setString(paramIdx++, status); - } - } - - try (ResultSet rs = stmt.executeQuery()) { - devices = new ArrayList<>(); - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDeviceIds(rs); - devices.add(device); - } - return devices; - } - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving information of all " + - "registered devices"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - -// TODO - add Oracle support for below billing method - @Override - public List getNonRemovedYearlyDeviceList(int tenantId, Timestamp startDate, Timestamp endDate) - throws DeviceManagementDAOException { - return null; - } - - // TODO - add Oracle support for below billing method - @Override - public List getRemovedYearlyDeviceList(int tenantId, Timestamp startDate, Timestamp endDate) - throws DeviceManagementDAOException { - return null; - } - - // TODO - add Oracle support for below billing method - @Override - public List getNonRemovedPriorYearsDeviceList(int tenantId, Timestamp startDate, Timestamp endDate) - throws DeviceManagementDAOException { - return null; - } - - // TODO - add Oracle support for below billing method - @Override - public List getRemovedPriorYearsDeviceList(int tenantId, Timestamp startDate, Timestamp endDate) - throws DeviceManagementDAOException { - return null; - } - - @Override - public List getDeviceListWithoutPagination(int tenantId) throws DeviceManagementDAOException { - return null; - } - - @Override - public List getAllocatedDevices(PaginationRequest request, int tenantId, - int activeServerCount, int serverIndex) - throws DeviceManagementDAOException { - Connection conn; - List devices = null; - String deviceType = request.getDeviceType(); - boolean isDeviceTypeProvided = false; - String deviceName = request.getDeviceName(); - boolean isDeviceNameProvided = false; - String owner = request.getOwner(); - boolean isOwnerProvided = false; - String ownerPattern = request.getOwnerPattern(); - boolean isOwnerPatternProvided = false; - String ownership = request.getOwnership(); - boolean isOwnershipProvided = false; - List statusList = request.getStatusList(); - boolean isStatusProvided = false; - Date since = request.getSince(); - boolean isSinceProvided = false; - boolean isPartitionedTask = false; - - try { - conn = getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, " + - "d1.DESCRIPTION, " + - "d1.NAME AS DEVICE_NAME, " + - "d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, " + - "e.OWNER, " + - "e.OWNERSHIP, " + - "e.STATUS, " + - "e.IS_TRANSFERRED, " + - "e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + - "FROM DM_ENROLMENT e, " + - "(SELECT d.ID, " + - "d.DESCRIPTION, " + - "d.NAME, " + - "d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE " + - "FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t "; - //Add the query to filter active devices on timestamp - if (since != null) { - sql = sql + ", DM_DEVICE_DETAIL dt"; - isSinceProvided = true; - } - sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; - //Add query for last updated timestamp - if (isSinceProvided) { - sql = sql + " AND dt.DEVICE_ID = d.ID AND dt.UPDATE_TIMESTAMP > ?"; - } - //Add the query for device-type - if (deviceType != null && !deviceType.isEmpty()) { - sql = sql + " AND t.NAME = ?"; - isDeviceTypeProvided = true; - } - //Add the query for device-name - if (deviceName != null && !deviceName.isEmpty()) { - sql = sql + " AND d.NAME LIKE ?"; - isDeviceNameProvided = true; - } - sql = sql + ") d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?"; - //Add the query for ownership - if (ownership != null && !ownership.isEmpty()) { - sql = sql + " AND e.OWNERSHIP = ?"; - isOwnershipProvided = true; - } - //Add the query for owner - if (owner != null && !owner.isEmpty()) { - sql = sql + " AND e.OWNER = ?"; - isOwnerProvided = true; - } else if (ownerPattern != null && !ownerPattern.isEmpty()) { - sql = sql + " AND e.OWNER LIKE ?"; - isOwnerPatternProvided = true; - } - if (statusList != null && !statusList.isEmpty()) { - sql += buildStatusQuery(statusList); - isStatusProvided = true; - } - if (activeServerCount > 0){ - sql = sql + " AND MOD(d1.ID, ?) = ?"; - isPartitionedTask = true; - } - sql = sql + " ORDER BY ENROLMENT_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - int paramIdx = 1; - stmt.setInt(paramIdx++, tenantId); - if (isSinceProvided) { - stmt.setLong(paramIdx++, since.getTime()); - } - if (isDeviceTypeProvided) { - stmt.setString(paramIdx++, deviceType); - } - if (isDeviceNameProvided) { - stmt.setString(paramIdx++, deviceName + "%"); - } - stmt.setInt(paramIdx++, tenantId); - if (isOwnershipProvided) { - stmt.setString(paramIdx++, ownership); - } - if (isOwnerProvided) { - stmt.setString(paramIdx++, owner); - } else if (isOwnerPatternProvided) { - stmt.setString(paramIdx++, ownerPattern + "%"); - } - if (isStatusProvided) { - for (String status : statusList) { - stmt.setString(paramIdx++, status); - } - } - if (isPartitionedTask) { - stmt.setInt(paramIdx++, activeServerCount); - stmt.setInt(paramIdx++, serverIndex); - } - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); - - try (ResultSet rs = stmt.executeQuery()) { - devices = new ArrayList<>(); - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - devices.add(device); - } - return devices; - } - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving information of all " + - "registered devices"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public List searchDevicesInGroup(PaginationRequest request, int tenantId) - throws DeviceManagementDAOException { - Connection conn; - List devices = null; - int groupId = request.getGroupId(); - String deviceType = request.getDeviceType(); - boolean isDeviceTypeProvided = false; - String deviceName = request.getDeviceName(); - boolean isDeviceNameProvided = false; - String owner = request.getOwner(); - boolean isOwnerProvided = false; - String ownerPattern = request.getOwnerPattern(); - boolean isOwnerPatternProvided = false; - String ownership = request.getOwnership(); - boolean isOwnershipProvided = false; - List statusList = request.getStatusList(); - boolean isStatusProvided = false; - Date since = request.getSince(); - boolean isSinceProvided = false; - String serial = request.getSerialNumber(); - boolean isSerialProvided = false; - - try { - conn = getConnection(); - String sql = "SELECT d1.DEVICE_ID, " + - "d1.DESCRIPTION, " + - "d1.NAME AS DEVICE_NAME, " + - "d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, " + - "e.OWNER, " + - "e.OWNERSHIP, " + - "e.STATUS, " + - "e.IS_TRANSFERRED, " + - "e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + - "FROM DM_ENROLMENT e, " + - "(SELECT gd.DEVICE_ID, " + - "gd.DESCRIPTION, " + - "gd.NAME, " + - "gd.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE " + - "FROM " + - "(SELECT d.ID AS DEVICE_ID, " + - "d.DESCRIPTION, " + - "d.NAME, " + - "d.DEVICE_IDENTIFICATION, " + - "d.DEVICE_TYPE_ID " + - "FROM DM_DEVICE d, " + - "(SELECT dgm.DEVICE_ID " + - "FROM DM_DEVICE_GROUP_MAP dgm " + - "WHERE dgm.GROUP_ID = ?) dgm1 " + - "WHERE " + - "d.ID = dgm1.DEVICE_ID " + - "AND d.TENANT_ID = ?"; - //Add the query for device-name - if (deviceName != null && !deviceName.isEmpty()) { - sql = sql + " AND d.NAME LIKE ?"; - isDeviceNameProvided = true; - } - sql = sql + ") gd, DM_DEVICE_TYPE t WHERE gd.DEVICE_TYPE_ID = t.ID"; - //Add query for last updated timestamp - if (since != null) { - sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; - isSinceProvided = true; - } - //Add the query for device-type - if (deviceType != null && !deviceType.isEmpty()) { - sql = sql + " AND t.NAME = ?"; - isDeviceTypeProvided = true; - } - sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? "; - //Add the query for ownership - if (ownership != null && !ownership.isEmpty()) { - sql = sql + " AND e.OWNERSHIP = ?"; - isOwnershipProvided = true; - } - //Add the query for owner - if (owner != null && !owner.isEmpty()) { - sql = sql + " AND e.OWNER = ?"; - isOwnerProvided = true; - } else if (ownerPattern != null && !ownerPattern.isEmpty()) { - sql = sql + " AND e.OWNER LIKE ?"; - isOwnerPatternProvided = true; - } - if (statusList != null && !statusList.isEmpty()) { - sql += buildStatusQuery(statusList); - isStatusProvided = true; - } - //Filter Group with serial number or any Custom Property in DM_DEVICE_INFO - if (serial != null || !request.getCustomProperty().isEmpty()) { - if (serial != null) { - sql += "AND EXISTS (" + - "SELECT VALUE_FIELD " + - "FROM DM_DEVICE_INFO di " + - "WHERE di.DEVICE_ID = d1.DEVICE_ID " + - "AND di.KEY_FIELD = 'serial' " + - "AND di.VALUE_FIELD LIKE ?) "; - isSerialProvided = true; - } - if (!request.getCustomProperty().isEmpty()) { - for (Map.Entry entry : request.getCustomProperty().entrySet()) { - sql += "AND EXISTS (" + - "SELECT VALUE_FIELD " + - "FROM DM_DEVICE_INFO di2 " + - "WHERE di2.DEVICE_ID = d1.DEVICE_ID " + - "AND di2.KEY_FIELD = '" + entry.getKey() + "' " + - "AND di2.VALUE_FIELD LIKE ?)"; - } - } - } - sql = sql + " ORDER BY ENROLMENT_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - int paramIdx = 1; - stmt.setInt(paramIdx++, groupId); - stmt.setInt(paramIdx++, tenantId); - if (isDeviceNameProvided) { - stmt.setString(paramIdx++, "%" + deviceName + "%"); - } - if (isSinceProvided) { - stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); - } - if (isDeviceTypeProvided) { - stmt.setString(paramIdx++, deviceType); - } - stmt.setInt(paramIdx++, tenantId); - if (isOwnershipProvided) { - stmt.setString(paramIdx++, ownership); - } - if (isOwnerProvided) { - stmt.setString(paramIdx++, owner); - } else if (isOwnerPatternProvided) { - stmt.setString(paramIdx++, ownerPattern + "%"); - } - if (isStatusProvided) { - for (String status : statusList) { - stmt.setString(paramIdx++, status); - } - } - if (isSerialProvided) { - stmt.setString(paramIdx++, "%" + serial + "%"); - } - if (!request.getCustomProperty().isEmpty()) { - for (Map.Entry entry : request.getCustomProperty().entrySet()) { - stmt.setString(paramIdx++, "%" + entry.getValue() + "%"); - } - } - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); - - try (ResultSet rs = stmt.executeQuery()) { - devices = new ArrayList<>(); - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - devices.add(device); - } - return devices; - } - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving information of" + - " devices belonging to group : " + groupId; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public List getDevicesOfUser(PaginationRequest request, int tenantId) - throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - List devices = new ArrayList<>(); - try { - conn = this.getConnection(); - String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.IS_TRANSFERRED, e1.DATE_OF_LAST_UPDATE," - + " e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.DEVICE_IDENTIFICATION, t.NAME " - + "AS DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, " - + "e.DEVICE_ID, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " - + "e.TENANT_ID = ? AND e.OWNER = ?) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " - + "AND t.ID = d.DEVICE_TYPE_ID ORDER BY ENROLMENT_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, tenantId); - stmt.setString(2, request.getOwner()); - stmt.setInt(3, request.getStartIndex()); - stmt.setInt(4, request.getRowCount()); - ResultSet rs = stmt.executeQuery(); - - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - devices.add(device); - } - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices belongs to '" + - request.getOwner() + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return devices; - } - - @Override - public List getDevicesByName(PaginationRequest request, int tenantId) - throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - List devices = new ArrayList<>(); - try { - conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " - + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " - + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " - + "d.DESCRIPTION, t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, " - + "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.NAME LIKE ? AND d.TENANT_ID = ?) d1 " - + "WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY ENROLMENT_ID " + - "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - stmt = conn.prepareStatement(sql); - stmt.setString(1, request.getDeviceName() + "%"); - stmt.setInt(2, tenantId); - stmt.setInt(3, tenantId); - stmt.setInt(4, request.getStartIndex()); - stmt.setInt(5, request.getRowCount()); - ResultSet rs = stmt.executeQuery(); - - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - devices.add(device); - } - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches " + - "'" + request.getDeviceName() + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return devices; - } - - @Override - public List getDevicesByOwnership(PaginationRequest request, int tenantId) - throws DeviceManagementDAOException { - Connection conn; - PreparedStatement stmt = null; - List devices = new ArrayList<>(); - try { - conn = this.getConnection(); - String sql = "SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, t.NAME AS DEVICE_TYPE, " - + "d.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " - + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM (SELECT e.ID, e.DEVICE_ID, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " - + "e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e " - + "WHERE TENANT_ID = ? AND OWNERSHIP = ?) e, DM_DEVICE d, DM_DEVICE_TYPE t " - + "WHERE DEVICE_ID = e.DEVICE_ID AND d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? ORDER BY ENROLMENT_ID " - + "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, tenantId); - stmt.setString(2, request.getOwnership()); - stmt.setInt(3, tenantId); - stmt.setInt(4, request.getStartIndex()); - stmt.setInt(5, request.getRowCount()); - ResultSet rs = stmt.executeQuery(); - - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - devices.add(device); - } - } catch (SQLException e) { - throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches to ownership " + - "'" + request.getOwnership() + "'", e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, null); - } - return devices; - } - - @Override - public List getDevicesByStatus(PaginationRequest request, int tenantId) - throws DeviceManagementDAOException { - Connection conn; - List devices = new ArrayList<>(); - List statusList = request.getStatusList(); - - try { - conn = getConnection(); - String sql = "SELECT d.ID AS DEVICE_ID, " + - "d.DESCRIPTION, " + - "d.NAME AS DEVICE_NAME, " + - "t.NAME AS DEVICE_TYPE, " + - "d.DEVICE_IDENTIFICATION, " + - "e.OWNER, " + - "e.OWNERSHIP, " + - "e.STATUS, " + - "e.IS_TRANSFERRED, " + - "e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + - "FROM (SELECT e.ID, " + - "e.DEVICE_ID, " + - "e.OWNER, " + - "e.OWNERSHIP, " + - "e.STATUS, " + - "e.IS_TRANSFERRED, " + - "e.DATE_OF_ENROLMENT, " + - "e.DATE_OF_LAST_UPDATE, " + - "e.ID AS ENROLMENT_ID " + - "FROM DM_ENROLMENT e " + - "WHERE TENANT_ID = ?"; - - if (statusList == null || statusList.isEmpty()) { - String msg = "Error occurred while fetching the list of devices. Status List can't " + - "be null or empty"; - log.error(msg); - throw new DeviceManagementDAOException(msg); - } - sql += buildStatusQuery(statusList); - sql += ") e," + - "DM_DEVICE d," + - "DM_DEVICE_TYPE t" + - "WHERE DEVICE_ID = e.DEVICE_ID" + - "AND d.DEVICE_TYPE_ID = t.ID" + - "AND d.TENANT_ID = ?" + - "LIMIT ?,?"; - - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - int paramIdx = 1; - stmt.setInt(paramIdx++, tenantId); - for (String status : statusList) { - stmt.setString(paramIdx++, status); - } - stmt.setInt(paramIdx++, tenantId); - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); - try (ResultSet rs = stmt.executeQuery()) { - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - devices.add(device); - } - return devices; - } - } - } catch (SQLException e) { - String msg = "Error occurred while fetching the list of devices that matches to status " + - request.getStatusList().toString(); - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public List getDevicesByDuration(PaginationRequest request, int tenantId, - String fromDate, String toDate) - throws DeviceManagementDAOException { - List devices; - List statusList = request.getStatusList(); - boolean isStatusProvided = false; - String ownership = request.getOwnership(); - - String sql = "SELECT " + - "d.ID AS DEVICE_ID, " + - "d.DESCRIPTION,d.NAME AS DEVICE_NAME, " + - "t.NAME AS DEVICE_TYPE, " + - "d.DEVICE_IDENTIFICATION, " + - "e.OWNER, " + - "e.OWNERSHIP, " + - "e.STATUS, " + - "e.IS_TRANSFERRED, " + - "e.DATE_OF_LAST_UPDATE," + - "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + - "FROM DM_DEVICE AS d , DM_ENROLMENT AS e , DM_DEVICE_TYPE AS t " + - "WHERE d.ID = e.DEVICE_ID AND " + - "d.DEVICE_TYPE_ID = t.ID AND " + - "e.TENANT_ID = ? AND " + - "e.DATE_OF_ENROLMENT BETWEEN ? AND ?"; - if (statusList != null && !statusList.isEmpty()) { - sql += buildStatusQuery(statusList); - isStatusProvided = true; - } - if (ownership != null) { - sql = sql + " AND e.OWNERSHIP = ?"; - } - sql = sql + " ORDER BY ENROLMENT_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - - try (Connection conn = this.getConnection(); - PreparedStatement stmt = conn.prepareStatement(sql)) { - int paramIdx = 1; - stmt.setInt(paramIdx++, tenantId); - stmt.setString(paramIdx++, fromDate); - stmt.setString(paramIdx++, toDate); - if (isStatusProvided) { - for (String status : statusList) { - stmt.setString(paramIdx++, status); - } - } - if (ownership != null) { - stmt.setString(paramIdx++, ownership); - } - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); - - try (ResultSet rs = stmt.executeQuery()) { - devices = new ArrayList<>(); - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - devices.add(device); - } - return devices; - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving information of all " + - "registered devices under tenant id " + tenantId; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public int getDevicesByDurationCount(List statusList, String ownership, String fromDate, String toDate, int tenantId) throws DeviceManagementDAOException { - return 0; - } - - @Override - public List getCountOfDevicesByDuration(PaginationRequest request, List statusList, int tenantId, - String fromDate, String toDate) - throws DeviceManagementDAOException { - List countList = new ArrayList<>(); - String ownership = request.getOwnership(); - boolean isStatusProvided; - - String sql = - "SELECT " + - "SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) AS ENROLMENT_DATE, " + - "COUNT(SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10)) AS ENROLMENT_COUNT " + - "FROM DM_DEVICE AS d " + - "INNER JOIN DM_ENROLMENT AS e ON d.ID = e.DEVICE_ID " + - "INNER JOIN DM_DEVICE_TYPE AS t ON d.DEVICE_TYPE_ID = t.ID " + - "AND e.TENANT_ID = ? " + - "AND e.DATE_OF_ENROLMENT BETWEEN ? AND ? "; - - //Add the query for status - StringBuilder sqlBuilder = new StringBuilder(sql); - isStatusProvided = buildStatusQuery(statusList, sqlBuilder); - sql = sqlBuilder.toString(); - - if (ownership != null) { - sql = sql + " AND e.OWNERSHIP = ?"; - } - - sql = sql + " GROUP BY SUBSTRING(e.DATE_OF_ENROLMENT, 1, 10) OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - - try { - Connection conn = this.getConnection(); - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - int paramIdx = 1; - stmt.setInt(paramIdx++, tenantId); - stmt.setString(paramIdx++, fromDate); - stmt.setString(paramIdx++, toDate); - if (isStatusProvided) { - for (String status : statusList) { - stmt.setString(paramIdx++, status); - } - } - if (ownership != null) { - stmt.setString(paramIdx++, ownership); - } - stmt.setInt(paramIdx++, request.getStartIndex()); - stmt.setInt(paramIdx, request.getRowCount()); - try (ResultSet rs = stmt.executeQuery()) { - while (rs.next()) { - Count count = new Count( - rs.getString("ENROLMENT_DATE"), - rs.getInt("ENROLMENT_COUNT") - ); - countList.add(count); - } - } - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving information of all " + - "registered devices under tenant id " + tenantId + " between " + fromDate + " to " + toDate; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - return countList; - } - - protected boolean buildStatusQuery(List statusList, StringBuilder sqlBuilder) { - if (statusList != null && !statusList.isEmpty() && !statusList.get(0).isEmpty()) { - sqlBuilder.append(" AND e.STATUS IN("); - for (int i = 0; i < statusList.size(); i++) { - sqlBuilder.append("?"); - if (i != statusList.size() - 1) { - sqlBuilder.append(","); - } - } - sqlBuilder.append(")"); - return true; - } else { - return false; - } - } - - /** - * Get the list of devices that matches with the given device name and (or) device type. - * - * @param deviceName Name of the device. - * @param tenantId Id of the current tenant - * @return device list - * @throws DeviceManagementDAOException - */ - @Override - public List getDevicesByNameAndType(String deviceName, String type, int tenantId, int offset, int limit) - throws DeviceManagementDAOException { - - String filteringString = ""; - if (deviceName != null && !deviceName.isEmpty()) { - filteringString = filteringString + " AND d.NAME LIKE ?"; - } - - if (type != null && !type.isEmpty()) { - filteringString = filteringString + " AND t.NAME = ?"; - } - - Connection conn; - PreparedStatement stmt = null; - List devices = new ArrayList<>(); - ResultSet rs = null; - try { - conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.NAME, " + - "d.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?" + filteringString + - ") d1 WHERE d1.ID = e.DEVICE_ID ORDER BY ENROLMENT_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - stmt = conn.prepareStatement(sql); - stmt.setInt(1, tenantId); - - int i = 1; - - if (deviceName != null && !deviceName.isEmpty()) { - stmt.setString(++i, deviceName + "%"); - } - - if (type != null && !type.isEmpty()) { - stmt.setString(++i, type); - } - - stmt.setInt(++i, offset); - stmt.setInt(++i, limit); - - rs = stmt.executeQuery(); - - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - devices.add(device); - } - } catch (SQLException e) { - String msg = "Error occurred while fetching the list of devices corresponding" + - "to the mentioned filtering criteria"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(stmt, rs); - } - return devices; - } - - @Override - public List getSubscribedDevices(PaginationRequest request, List deviceIds, int tenantId) - throws DeviceManagementDAOException { - Connection conn; - int limitValue = request.getRowCount(); - int offsetValue = request.getStartIndex(); - List status = request.getStatusList(); - String name = request.getDeviceName(); - String user = request.getOwner(); - String ownership = request.getOwnership(); - try { - List devices = new ArrayList<>(); - if (deviceIds.isEmpty()) { - return devices; - } - conn = this.getConnection(); - int index = 1; - - boolean isStatusProvided = false; - boolean isDeviceNameProvided = false; - boolean isOwnerProvided = false; - boolean isOwnershipProvided = false; - StringJoiner joiner = new StringJoiner(",", - "SELECT " - + "DM_DEVICE.ID AS DEVICE_ID, " - + "DM_DEVICE.NAME AS DEVICE_NAME, " - + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " - + "DM_DEVICE.DEVICE_TYPE_ID, " - + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " - + "e.ID AS ENROLMENT_ID, " - + "e.OWNER, " - + "e.OWNERSHIP, " - + "e.DATE_OF_ENROLMENT, " - + "e.DATE_OF_LAST_UPDATE, " - + "e.STATUS, " - + "e.IS_TRANSFERRED, " - + "device_types.NAME AS DEVICE_TYPE " - + "FROM DM_DEVICE " - + "INNER JOIN DM_ENROLMENT e ON " - + "DM_DEVICE.ID = e.DEVICE_ID AND " - + "DM_DEVICE.TENANT_ID = e.TENANT_ID " - + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " - + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " - + "WHERE DM_DEVICE.ID IN (", - ") AND DM_DEVICE.TENANT_ID AND e.STATUS NOT IN (?, ?)"); - - deviceIds.stream().map(ignored -> "?").forEach(joiner::add); - String query = joiner.toString(); - - if (name != null && !name.isEmpty()) { - query += " AND DM_DEVICE.NAME LIKE ?"; - isDeviceNameProvided = true; - } - if (ownership != null && !ownership.isEmpty()) { - query += " AND e.OWNERSHIP = ?"; - isOwnershipProvided = true; - } - if (user != null && !user.isEmpty()) { - query += " AND e.OWNER = ?"; - isOwnerProvided = true; - } - if (status != null && !status.isEmpty()) { - query += buildStatusQuery(status); - isStatusProvided = true; - } - // Loop through custom properties and add conditions - if (!request.getCustomProperty().isEmpty()) { - for (Map.Entry entry : request.getCustomProperty().entrySet()) { - query += " AND EXISTS (" + - "SELECT VALUE_FIELD " + - "FROM DM_DEVICE_INFO di2 " + - "WHERE di2.DEVICE_ID = DM_DEVICE.ID " + - "AND di2.KEY_FIELD = '" + entry.getKey() + "' " + - "AND di2.VALUE_FIELD LIKE ?)"; - } - } - - query = query + " ORDER BY DM_DEVICE.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - - try (PreparedStatement ps = conn.prepareStatement(query)) { - - for (Integer deviceId : deviceIds) { - ps.setObject(index++, deviceId); - } - - ps.setInt(index++, tenantId); - ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); - ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); - if (isDeviceNameProvided) { - ps.setString(index++, name + "%"); - } - if (isOwnershipProvided) { - ps.setString(index++, ownership); - } - if (isOwnerProvided) { - ps.setString(index++, user); - } - if (isStatusProvided) { - for (String deviceStatus : status) { - ps.setString(index++, deviceStatus); - } - } - // Set custom property values in the loop - if (!request.getCustomProperty().isEmpty()) { - for (Map.Entry entry : request.getCustomProperty().entrySet()) { - ps.setString(index++, "%" + entry.getValue() + "%"); - } - } - ps.setInt(index++, offsetValue); - ps.setInt(index, limitValue); - - try (ResultSet rs = ps.executeQuery()) { - while (rs.next()) { - devices.add(DeviceManagementDAOUtil.loadDevice(rs)); - } - return devices; - } - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving information of all registered devices " + - "according to device ids and the limit area."; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public int getSubscribedDeviceCount(List deviceIds, int tenantId, List status) - throws DeviceManagementDAOException { - try { - if (deviceIds.isEmpty()) { - return 0; - } - Connection conn = this.getConnection(); - int index = 1; - StringJoiner joiner = new StringJoiner(",", - "SELECT " + - "COUNT(e.DEVICE_ID) AS DEVICE_ID " + - "FROM DM_ENROLMENT AS e, DM_DEVICE AS f " + - "WHERE " + - "e.DEVICE_ID=f.ID AND " + - "e.DEVICE_ID IN (", ") AND e.TENANT_ID = ?"); - - deviceIds.stream().map(ignored -> "?").forEach(joiner::add); - String query = joiner.toString(); - - if (status != null && !status.isEmpty()) { - query += buildStatusQuery(status); - } - - try (PreparedStatement ps = conn.prepareStatement(query)) { - for (Integer deviceId : deviceIds) { - ps.setObject(index++, deviceId); - } - - ps.setInt(index++, tenantId); - if (status != null && !status.isEmpty()) { - for (String deviceStatus : status) { - ps.setString(index++, deviceStatus); - } - } - - try (ResultSet rs = ps.executeQuery()) { - if (rs.next()) { - return rs.getInt("DEVICE_ID"); - } - return 0; - } - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving information of all registered devices " + - "according to device ids and the limit area."; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public List getDevicesExpiredByOSVersion(PaginationRequest request, int tenantId) - throws DeviceManagementDAOException { - try { - Long osValue = (Long) request.getProperty(Constants.OS_VALUE); - Connection conn = getConnection(); - String sql = "SELECT " + - "d1.DEVICE_TYPE, " + - "d1.DEVICE_ID, " + - "d1.DEVICE_NAME, " + - "d1.DESCRIPTION, " + - "d1.DEVICE_IDENTIFICATION, " + - "ddd.OS_VERSION, " + - "e.ID AS ENROLMENT_ID, " + - "e.OWNER, " + - "e.OWNERSHIP, " + - "e.STATUS, " + - "e.IS_TRANSFERRED, " + - "e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT " + - "FROM DM_DEVICE_INFO ddi, " + - "DM_DEVICE_DETAIL ddd, " + - "DM_ENROLMENT e, " + - "(SELECT dt.NAME AS DEVICE_TYPE, " + - "d.ID AS DEVICE_ID, " + - "d.NAME AS DEVICE_NAME, " + - "DESCRIPTION, " + - "DEVICE_IDENTIFICATION " + - " FROM DM_DEVICE_TYPE dt, " + - "DM_DEVICE d " + - "WHERE dt.NAME = ? " + - "AND PROVIDER_TENANT_ID = ? " + - "AND dt.ID = d.DEVICE_TYPE_ID " + - ") d1 " + - "WHERE d1.DEVICE_ID = e.DEVICE_ID " + - "AND d1.DEVICE_ID = ddi.DEVICE_ID " + - "AND d1.DEVICE_ID = ddd.DEVICE_ID " + - "AND ddi.KEY_FIELD = ? " + - "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ? " + - "ORDER BY ENROLMENT_ID " + - "OFFSET ? ROWS " + - "FETCH NEXT ? ROWS ONLY"; - - try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setString(1, request.getDeviceType()); - ps.setInt(2, tenantId); - ps.setString(3, Constants.OS_VALUE); - ps.setLong(4, osValue); - ps.setInt(5, request.getStartIndex()); - ps.setInt(6, request.getRowCount()); - - try (ResultSet rs = ps.executeQuery()) { - List devices = new ArrayList<>(); - while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - DeviceInfo deviceInfo = new DeviceInfo(); - deviceInfo.setOsVersion(rs.getString("OS_VERSION")); - device.setDeviceInfo(deviceInfo); - devices.add(device); - } - return devices; - } - } - } catch (SQLException e) { - String msg = "Error occurred while building or executing queries to retrieve information " + - "of devices with an older OS build date"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public int getCountOfDeviceExpiredByOSVersion(String deviceType, Long osValue, int tenantId) - throws DeviceManagementDAOException { - try { - Connection conn = getConnection(); - String sql = "SELECT " + - "COUNT(ddi.DEVICE_ID) AS DEVICE_COUNT " + - "FROM DM_DEVICE_INFO ddi, " + - "(SELECT d.ID AS DEVICE_ID " + - "FROM DM_DEVICE_TYPE dt, " + - "DM_DEVICE d " + - "WHERE dt.NAME = ? " + - "AND PROVIDER_TENANT_ID = ? " + - "AND dt.ID = d.DEVICE_TYPE_ID " + - ") d1 " + - "WHERE d1.DEVICE_ID = ddi.DEVICE_ID " + - "AND ddi.KEY_FIELD = ? " + - "AND CAST( ddi.VALUE_FIELD AS BIGINT ) < ?"; - - try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setString(1, deviceType); - ps.setInt(2, tenantId); - ps.setString(3, Constants.OS_VALUE); - ps.setLong(4, osValue); - - try (ResultSet rs = ps.executeQuery()) { - if (rs.next()) { - return rs.getInt("DEVICE_COUNT"); - } - return 0; - } - } - } catch (SQLException e) { - String msg = "Error occurred while building or executing queries to retrieve the count " + - "of devices with an older OS build date"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public List getDevicesByEncryptionStatus(PaginationRequest request, int tenantId, boolean isEncrypted) - throws DeviceManagementDAOException { - try { - Connection conn = getConnection(); - String sql = "" + - "SELECT e1.owner, " + - "e1.ownership, " + - "e1.enrolment_id, " + - "e1.device_id, " + - "e1.status, " + - "e1.date_of_last_update, " + - "e1.date_of_enrolment, " + - "d.description, " + - "d.NAME AS DEVICE_NAME, " + - "d.device_identification, " + - "t.NAME AS DEVICE_TYPE " + - "FROM dm_device d, " + - "(SELECT e.owner, " + - "e.ownership, " + - "e.id AS ENROLMENT_ID, " + - "e.device_id, " + - "e.status, " + - "e.date_of_last_update, " + - "e.date_of_enrolment " + - "FROM dm_enrolment e " + - "INNER JOIN " + - "(SELECT DEVICE_ID " + - "FROM DM_DEVICE_INFO " + - "WHERE " + - "KEY_FIELD = 'encryptionEnabled' " + - "AND VALUE_FIELD = ?) AS di " + - "ON di.DEVICE_ID = e.DEVICE_ID " + - "WHERE e.tenant_id = ?) e1, " + - "dm_device_type t " + - "WHERE d.id = e1.device_id " + - "AND t.id = d.device_type_id " + - "ORDER BY e1.date_of_last_update DESC " + - "OFFSET ? ROWS " + - "FETCH NEXT ? ROWS ONLY"; - - try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setBoolean(1, isEncrypted); - ps.setInt(2, tenantId); - ps.setInt(3, request.getStartIndex()); - ps.setInt(4, request.getRowCount()); - - try (ResultSet rs = ps.executeQuery()) { - List devices = new ArrayList<>(); - if (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); - devices.add(device); - } - return devices; - } - } - } catch (SQLException e) { - String msg = "Error occurred while building or executing queries to retrieve information " + - "of devices filtered by encryption status: " + isEncrypted; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public List getGroupedDevicesDetails(PaginationRequest request, List deviceIds, String groupName, - int tenantId) throws DeviceManagementDAOException { - int limitValue = request.getRowCount(); - int offsetValue = request.getStartIndex(); - try { - List devices = new ArrayList<>(); - if (deviceIds.isEmpty()) { - return devices; - } - Connection conn = this.getConnection(); - int index = 1; - StringJoiner joiner = new StringJoiner(",", - "SELECT " - + "DM_DEVICE.ID AS DEVICE_ID, " - + "DM_DEVICE.NAME AS DEVICE_NAME, " - + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " - + "DM_DEVICE.DEVICE_TYPE_ID, " - + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " - + "e.ID AS ENROLMENT_ID, " - + "e.OWNER, " - + "e.OWNERSHIP, " - + "e.DATE_OF_ENROLMENT, " - + "e.DATE_OF_LAST_UPDATE, " - + "e.STATUS, " - + "e.IS_TRANSFERRED, " - + "device_types.NAME AS DEVICE_TYPE " - + "FROM DM_DEVICE_GROUP_MAP " - + "INNER JOIN DM_DEVICE ON " - + "DM_DEVICE_GROUP_MAP.DEVICE_ID = DM_DEVICE.ID " - + "INNER JOIN DM_GROUP ON " - + "DM_DEVICE_GROUP_MAP.GROUP_ID = DM_GROUP.ID " - + "INNER JOIN DM_ENROLMENT e ON " - + "DM_DEVICE.ID = e.DEVICE_ID AND " - + "DM_DEVICE.TENANT_ID = e.TENANT_ID " - + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " - + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " - + "WHERE DM_DEVICE.ID IN (", - ") AND DM_DEVICE.TENANT_ID = ?"); - - deviceIds.stream().map(ignored -> "?").forEach(joiner::add); - String query = joiner.toString(); - if (StringUtils.isNotBlank(groupName)) { - query += " AND DM_GROUP.GROUP_NAME = ?"; - } - query += " ORDER BY DEVICE_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - - try (PreparedStatement ps = conn.prepareStatement(query)) { - for (Integer deviceId : deviceIds) { - ps.setInt(index++, deviceId); - } - ps.setInt(index++, tenantId); - if (StringUtils.isNotBlank(groupName)) { - ps.setString(index++, groupName); - } - ps.setInt(index++, offsetValue); - ps.setInt(index, limitValue); - - try (ResultSet rs = ps.executeQuery()) { - while (rs.next()) { - devices.add(DeviceManagementDAOUtil.loadDevice(rs)); - } - return devices; - } - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving information of all registered devices " + - "according to device ids and the limit area."; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - private Connection getConnection() throws SQLException { - return DeviceManagementDAOFactory.getConnection(); - } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/GenericGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/GenericGroupDAOImpl.java index c3f620ae28..9108016e37 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/GenericGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/GenericGroupDAOImpl.java @@ -45,25 +45,26 @@ public class GenericGroupDAOImpl extends AbstractGroupDAOImpl { List devices = null; try { conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "d1.DEVICE_IDENTIFICATION, d1.LAST_UPDATED_TIMESTAMP, e.OWNER, e.OWNERSHIP, e.STATUS, " + + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + - "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " + + "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, gd.LAST_UPDATED_TIMESTAMP " + "FROM " + - "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.DEVICE_TYPE_ID FROM" + + "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP FROM" + " DM_DEVICE d, (" + "SELECT dgm.DEVICE_ID FROM DM_DEVICE_GROUP_MAP dgm WHERE dgm.GROUP_ID = ?) dgm1 " + - "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd, DM_DEVICE_TYPE t " + - "WHERE gd.DEVICE_TYPE_ID = t.ID) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? LIMIT ? , ?"; + "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd) d1 " + + "WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? LIMIT ? OFFSET ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, groupId); stmt.setInt(2, tenantId); stmt.setInt(3, tenantId); //noinspection JpaQueryApiInspection - stmt.setInt(4, startIndex); + stmt.setInt(4, rowCount); //noinspection JpaQueryApiInspection - stmt.setInt(5, rowCount); + stmt.setInt(5, startIndex); rs = stmt.executeQuery(); devices = new ArrayList<>(); while (rs.next()) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/OracleGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/OracleGroupDAOImpl.java index b5a927a30f..26547f417d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/OracleGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/OracleGroupDAOImpl.java @@ -192,16 +192,17 @@ public class OracleGroupDAOImpl extends AbstractGroupDAOImpl { List devices = null; try { conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "d1.DEVICE_IDENTIFICATION, d1.LAST_UPDATED_TIMESTAMP, e.OWNER, e.OWNERSHIP, e.STATUS, " + + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + - "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " + + "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, gd.LAST_UPDATED_TIMESTAMP " + "FROM " + - "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.DEVICE_TYPE_ID FROM" + + "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP FROM" + " DM_DEVICE d, (" + "SELECT dgm.DEVICE_ID FROM DM_DEVICE_GROUP_MAP dgm WHERE dgm.GROUP_ID = ?) dgm1 " + - "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd, DM_DEVICE_TYPE t " + - "WHERE gd.DEVICE_TYPE_ID = t.ID) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd) d1 " + + "WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; stmt = conn.prepareStatement(sql); stmt.setInt(1, groupId); @@ -219,7 +220,7 @@ public class OracleGroupDAOImpl extends AbstractGroupDAOImpl { } } catch (SQLException e) { throw new GroupManagementDAOException("Error occurred while retrieving information of all " + - "registered devices", e); + "registered devices", e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java index 67994b51a6..da0312c89c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/PostgreSQLGroupDAOImpl.java @@ -133,16 +133,17 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { List devices = null; try { conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "d1.DEVICE_IDENTIFICATION, d1.LAST_UPDATED_TIMESTAMP, e.OWNER, e.OWNERSHIP, e.STATUS, " + + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + - "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " + + "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, gd.LAST_UPDATED_TIMESTAMP " + "FROM " + - "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.DEVICE_TYPE_ID FROM" + + "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP FROM" + " DM_DEVICE d, (" + "SELECT dgm.DEVICE_ID FROM DM_DEVICE_GROUP_MAP dgm WHERE dgm.GROUP_ID = ?) dgm1 " + - "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd, DM_DEVICE_TYPE t " + - "WHERE gd.DEVICE_TYPE_ID = t.ID) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? LIMIT ? OFFSET ?"; + "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd) d1 " + + "WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? LIMIT ? OFFSET ?"; stmt = conn.prepareStatement(sql); stmt.setInt(1, groupId); @@ -160,7 +161,7 @@ public class PostgreSQLGroupDAOImpl extends AbstractGroupDAOImpl { } } catch (SQLException e) { throw new GroupManagementDAOException("Error occurred while retrieving information of all " + - "registered devices", e); + "registered devices", e); } finally { DeviceManagementDAOUtil.cleanupResources(stmt, rs); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/SQLServerGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/SQLServerGroupDAOImpl.java index 340e4a8745..37a0ebba80 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/SQLServerGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/group/SQLServerGroupDAOImpl.java @@ -192,16 +192,17 @@ public class SQLServerGroupDAOImpl extends AbstractGroupDAOImpl { List devices = null; try { conn = GroupManagementDAOFactory.getConnection(); - String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + + String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, e.DEVICE_TYPE, " + + "d1.DEVICE_IDENTIFICATION, d1.LAST_UPDATED_TIMESTAMP, e.OWNER, e.OWNERSHIP, e.STATUS, " + + "e.IS_TRANSFERRED, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, " + - "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " + + "(SELECT gd.DEVICE_ID, gd.DESCRIPTION, gd.NAME, gd.DEVICE_IDENTIFICATION, gd.LAST_UPDATED_TIMESTAMP " + "FROM " + - "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.DEVICE_TYPE_ID FROM" + + "(SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION, d.LAST_UPDATED_TIMESTAMP FROM" + " DM_DEVICE d, (" + "SELECT dgm.DEVICE_ID FROM DM_DEVICE_GROUP_MAP dgm WHERE dgm.GROUP_ID = ?) dgm1 " + - "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd, DM_DEVICE_TYPE t " + - "WHERE gd.DEVICE_TYPE_ID = t.ID) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY d1.DEVICE_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + "WHERE d.ID = dgm1.DEVICE_ID AND d.TENANT_ID = ?) gd) d1 " + + "WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? ORDER BY d1.DEVICE_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; stmt = conn.prepareStatement(sql); stmt.setInt(1, groupId); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java index 0d2d563f34..a8529398c7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java @@ -230,6 +230,7 @@ public final class DeviceManagementDAOUtil { device.setDescription(rs.getString("DESCRIPTION")); device.setType(rs.getString("DEVICE_TYPE")); device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION")); + device.setLastUpdatedTimeStamp(rs.getTimestamp("LAST_UPDATED_TIMESTAMP").getTime()); device.setEnrolmentInfo(loadEnrolment(rs)); return device; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java index ff81879563..7af356c896 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java @@ -142,9 +142,12 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager { log.info("Device identifier " + device.getDeviceIdentifier() + ", Device name " + "changed by user from " + device.getName() + " to " + name); device.setName(name); + deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId()); + } else { + deviceDAO.recordDeviceUpdate( + new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()), + CarbonContext.getThreadLocalCarbonContext().getTenantId()); } - - deviceDAO.updateDevice(device, CarbonContext.getThreadLocalCarbonContext().getTenantId()); DeviceManagementDAOFactory.commitTransaction(); //TODO :: This has to be fixed by adding the enrollment ID. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index 683971472b..689fc1b243 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -669,6 +669,8 @@ public interface DeviceManagementProviderService { void addLicense(String deviceType, License license) throws DeviceManagementException; + boolean recordDeviceUpdate(DeviceIdentifier deviceIdentifier) throws DeviceManagementException; + boolean modifyEnrollment(Device device) throws DeviceManagementException; boolean enrollDevice(Device device) throws DeviceManagementException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index a62aaada9e..7b233b90ca 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -38,7 +38,6 @@ import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.Billing; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceEnrollmentInfoNotification; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; @@ -58,7 +57,6 @@ import io.entgra.device.mgt.core.device.mgt.common.StartupOperationConfig; import io.entgra.device.mgt.core.device.mgt.common.BillingResponse; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; -import io.entgra.device.mgt.core.device.mgt.common.app.mgt.MobileAppTypes; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.AmbiguousConfigurationException; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationEntry; import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.ConfigurationManagementException; @@ -452,6 +450,31 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return status; } + @Override + public boolean recordDeviceUpdate(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { + int tenantId = this.getTenantId(); + boolean isUpdated; + try { + DeviceManagementDAOFactory.beginTransaction(); + isUpdated = deviceDAO.recordDeviceUpdate(deviceIdentifier, tenantId); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while setting updated " + + "timestamp of device: " + deviceIdentifier; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction to set updated " + + "timestamp of device: " + deviceIdentifier; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + return isUpdated; + } + @Override public boolean modifyEnrollment(Device device) throws DeviceManagementException { if (device == null) { @@ -490,10 +513,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (device.getName() == null) { device.setName(currentDevice.getName()); } - deviceDAO.updateDevice(device, tenantId); + int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId); boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId); - boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(device.getType(),device.getEnrolmentInfo().getStatus().name(),tenantId); + boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(device.getType(), + device.getEnrolmentInfo().getStatus().name(),tenantId); if (updatedRows == 1 && !deviceStatusManagementService.getDeviceStatusCheck(tenantId)){ enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus()); } else if (updatedRows ==1 && isEnableDeviceStatusCheck && isValidState ) { @@ -501,7 +525,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } DeviceManagementDAOFactory.commitTransaction(); - log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(currentDevice.getId())).setDeviceType(String.valueOf(currentDevice.getType())).setOwner(currentDevice.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(currentDevice.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); + log.info("Device enrollment modified successfully", + deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(currentDevice.getId())) + .setDeviceType(String.valueOf(currentDevice.getType())) + .setOwner(currentDevice.getEnrolmentInfo().getOwner()) + .setOwnership(String.valueOf(currentDevice.getEnrolmentInfo().getOwnership())) + .setTenantID(String.valueOf(tenantId)) + .setTenantDomain(tenantDomain) + .setUserName(userName).build()); + this.removeDeviceFromCache(deviceIdentifier); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); @@ -616,20 +648,27 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } else if (updatedRows ==1 && isEnableDeviceStatusCheck && isValidState ) { enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus()); } - deviceDAO.updateDevice(device, tenantId); DeviceManagementDAOFactory.commitTransaction(); this.removeDeviceFromCache(deviceId); - //procees to dis-enroll a device from traccar starts + //process to dis-enroll a device from traccar starts if (HttpReportingUtil.isTrackerEnabled()) { - DeviceManagementDataHolder.getInstance().getTraccarManagementService().unLinkTraccarDevice(device.getEnrolmentInfo().getId()); + DeviceManagementDataHolder.getInstance().getTraccarManagementService() + .unLinkTraccarDevice(device.getEnrolmentInfo().getId()); } else { if (log.isDebugEnabled()) { log.debug("Traccar is disabled"); } } - //procees to dis-enroll a device from traccar ends - log.info("Device disenrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(device.getId())).setDeviceType(String.valueOf(device.getType())).setOwner(device.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(device.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build()); + //process to dis-enroll a device from traccar ends + log.info("Device disenrolled successfully", + deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(device.getId())) + .setDeviceType(String.valueOf(device.getType())) + .setOwner(device.getEnrolmentInfo().getOwner()) + .setOwnership(String.valueOf(device.getEnrolmentInfo().getOwnership())) + .setTenantID(String.valueOf(tenantId)) + .setTenantDomain(tenantDomain) + .setUserName(userName).build()); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while dis-enrolling '" + deviceId.getType() + @@ -4456,15 +4495,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } catch (MetadataManagementException e) { throw new RuntimeException(e); } - try { - deviceDAO.updateDevice(device, tenantId); - } catch (DeviceManagementDAOException e) { - DeviceManagementDAOFactory.rollbackTransaction(); - String msg = "Error occurred while updating device: " + - device.getName(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } } } DeviceManagementDAOFactory.commitTransaction(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java index f069c1fb43..e76a4f7850 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.Assert; @@ -33,6 +34,8 @@ import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import java.sql.*; +import java.util.Collections; +import java.util.List; public class DevicePersistTests extends BaseDeviceManagementTest { @@ -224,4 +227,60 @@ public class DevicePersistTests extends BaseDeviceManagementTest { DeviceManagementDAOFactory.closeConnection(); } } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesByIdentifiersTest() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.openConnection(); + DeviceIdentifier deviceId = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + List retrieved = deviceDAO.getDevicesByIdentifiers( + Collections.singletonList(deviceId.getId()), TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, retrieved.size(), "Device count is not matched to expected."); + } catch (DeviceManagementDAOException | SQLException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the current status of the " + + "enrolment", e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void recordDeviceUpdateTest() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.beginTransaction(); + device = deviceDAO.getDevice(device.getDeviceIdentifier(), TestDataHolder.SUPER_TENANT_ID); + log.info("Device before update: " + device); + DeviceIdentifier deviceId = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + boolean updated = deviceDAO.recordDeviceUpdate(deviceId, TestDataHolder.SUPER_TENANT_ID); + Assert.assertTrue(updated, "Device timestamp is not updated."); + Device updatedDevice = deviceDAO.getDevice(device.getDeviceIdentifier(), TestDataHolder.SUPER_TENANT_ID); + log.info("Device after update: " + updatedDevice); + Assert.assertTrue(device.getLastUpdatedTimeStamp() < updatedDevice.getLastUpdatedTimeStamp(), + "Last updated timestamp is way older."); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the current status of the " + + "enrolment", e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceByStatusTest() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setStatusList(Collections.singletonList(Status.ACTIVE.name())); + List results = deviceDAO.getDevicesByStatus(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results.size(), "No device returned"); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the current status of the " + + "enrolment", e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + } From e154c687e6f1dd7f4dad0553c801542980209fcb Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Thu, 16 May 2024 12:29:40 +0530 Subject: [PATCH 190/343] Add additional indexes to DM_DB --- .../src/main/resources/dbscripts/cdm/mysql.sql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 7000513833..cd28fb74f1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -63,6 +63,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( CREATE INDEX IDX_DM_DEVICE ON DM_DEVICE(TENANT_ID, DEVICE_TYPE_ID); CREATE INDEX IDX_DM_DEVICE_TYPE_ID_DEVICE_IDENTIFICATION ON DM_DEVICE(TENANT_ID, DEVICE_TYPE_ID,DEVICE_IDENTIFICATION); +CREATE INDEX IDX_DM_DEVICE_DEVICE_IDENTIFICATION ON DM_DEVICE(DEVICE_IDENTIFICATION); +CREATE INDEX IDX_DM_DEVICE_LAST_UPDATED_TIMESTAMP ON DM_DEVICE(LAST_UPDATED_TIMESTAMP); CREATE TABLE IF NOT EXISTS DM_DEVICE_PROPERTIES ( DEVICE_TYPE_NAME VARCHAR(300) NOT NULL, @@ -132,10 +134,13 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( CONSTRAINT FK_DM_DEVICE_ENROLMENT FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION )ENGINE = InnoDB; -CREATE INDEX IDX_ENROLMENT_FK_DEVICE_ID ON DM_ENROLMENT(DEVICE_ID); -CREATE INDEX IDX_ENROLMENT_DEVICE_TYPE ON DM_ENROLMENT(DEVICE_TYPE); +CREATE INDEX IDX_ENROLMENT_DATE_OF_LAST_UPDATE ON DM_ENROLMENT(DATE_OF_LAST_UPDATE); CREATE INDEX IDX_ENROLMENT_DEVICE_IDENTIFICATION ON DM_ENROLMENT(DEVICE_IDENTIFICATION); +CREATE INDEX IDX_ENROLMENT_DEVICE_TYPE ON DM_ENROLMENT(DEVICE_TYPE); +CREATE INDEX IDX_ENROLMENT_FK_DEVICE_ID ON DM_ENROLMENT(DEVICE_ID); CREATE INDEX IDX_ENROLMENT_STATUS ON DM_ENROLMENT(STATUS); +CREATE INDEX IDX_ENROLMENT_TENANT_ID ON DM_ENROLMENT(TENANT_ID); + CREATE TABLE IF NOT EXISTS DM_DEVICE_STATUS ( ID INTEGER AUTO_INCREMENT NOT NULL, From 7c0df33738edef5395b058d234ea2b0479c79356 Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Thu, 16 May 2024 21:25:16 +0530 Subject: [PATCH 191/343] Fix issue DB transaction handling issue --- .../DeviceManagementProviderServiceImpl.java | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 7b233b90ca..75f3836a34 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -1147,7 +1147,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv List deviceStatus; for (Device device : allDevices) { long dateDiff = 0; - deviceStatus = getDeviceStatusHistory(device, null, endDate, true); + deviceStatus = getDeviceStatusHistoryInsideTransaction(device, null, endDate, true); if (device.getEnrolmentInfo().getDateOfEnrolment() < startDate.getTime()) { if (!deviceStatus.isEmpty() && (String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED") || String.valueOf(deviceStatus.get(0).getStatus()).equals("DELETED"))) { @@ -2202,23 +2202,52 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } } + /* + This is just to avoid breaking the billing functionality as it required to call getDeviceStatusHistory method + without transaction handling. + */ + private List getDeviceStatusHistoryInsideTransaction( + Device device, Date fromDate, Date toDate, boolean billingStatus) + throws DeviceManagementException { + if (log.isDebugEnabled()) { + log.debug("get status history of device: " + device.getDeviceIdentifier()); + } + try { + DeviceManagementDAOFactory.getConnection(); + int tenantId = this.getTenantId(); + return deviceStatusDAO.getStatus(device.getId(), tenantId, fromDate, toDate, billingStatus); + } catch (DeviceManagementDAOException e) { + String msg = "Error occurred in retrieving status history for device :" + device.getDeviceIdentifier(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while opening a connection to the data source"; + log.info(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + @Override public List getDeviceStatusHistory(Device device, Date fromDate, Date toDate, boolean billingStatus) throws DeviceManagementException { if (log.isDebugEnabled()) { log.debug("get status history of device: " + device.getDeviceIdentifier()); } try { + DeviceManagementDAOFactory.openConnection(); int tenantId = this.getTenantId(); return deviceStatusDAO.getStatus(device.getId(), tenantId, fromDate, toDate, billingStatus); } catch (DeviceManagementDAOException e) { - DeviceManagementDAOFactory.rollbackTransaction(); - String msg = "Error occurred while retrieving status history"; - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } catch (Exception e) { String msg = "Error occurred in retrieving status history for device :" + device.getDeviceIdentifier(); log.error(msg, e); throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while opening a connection to the data source"; + log.info(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); } } From caf548ac757a0d6b9255ea44e36d3121bf2a835f Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Sun, 26 May 2024 14:19:45 +0530 Subject: [PATCH 192/343] Fix overrides in DeviceDAO --- .../core/dao/impl/device/PostgreSQLDeviceDAOImpl.java | 9 +-------- .../core/dao/impl/device/SQLServerDeviceDAOImpl.java | 10 +--------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index 4f602afc9f..0f502cf874 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -18,18 +18,14 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.device; -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Count; import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceBilling; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; @@ -47,7 +43,7 @@ import java.util.Map; /** * This class holds the generic implementation of DeviceDAO which can be used to support ANSI db syntax. */ -public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { +public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { private static final Log log = LogFactory.getLog(PostgreSQLDeviceDAOImpl.class); @@ -1300,7 +1296,4 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { } } - private Connection getConnection() throws SQLException { - return DeviceManagementDAOFactory.getConnection(); - } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index d98b2af00a..7de242ead9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -27,11 +27,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.impl.AbstractDeviceDAOImpl; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; -import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCoordinate; import io.entgra.device.mgt.core.device.mgt.core.report.mgt.Constants; import java.sql.Connection; @@ -48,7 +44,7 @@ import java.util.Map; /** * This class holds the generic implementation of DeviceDAO which can be used to support ANSI db syntax. */ -public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { +public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { private static final Log log = LogFactory.getLog(SQLServerDeviceDAOImpl.class); @@ -1117,10 +1113,6 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { } } - private Connection getConnection() throws SQLException { - return DeviceManagementDAOFactory.getConnection(); - } - @Override public List getDevicesByDuration(PaginationRequest request, int tenantId, String fromDate, String toDate) From 4b960534195fef1f0e3c0a573263162834d85762 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Tue, 28 May 2024 11:19:39 +0530 Subject: [PATCH 193/343] Add /permission/admin/device-mgt/devices/any-group/permitted-actions-under-owning-group permission --- .../src/main/resources/conf/cdm-config.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index a9214f24a8..f4b6d5266b 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -295,6 +295,14 @@ Internal/devicemgt-user + + /permission/admin/device-mgt/devices/any-group/permitted-actions-under-owning-group + + Apply permitted actions on any group + dm:group:any:permitted + Internal/devicemgt-user + + From 7616c2255c054e21a10f4f85ced02513f94ab385 Mon Sep 17 00:00:00 2001 From: ashvini Date: Wed, 29 May 2024 12:44:59 +0530 Subject: [PATCH 194/343] Add filter to get Web apps in Enrollment Application Install Add filter file --- .../mgt/core/application/mgt/common/Filter.java | 13 +++++++++++++ .../impl/application/GenericApplicationDAOImpl.java | 12 ++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/Filter.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/Filter.java index 272e9ba8a3..88f7e90a0a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/Filter.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/Filter.java @@ -118,6 +118,11 @@ public class Filter { */ private boolean isNotRetired; + /** + * To check whether web applications should be returned + */ + private boolean withWebApps; + public int getLimit() { return limit; } @@ -221,4 +226,12 @@ public class Filter { public void setNotRetired(boolean notRetired) { isNotRetired = notRetired; } + + public boolean isWithWebApps() { + return withWebApps; + } + + public void setWithWebApps(boolean withWebApps) { + this.withWebApps = withWebApps; + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 7c71880fa6..618149cd72 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -178,7 +178,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic sql += "AND AP_APP_RELEASE.CURRENT_STATE = ? "; } if (deviceTypeId != -1) { - sql += "AND AP_APP.DEVICE_TYPE_ID = ? "; + sql += "AND (AP_APP.DEVICE_TYPE_ID = ? "; + if (filter.isWithWebApps()) { + sql += "OR AP_APP.DEVICE_TYPE_ID = 0 "; + } + sql += ") "; } if (filter.isNotRetired()) { sql += "AND AP_APP.STATUS != 'RETIRED' "; @@ -309,7 +313,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic sql += " AND AP_APP_RELEASE.CURRENT_STATE = ?"; } if (deviceTypeId != -1) { - sql += " AND AP_APP.DEVICE_TYPE_ID = ?"; + sql += "AND (AP_APP.DEVICE_TYPE_ID = ? "; + if (filter.isWithWebApps()) { + sql += "OR AP_APP.DEVICE_TYPE_ID = 0 "; + } + sql += ") "; } if (filter.isNotRetired()) { sql += " AND AP_APP.STATUS != 'RETIRED'"; From 65ac47aec0d4bac537e9db9dd870e7b8e90971ea Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Fri, 31 May 2024 07:21:12 +0530 Subject: [PATCH 195/343] Add missing permission --- .../templates/repository/conf/cdm-config.xml.j2 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index 259a12301a..59e026f679 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -469,6 +469,14 @@ Internal/devicemgt-user + + /permission/admin/device-mgt/devices/any-group/permitted-actions-under-owning-group + + Apply permitted actions on any group + dm:group:any:permitted + Internal/devicemgt-user + + From 694e601a4bc5906c5566675cba0ce56a8077915d Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Fri, 31 May 2024 11:31:10 +0530 Subject: [PATCH 196/343] Fix remote share authorization issue --- .../device/mgt/core/ui/request/interceptor/UserHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java index 04cb1f08b8..5ca4860c87 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/UserHandler.java @@ -124,7 +124,7 @@ public class UserHandler extends HttpServlet { proxyResponse.setData(mapper.convertValue(data, JsonNode.class)); HandlerUtil.handleSuccess(resp, proxyResponse); - httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, tokenData.get("username").toString()); + httpSession.setAttribute(HandlerConstants.USERNAME_WITH_DOMAIN, tokenData.get("username").textValue()); log.info( "User " + proxyResponse.getData() + " logged in", userLoginLogContextBuilder From aca7aa3ccc7ac6105fa7513c90f98787427e17f0 Mon Sep 17 00:00:00 2001 From: Charitha Date: Sun, 2 Jun 2024 10:04:47 +0530 Subject: [PATCH 197/343] Disable validateOperationCodeFiltering for validateOperationLogFilters --- .../api/jaxrs/service/impl/util/RequestValidationUtil.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java index 5eb474cb32..71d875a6b9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java @@ -574,7 +574,11 @@ public class RequestValidationUtil { } if (operationCode != null && !operationCode.isEmpty()) { - validateOperationCodeFiltering(operationCode, type); + /* + Commenting this as dynamic device types doesn't have configuration based feature manager which + used to define fixed set of operation codes. + */ +// validateOperationCodeFiltering(operationCode, type); operationLogFilters.setOperationCode(operationCode); } return operationLogFilters; From 641ddbfb85c8f3b8cdcfeba30d423502c087b80f Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Thu, 6 Jun 2024 09:50:27 +0530 Subject: [PATCH 198/343] Fix sql syntax errors --- .../jaxrs/service/impl/GroupManagementServiceImpl.java | 2 +- .../device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 7 +++---- .../device/mgt/core/dao/impl/AbstractGroupDAOImpl.java | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java index fc8f080b07..e8c56680b1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -273,7 +273,7 @@ public class GroupManagementServiceImpl implements GroupManagementService { ); return Response.status(Response.Status.OK).build(); } catch (GroupManagementException e) { - String msg = "Error occurred while adding new group."; + String msg = "Error occurred while updating group. "; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (GroupNotExistException e) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 7ab1cdb6e3..e95183d8c3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -176,7 +176,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "d.DESCRIPTION, " + "d.NAME, " + "d.LAST_UPDATED_TIMESTAMP " - + "FROM DM_DEVICE d" + + "FROM DM_DEVICE d WHERE " + "d.DEVICE_IDENTIFICATION = ? AND " + "d.TENANT_ID = ?"; @@ -197,7 +197,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIndx = 1; - stmt.setString(paramIndx++, deviceData.getDeviceIdentifier().getType()); stmt.setString(paramIndx++, deviceData.getDeviceIdentifier().getId()); stmt.setInt(paramIndx++, tenantId); if (deviceData.getLastModifiedDate() != null) { @@ -964,12 +963,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "d.NAME AS DEVICE_NAME, " + "d.DEVICE_IDENTIFICATION, " + "d.LAST_UPDATED_TIMESTAMP, " - + "e.DEVICE_TYPE " + + "e1.DEVICE_TYPE " + "FROM " + "DM_DEVICE d, " + "(SELECT " + "e.OWNER, " - + "e.DEVICE_TYPE " + + "e.DEVICE_TYPE, " + "e.OWNERSHIP, " + "e.ID AS ENROLMENT_ID, " + "e.DEVICE_ID, " diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 374c1ca0aa..c65692870d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1282,8 +1282,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { StringJoiner joiner = new StringJoiner(",","SELECT " + "d1.DEVICE_ID, " + "d1.DESCRIPTION, " - + "e.DEVICE_NAME, " - + "d1.DEVICE_TYPE, " + + "d1.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, " + "d1.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, " @@ -1343,8 +1343,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { String sql = "SELECT " + "d1.DEVICE_ID, " + "d1.DESCRIPTION, " - + "e.DEVICE_NAME, " - + "d1.DEVICE_TYPE, " + + "d1.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, " + "d1.LAST_UPDATED_TIMESTAMP, " + "e.OWNER, " From f0c48c585de2311dd71cae55e46164b77645158d Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Fri, 7 Jun 2024 13:04:51 +0530 Subject: [PATCH 199/343] Fix sql syntax errors --- .../mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index e95183d8c3..58bfed7d4a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -1036,12 +1036,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "(SELECT gd.DEVICE_ID, " + "gd.DESCRIPTION, " + "gd.NAME, " + - "gd.DEVICE_IDENTIFICATION, " + + "gd.DEVICE_IDENTIFICATION " + "FROM " + "(SELECT d.ID AS DEVICE_ID, " + "d.DESCRIPTION, " + "d.NAME, " + - "d.DEVICE_IDENTIFICATION, " + + "d.DEVICE_IDENTIFICATION " + "FROM DM_DEVICE d, " + "(SELECT dgm.DEVICE_ID " + "FROM DM_DEVICE_GROUP_MAP dgm " + @@ -2365,7 +2365,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "e.device_id," + "e.status, " + "e.date_of_last_update, " + - "e.date_of_enrolment " + + "e.date_of_enrolment, " + "e.DEVICE_TYPE " + "FROM dm_enrolment e " + "INNER JOIN " + @@ -2375,7 +2375,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "KEY_FIELD = 'encryptionEnabled' " + "AND VALUE_FIELD = ?) AS di " + "ON di.DEVICE_ID = e.DEVICE_ID " + - "WHERE e.tenant_id = ?) e1, " + + "WHERE e.tenant_id = ?) e1 " + "WHERE d.id = e1.device_id " + "ORDER BY e1.date_of_last_update DESC " + "LIMIT ? OFFSET ?"; @@ -2409,7 +2409,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try { Connection conn = getConnection(); String sql = - "SELECT COUNT(DEVICE_ID) " + + "SELECT COUNT(DEVICE_ID) AS DEVICE_COUNT " + "FROM DM_DEVICE_INFO " + "WHERE KEY_FIELD = 'encryptionEnabled' " + "AND VALUE_FIELD = ?"; @@ -2417,7 +2417,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setBoolean(1, isEncrypted); - ps.setInt(2, tenantId); try (ResultSet rs = ps.executeQuery()) { return rs.next() ? rs.getInt("DEVICE_COUNT") : 0; From b0362c58256ed0a3a1c6d8a7d9d456e9190a3c91 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Fri, 7 Jun 2024 21:57:21 +0530 Subject: [PATCH 200/343] Fix devices of a group not loading --- .../mgt/core/dao/impl/device/GenericDeviceDAOImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index efe07d1335..d1ea236645 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -646,8 +646,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } @Override - public List searchDevicesInGroup(PaginationRequest request, int tenantId) - throws DeviceManagementDAOException { + public List searchDevicesInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException { List devices = null; int groupId = request.getGroupId(); String deviceType = request.getDeviceType(); @@ -687,6 +686,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "gd.DESCRIPTION, " + "gd.NAME, " + "gd.DEVICE_IDENTIFICATION, " + + "gd.LAST_UPDATED_TIMESTAMP " + "FROM " + "(SELECT d.ID AS DEVICE_ID, " + "d.DESCRIPTION, " + @@ -708,10 +708,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { sql = sql + " WHERE 1 = 1"; //Add query for last updated timestamp if (since != null) { - sql = sql + " AND d.LAST_UPDATED_TIMESTAMP > ?"; + sql = sql + " AND gd.LAST_UPDATED_TIMESTAMP > ?"; isSinceProvided = true; } - sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? "; + sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND e.TENANT_ID = ? "; //Add the query for device-type if (deviceType != null && !deviceType.isEmpty()) { sql = sql + " AND e.DEVICE_TYPE = ?"; From 1aec609bff712089d658ee56608967286658efaf Mon Sep 17 00:00:00 2001 From: Lasantha Dharmakeerthi Date: Mon, 10 Jun 2024 07:43:29 +0000 Subject: [PATCH 201/343] Fix SQL error --- .../core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 58bfed7d4a..ec03136c6b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -1716,7 +1716,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { String sql = "SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.LAST_UPDATED_TIMESTAMP, " + "e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, " + "e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, e.ENROLMENT_ID FROM " + - "(SELECT e.ID, e.DEVICE_ID, e.DEVICE_TYPE, e.OWNER, " + + "(SELECT e.ID, e.DEVICE_ID, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION, e.OWNER, " + "e.OWNERSHIP, e.STATUS, e.IS_TRANSFERRED, e.DATE_OF_ENROLMENT, e.DATE_OF_LAST_UPDATE, e.ID AS " + "ENROLMENT_ID FROM DM_ENROLMENT e WHERE TENANT_ID = ? AND STATUS = ?) e, " + "DM_DEVICE d WHERE d.ID = e.DEVICE_ID AND d.TENANT_ID = ?"; From d443fef6e0314ab2a8c3799405d1ced60d096bcc Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Tue, 11 Jun 2024 10:38:54 +0530 Subject: [PATCH 202/343] Add missing test cases for DevicePersistTests and GroupPersistTests --- .../mgt/core/common/TestDataHolder.java | 18 + .../mgt/core/dao/DevicePersistTests.java | 514 ++++++++++++++++++ .../mgt/core/dao/GroupPersistTests.java | 306 ++++++++++- 3 files changed, 817 insertions(+), 21 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java index bea2094a77..322b2b449d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java @@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.MonitoringOperation; import io.entgra.device.mgt.core.device.mgt.common.OperationMonitoringTaskConfig; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; +import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceData; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; @@ -32,6 +33,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Properties; +import java.util.Calendar; public class TestDataHolder { @@ -39,11 +41,18 @@ public class TestDataHolder { public final static Integer SUPER_TENANT_ID = -1234; public final static String SUPER_TENANT_DOMAIN = "carbon.super"; public final static String initialDeviceIdentifier = "12345"; + public final static String initialDeviceName = "TEST-DEVICE"; public final static String OWNER = "admin"; public static final String OPERATION_CONFIG = "TEST-OPERATION-"; public static Device initialTestDevice; public static DeviceType initialTestDeviceType; + public static Date getTimeBefore(int minutes) { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MINUTE, -minutes); + return calendar.getTime(); + } + public static Device generateDummyDeviceData(String deviceType) { Device device = new Device(); device.setEnrolmentInfo(generateEnrollmentInfo(new Date().getTime(), new Date().getTime(), OWNER, EnrolmentInfo @@ -141,6 +150,15 @@ public class TestDataHolder { return device; } + public static DeviceData generateDummyDevice(DeviceIdentifier deviceIdentifier) { + DeviceData deviceData = new DeviceData(); + deviceData.setDeviceIdentifier(deviceIdentifier); + deviceData.setDeviceOwner(OWNER); + deviceData.setDeviceOwnership(EnrolmentInfo.OwnerShip.BYOD.toString()); + deviceData.setLastModifiedDate(getTimeBefore(1)); + return deviceData; + } + public static DeviceType generateDeviceTypeData(String devTypeName) { DeviceType deviceType = new DeviceType(); deviceType.setName(devTypeName); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java index e76a4f7850..a8bc1b6924 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java @@ -18,7 +18,13 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceData; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCoordinate; +import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoQuery; +import org.apache.commons.collections.map.SingletonMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.Assert; @@ -34,6 +40,7 @@ import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import java.sql.*; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -89,6 +96,7 @@ public class DevicePersistTests extends BaseDeviceManagementTest { public void testAddDeviceTest() { int tenantId = TestDataHolder.SUPER_TENANT_ID; Device device = TestDataHolder.generateDummyDeviceData(TestDataHolder.TEST_DEVICE_TYPE); + device.setName(TestDataHolder.initialDeviceName); try { DeviceManagementDAOFactory.beginTransaction(); @@ -275,6 +283,7 @@ public class DevicePersistTests extends BaseDeviceManagementTest { pr.setStatusList(Collections.singletonList(Status.ACTIVE.name())); List results = deviceDAO.getDevicesByStatus(pr, TestDataHolder.SUPER_TENANT_ID); Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); } catch (DeviceManagementDAOException e) { throw new DeviceManagementDAOException("Error occurred while retrieving the current status of the " + "enrolment", e); @@ -283,4 +292,509 @@ public class DevicePersistTests extends BaseDeviceManagementTest { } } + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesByTenantId() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevices(TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceByDeviceId() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.beginTransaction(); + Device results = deviceDAO.getDevice(device.getDeviceIdentifier(), TestDataHolder.SUPER_TENANT_ID); + Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceByDeviceIdentifierWithTenantId() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.beginTransaction(); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + Device results = deviceDAO.getDevice(deviceIdentifier, TestDataHolder.SUPER_TENANT_ID); + Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceByDeviceData() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + DeviceData deviceData = TestDataHolder.generateDummyDevice(deviceIdentifier); + try { + DeviceManagementDAOFactory.beginTransaction(); + Device results = deviceDAO.getDevice(deviceData, TestDataHolder.SUPER_TENANT_ID); + Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceByOwner() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + try { + DeviceManagementDAOFactory.beginTransaction(); + Device results = deviceDAO.getDevice(deviceIdentifier, TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID); + Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceByDateSince() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + try { + DeviceManagementDAOFactory.beginTransaction(); + Device results = deviceDAO.getDevice(deviceIdentifier, TestDataHolder.getTimeBefore(1), TestDataHolder.SUPER_TENANT_ID); + Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceByDateSinceWithDeviceId() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.beginTransaction(); + Device results = deviceDAO.getDevice(device.getDeviceIdentifier(), TestDataHolder.getTimeBefore(1), TestDataHolder.SUPER_TENANT_ID); + Assert.assertNotNull(results.getDeviceIdentifier(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceByEnrollmentStatus() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + try { + DeviceManagementDAOFactory.beginTransaction(); + Device results = deviceDAO.getDevice(deviceIdentifier, Status.ACTIVE, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(device.getDeviceIdentifier(), results.getDeviceIdentifier(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceByDeviceIdentifier() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + try { + DeviceManagementDAOFactory.beginTransaction(); + SingletonMap results = deviceDAO.getDevice(deviceIdentifier); + Assert.assertNotNull(results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceByDeviceType() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevices(device.getType(), TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getAllocatedDevices() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getAllocatedDevices(device.getType(), TestDataHolder.SUPER_TENANT_ID, 1, 0); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesOfUser() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevicesOfUser(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesOfUserWithDeviceType() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevicesOfUser(TestDataHolder.OWNER, device.getType(), TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesOfUserWithDeviceStatus() throws DeviceManagementDAOException, TransactionManagementException { + List status = new ArrayList<>() ; + status.add(Status.ACTIVE.name()); + try { + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevicesOfUser(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID, status); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getCountOfDevicesInGroup() throws DeviceManagementDAOException, TransactionManagementException { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setGroupId(1); + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getCountOfDevicesInGroup(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(0, results, "No device count returned in group"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device count" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountWithOwner() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getDeviceCount(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountWithType() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getDeviceCount(device.getType(), Status.ACTIVE.name(), TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void setEnrolmentStatusInBulk() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + List devices = new ArrayList<>() ; + devices.add(device.getDeviceIdentifier()); + try { + DeviceManagementDAOFactory.beginTransaction(); + boolean results = deviceDAO.setEnrolmentStatusInBulk(device.getType(), Status.ACTIVE.name(),TestDataHolder.SUPER_TENANT_ID, devices ); + Assert.assertTrue(results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCount() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getDeviceCount(TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountWithPagination() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setDeviceName(device.getName()); + pr.setDeviceType(device.getType()); + pr.setOwner(TestDataHolder.OWNER); + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getDeviceCount(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountByType() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getDeviceCountByType(device.getType(), TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountByUser() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getDeviceCountByUser(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountByName() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getDeviceCountByName(TestDataHolder.initialDeviceName, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountByOwnership() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getDeviceCountByOwnership(EnrolmentInfo.OwnerShip.BYOD.name(), TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountByStatus() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getDeviceCountByStatus(Status.ACTIVE.name(), TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountByStatusWithType() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getDeviceCountByStatus(device.getType(), Status.ACTIVE.name(), TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getActiveEnrolment() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()); + try { + DeviceManagementDAOFactory.beginTransaction(); + EnrolmentInfo results = deviceDAO.getActiveEnrolment(deviceIdentifier, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(Status.ACTIVE, results.getStatus(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceEnrolledTenants() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDeviceEnrolledTenants(); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void findGeoClusters() throws DeviceManagementDAOException, TransactionManagementException { + GeoQuery geoQuery = new GeoQuery(new GeoCoordinate(123, 123), new GeoCoordinate(123, 123), 12345); + try { + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.findGeoClusters(geoQuery, TestDataHolder.SUPER_TENANT_ID); + Assert.assertNotNull(results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getAppNotInstalledDevices() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setDeviceType(device.getType()); + try { + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getAppNotInstalledDevices(pr, TestDataHolder.SUPER_TENANT_ID, "com.google.calc", "1.0.0"); + Assert.assertNotNull(results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getCountOfAppNotInstalledDevices() throws DeviceManagementDAOException, TransactionManagementException { + Device device = TestDataHolder.initialTestDevice; + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setDeviceType(device.getType()); + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getCountOfAppNotInstalledDevices(pr, TestDataHolder.SUPER_TENANT_ID, "com.google.calc", "1.0.0"); + Assert.assertEquals(1, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesByEncryptionStatus() throws DeviceManagementDAOException, TransactionManagementException { + PaginationRequest pr = new PaginationRequest(0, 10); + try { + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevicesByEncryptionStatus(pr, TestDataHolder.SUPER_TENANT_ID, false); + Assert.assertNotNull(results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getCountOfDevicesByEncryptionStatus() throws DeviceManagementDAOException, TransactionManagementException { + try { + DeviceManagementDAOFactory.beginTransaction(); + int results = deviceDAO.getCountOfDevicesByEncryptionStatus(TestDataHolder.SUPER_TENANT_ID, true); + Assert.assertEquals(0, results, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupPersistTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupPersistTests.java index 0ea871994c..e484bc4923 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupPersistTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupPersistTests.java @@ -18,6 +18,8 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.Assert; @@ -54,19 +56,18 @@ public class GroupPersistTests extends BaseDeviceManagementTest { GroupManagementDAOFactory.beginTransaction(); groupId = groupDAO.addGroup(deviceGroup, TestDataHolder.SUPER_TENANT_ID); GroupManagementDAOFactory.commitTransaction(); - GroupManagementDAOFactory.closeConnection(); log.debug("Group added to database. ID: " + groupId); } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while adding device type '" + deviceGroup.getName() + "'."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while initiating transaction."; log.error(msg, e); Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); } DeviceGroup group = getGroupById(groupId); if (!isMock()) { @@ -83,22 +84,21 @@ public class GroupPersistTests extends BaseDeviceManagementTest { request.setGroupName(null); request.setOwner(null); List groups = groupDAO.getGroups(request, TestDataHolder.SUPER_TENANT_ID); - GroupManagementDAOFactory.closeConnection(); if (!isMock()) { Assert.assertNotEquals(groups.size(), 0, "No groups found"); Assert.assertNotNull(groups.get(0), "Group is null"); log.debug("No of Groups found: " + groups.size()); } } catch (GroupManagementDAOException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while find group by name."; log.error(msg, e); Assert.fail(msg, e); } catch (SQLException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while opening a connection to the data source."; log.error(msg, e); Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); } } @@ -114,21 +114,20 @@ public class GroupPersistTests extends BaseDeviceManagementTest { } GroupManagementDAOFactory.commitTransaction(); List roles = groupDAO.getRoles(groupId, TestDataHolder.SUPER_TENANT_ID); - GroupManagementDAOFactory.closeConnection(); if (!isMock()) { Assert.assertEquals(roles, addedRoles, "Added roles are not equal to returned roles."); } log.debug("Group shared with roles."); } catch (GroupManagementDAOException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while find group by name."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while opening a connection to the data source."; log.error(msg, e); Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); } } @@ -141,22 +140,21 @@ public class GroupPersistTests extends BaseDeviceManagementTest { roles.remove(0); } List deviceGroups = groupDAO.getGroups(roles.toArray(new String[roles.size()]), TestDataHolder.SUPER_TENANT_ID); - GroupManagementDAOFactory.closeConnection(); if (!isMock()) { Assert.assertEquals(deviceGroups.size(), 1, "Unexpected number of device groups found with role."); Assert.assertEquals(deviceGroups.get(0).getGroupId(), groupId, "Unexpected groupId found with role."); } log.debug("Group found for given roles."); } catch (GroupManagementDAOException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while getting groups shared with roles."; log.error(msg, e); Assert.fail(msg, e); } catch (SQLException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while opening a connection to the data source."; log.error(msg, e); Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); } } @@ -271,19 +269,18 @@ public class GroupPersistTests extends BaseDeviceManagementTest { GroupManagementDAOFactory.beginTransaction(); groupDAO.updateGroup(group, groupId, TestDataHolder.SUPER_TENANT_ID); GroupManagementDAOFactory.commitTransaction(); - GroupManagementDAOFactory.closeConnection(); log.debug("Group updated"); } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while updating group details."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while initiating transaction."; log.error(msg, e); Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); } if (!isMock()) { group = getGroupById(groupId); @@ -301,20 +298,20 @@ public class GroupPersistTests extends BaseDeviceManagementTest { GroupManagementDAOFactory.beginTransaction(); groupDAO.deleteGroup(group.getGroupId(), TestDataHolder.SUPER_TENANT_ID); GroupManagementDAOFactory.commitTransaction(); - GroupManagementDAOFactory.closeConnection(); log.debug("Group deleted"); } catch (GroupManagementDAOException e) { GroupManagementDAOFactory.rollbackTransaction(); - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while updating group details."; log.error(msg, e); Assert.fail(msg, e); } catch (TransactionManagementException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while initiating transaction."; log.error(msg, e); Assert.fail(msg, e); } + finally { + GroupManagementDAOFactory.closeConnection(); + } group = getGroupById(groupId); if (!isMock()) { Assert.assertNull(group, "Group is not deleted"); @@ -325,23 +322,290 @@ public class GroupPersistTests extends BaseDeviceManagementTest { try { GroupManagementDAOFactory.openConnection(); DeviceGroup deviceGroup = groupDAO.getGroup(groupId, TestDataHolder.SUPER_TENANT_ID); - GroupManagementDAOFactory.closeConnection(); if (deviceGroup == null && isMock()) { deviceGroup = new DeviceGroup(); deviceGroup.setGroupId(groupId); } return deviceGroup; } catch (GroupManagementDAOException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while retrieving group details."; log.error(msg, e); Assert.fail(msg, e); } catch (SQLException e) { - GroupManagementDAOFactory.closeConnection(); String msg = "Error occurred while opening a connection to the data source."; log.error(msg, e); Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); } return null; } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getAllDevicesOfGroupWithStatus() { + DeviceGroup deviceGroup = getGroupById(groupId); + Assert.assertNotNull(deviceGroup, "Group is null"); + List deviceStatus = new ArrayList<>(); + deviceStatus.add(EnrolmentInfo.Status.ACTIVE.name()); + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getAllDevicesOfGroup(deviceGroup.getName(), deviceStatus, TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting devices of group '" + groupId + "'."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getAllDevicesOfGroup() { + DeviceGroup deviceGroup = getGroupById(groupId); + Assert.assertNotNull(deviceGroup, "Group is null"); + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getAllDevicesOfGroup(deviceGroup.getName(), TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting devices of group '" + groupId + "'."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getGroupUnassignedDevices() { + DeviceGroup deviceGroup = getGroupById(groupId); + Device device = TestDataHolder.initialTestDevice; + Assert.assertNotNull(deviceGroup, "Group is null"); + PaginationRequest pr = new PaginationRequest(0,10); + pr.setDeviceType(device.getType()); + List groupNames = new ArrayList<>(); + groupNames.add(deviceGroup.getName()); + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getGroupUnassignedDevices(pr, groupNames); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting devices of group '" + groupId + "'."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getOwnGroupsCount() { + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getOwnGroupsCount(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID, "/"); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting own group count for '" + TestDataHolder.OWNER + "'."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getOwnGroups() { + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getOwnGroups(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting own groups for '" + TestDataHolder.OWNER + "'."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getOwnGroupIds() { + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getOwnGroupIds(TestDataHolder.OWNER, TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting own group Ids for '" + TestDataHolder.OWNER + "'."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getDeviceCount() { + DeviceGroup deviceGroup = getGroupById(groupId); + Assert.assertNotNull(deviceGroup, "Group is null"); + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getDeviceCount(deviceGroup.getGroupId(), TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting device count for '" +groupId+ "'."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void isDeviceMappedToGroup() { + DeviceGroup deviceGroup = getGroupById(groupId); + Device device = TestDataHolder.initialTestDevice; + Assert.assertNotNull(deviceGroup, "Group is null"); + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.isDeviceMappedToGroup(deviceGroup.getGroupId(), Integer.parseInt(device.getDeviceIdentifier()), TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while checking device map to group for '" +groupId+ "'."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getGroupCount() { + DeviceGroup deviceGroup = getGroupById(groupId); + GroupPaginationRequest pr = new GroupPaginationRequest(0,10); + pr.setGroupName(deviceGroup.getName()); + Assert.assertNotNull(deviceGroup, "Group is null"); + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getGroupCount(pr, TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting group count for '" +TestDataHolder.SUPER_TENANT_ID+ "'."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getGroupCountWithStatus() { + DeviceGroup deviceGroup = getGroupById(groupId); + Assert.assertNotNull(deviceGroup, "Group is null"); + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getGroupCount(TestDataHolder.SUPER_TENANT_ID, EnrolmentInfo.Status.ACTIVE.name()); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting group count for" + TestDataHolder.SUPER_TENANT_ID; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getRootGroups() { + DeviceGroup deviceGroup = getGroupById(groupId); + Assert.assertNotNull(deviceGroup, "Group is null"); + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getRootGroups(TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting group count for " + TestDataHolder.SUPER_TENANT_ID; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"addDeviceToGroupTest"}) + public void getAllGroupProperties() { + DeviceGroup deviceGroup = getGroupById(groupId); + Assert.assertNotNull(deviceGroup, "Group is null"); + try { + GroupManagementDAOFactory.beginTransaction(); + groupDAO.getAllGroupProperties(groupId, TestDataHolder.SUPER_TENANT_ID); + GroupManagementDAOFactory.commitTransaction(); + } catch (GroupManagementDAOException e) { + GroupManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while getting groups for " + TestDataHolder.SUPER_TENANT_ID; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } } From 31c25de95663c7d25345515ff0e70e5ca3121179 Mon Sep 17 00:00:00 2001 From: Gimhan-minion Date: Thu, 13 Jun 2024 00:51:15 +0530 Subject: [PATCH 203/343] Modify permission of operation status update --- .../jaxrs/service/api/DeviceManagementService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index f1e464a0d9..a028654cdc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -165,6 +165,13 @@ import java.util.Map; roles = {"Internal/devicemgt-user"}, permissions = {"/device-mgt/devices/change-status"} ), + @Scope( + name = "Update status of a given operation", + description = "Updates the status of a given operation of a given device", + key = "dm:devices:ops:status:update", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/devices/operations/status-update"} + ), @Scope( name = "Enroll Device", description = "Register a device", @@ -2714,12 +2721,12 @@ public interface DeviceManagementService { @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "PUT", - value = "Update status of a given opeation", + value = "Update status of a given operation", notes = "Updates the status of a given operation of a given device in Entgra IoT Server.", tags = "Device Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "dm:devices:ops:view") + @ExtensionProperty(name = Constants.SCOPE, value = "dm:devices:ops:status:update") }) } ) From eadb2efb8636395b0a35f29589a163e187d46a27 Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 14 Jun 2024 09:31:17 +0530 Subject: [PATCH 204/343] Change scope key not found log to debug level log --- .../extension/rest/api/PublisherRESTAPIServicesImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 8db730cc7b..e322ae0307 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 @@ -120,7 +120,9 @@ public class PublisherRESTAPIServicesImpl implements PublisherRESTAPIServices { throw new BadRequestException(msg); } else if (HttpStatus.SC_NOT_FOUND == response.code()) { String msg = "Shared scope key not found : " + key; - log.info(msg); + if (log.isDebugEnabled()) { + log.debug(msg); + } return false; } else { String msg = "Response : " + response.code() + response.body(); From 665b013a9624edb4a110b0e16762f1cda68c2676 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Wed, 19 Jun 2024 11:20:26 +0530 Subject: [PATCH 205/343] Fix issue when string parsing in proxy --- .../request/interceptor/util/HandlerUtil.java | 112 ++++++++++++------ 1 file changed, 77 insertions(+), 35 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 3451a4addf..8c0d0b4064 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -19,9 +19,13 @@ package io.entgra.device.mgt.core.ui.request.interceptor.util; import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -62,8 +66,11 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.PrintWriter; +import java.io.Reader; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -93,10 +100,6 @@ public class HandlerUtil { public static ProxyResponse execute(ClassicHttpRequest httpRequest) throws IOException { try (CloseableHttpClient client = getHttpClient()) { - - JsonFactory jsonFactory = new JsonFactory(); - ObjectMapper objectMapper = new ObjectMapper(jsonFactory); - return client.execute(httpRequest, response -> { final HttpEntity responseEntity = response.getEntity(); ProxyResponse handlerResponse = new ProxyResponse(); @@ -109,41 +112,39 @@ public class HandlerUtil { HandlerConstants.INTERNAL_ERROR_CODE)); return handlerResponse; } - try (InputStream inputStream = responseEntity.getContent()) { - JsonNode responseData = objectMapper.readTree(inputStream); - if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { - handlerResponse.setCode(statusCode); - handlerResponse.setData(responseData); - handlerResponse.setStatus(ProxyResponse.Status.SUCCESS); - handlerResponse.setExecutorResponse("SUCCESS"); - handlerResponse.setHeaders(response.getHeaders()); - return handlerResponse; - } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) { - if (isTokenExpired(responseData)) { - handlerResponse.setCode(statusCode); - handlerResponse.setStatus(ProxyResponse.Status.ERROR); - handlerResponse.setExecutorResponse(HandlerConstants.TOKEN_IS_EXPIRED); - } else { - log.error( - "Received " + statusCode + " response for http request : " + httpRequest.getMethod() - + " " + httpRequest.getRequestUri() + ". Error message: " + responseData.textValue()); - handlerResponse.setCode(statusCode); - handlerResponse.setData(responseData); - handlerResponse.setStatus(ProxyResponse.Status.ERROR); - handlerResponse.setExecutorResponse( - HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); - } - return handlerResponse; - } - log.error("Received " + statusCode + " response for http request : " + httpRequest.getMethod() - + " " + httpRequest.getRequestUri() + ". Error message: " + responseData.textValue()); + JsonNode responseData = getResponseData(responseEntity); + if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { handlerResponse.setCode(statusCode); handlerResponse.setData(responseData); - handlerResponse.setStatus(ProxyResponse.Status.ERROR); - handlerResponse - .setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); + handlerResponse.setStatus(ProxyResponse.Status.SUCCESS); + handlerResponse.setExecutorResponse("SUCCESS"); + handlerResponse.setHeaders(response.getHeaders()); + return handlerResponse; + } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) { + if (isTokenExpired(responseData)) { + handlerResponse.setCode(statusCode); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse.setExecutorResponse(HandlerConstants.TOKEN_IS_EXPIRED); + } else { + log.error( + "Received " + statusCode + " response for http request : " + httpRequest.getMethod() + + " " + httpRequest.getRequestUri() + ". Error message: " + responseData.textValue()); + handlerResponse.setCode(statusCode); + handlerResponse.setData(responseData); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse.setExecutorResponse( + HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); + } return handlerResponse; } + log.error("Received " + statusCode + " response for http request : " + httpRequest.getMethod() + + " " + httpRequest.getRequestUri() + ". Error message: " + responseData.textValue()); + handlerResponse.setCode(statusCode); + handlerResponse.setData(responseData); + handlerResponse.setStatus(ProxyResponse.Status.ERROR); + handlerResponse + .setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + getStatusKey(statusCode)); + return handlerResponse; }); } } @@ -748,4 +749,45 @@ public class HandlerUtil { public static String generateStateToken() { return new BigInteger(130, new SecureRandom()).toString(32); } + + /** + * Get response data and convert data into a json tree + * @param responseEntity Incoming {@link HttpEntity} + * @return {@link JsonNode} consists with response data content + * @throws IOException Throws when IO exception encountered + */ + public static JsonNode getResponseData(HttpEntity responseEntity) throws IOException { + JsonFactory jsonFactory = new JsonFactory(); + ObjectMapper objectMapper = new ObjectMapper(jsonFactory); + JsonNode finalNode; + try (InputStream inputStream = responseEntity.getContent()) { + String content = getResponseAsString(inputStream); + try { + finalNode = objectMapper.readTree(content); + } catch (JsonProcessingException e) { + ObjectNode objectNode = objectMapper.createObjectNode(); + objectNode.put("message", content); + finalNode = objectMapper.valueToTree(objectNode); + } + } + return finalNode; + } + + /** + * Get response content as a string + * @param inputStream Incoming response content as a stream + * @return String content of the incoming response + * @throws IOException Throws when IO exception encountered + */ + public static String getResponseAsString(InputStream inputStream) throws IOException { + char []buffer = new char[8192]; + StringBuilder stringBuilder = new StringBuilder(); + try (Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { + int charsRead; + while ((charsRead = reader.read(buffer, 0, buffer.length)) > 0) { + stringBuilder.append(buffer, 0, charsRead); + } + } + return stringBuilder.toString(); + } } From 1352168d5e0ba436523a3daa31a15128bc0ffa63 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Wed, 19 Jun 2024 11:46:28 +0530 Subject: [PATCH 206/343] Change method names into meaningfull names --- .../mgt/core/ui/request/interceptor/util/HandlerUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 8c0d0b4064..26c4be4201 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -112,7 +112,7 @@ public class HandlerUtil { HandlerConstants.INTERNAL_ERROR_CODE)); return handlerResponse; } - JsonNode responseData = getResponseData(responseEntity); + JsonNode responseData = getResponseDataAsJsonNode(responseEntity); if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { handlerResponse.setCode(statusCode); handlerResponse.setData(responseData); @@ -756,12 +756,12 @@ public class HandlerUtil { * @return {@link JsonNode} consists with response data content * @throws IOException Throws when IO exception encountered */ - public static JsonNode getResponseData(HttpEntity responseEntity) throws IOException { + public static JsonNode getResponseDataAsJsonNode(HttpEntity responseEntity) throws IOException { JsonFactory jsonFactory = new JsonFactory(); ObjectMapper objectMapper = new ObjectMapper(jsonFactory); JsonNode finalNode; try (InputStream inputStream = responseEntity.getContent()) { - String content = getResponseAsString(inputStream); + String content = getResponseDataAsString(inputStream); try { finalNode = objectMapper.readTree(content); } catch (JsonProcessingException e) { @@ -779,7 +779,7 @@ public class HandlerUtil { * @return String content of the incoming response * @throws IOException Throws when IO exception encountered */ - public static String getResponseAsString(InputStream inputStream) throws IOException { + public static String getResponseDataAsString(InputStream inputStream) throws IOException { char []buffer = new char[8192]; StringBuilder stringBuilder = new StringBuilder(); try (Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { From b7848fd0c315819f9082f60a4a833501305b2688 Mon Sep 17 00:00:00 2001 From: "amalka.subasinghe" Date: Mon, 24 Jun 2024 12:04:41 +0530 Subject: [PATCH 207/343] scopes and related permissions added when scope is not attached to an api --- .../pom.xml | 4 +++- .../webapp/publisher/APIPublisherServiceImpl.java | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 10bfbf4145..a668025519 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -205,7 +205,9 @@ org.wso2.carbon.utils;version="4.6", org.wso2.carbon.utils.multitenancy;version="4.6", org.apache.commons.lang, - org.json + org.json, + io.entgra.device.mgt.core.device.mgt.common.permission.mgt, + io.entgra.device.mgt.core.device.mgt.core.permission.mgt jsr311-api;scope=compile|runtime;inline=false diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index e9a58e556c..cab16f8482 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -46,6 +46,7 @@ import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; import io.entgra.device.mgt.core.device.mgt.core.config.permission.DefaultPermission; import io.entgra.device.mgt.core.device.mgt.core.config.permission.DefaultPermissions; import io.entgra.device.mgt.core.device.mgt.core.config.permission.ScopeMapping; +import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -68,6 +69,8 @@ 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 io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; +import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; import java.io.BufferedReader; import java.io.File; @@ -610,9 +613,17 @@ public class APIPublisherServiceImpl implements APIPublisherService { if (publisherRESTAPIServices.isSharedScopeNameExists(apiApplicationKey, accessTokenInfo, scope.getName())) { publisherRESTAPIServices.updateSharedScope(apiApplicationKey, accessTokenInfo, scope); + // todo: permission changed in update path, is not handled yet. } else { - // todo: come to this level means, that scope is removed from API, but haven't removed from the scope-role-permission-mappings list - log.warn(scope.getName() + " not available as shared scope"); + // This scope doesn't have an api attached. + log.warn(scope.getName() + " not available as shared, add as new scope"); + publisherRESTAPIServices.addNewSharedScope(apiApplicationKey, accessTokenInfo, scope); + // add permission if not exist + try { + PermissionUtils.putPermission(permission); + } catch(PermissionManagementException e) { + log.error("Error when adding permission ", e); + } } } for (String role : rolePermissions.keySet()) { From 01d76c6dbd251e090ea70d4e5f32f38e6ec54b40 Mon Sep 17 00:00:00 2001 From: Sasini Sandamali Date: Mon, 24 Jun 2024 14:21:34 +0000 Subject: [PATCH 208/343] Add necessary improvements and configs for grafana version 10.3.3 (#396) Co-authored-by: Sasini_Sandamali Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/396 Co-authored-by: Sasini Sandamali Co-committed-by: Sasini Sandamali --- .../proxy/api/GrafanaAPIProxyService.java | 50 +++++++++++++++++++ .../api/impl/GrafanaAPIProxyServiceImpl.java | 37 +++++++++++++- .../impl/util/GrafanaRequestHandlerUtil.java | 20 +++++--- .../core/config/GrafanaConfiguration.java | 11 ++++ .../config/xml/bean/ValidationConfig.java | 45 +++++++++++++++++ .../main/resources/conf/grafana-config.xml | 6 +++ .../grafana-config.xml.j2 | 6 +++ 7 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/config/xml/bean/ValidationConfig.java diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/GrafanaAPIProxyService.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/GrafanaAPIProxyService.java index 18fb6201af..5bdf335d30 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/GrafanaAPIProxyService.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/GrafanaAPIProxyService.java @@ -107,6 +107,23 @@ public interface GrafanaAPIProxyService { ) Response frontendMetrics(JsonObject body, @Context HttpHeaders headers, @Context UriInfo requestUriInfo); + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @Path("/user/auth-tokens/rotate") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Rotate authentication tokens", + tags = "Analytics", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "grafana:api:view") + }) + } + ) + Response rotateAuthToken(JsonObject body, @Context HttpHeaders headers, @Context UriInfo requestUriInfo); + @GET @Produces(MediaType.APPLICATION_JSON) @Path("/dashboards/uid/{uid}") @@ -123,6 +140,22 @@ public interface GrafanaAPIProxyService { ) Response getDashboard(@Context HttpHeaders headers, @Context UriInfo requestUriInfo) throws ClassNotFoundException; + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/folders/{uid}") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Grafana dashboard folder information", + tags = "Analytics", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "grafana:api:view") + }) + } + ) + Response getFolders(@Context HttpHeaders headers, @Context UriInfo requestUriInfo) throws ClassNotFoundException; + @GET @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -140,6 +173,23 @@ public interface GrafanaAPIProxyService { ) Response getAnnotations(@Context HttpHeaders headers, @Context UriInfo requestUriInfo) throws ClassNotFoundException; + @GET + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @Path("/prometheus/grafana/api/v1/rules") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Accessing Grafana Prometheus rule information", + tags = "Analytics", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "grafana:api:view") + }) + } + ) + Response prometheusRuleInfo(@Context HttpHeaders headers, @Context UriInfo requestUriInfo) throws ClassNotFoundException; + @GET @Produces(MediaType.APPLICATION_JSON) @Path("/alerts/states-for-dashboard") diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java index 8ed6fe1ca1..92eed32c74 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/GrafanaAPIProxyServiceImpl.java @@ -26,6 +26,8 @@ import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util.Grafa import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.impl.util.GrafanaRequestHandlerUtil; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception.GrafanaManagementException; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean.GrafanaPanelIdentifier; +import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config.GrafanaConfiguration; +import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config.GrafanaConfigurationManager; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.exception.MaliciousQueryAttempt; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -56,9 +58,13 @@ public class GrafanaAPIProxyServiceImpl implements GrafanaAPIProxyService { @Override public Response queryDatasource(JsonObject body, @Context HttpHeaders headers, @Context UriInfo requestUriInfo) { try { + GrafanaConfiguration configuration = GrafanaConfigurationManager.getInstance().getGrafanaConfiguration(); GrafanaPanelIdentifier panelIdentifier = GrafanaRequestHandlerUtil.getPanelIdentifier(headers); - GrafanaMgtAPIUtils.getGrafanaQueryService().buildSafeQuery(body, panelIdentifier.getDashboardId(), - panelIdentifier.getPanelId(), requestUriInfo.getRequestUri()); + boolean queryValidationConfig = configuration.getValidationConfig().getDSQueryValidation(); + if (queryValidationConfig) { + GrafanaMgtAPIUtils.getGrafanaQueryService().buildSafeQuery(body, panelIdentifier.getDashboardId(), + panelIdentifier.getPanelId(), requestUriInfo.getRequestUri()); + } return GrafanaRequestHandlerUtil.proxyPassPostRequest(body, requestUriInfo, panelIdentifier.getOrgId()); } catch (MaliciousQueryAttempt e) { return Response.status(Response.Status.BAD_REQUEST).entity( @@ -83,6 +89,15 @@ public class GrafanaAPIProxyServiceImpl implements GrafanaAPIProxyService { return proxyPassPostRequest(body, headers, requestUriInfo); } + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @Path("/user/auth-tokens/rotate") + @Override + public Response rotateAuthToken(JsonObject body, @Context HttpHeaders headers, @Context UriInfo requestUriInfo) { + return proxyPassPostRequest(body, headers, requestUriInfo); + } + @GET @Produces(MediaType.APPLICATION_JSON) @Path("/dashboards/uid/{uid}") @@ -91,6 +106,14 @@ public class GrafanaAPIProxyServiceImpl implements GrafanaAPIProxyService { return proxyPassGetRequest(headers, requestUriInfo); } + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/folders/{uid}") + @Override + public Response getFolders(@Context HttpHeaders headers, @Context UriInfo requestUriInfo) { + return proxyPassGetRequest(headers, requestUriInfo); + } + @GET @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -99,6 +122,16 @@ public class GrafanaAPIProxyServiceImpl implements GrafanaAPIProxyService { public Response getAnnotations(@Context HttpHeaders headers, @Context UriInfo requestUriInfo) { return proxyPassGetRequest(headers, requestUriInfo); } + + @GET + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @Path("/prometheus/grafana/api/v1/rules") + @Override + public Response prometheusRuleInfo(@Context HttpHeaders headers, @Context UriInfo requestUriInfo) { + return proxyPassGetRequest(headers, requestUriInfo); + } + @GET @Produces(MediaType.APPLICATION_JSON) @Path("/alerts/states-for-dashboard") diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaRequestHandlerUtil.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaRequestHandlerUtil.java index d81a6d4d26..e94b3ccf53 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaRequestHandlerUtil.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/api/impl/util/GrafanaRequestHandlerUtil.java @@ -22,6 +22,8 @@ import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.bean.ErrorRespo import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.exception.RefererNotValid; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception.GrafanaManagementException; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean.GrafanaPanelIdentifier; +import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config.GrafanaConfiguration; +import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config.GrafanaConfigurationManager; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.exception.GrafanaEnvVariablesNotDefined; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util.GrafanaConstants; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util.GrafanaUtil; @@ -120,19 +122,23 @@ public class GrafanaRequestHandlerUtil { return path; } - public static GrafanaPanelIdentifier getPanelIdentifier(HttpHeaders headers) throws RefererNotValid { + public static GrafanaPanelIdentifier getPanelIdentifier(HttpHeaders headers) throws RefererNotValid, GrafanaManagementException { String referer = headers.getHeaderString(GrafanaConstants.REFERER_HEADER); - if(referer == null) { + if (referer == null) { String errMsg = "Request does not contain Referer header"; log.error(errMsg); throw new RefererNotValid(errMsg); } + GrafanaConfiguration configuration = GrafanaConfigurationManager.getInstance().getGrafanaConfiguration(); + boolean dashboardIntegrationConfig = configuration.getValidationConfig().getDashboardIntegration(); GrafanaPanelIdentifier panelIdentifier = GrafanaUtil.getPanelIdentifierFromReferer(referer); - if(panelIdentifier.getDashboardId() == null || - panelIdentifier.getPanelId() == null || panelIdentifier.getOrgId() == null) { - String errMsg = "Referer must contain dashboardId, panelId and orgId"; - log.error(errMsg); - throw new RefererNotValid(errMsg); + if (!dashboardIntegrationConfig) { + if (panelIdentifier.getDashboardId() == null || + panelIdentifier.getPanelId() == null || panelIdentifier.getOrgId() == null) { + String errMsg = "Referer must contain dashboardId, panelId, and orgId"; + log.error(errMsg); + throw new RefererNotValid(errMsg); + } } return panelIdentifier; } diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/config/GrafanaConfiguration.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/config/GrafanaConfiguration.java index bf2cbce90f..137dc86025 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/config/GrafanaConfiguration.java +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/config/GrafanaConfiguration.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config.xml.bean.CacheConfiguration; +import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config.xml.bean.ValidationConfig; import io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config.xml.bean.User; import javax.xml.bind.annotation.XmlElement; @@ -30,6 +31,7 @@ import java.util.List; public class GrafanaConfiguration { private User adminUser; + private ValidationConfig validationConfig; private List caches; @XmlElement(name = "AdminUser") @@ -37,6 +39,15 @@ public class GrafanaConfiguration { return adminUser; } + @XmlElement(name = "ValidationConfig") + public ValidationConfig getValidationConfig() { + return validationConfig; + } + + public void setValidationConfig(ValidationConfig validationConfig) { + this.validationConfig = validationConfig; + } + public void setAdminUser(User user) { this.adminUser = user; } diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/config/xml/bean/ValidationConfig.java b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/config/xml/bean/ValidationConfig.java new file mode 100644 index 0000000000..b15955bbe2 --- /dev/null +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/src/main/java/io/entgra/device/mgt/core/analytics/mgt/grafana/proxy/core/config/xml/bean/ValidationConfig.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018 - 2024, 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.analytics.mgt.grafana.proxy.core.config.xml.bean; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "ValidationConfig") +public class ValidationConfig { + private boolean dsQueryValidation; + private boolean dashboardIntegration; + + @XmlElement(name = "DSQueryValidation") + public boolean getDSQueryValidation() { + return dsQueryValidation; + } + + public void setDSQueryValidation(boolean dsQueryValidation) { + this.dsQueryValidation = dsQueryValidation; + } + + @XmlElement(name = "DashboardIntegration") + public boolean getDashboardIntegration() { + return dashboardIntegration; + } + + public void setDashboardIntegration(boolean dashboardIntegration) { + this.dashboardIntegration = dashboardIntegration; + } +} diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/src/main/resources/conf/grafana-config.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/src/main/resources/conf/grafana-config.xml index f6ae22a601..e7b5a7bf3e 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/src/main/resources/conf/grafana-config.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/src/main/resources/conf/grafana-config.xml @@ -32,4 +32,10 @@ admin admin + + + true + + false + diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/src/main/resources/conf_templates.templates.repository.conf/grafana-config.xml.j2 b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/src/main/resources/conf_templates.templates.repository.conf/grafana-config.xml.j2 index 623a6cda06..dbf9d38a6e 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/src/main/resources/conf_templates.templates.repository.conf/grafana-config.xml.j2 +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/src/main/resources/conf_templates.templates.repository.conf/grafana-config.xml.j2 @@ -32,4 +32,10 @@ admin admin + + + true + + false + From 5c73277c32d80d629ab69e94035f5860727e0441 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Wed, 12 Jun 2024 12:37:25 +0530 Subject: [PATCH 209/343] Add FCM changes --- .../pom.xml | 8 ++- .../provider/fcm/FCMNotificationStrategy.java | 69 ++++++++++++++++--- pom.xml | 5 ++ 3 files changed, 73 insertions(+), 9 deletions(-) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index ffb529ef29..ea7aec37a0 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -111,6 +111,10 @@ org.wso2.carbon.analytics-common org.wso2.carbon.event.output.adapter.core + + com.google.auth + google-auth-library-oauth2-http + @@ -141,7 +145,9 @@ io.entgra.device.mgt.core.device.mgt.common.push.notification, org.apache.commons.logging, io.entgra.device.mgt.core.device.mgt.common.*, - io.entgra.device.mgt.core.device.mgt.core.service + io.entgra.device.mgt.core.device.mgt.core.service, + io.entgra.device.mgt.core.device.mgt.extensions.logger.spi, + io.entgra.device.mgt.core.notification.logger.* diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java index c6100aa418..669edd314a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java @@ -17,9 +17,14 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm; +import com.google.auth.oauth2.GoogleCredentials; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; +import com.hazelcast.aws.utility.Environment; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceConnectivityLoggerImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; @@ -30,10 +35,14 @@ import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotific import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationExecutionFailedException; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.internal.FCMDataHolder; -import java.io.IOException; -import java.io.OutputStream; +import java.io.*; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.Arrays; import java.util.List; public class FCMNotificationStrategy implements NotificationStrategy { @@ -42,7 +51,7 @@ public class FCMNotificationStrategy implements NotificationStrategy { private static final String NOTIFIER_TYPE_FCM = "FCM"; private static final String FCM_TOKEN = "FCM_TOKEN"; - private static final String FCM_ENDPOINT = "https://fcm.googleapis.com/fcm/send"; + private static final String FCM_ENDPOINT = "https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send"; private static final String FCM_API_KEY = "fcmAPIKey"; private static final int TIME_TO_LIVE = 2419199; // 1 second less that 28 days private static final int HTTP_STATUS_CODE_OK = 200; @@ -59,12 +68,13 @@ public class FCMNotificationStrategy implements NotificationStrategy { @Override public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException { + String token = getFcmOauthToken(); try { if (NOTIFIER_TYPE_FCM.equals(config.getType())) { Device device = FCMDataHolder.getInstance().getDeviceManagementProviderService() .getDeviceWithTypeProperties(ctx.getDeviceId()); if(device.getProperties() != null && getFCMToken(device.getProperties()) != null) { - this.sendWakeUpCall(ctx.getOperation().getCode(), device); + this.sendWakeUpCall(ctx.getOperation().getCode(), device, token); } } else { if (log.isDebugEnabled()) { @@ -79,6 +89,25 @@ public class FCMNotificationStrategy implements NotificationStrategy { } } + private String getFcmOauthToken() { + GoogleCredentials googleCredentials = null; + try { + googleCredentials = GoogleCredentials + .fromStream(new FileInputStream("/etc/service-account.json")) + .createScoped(Arrays.asList("https://www.googleapis.com/auth/firebase.messaging")); + googleCredentials.refresh(); + if (null != googleCredentials) { + writeLog("========= Google Credentials created " + googleCredentials.getAccessToken()); + } else { + writeLog("========= Google Credentials is null"); + } + return googleCredentials.getAccessToken().getTokenValue(); + } catch (IOException e) { + log.error("Error occurred while getting the FCM OAuth token.", e); + throw new RuntimeException(e); + } + } + @Override public NotificationContext buildContext() { return null; @@ -89,9 +118,10 @@ public class FCMNotificationStrategy implements NotificationStrategy { } - private void sendWakeUpCall(String message, Device device) throws IOException, + private void sendWakeUpCall(String message, Device device, String token) throws IOException, PushNotificationExecutionFailedException { if (device.getProperties() != null) { + writeLog("===== Calling senWakeupCall " + device); OutputStream os = null; byte[] bytes = getFCMRequest(message, getFCMToken(device.getProperties())).getBytes(); @@ -99,7 +129,7 @@ public class FCMNotificationStrategy implements NotificationStrategy { try { conn = (HttpURLConnection) new URL(FCM_ENDPOINT).openConnection(); conn.setRequestProperty("Content-Type", "application/json"); - conn.setRequestProperty("Authorization", "key=" + config.getProperty(FCM_API_KEY)); + conn.setRequestProperty("Authorization", "Bearer " + token); conn.setRequestMethod("POST"); conn.setDoOutput(true); os = conn.getOutputStream(); @@ -125,7 +155,16 @@ public class FCMNotificationStrategy implements NotificationStrategy { private static String getFCMRequest(String message, String registrationId) { JsonObject fcmRequest = new JsonObject(); - fcmRequest.addProperty("delay_while_idle", false); + JsonObject messageObject = new JsonObject(); + messageObject.addProperty("token", registrationId); + JsonObject notification = new JsonObject(); + notification.addProperty("title", "FCM Message"); + notification.addProperty("body", message); + messageObject.add("notification", notification); + fcmRequest.add("message", messageObject); + + + /*fcmRequest.addProperty("delay_while_idle", false); fcmRequest.addProperty("time_to_live", TIME_TO_LIVE); fcmRequest.addProperty("priority", "high"); @@ -140,7 +179,9 @@ public class FCMNotificationStrategy implements NotificationStrategy { JsonArray regIds = new JsonArray(); regIds.add(new JsonPrimitive(registrationId)); - fcmRequest.add("registration_ids", regIds); + fcmRequest.add("registration_ids", regIds);*/ + + writeLog("========= FCM Request " + fcmRequest); return fcmRequest.toString(); } @@ -155,9 +196,21 @@ public class FCMNotificationStrategy implements NotificationStrategy { return fcmToken; } + private static void writeLog(String message) { + try (FileWriter fw = new FileWriter("/opt/entgra/migration/entgra-uem-ultimate-6.0.3.0/log.txt", true); + BufferedWriter bw = new BufferedWriter(fw)) { + bw.write(message); + bw.newLine(); + bw.flush(); + } catch (IOException e) { + e.printStackTrace(); + } + } + @Override public PushNotificationConfig getConfig() { return config; } + } diff --git a/pom.xml b/pom.xml index 680a4ced22..516bd8e982 100644 --- a/pom.xml +++ b/pom.xml @@ -1916,6 +1916,11 @@ mockito-inline ${mokito.version} + + com.google.auth + google-auth-library-oauth2-http + 1.20.0 + From aafa824f0838cd64c86c11cd5b54bd79a3966c01 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Sun, 16 Jun 2024 15:51:56 +0530 Subject: [PATCH 210/343] Migrate from legacy FCM APIs to HTTP v1 --- .../pom.xml | 53 ++++- .../fcm/FCMBasedPushNotificationProvider.java | 4 +- .../provider/fcm/FCMNotificationStrategy.java | 207 ++++++++---------- .../push/notification/ContextMetadata.java | 30 +++ .../PushNotificationConfiguration.java | 11 + .../repository/conf/cdm-config.xml.j2 | 5 + pom.xml | 55 ++++- 7 files changed, 250 insertions(+), 115 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/ContextMetadata.java diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index ea7aec37a0..4d4bf35cf9 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -112,9 +112,45 @@ org.wso2.carbon.event.output.adapter.core - com.google.auth + org.wso2.orbit.com.google.http-client + google-http-client + + + org.wso2.orbit.com.google.auth-library-oauth2-http google-auth-library-oauth2-http + + org.wso2.orbit.io.opencensus + opencensus + + + io.opencensus + opencensus-api + + + io.opencensus + opencensus-contrib-http-util + + + org.wso2.orbit.io.grpc + grpc-context + + + com.google.http-client + google-http-client-gson + + + com.google.guava + failureaccess + + + com.google.guava + guava + + + org.wso2.carbon + org.wso2.carbon.utils + @@ -141,14 +177,27 @@ com.google.gson, org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", + org.wso2.carbon.utils.*, io.entgra.device.mgt.core.device.mgt.common.operation.mgt, io.entgra.device.mgt.core.device.mgt.common.push.notification, org.apache.commons.logging, io.entgra.device.mgt.core.device.mgt.common.*, io.entgra.device.mgt.core.device.mgt.core.service, + io.entgra.device.mgt.core.device.mgt.core.config.*, + io.entgra.device.mgt.core.device.mgt.core.config.push.notification.*, io.entgra.device.mgt.core.device.mgt.extensions.logger.spi, - io.entgra.device.mgt.core.notification.logger.* + io.entgra.device.mgt.core.notification.logger.*, + com.google.auth.oauth2.* + + google-auth-library-oauth2-http;scope=compile|runtime, + google-http-client;scope=compile|runtime, + grpc-context;scope=compile|runtime, + guava;scope=compile|runtime, + opencensus;scope=compile|runtime, + failureaccess;scope=compile|runtime + + true diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java index 1dbbacd720..2f849a4366 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java @@ -32,7 +32,9 @@ public class FCMBasedPushNotificationProvider implements PushNotificationProvide @Override public NotificationStrategy getNotificationStrategy(PushNotificationConfig config) { - return new FCMNotificationStrategy(config); + FCMNotificationStrategy fcmNotificationStrategy = new FCMNotificationStrategy(config); + fcmNotificationStrategy.init(); + return fcmNotificationStrategy; } } diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java index 669edd314a..f003983360 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java @@ -18,13 +18,10 @@ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm; import com.google.auth.oauth2.GoogleCredentials; -import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.hazelcast.aws.utility.Environment; -import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationManagerImpl; -import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; -import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceConnectivityLoggerImpl; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.ContextMetadata; +import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.PushNotificationConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; @@ -34,28 +31,34 @@ import io.entgra.device.mgt.core.device.mgt.common.push.notification.Notificatio import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationExecutionFailedException; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.internal.FCMDataHolder; +import org.wso2.carbon.utils.CarbonUtils; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; -import java.util.Arrays; import java.util.List; +import java.util.Properties; public class FCMNotificationStrategy implements NotificationStrategy { private static final Log log = LogFactory.getLog(FCMNotificationStrategy.class); - private static final String NOTIFIER_TYPE_FCM = "FCM"; private static final String FCM_TOKEN = "FCM_TOKEN"; - private static final String FCM_ENDPOINT = "https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send"; private static final String FCM_API_KEY = "fcmAPIKey"; - private static final int TIME_TO_LIVE = 2419199; // 1 second less that 28 days + private static final int TIME_TO_LIVE = 2419199; // 1 second less than 28 days private static final int HTTP_STATUS_CODE_OK = 200; private final PushNotificationConfig config; + private static final String FCM_SERVICE_ACCOUNT_PATH = CarbonUtils.getCarbonHome() + File.separator + + "repository" + File.separator + "resources" + File.separator + "service-account.json"; + private static final String[] FCM_SCOPES = { "https://www.googleapis.com/auth/firebase.messaging" }; + private static final String FCM_ENDPOINT_KEY = "FCM_SERVER_ENDPOINT"; + private Properties contextMetadataProperties; + private volatile GoogleCredentials defaultApplication; public FCMNotificationStrategy(PushNotificationConfig config) { this.config = config; @@ -63,23 +66,25 @@ public class FCMNotificationStrategy implements NotificationStrategy { @Override public void init() { - + initContextConfigs(); + initDefaultOAuthApplication(); } @Override public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException { - String token = getFcmOauthToken(); try { if (NOTIFIER_TYPE_FCM.equals(config.getType())) { Device device = FCMDataHolder.getInstance().getDeviceManagementProviderService() .getDeviceWithTypeProperties(ctx.getDeviceId()); if(device.getProperties() != null && getFCMToken(device.getProperties()) != null) { - this.sendWakeUpCall(ctx.getOperation().getCode(), device, token); + defaultApplication.refresh(); + sendWakeUpCall(defaultApplication.getAccessToken().getTokenValue(), + getFCMToken(device.getProperties())); } } else { if (log.isDebugEnabled()) { log.debug("Not using FCM notifier as notifier type is set to " + config.getType() + - " in Platform Configurations."); + " in Platform Configurations."); } } } catch (DeviceManagementException e) { @@ -89,25 +94,85 @@ public class FCMNotificationStrategy implements NotificationStrategy { } } - private String getFcmOauthToken() { - GoogleCredentials googleCredentials = null; - try { - googleCredentials = GoogleCredentials - .fromStream(new FileInputStream("/etc/service-account.json")) - .createScoped(Arrays.asList("https://www.googleapis.com/auth/firebase.messaging")); - googleCredentials.refresh(); - if (null != googleCredentials) { - writeLog("========= Google Credentials created " + googleCredentials.getAccessToken()); - } else { - writeLog("========= Google Credentials is null"); + private void initDefaultOAuthApplication() { + if (defaultApplication == null) { + synchronized (FCMNotificationStrategy.class) { + if (defaultApplication == null) { + Path serviceAccountPath = Paths.get(FCM_SERVICE_ACCOUNT_PATH); + try { + this.defaultApplication = GoogleCredentials. + fromStream(Files.newInputStream(serviceAccountPath)). + createScoped(FCM_SCOPES); + } catch (IOException e) { + log.error("Fail to initialize default OAuth application for FCM communication"); + throw new IllegalStateException(e); + } + } } - return googleCredentials.getAccessToken().getTokenValue(); - } catch (IOException e) { - log.error("Error occurred while getting the FCM OAuth token.", e); - throw new RuntimeException(e); } } + private void initContextConfigs() { + PushNotificationConfiguration pushNotificationConfiguration = DeviceConfigurationManager.getInstance(). + getDeviceManagementConfig().getPushNotificationConfiguration(); + List contextMetadata = pushNotificationConfiguration.getContextMetadata(); + Properties properties = new Properties(); + if (contextMetadata != null) { + for (ContextMetadata metadata : contextMetadata) { + properties.setProperty(metadata.getKey(), metadata.getValue()); + } + } + contextMetadataProperties = properties; + } + + private void sendWakeUpCall(String accessToken, String registrationId) throws IOException, + PushNotificationExecutionFailedException { + OutputStream os = null; + HttpURLConnection conn = null; + + String fcmServerEndpoint = contextMetadataProperties.getProperty(FCM_ENDPOINT_KEY); + if(fcmServerEndpoint == null) { + String msg = "Encountered configuration issue. " + FCM_ENDPOINT_KEY + " is not defined"; + log.error(msg); + throw new PushNotificationExecutionFailedException(msg); + } + + try { + byte[] bytes = getFCMRequest(registrationId).getBytes(); + URL url = new URL(fcmServerEndpoint); + conn = (HttpURLConnection) url.openConnection(); + conn.setRequestProperty("Content-Type", "application/json"); + conn.setRequestProperty("Authorization", "Bearer " + accessToken); + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + + os = conn.getOutputStream(); + os.write(bytes); + + int status = conn.getResponseCode(); + if (status != 200) { + log.error("Response Status: " + status + ", Response Message: " + conn.getResponseMessage()); + } + } finally { + if (os != null) { + os.close(); + } + if (conn != null) { + conn.disconnect(); + } + } + } + + private static String getFCMRequest(String registrationId) { + JsonObject messageObject = new JsonObject(); + messageObject.addProperty("token", registrationId); + + JsonObject fcmRequest = new JsonObject(); + fcmRequest.add("message", messageObject); + + return fcmRequest.toString(); + } + @Override public NotificationContext buildContext() { return null; @@ -118,73 +183,6 @@ public class FCMNotificationStrategy implements NotificationStrategy { } - private void sendWakeUpCall(String message, Device device, String token) throws IOException, - PushNotificationExecutionFailedException { - if (device.getProperties() != null) { - writeLog("===== Calling senWakeupCall " + device); - OutputStream os = null; - byte[] bytes = getFCMRequest(message, getFCMToken(device.getProperties())).getBytes(); - - HttpURLConnection conn = null; - try { - conn = (HttpURLConnection) new URL(FCM_ENDPOINT).openConnection(); - conn.setRequestProperty("Content-Type", "application/json"); - conn.setRequestProperty("Authorization", "Bearer " + token); - conn.setRequestMethod("POST"); - conn.setDoOutput(true); - os = conn.getOutputStream(); - os.write(bytes); - } finally { - if (os != null) { - os.close(); - } - if (conn != null) { - conn.disconnect(); - } - } - int status = conn.getResponseCode(); - if (log.isDebugEnabled()) { - log.debug("Result code: " + status + ", Message: " + conn.getResponseMessage()); - } - if (status != HTTP_STATUS_CODE_OK) { - throw new PushNotificationExecutionFailedException("Push notification sending failed with the HTTP " + - "error code '" + status + "'"); - } - } - } - - private static String getFCMRequest(String message, String registrationId) { - JsonObject fcmRequest = new JsonObject(); - JsonObject messageObject = new JsonObject(); - messageObject.addProperty("token", registrationId); - JsonObject notification = new JsonObject(); - notification.addProperty("title", "FCM Message"); - notification.addProperty("body", message); - messageObject.add("notification", notification); - fcmRequest.add("message", messageObject); - - - /*fcmRequest.addProperty("delay_while_idle", false); - fcmRequest.addProperty("time_to_live", TIME_TO_LIVE); - fcmRequest.addProperty("priority", "high"); - - //Add message to FCM request - JsonObject data = new JsonObject(); - if (message != null && !message.isEmpty()) { - data.addProperty("data", message); - fcmRequest.add("data", data); - } - - //Set device reg-id - JsonArray regIds = new JsonArray(); - regIds.add(new JsonPrimitive(registrationId)); - - fcmRequest.add("registration_ids", regIds);*/ - - writeLog("========= FCM Request " + fcmRequest); - return fcmRequest.toString(); - } - private static String getFCMToken(List properties) { String fcmToken = null; for (Device.Property property : properties) { @@ -196,21 +194,8 @@ public class FCMNotificationStrategy implements NotificationStrategy { return fcmToken; } - private static void writeLog(String message) { - try (FileWriter fw = new FileWriter("/opt/entgra/migration/entgra-uem-ultimate-6.0.3.0/log.txt", true); - BufferedWriter bw = new BufferedWriter(fw)) { - bw.write(message); - bw.newLine(); - bw.flush(); - } catch (IOException e) { - e.printStackTrace(); - } - } - @Override public PushNotificationConfig getConfig() { return config; } - - } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/ContextMetadata.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/ContextMetadata.java new file mode 100644 index 0000000000..9f89474766 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/ContextMetadata.java @@ -0,0 +1,30 @@ +package io.entgra.device.mgt.core.device.mgt.core.config.push.notification; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; + +@XmlRootElement(name = "ContextMetadata") +public class ContextMetadata { + private String key; + private String value; + + @XmlAttribute(name = "key") + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + @XmlValue + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/PushNotificationConfiguration.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/PushNotificationConfiguration.java index 90c6639cb1..0d64e45cdd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/PushNotificationConfiguration.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/PushNotificationConfiguration.java @@ -33,6 +33,7 @@ public class PushNotificationConfiguration { private int schedulerTaskInitialDelay; private boolean schedulerTaskEnabled; private List pushNotificationProviders; + private List contextMetadata; @XmlElement(name = "SchedulerBatchSize", required = true) public int getSchedulerBatchSize() { @@ -79,4 +80,14 @@ public class PushNotificationConfiguration { public void setPushNotificationProviders(List pushNotificationProviders) { this.pushNotificationProviders = pushNotificationProviders; } + + @XmlElementWrapper(name = "ProviderContextMetadata") + @XmlElement(name = "ContextMetadata", required = true) + public List getContextMetadata() { + return contextMetadata; + } + + public void setContextMetadata(List contextMetadata) { + this.contextMetadata = contextMetadata; + } } diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index 59e026f679..2d5f7639f8 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -48,6 +48,11 @@ {% endfor %} {% endif %} + {% if device_mgt_conf.push_notification_conf.fcm_server_endpoint is defined %} + + {{device_mgt_conf.push_notification_conf.fcm_server_endpoint}} + + {% endif %} {% if device_mgt_conf.pull_notification_conf is defined %} diff --git a/pom.xml b/pom.xml index 516bd8e982..2c7c6c6af3 100644 --- a/pom.xml +++ b/pom.xml @@ -405,7 +405,11 @@ ${io.entgra.device.mgt.core.version} - + + org.wso2.orbit.com.google.auth-library-oauth2-http + google-auth-library-oauth2-http + 1.20.0.wso2v1 + org.wso2.carbon @@ -1921,6 +1925,46 @@ google-auth-library-oauth2-http 1.20.0 + + org.wso2.orbit.com.google.http-client + google-http-client + ${com.google.http.client.version} + + + org.wso2.orbit.com.google.auth-library-oauth2-http + google-auth-library-oauth2-http + ${com.google.auth.library.auth2.http.version} + + + org.wso2.orbit.io.opencensus + opencensus + ${io.opencensus.version} + + + io.opencensus + opencensus-api + ${io.opencensus.api.version} + + + io.opencensus + opencensus-contrib-http-util + ${io.opencensus.contrib.http.util.version} + + + org.wso2.orbit.io.grpc + grpc-context + ${io.grpc.context.version} + + + com.google.http-client + google-http-client-gson + ${com.google.http.client.gson.version} + + + com.google.guava + failureaccess + ${com.google.failureaccess.version} + @@ -2311,6 +2355,15 @@ 4.3.1.wso2v1 1.4.199.wso2v1 1.1.3 + + 1.20.0.wso2v1 + 1.41.2.wso2v2 + 1.0.1 + 1.43.3 + 1.27.2.wso2v1 + 0.30.0.wso2v1 + 0.30.0 + 0.30.0 From b1d3503e8b3505907116d1fe4ead9f97f9bb99f1 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Sun, 16 Jun 2024 18:11:19 +0530 Subject: [PATCH 211/343] Add improvements to Google API token generation in FCM --- .../provider/fcm/FCMNotificationStrategy.java | 44 ++-------- .../provider/fcm/util/FCMUtil.java | 80 +++++++++++++++++++ 2 files changed, 85 insertions(+), 39 deletions(-) create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java index f003983360..033ef30293 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java @@ -22,6 +22,7 @@ import com.google.gson.JsonObject; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.ContextMetadata; import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.PushNotificationConfiguration; +import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.util.FCMUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; @@ -53,12 +54,7 @@ public class FCMNotificationStrategy implements NotificationStrategy { private static final int TIME_TO_LIVE = 2419199; // 1 second less than 28 days private static final int HTTP_STATUS_CODE_OK = 200; private final PushNotificationConfig config; - private static final String FCM_SERVICE_ACCOUNT_PATH = CarbonUtils.getCarbonHome() + File.separator + - "repository" + File.separator + "resources" + File.separator + "service-account.json"; - private static final String[] FCM_SCOPES = { "https://www.googleapis.com/auth/firebase.messaging" }; private static final String FCM_ENDPOINT_KEY = "FCM_SERVER_ENDPOINT"; - private Properties contextMetadataProperties; - private volatile GoogleCredentials defaultApplication; public FCMNotificationStrategy(PushNotificationConfig config) { this.config = config; @@ -66,8 +62,7 @@ public class FCMNotificationStrategy implements NotificationStrategy { @Override public void init() { - initContextConfigs(); - initDefaultOAuthApplication(); + } @Override @@ -77,8 +72,8 @@ public class FCMNotificationStrategy implements NotificationStrategy { Device device = FCMDataHolder.getInstance().getDeviceManagementProviderService() .getDeviceWithTypeProperties(ctx.getDeviceId()); if(device.getProperties() != null && getFCMToken(device.getProperties()) != null) { - defaultApplication.refresh(); - sendWakeUpCall(defaultApplication.getAccessToken().getTokenValue(), + FCMUtil.getInstance().getDefaultApplication().refresh(); + sendWakeUpCall(FCMUtil.getInstance().getDefaultApplication().getAccessToken().getTokenValue(), getFCMToken(device.getProperties())); } } else { @@ -94,43 +89,14 @@ public class FCMNotificationStrategy implements NotificationStrategy { } } - private void initDefaultOAuthApplication() { - if (defaultApplication == null) { - synchronized (FCMNotificationStrategy.class) { - if (defaultApplication == null) { - Path serviceAccountPath = Paths.get(FCM_SERVICE_ACCOUNT_PATH); - try { - this.defaultApplication = GoogleCredentials. - fromStream(Files.newInputStream(serviceAccountPath)). - createScoped(FCM_SCOPES); - } catch (IOException e) { - log.error("Fail to initialize default OAuth application for FCM communication"); - throw new IllegalStateException(e); - } - } - } - } - } - private void initContextConfigs() { - PushNotificationConfiguration pushNotificationConfiguration = DeviceConfigurationManager.getInstance(). - getDeviceManagementConfig().getPushNotificationConfiguration(); - List contextMetadata = pushNotificationConfiguration.getContextMetadata(); - Properties properties = new Properties(); - if (contextMetadata != null) { - for (ContextMetadata metadata : contextMetadata) { - properties.setProperty(metadata.getKey(), metadata.getValue()); - } - } - contextMetadataProperties = properties; - } private void sendWakeUpCall(String accessToken, String registrationId) throws IOException, PushNotificationExecutionFailedException { OutputStream os = null; HttpURLConnection conn = null; - String fcmServerEndpoint = contextMetadataProperties.getProperty(FCM_ENDPOINT_KEY); + String fcmServerEndpoint = FCMUtil.getInstance().getContextMetadataProperties().getProperty(FCM_ENDPOINT_KEY); if(fcmServerEndpoint == null) { String msg = "Encountered configuration issue. " + FCM_ENDPOINT_KEY + " is not defined"; log.error(msg); diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java new file mode 100644 index 0000000000..66212fc49b --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java @@ -0,0 +1,80 @@ +package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.util; + +import com.google.auth.oauth2.GoogleCredentials; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.ContextMetadata; +import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.PushNotificationConfiguration; +import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMNotificationStrategy; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.utils.CarbonUtils; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Properties; + +public class FCMUtil { + + private static final Log log = LogFactory.getLog(FCMUtil.class); + private static volatile FCMUtil instance; + private static GoogleCredentials defaultApplication; + private static final String FCM_SERVICE_ACCOUNT_PATH = CarbonUtils.getCarbonHome() + File.separator + + "repository" + File.separator + "resources" + File.separator + "service-account.json"; + private static final String[] FCM_SCOPES = { "https://www.googleapis.com/auth/firebase.messaging" }; + private Properties contextMetadataProperties; + + private FCMUtil() { + initContextConfigs(); + initDefaultOAuthApplication(); + } + + private void initDefaultOAuthApplication() { + if (defaultApplication == null) { + Path serviceAccountPath = Paths.get(FCM_SERVICE_ACCOUNT_PATH); + try { + defaultApplication = GoogleCredentials. + fromStream(Files.newInputStream(serviceAccountPath)). + createScoped(FCM_SCOPES); + } catch (IOException e) { + log.error("Fail to initialize default OAuth application for FCM communication"); + throw new IllegalStateException(e); + } + } + } + + private void initContextConfigs() { + PushNotificationConfiguration pushNotificationConfiguration = DeviceConfigurationManager.getInstance(). + getDeviceManagementConfig().getPushNotificationConfiguration(); + List contextMetadata = pushNotificationConfiguration.getContextMetadata(); + Properties properties = new Properties(); + if (contextMetadata != null) { + for (ContextMetadata metadata : contextMetadata) { + properties.setProperty(metadata.getKey(), metadata.getValue()); + } + } + contextMetadataProperties = properties; + } + + public static FCMUtil getInstance() { + if (instance == null) { + synchronized (FCMUtil.class) { + if (instance == null) { + instance = new FCMUtil(); + } + } + } + return instance; + } + + public GoogleCredentials getDefaultApplication() { + return defaultApplication; + } + + public Properties getContextMetadataProperties() { + return contextMetadataProperties; + } +} From c38aea743bb6b69e62fda0cf4fb2c63f508857c6 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Tue, 25 Jun 2024 17:30:33 +0530 Subject: [PATCH 212/343] Add missing license headers --- .../notification/provider/fcm/util/FCMUtil.java | 17 +++++++++++++++++ .../push/notification/ContextMetadata.java | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java index 66212fc49b..11cef37c0f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.extensions.push.notification.provider.fcm.util; import com.google.auth.oauth2.GoogleCredentials; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/ContextMetadata.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/ContextMetadata.java index 9f89474766..a5ead67f0a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/ContextMetadata.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/push/notification/ContextMetadata.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2018 - 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.device.mgt.core.config.push.notification; import javax.xml.bind.annotation.XmlAttribute; From 502e89ecf3c4c5593259d878b78b4066ed41ecf1 Mon Sep 17 00:00:00 2001 From: "osh.silva" Date: Fri, 28 Jun 2024 09:10:57 +0530 Subject: [PATCH 213/343] Add status scope to mdm-config --- .../src/main/resources/conf/mdm-ui-config.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 8303fc6402..32dc388789 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -421,6 +421,7 @@ dm:admin:cea:delete dm:admin:cea:sync am:pub:app:upload + dm:devices:ops:status:update device-mgt From fc269dba22e6a1a77a479f94b27d91dcae8fdaee Mon Sep 17 00:00:00 2001 From: nipuni Date: Fri, 28 Jun 2024 07:22:47 +0530 Subject: [PATCH 214/343] Add backend implementation to get devices not in a group. --- .../service/api/DeviceManagementService.java | 6 + .../impl/DeviceManagementServiceImpl.java | 18 +- .../impl/DeviceManagementServiceImplTest.java | 34 ++-- .../core/device/mgt/core/dao/DeviceDAO.java | 20 ++ .../core/dao/impl/AbstractDeviceDAOImpl.java | 108 +++++++++++ .../dao/impl/device/GenericDeviceDAOImpl.java | 172 +++++++++++++++++- .../DeviceManagementProviderService.java | 13 ++ .../DeviceManagementProviderServiceImpl.java | 55 ++++++ 8 files changed, 406 insertions(+), 20 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index a028654cdc..5c41168bcb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -310,6 +310,12 @@ public interface DeviceManagementService { required = false) @QueryParam("groupId") int groupId, + @ApiParam( + name = "excludeGroupId", + value = "Id of the group that needs to get the devices that are not belong.", + required = false) + @QueryParam("excludeGroupId") + int excludeGroupId, @ApiParam( name = "since", value = "Checks if the requested variant was created since the specified date-time.\n" + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 58259e19c8..4a141ca30c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -147,6 +147,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @QueryParam("customProperty") String customProperty, @QueryParam("status") List status, @QueryParam("groupId") int groupId, + @QueryParam("excludeGroupId") int excludeGroupId, @QueryParam("since") String since, @HeaderParam("If-Modified-Since") String ifModifiedSince, @QueryParam("requireDeviceInfo") boolean requireDeviceInfo, @@ -209,7 +210,22 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { request.setStatusList(status); } } - // this is the user who initiates the request + + if (excludeGroupId != 0) { + request.setGroupId(excludeGroupId); + + if (user != null && !user.isEmpty()) { + request.setOwner(MultitenantUtils.getTenantAwareUsername(user)); + } else if (userPattern != null && !userPattern.isEmpty()) { + request.setOwnerPattern(userPattern); + } + + result = dms.getDevicesNotInGroup(request, requireDeviceInfo); + devices.setList((List) result.getData()); + devices.setCount(result.getRecordsTotal()); + return Response.status(Response.Status.OK).entity(devices).build(); + } + String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername(); if (groupId != 0) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java index 63bb401d61..b66773e84d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java @@ -157,7 +157,7 @@ public class DeviceManagementServiceImplTest { .toReturn(this.deviceAccessAuthorizationService); Response response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, false, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -177,22 +177,22 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null,null, DEFAULT_STATUS_LIST, 1, null, null, false, + null,null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, null, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, false, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, null, null, null, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, false, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, null, null, null, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, true, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, true, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -307,7 +307,7 @@ public class DeviceManagementServiceImplTest { Mockito.when(deviceAccessAuthorizationService.isDeviceAdminUser()).thenReturn(true); deviceManagementService.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null,null, DEFAULT_STATUS_LIST, 1, - null, null, false, 10, 5); + 0, null, null, false, 10, 5); } @Test(description = "Testing get devices when user is the device admin") @@ -326,11 +326,11 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP - , null, null, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + , null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, null, DEFAULT_USERNAME, DEFAULT_ROLE, DEFAULT_OWNERSHIP - , null, null, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + , null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -352,7 +352,7 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, "newuser", null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 0, null, null, false, + null, null, DEFAULT_STATUS_LIST, 0, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode()); Mockito.reset(this.deviceAccessAuthorizationService); @@ -374,17 +374,17 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, false, + null, null, DEFAULT_STATUS_LIST, 0, 0, null, ifModifiedSince, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, true, + null, null, DEFAULT_STATUS_LIST, 0, 0, null, ifModifiedSince, true, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 0, null, "ErrorModifiedSince", + null, null, DEFAULT_STATUS_LIST, 0, 0, null, "ErrorModifiedSince", false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -405,17 +405,17 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null,DEFAULT_STATUS_LIST, 0, since, null, false, + null, null,DEFAULT_STATUS_LIST, 0, 0, since, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null,DEFAULT_STATUS_LIST, 0, since, null, true, + null, null,DEFAULT_STATUS_LIST, 0, 0, since, null, true, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null,DEFAULT_STATUS_LIST, 0, "ErrorSince", null, false, + null, null,DEFAULT_STATUS_LIST, 0, 0, "ErrorSince", null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -438,7 +438,7 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, false, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); Mockito.reset(this.deviceManagementProviderService); @@ -461,7 +461,7 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, false, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); Mockito.reset(this.deviceAccessAuthorizationService); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java index 731bb11d59..b71b6cd640 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java @@ -844,4 +844,24 @@ public interface DeviceDAO { List getAgentVersions(int tenantId) throws DeviceManagementDAOException; List getDevicesEnrolledSince(Date since) throws DeviceManagementDAOException; List getDevicesEnrolledPriorTo(Date priorTo) throws DeviceManagementDAOException; + + /** + * This method is used to search for devices that are not in a specific group. + * + * @param request PaginationRequest object holding the data for pagination + * @param tenantId tenant id. + * @return returns paginated list of devices. + * @throws DeviceManagementDAOException + */ + List searchDevicesNotInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException; + + /** + * This method is used to get device count that are not within a specific group. + * + * @param request PaginationRequest object holding the data for pagination + * @param tenantId tenant id + * @return Device count + * @throws DeviceManagementDAOException + */ + int getCountOfDevicesNotInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index ec03136c6b..6ca1095faf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -3190,4 +3190,112 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { public abstract void refactorDeviceStatus (Connection conn, List validDevices) throws DeviceManagementDAOException; + @Override + public int getCountOfDevicesNotInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException { + int deviceCount = 0; + int groupId = request.getGroupId(); + String deviceType = request.getDeviceType(); + boolean isDeviceTypeProvided = false; + String deviceName = request.getDeviceName(); + boolean isDeviceNameProvided = false; + String owner = request.getOwner(); + boolean isOwnerProvided = false; + String ownerPattern = request.getOwnerPattern(); + boolean isOwnerPatternProvided = false; + String ownership = request.getOwnership(); + boolean isOwnershipProvided = false; + List statusList = request.getStatusList(); + boolean isStatusProvided = false; + Date since = request.getSince(); + boolean isSinceProvided = false; + + try { + Connection conn = getConnection(); + String sql = "SELECT COUNT(d1.DEVICE_ID) AS DEVICE_COUNT " + + "FROM DM_ENROLMENT e, " + + "(SELECT gd.ID AS DEVICE_ID, " + + "gd.DESCRIPTION, " + + "gd.NAME, " + + "gd.DEVICE_IDENTIFICATION " + + "FROM DM_DEVICE gd " + + "WHERE gd.ID NOT IN (SELECT dgm.DEVICE_ID " + + "FROM DM_DEVICE_GROUP_MAP dgm " + + "WHERE dgm.GROUP_ID = ?) " + + "AND gd.TENANT_ID = ?"; + + if (deviceName != null && !deviceName.isEmpty()) { + sql += " AND gd.NAME LIKE ?"; + isDeviceNameProvided = true; + } + sql += " AND 1=1"; + + if (since != null) { + sql += " AND gd.LAST_UPDATED_TIMESTAMP > ?"; + isSinceProvided = true; + } + sql += " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND e.TENANT_ID = ?"; + + if (deviceType != null && !deviceType.isEmpty()) { + sql += " AND e.DEVICE_TYPE = ?"; + isDeviceTypeProvided = true; + } + + if (ownership != null && !ownership.isEmpty()) { + sql += " AND e.OWNERSHIP = ?"; + isOwnershipProvided = true; + } + + if (owner != null && !owner.isEmpty()) { + sql += " AND e.OWNER = ?"; + isOwnerProvided = true; + } else if (ownerPattern != null && !ownerPattern.isEmpty()) { + sql += " AND e.OWNER LIKE ?"; + isOwnerPatternProvided = true; + } + if (statusList != null && !statusList.isEmpty()) { + sql += buildStatusQuery(statusList); + isStatusProvided = true; + } + + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + int paramIdx = 1; + stmt.setInt(paramIdx++, groupId); + stmt.setInt(paramIdx++, tenantId); + if (isDeviceNameProvided) { + stmt.setString(paramIdx++, "%" + deviceName + "%"); + } + if (isSinceProvided) { + stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); + } + stmt.setInt(paramIdx++, tenantId); + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, deviceType); + } + if (isOwnershipProvided) { + stmt.setString(paramIdx++, ownership); + } + if (isOwnerProvided) { + stmt.setString(paramIdx++, owner); + } else if (isOwnerPatternProvided) { + stmt.setString(paramIdx++, ownerPattern + "%"); + } + if (isStatusProvided) { + for (String status : statusList) { + stmt.setString(paramIdx++, status); + } + } + + try (ResultSet rs = stmt.executeQuery()) { + if (rs.next()) { + deviceCount = rs.getInt("DEVICE_COUNT"); + } + return deviceCount; + } + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving count of devices not in group: " + groupId; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index d1ea236645..e2063761db 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -724,7 +724,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } //Add the query for owner if (owner != null && !owner.isEmpty()) { - sql = sql + " AND e.OWNER = ?"; + sql = sql + " AND e.OWNER LIKE ?"; isOwnerProvided = true; } else if (ownerPattern != null && !ownerPattern.isEmpty()) { sql = sql + " AND e.OWNER LIKE ?"; @@ -776,7 +776,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, ownership); } if (isOwnerProvided) { - stmt.setString(paramIdx++, owner); + stmt.setString(paramIdx++, "%" + owner + "%"); } else if (isOwnerPatternProvided) { stmt.setString(paramIdx++, ownerPattern + "%"); } @@ -1689,4 +1689,172 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } } + @Override + public List searchDevicesNotInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException { + List devices = null; + int groupId = request.getGroupId(); + String deviceType = request.getDeviceType(); + boolean isDeviceTypeProvided = false; + String deviceName = request.getDeviceName(); + boolean isDeviceNameProvided = false; + String owner = request.getOwner(); + boolean isOwnerProvided = false; + String ownerPattern = request.getOwnerPattern(); + boolean isOwnerPatternProvided = false; + String ownership = request.getOwnership(); + boolean isOwnershipProvided = false; + List statusList = request.getStatusList(); + boolean isStatusProvided = false; + Date since = request.getSince(); + boolean isSinceProvided = false; + String serial = request.getSerialNumber(); + boolean isSerialProvided = false; + + try { + Connection conn = getConnection(); + String sql = "SELECT d1.DEVICE_ID, " + + "d1.DESCRIPTION, " + + "d1.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE, " + + "d1.DEVICE_IDENTIFICATION, " + + "d1.LAST_UPDATED_TIMESTAMP, " + + "e.OWNER, " + + "e.OWNERSHIP, " + + "e.STATUS, " + + "e.IS_TRANSFERRED, " + + "e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, " + + "e.ID AS ENROLMENT_ID " + + "FROM DM_ENROLMENT e, " + + "(SELECT gd.DEVICE_ID, " + + "gd.DESCRIPTION, " + + "gd.NAME, " + + "gd.DEVICE_IDENTIFICATION, " + + "gd.LAST_UPDATED_TIMESTAMP " + + "FROM " + + "(SELECT d.ID AS DEVICE_ID, " + + "d.DESCRIPTION, " + + "d.NAME, " + + "d.DEVICE_IDENTIFICATION, " + + "d.LAST_UPDATED_TIMESTAMP " + + "FROM DM_DEVICE d " + + "WHERE d.ID NOT IN " + + "(SELECT dgm.DEVICE_ID " + + "FROM DM_DEVICE_GROUP_MAP dgm " + + "WHERE dgm.GROUP_ID = ?) " + + "AND d.TENANT_ID = ?"; + + if (deviceName != null && !deviceName.isEmpty()) { + sql = sql + " AND d.NAME LIKE ?"; + isDeviceNameProvided = true; + } + sql = sql + ") gd"; + sql = sql + " WHERE 1 = 1"; + + if (since != null) { + sql = sql + " AND gd.LAST_UPDATED_TIMESTAMP > ?"; + isSinceProvided = true; + } + sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND e.TENANT_ID = ? "; + + if (deviceType != null && !deviceType.isEmpty()) { + sql = sql + " AND e.DEVICE_TYPE = ?"; + isDeviceTypeProvided = true; + } + + if (ownership != null && !ownership.isEmpty()) { + sql = sql + " AND e.OWNERSHIP = ?"; + isOwnershipProvided = true; + } + + if (owner != null && !owner.isEmpty()) { + sql = sql + " AND e.OWNER LIKE ?"; + isOwnerProvided = true; + } else if (ownerPattern != null && !ownerPattern.isEmpty()) { + sql = sql + " AND e.OWNER LIKE ?"; + isOwnerPatternProvided = true; + } + if (statusList != null && !statusList.isEmpty()) { + sql += buildStatusQuery(statusList); + isStatusProvided = true; + } + + if (serial != null || !request.getCustomProperty().isEmpty()) { + if (serial != null) { + sql += "AND EXISTS (" + + "SELECT VALUE_FIELD " + + "FROM DM_DEVICE_INFO di " + + "WHERE di.DEVICE_ID = d1.DEVICE_ID " + + "AND di.KEY_FIELD = 'serial' " + + "AND di.VALUE_FIELD LIKE ?) "; + isSerialProvided = true; + } + if (!request.getCustomProperty().isEmpty()) { + for (Map.Entry entry : request.getCustomProperty().entrySet()) { + sql += "AND EXISTS (" + + "SELECT VALUE_FIELD " + + "FROM DM_DEVICE_INFO di2 " + + "WHERE di2.DEVICE_ID = d1.DEVICE_ID " + + "AND di2.KEY_FIELD = '" + entry.getKey() + "' " + + "AND di2.VALUE_FIELD LIKE ?)"; + } + } + } + sql = sql + " LIMIT ? OFFSET ?"; + + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + int paramIdx = 1; + stmt.setInt(paramIdx++, groupId); + stmt.setInt(paramIdx++, tenantId); + if (isDeviceNameProvided) { + stmt.setString(paramIdx++, "%" + deviceName + "%"); + } + if (isSinceProvided) { + stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); + } + stmt.setInt(paramIdx++, tenantId); + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, deviceType); + } + if (isOwnershipProvided) { + stmt.setString(paramIdx++, ownership); + } + if (isOwnerProvided) { + stmt.setString(paramIdx++, "%" + owner + "%"); + } else if (isOwnerPatternProvided) { + stmt.setString(paramIdx++, "%" + ownerPattern + "%"); + } + if (isStatusProvided) { + for (String status : statusList) { + stmt.setString(paramIdx++, status); + } + } + if (isSerialProvided) { + stmt.setString(paramIdx++, "%" + serial + "%"); + } + if (!request.getCustomProperty().isEmpty()) { + for (Map.Entry entry : request.getCustomProperty().entrySet()) { + stmt.setString(paramIdx++, "%" + entry.getValue() + "%"); + } + } + stmt.setInt(paramIdx++, request.getRowCount()); + stmt.setInt(paramIdx, request.getStartIndex()); + + try (ResultSet rs = stmt.executeQuery()) { + devices = new ArrayList<>(); + while (rs.next()) { + Device device = DeviceManagementDAOUtil.loadDevice(rs); + devices.add(device); + } + return devices; + } + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving information of" + + " devices not belonging to group : " + groupId; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index 689fc1b243..1775d7ab55 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -1073,4 +1073,17 @@ public interface DeviceManagementProviderService { List getEnrolledDevicesSince(Date since) throws DeviceManagementException; List getEnrolledDevicesPriorTo(Date before) throws DeviceManagementException; void deleteDeviceDataByTenantDomain(String tenantDomain) throws DeviceManagementException; + + /** + * Method to retrieve all the devices that are not in a group with pagination support. + * + * @param request PaginationRequest object holding the data for pagination + * @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required + * along with the device data. + * @return PaginationResult - Result including the required parameters necessary to do pagination. + * @throws DeviceManagementException If some unusual behaviour is observed while fetching the + * devices. + */ + PaginationResult getDevicesNotInGroup(PaginationRequest request, boolean requireDeviceInfo) + throws DeviceManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 75f3836a34..3ccc1f2983 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -5339,4 +5339,59 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.closeConnection(); } } + + @Override + public PaginationResult getDevicesNotInGroup(PaginationRequest request, boolean requireDeviceInfo) + throws DeviceManagementException { + if (request == null) { + String msg = "Received incomplete pagination request for method getDevicesNotInGroup"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get devices not in group with pagination " + request.toString() + + " and requiredDeviceInfo: " + requireDeviceInfo); + } + PaginationResult paginationResult = new PaginationResult(); + List devicesNotInGroup = null; + int count = 0; + int tenantId = this.getTenantId(); + DeviceManagerUtil.validateDeviceListPageSize(request); + + try { + DeviceManagementDAOFactory.openConnection(); + if (request.getGroupId() != 0) { + devicesNotInGroup = deviceDAO.searchDevicesNotInGroup(request, tenantId); + count = deviceDAO.getCountOfDevicesNotInGroup(request, tenantId); + } else { + String msg = "Group ID is not provided for method getDevicesNotInGroup"; + log.error(msg); + throw new DeviceManagementException(msg); + } + } catch (DeviceManagementDAOException e) { + String msg = "Error occurred while retrieving device list that are not in the specified group for the current tenant"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevicesNotInGroup"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + + if (requireDeviceInfo && devicesNotInGroup != null && !devicesNotInGroup.isEmpty()) { + paginationResult.setData(populateAllDeviceInfo(devicesNotInGroup)); + } else { + paginationResult.setData(devicesNotInGroup); + } + + paginationResult.setRecordsFiltered(count); + paginationResult.setRecordsTotal(count); + return paginationResult; + } } From 05ce0dd0b4dbf114e9a18fdb7a4519c80b93b898 Mon Sep 17 00:00:00 2001 From: Oshani Silva Date: Sun, 30 Jun 2024 10:49:36 +0000 Subject: [PATCH 215/343] Add fix for multiple device app activity details retrieval fixes https://roadmap.entgra.net/issues/10260 Co-authored-by: Oshani Silva Co-committed-by: Oshani Silva --- .../dao/impl/subscription/GenericSubscriptionDAOImpl.java | 4 ++-- .../device/mgt/core/application/mgt/core/util/DAOUtil.java | 1 - .../api/jaxrs/service/impl/ActivityProviderServiceImpl.java | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 79e7b76660..cc3a289a4b 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -1445,13 +1445,13 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc + "AR.PACKAGE_NAME, " + "AR.VERSION, " + "DS.SUBSCRIBED_BY, " - + "DS.STATUS, " + "DS.ACTION_TRIGGERED_FROM " + "FROM AP_APP_SUB_OP_MAPPING SOP " + "JOIN AP_DEVICE_SUBSCRIPTION DS ON SOP.AP_DEVICE_SUBSCRIPTION_ID = DS.ID " + "JOIN AP_APP_RELEASE AR ON DS.AP_APP_RELEASE_ID = AR.ID " + "JOIN AP_APP AP ON AP.ID = AR.AP_APP_ID " - + " WHERE SOP.OPERATION_ID = ? AND SOP.TENANT_ID = ?"; + + "WHERE SOP.OPERATION_ID = ? AND SOP.TENANT_ID = ? " + + "LIMIT 1"; Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java index 2177c6ad13..6b06a7aa62 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/DAOUtil.java @@ -383,7 +383,6 @@ public class DAOUtil { activity.setAppType(rs.getString("TYPE")); activity.setUsername(rs.getString("SUBSCRIBED_BY")); activity.setPackageName(rs.getString("PACKAGE_NAME")); - activity.setStatus(rs.getString("STATUS")); activity.setVersion(rs.getString("VERSION")); activity.setTriggeredBy(rs.getString("ACTION_TRIGGERED_FROM")); activities.add(activity); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java index a4148f07a8..bcfdb69aac 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java @@ -175,7 +175,6 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService activity.setUsername(appActivity.getUsername()); activity.setPackageName(appActivity.getPackageName()); activity.setAppName(appActivity.getAppName()); - activity.setStatus(appActivity.getStatus()); activity.setAppType(appActivity.getAppType()); activity.setVersion(appActivity.getVersion()); activity.setTriggeredBy(appActivity.getTriggeredBy()); From 6099c68d881412ff3dc1cb852bbacac516a00e6e Mon Sep 17 00:00:00 2001 From: Kavin Prathaban Date: Sun, 30 Jun 2024 16:06:00 +0000 Subject: [PATCH 216/343] Add application installation monitoring feature (#436) ## Purpose * Fixes https://roadmap.entgra.net/issues/11098 Co-authored-by: Kavin Prathaban Co-committed-by: Kavin Prathaban --- .../common/CategorizedSubscriptionResult.java | 103 ++ .../mgt/common/DeviceSubscriptionData.java | 98 +- .../dto/CategorizedSubscriptionCountsDTO.java | 55 + .../mgt/common/dto/DeviceOperationDTO.java | 126 ++ .../mgt/common/dto/DeviceSubscriptionDTO.java | 82 +- .../dto/DeviceSubscriptionResponseDTO.java | 60 + .../mgt/common/dto/GroupSubscriptionDTO.java | 18 + .../mgt/common/dto/RoleSubscriptionDTO.java | 98 +- .../common/dto/SubscriptionResponseDTO.java | 52 + .../mgt/common/dto/SubscriptionsDTO.java | 162 +++ .../common/services/SubscriptionManager.java | 99 +- .../mgt/core/dao/SubscriptionDAO.java | 202 ++- .../GenericSubscriptionDAOImpl.java | 803 ++++++++++++ .../core/impl/SubscriptionManagerImpl.java | 1104 ++++++++++++++++- .../application/mgt/core/BaseTestCase.java | 2 + .../device/mgt/core/dao/EnrollmentDAO.java | 31 + .../core/device/mgt/core/dao/GroupDAO.java | 15 +- .../dao/impl/AbstractEnrollmentDAOImpl.java | 113 +- .../core/dao/impl/AbstractGroupDAOImpl.java | 90 +- .../device/mgt/core/dto/DeviceDetailsDTO.java | 49 + .../device/mgt/core/dto/GroupDetailsDTO.java | 115 ++ .../device/mgt/core/dto/OperationDTO.java | 72 ++ .../mgt/core/dto/OperationResponseDTO.java} | 31 +- .../mgt/core/dto/OwnerWithDeviceDTO.java | 70 ++ .../core/operation/mgt/dao/OperationDAO.java | 13 + .../mgt/dao/impl/GenericOperationDAOImpl.java | 76 +- .../mgt/dao/util/OperationDAOUtil.java | 53 + .../DeviceManagementProviderService.java | 38 + .../DeviceManagementProviderServiceImpl.java | 110 ++ .../GroupManagementProviderService.java | 13 + .../GroupManagementProviderServiceImpl.java | 36 +- .../type/template/BaseExtensionsTest.java | 2 + 32 files changed, 3869 insertions(+), 122 deletions(-) create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/CategorizedSubscriptionCountsDTO.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceOperationDTO.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionResponseDTO.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionResponseDTO.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionsDTO.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/GroupDetailsDTO.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OperationDTO.java rename components/{application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/UserSubscriptionDTO.java => device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OperationResponseDTO.java} (55%) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OwnerWithDeviceDTO.java diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java new file mode 100644 index 0000000000..28cc436115 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common; + +import java.util.List; + +public class CategorizedSubscriptionResult { + private List installedDevices; + private List pendingDevices; + private List errorDevices; + private List newDevices; + private List subscribedDevices; + + public CategorizedSubscriptionResult(List installedDevices, + List pendingDevices, + List errorDevices) { + this.installedDevices = installedDevices; + this.pendingDevices = pendingDevices; + this.errorDevices = errorDevices; + this.newDevices = null; + this.subscribedDevices = null; + } + + public CategorizedSubscriptionResult(List installedDevices, + List pendingDevices, + List errorDevices, + List newDevices) { + this.installedDevices = installedDevices; + this.pendingDevices = pendingDevices; + this.errorDevices = errorDevices; + this.newDevices = newDevices; + this.subscribedDevices = null; + } + + public CategorizedSubscriptionResult(List installedDevices, + List pendingDevices, + List errorDevices, + List newDevices, + List subscribedDevices) { + this.installedDevices = installedDevices; + this.pendingDevices = pendingDevices; + this.errorDevices = errorDevices; + this.newDevices = newDevices; + this.subscribedDevices = subscribedDevices; + } + + public List getInstalledDevices() { + return installedDevices; + } + + public void setInstalledDevices(List installedDevices) { + this.installedDevices = installedDevices; + } + + public List getPendingDevices() { + return pendingDevices; + } + + public void setPendingDevices(List pendingDevices) { + this.pendingDevices = pendingDevices; + } + + public List getErrorDevices() { + return errorDevices; + } + + public void setErrorDevices(List errorDevices) { + this.errorDevices = errorDevices; + } + + public List getNewDevices() { + return newDevices; + } + + public void setNewDevices(List newDevices) { + this.newDevices = newDevices; + } + + public List getSubscribedDevices() { + return subscribedDevices; + } + + public void setSubscribedDevices(List subscribedDevices) { + this.subscribedDevices = subscribedDevices; + } +} + diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java index 55f2ec9edc..465db48c53 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java @@ -26,12 +26,20 @@ public class DeviceSubscriptionData { private int subId; private String action; - private long actionTriggeredTimestamp; + private Timestamp actionTriggeredTimestamp; + private String actionTriggeredFrom; private String actionTriggeredBy; private String actionType; private String status; private Device device; private String currentInstalledVersion; + private int deviceId; + private String deviceOwner; + private String deviceStatus; + private boolean unsubscribed; + private String unsubscribedBy; + private Timestamp unsubscribedTimestamp; + private String deviceName; public String getAction() { return action; @@ -41,14 +49,6 @@ public class DeviceSubscriptionData { this.action = action; } - public long getActionTriggeredTimestamp() { - return actionTriggeredTimestamp; - } - - public void setActionTriggeredTimestamp(long actionTriggeredTimestamp) { - this.actionTriggeredTimestamp = actionTriggeredTimestamp; - } - public String getActionTriggeredBy() { return actionTriggeredBy; } @@ -81,9 +81,13 @@ public class DeviceSubscriptionData { this.device = device; } - public String getCurrentInstalledVersion() { return currentInstalledVersion; } + public String getCurrentInstalledVersion() { + return currentInstalledVersion; + } - public void setCurrentInstalledVersion(String currentInstalledVersion) { this.currentInstalledVersion = currentInstalledVersion; } + public void setCurrentInstalledVersion(String currentInstalledVersion) { + this.currentInstalledVersion = currentInstalledVersion; + } public int getSubId() { return subId; @@ -92,4 +96,76 @@ public class DeviceSubscriptionData { public void setSubId(int subId) { this.subId = subId; } + + public int getDeviceId() { + return deviceId; + } + + public void setDeviceId(int deviceId) { + this.deviceId = deviceId; + } + + public String getActionTriggeredFrom() { + return actionTriggeredFrom; + } + + public void setActionTriggeredFrom(String actionTriggeredFrom) { + this.actionTriggeredFrom = actionTriggeredFrom; + } + + public Timestamp getActionTriggeredTimestamp() { + return actionTriggeredTimestamp; + } + + public void setActionTriggeredTimestamp(Timestamp actionTriggeredTimestamp) { + this.actionTriggeredTimestamp = actionTriggeredTimestamp; + } + + public String getDeviceOwner() { + return deviceOwner; + } + + public void setDeviceOwner(String deviceOwner) { + this.deviceOwner = deviceOwner; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public boolean isUnsubscribed() { + return unsubscribed; + } + + public void setUnsubscribed(boolean unsubscribed) { + this.unsubscribed = unsubscribed; + } + + public String getUnsubscribedBy() { + return unsubscribedBy; + } + + public void setUnsubscribedBy(String unsubscribedBy) { + this.unsubscribedBy = unsubscribedBy; + } + + public Timestamp getUnsubscribedTimestamp() { + return unsubscribedTimestamp; + } + + public void setUnsubscribedTimestamp(Timestamp unsubscribedTimestamp) { + this.unsubscribedTimestamp = unsubscribedTimestamp; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/CategorizedSubscriptionCountsDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/CategorizedSubscriptionCountsDTO.java new file mode 100644 index 0000000000..2ee5bb3cb0 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/CategorizedSubscriptionCountsDTO.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common.dto; + +public class CategorizedSubscriptionCountsDTO { + private String subscriptionType; + private int subscriptionCount; + private int unsubscriptionCount; + + public CategorizedSubscriptionCountsDTO(String subscriptionType, int subscriptionCount, int unsubscriptionCount) { + this.subscriptionType = subscriptionType; + this.subscriptionCount = subscriptionCount; + this.unsubscriptionCount = unsubscriptionCount; + } + + public String getSubscriptionType() { + return subscriptionType; + } + + public void setSubscriptionType(String subscriptionType) { + this.subscriptionType = subscriptionType; + } + + public int getSubscriptionCount() { + return subscriptionCount; + } + + public void setSubscriptionCount(int subscriptionCount) { + this.subscriptionCount = subscriptionCount; + } + + public int getUnsubscriptionCount() { + return unsubscriptionCount; + } + + public void setUnsubscriptionCount(int unsubscriptionCount) { + this.unsubscriptionCount = unsubscriptionCount; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceOperationDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceOperationDTO.java new file mode 100644 index 0000000000..75699431a2 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceOperationDTO.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common.dto; + +import io.entgra.device.mgt.core.device.mgt.core.dto.OperationResponseDTO; + +import java.sql.Timestamp; +import java.util.List; + +public class DeviceOperationDTO { + private int deviceId; + private String uuid; + private String status; + private int operationId; + private String actionTriggeredFrom; + private Timestamp actionTriggeredAt; + private int appReleaseId; + private String operationCode; + private Object operationDetails; + private Object operationProperties; + private List operationResponses; + + public int getDeviceId() { + return deviceId; + } + + public void setDeviceId(int deviceId) { + this.deviceId = deviceId; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public int getOperationId() { + return operationId; + } + + public void setOperationId(int operationId) { + this.operationId = operationId; + } + + public String getActionTriggeredFrom() { + return actionTriggeredFrom; + } + + public void setActionTriggeredFrom(String actionTriggeredFrom) { + this.actionTriggeredFrom = actionTriggeredFrom; + } + + public Timestamp getActionTriggeredAt() { + return actionTriggeredAt; + } + + public void setActionTriggeredAt(Timestamp actionTriggeredAt) { + this.actionTriggeredAt = actionTriggeredAt; + } + + public int getAppReleaseId() { + return appReleaseId; + } + + public void setAppReleaseId(int appReleaseId) { + this.appReleaseId = appReleaseId; + } + + public String getOperationCode() { + return operationCode; + } + + public void setOperationCode(String operationCode) { + this.operationCode = operationCode; + } + + public Object getOperationDetails() { + return operationDetails; + } + + public void setOperationDetails(Object operationDetails) { + this.operationDetails = operationDetails; + } + + public Object getOperationProperties() { + return operationProperties; + } + + public void setOperationProperties(Object operationProperties) { + this.operationProperties = operationProperties; + } + + public List getOperationResponses() { + return operationResponses; + } + + public void setOperationResponses(List operationResponses) { + this.operationResponses = operationResponses; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionDTO.java index 9a30ec07c2..3306256b19 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionDTO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionDTO.java @@ -31,44 +31,94 @@ public class DeviceSubscriptionDTO { private String actionTriggeredFrom; private String status; private int deviceId; + private int appReleaseId; + private String appUuid; - public int getId() { return id; } + public int getId() { + return id; + } - public void setId(int id) { this.id = id; } + public void setId(int id) { + this.id = id; + } - public String getSubscribedBy() { return subscribedBy; } + public String getSubscribedBy() { + return subscribedBy; + } - public void setSubscribedBy(String subscribedBy) { this.subscribedBy = subscribedBy; } + public void setSubscribedBy(String subscribedBy) { + this.subscribedBy = subscribedBy; + } - public Timestamp getSubscribedTimestamp() { return subscribedTimestamp; } + public Timestamp getSubscribedTimestamp() { + return subscribedTimestamp; + } public void setSubscribedTimestamp(Timestamp subscribedTimestamp) { this.subscribedTimestamp = subscribedTimestamp; } - public boolean isUnsubscribed() { return isUnsubscribed; } + public boolean isUnsubscribed() { + return isUnsubscribed; + } - public void setUnsubscribed(boolean unsubscribed) { isUnsubscribed = unsubscribed; } + public void setUnsubscribed(boolean unsubscribed) { + isUnsubscribed = unsubscribed; + } - public String getUnsubscribedBy() { return unsubscribedBy; } + public String getUnsubscribedBy() { + return unsubscribedBy; + } - public void setUnsubscribedBy(String unsubscribedBy) { this.unsubscribedBy = unsubscribedBy; } + public void setUnsubscribedBy(String unsubscribedBy) { + this.unsubscribedBy = unsubscribedBy; + } - public Timestamp getUnsubscribedTimestamp() { return unsubscribedTimestamp; } + public Timestamp getUnsubscribedTimestamp() { + return unsubscribedTimestamp; + } public void setUnsubscribedTimestamp(Timestamp unsubscribedTimestamp) { this.unsubscribedTimestamp = unsubscribedTimestamp; } - public String getActionTriggeredFrom() { return actionTriggeredFrom; } + public String getActionTriggeredFrom() { + return actionTriggeredFrom; + } - public void setActionTriggeredFrom(String actionTriggeredFrom) { this.actionTriggeredFrom = actionTriggeredFrom; } + public void setActionTriggeredFrom(String actionTriggeredFrom) { + this.actionTriggeredFrom = actionTriggeredFrom; + } - public String getStatus() { return status; } + public String getStatus() { + return status; + } - public void setStatus(String status) { this.status = status; } + public void setStatus(String status) { + this.status = status; + } - public int getDeviceId() { return deviceId; } + public int getDeviceId() { + return deviceId; + } - public void setDeviceId(int deviceId) { this.deviceId = deviceId; } + public void setDeviceId(int deviceId) { + this.deviceId = deviceId; + } + + public int getAppReleaseId() { + return appReleaseId; + } + + public void setAppReleaseId(int appReleaseId) { + this.appReleaseId = appReleaseId; + } + + public String getAppUuid() { + return appUuid; + } + + public void setAppUuid(String appUuid) { + this.appUuid = appUuid; + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionResponseDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionResponseDTO.java new file mode 100644 index 0000000000..5d132bfd37 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionResponseDTO.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common.dto; + +import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult; + +import java.util.Map; + +public class DeviceSubscriptionResponseDTO { + private int deviceCount; + private Map statusPercentages; + private CategorizedSubscriptionResult devices; + + public DeviceSubscriptionResponseDTO(int deviceCount, Map statusPercentages, + CategorizedSubscriptionResult devices) { + this.deviceCount = deviceCount; + this.statusPercentages = statusPercentages; + this.devices = devices; + } + + public int getDeviceCount() { + return deviceCount; + } + + public void setDeviceCount(int deviceCount) { + this.deviceCount = deviceCount; + } + + public Map getStatusPercentages() { + return statusPercentages; + } + + public void setStatusPercentages(Map statusPercentages) { + this.statusPercentages = statusPercentages; + } + + public CategorizedSubscriptionResult getDevices() { + return devices; + } + + public void setDevices(CategorizedSubscriptionResult devices) { + this.devices = devices; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/GroupSubscriptionDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/GroupSubscriptionDTO.java index 3d9e6dfd2c..76a7b39d2d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/GroupSubscriptionDTO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/GroupSubscriptionDTO.java @@ -22,6 +22,7 @@ import java.sql.Timestamp; public class GroupSubscriptionDTO { private int id; + private String groupName; private String subscribedBy; private Timestamp subscribedTimestamp; private boolean isUnsubscribed; @@ -29,6 +30,7 @@ public class GroupSubscriptionDTO { private Timestamp unsubscribedTimestamp; private String subscribedFrom; private int groupdId; + private int appReleaseId; public int getId() { return id; } @@ -61,4 +63,20 @@ public class GroupSubscriptionDTO { public int getGroupdId() { return groupdId; } public void setGroupdId(int groupdId) { this.groupdId = groupdId; } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public int getAppReleaseId() { + return appReleaseId; + } + + public void setAppReleaseId(int appReleaseId) { + this.appReleaseId = appReleaseId; + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/RoleSubscriptionDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/RoleSubscriptionDTO.java index 869ed1fd6d..b8139181de 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/RoleSubscriptionDTO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/RoleSubscriptionDTO.java @@ -18,51 +18,115 @@ package io.entgra.device.mgt.core.application.mgt.common.dto; +import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult; + import java.sql.Timestamp; +import java.util.Map; public class RoleSubscriptionDTO { - private int id; private String subscribedBy; private Timestamp subscribedTimestamp; private boolean isUnsubscribed; + private boolean unsubscribed; private String unsubscribedBy; private Timestamp unsubscribedTimestamp; private String subscribedFrom; private String roleName; + private int appReleaseId; + private int deviceCount; + private Map statusPercentages; + private CategorizedSubscriptionResult devices; - public int getId() { return id; } + public String getSubscribedBy() { + return subscribedBy; + } - public void setId(int id) { this.id = id; } + public void setSubscribedBy(String subscribedBy) { + this.subscribedBy = subscribedBy; + } - public String getSubscribedBy() { return subscribedBy; } - - public void setSubscribedBy(String subscribedBy) { this.subscribedBy = subscribedBy; } - - public Timestamp getSubscribedTimestamp() { return subscribedTimestamp; } + public Timestamp getSubscribedTimestamp() { + return subscribedTimestamp; + } public void setSubscribedTimestamp(Timestamp subscribedTimestamp) { this.subscribedTimestamp = subscribedTimestamp; } - public boolean isUnsubscribed() { return isUnsubscribed; } + public boolean getUnsubscribed() { + return unsubscribed; + } - public void setUnsubscribed(boolean unsubscribed) { isUnsubscribed = unsubscribed; } + public void setUnsubscribed(boolean unsubscribed) { + this.unsubscribed = unsubscribed; + } - public String getUnsubscribedBy() { return unsubscribedBy; } + public boolean isUnsubscribed() { + return isUnsubscribed; + } - public void setUnsubscribedBy(String unsubscribedBy) { this.unsubscribedBy = unsubscribedBy; } + public String getUnsubscribedBy() { + return unsubscribedBy; + } - public Timestamp getUnsubscribedTimestamp() { return unsubscribedTimestamp; } + public void setUnsubscribedBy(String unsubscribedBy) { + this.unsubscribedBy = unsubscribedBy; + } + + public Timestamp getUnsubscribedTimestamp() { + return unsubscribedTimestamp; + } public void setUnsubscribedTimestamp(Timestamp unsubscribedTimestamp) { this.unsubscribedTimestamp = unsubscribedTimestamp; } - public String getSubscribedFrom() { return subscribedFrom; } + public String getSubscribedFrom() { + return subscribedFrom; + } - public void setSubscribedFrom(String subscribedFrom) { this.subscribedFrom = subscribedFrom; } + public void setSubscribedFrom(String subscribedFrom) { + this.subscribedFrom = subscribedFrom; + } - public String getRoleName() { return roleName; } + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public int getAppReleaseId() { + return appReleaseId; + } + + public void setAppReleaseId(int appReleaseId) { + this.appReleaseId = appReleaseId; + } + + public int getDeviceCount() { + return deviceCount; + } + + public void setDeviceCount(int deviceCount) { + this.deviceCount = deviceCount; + } + + public Map getStatusPercentages() { + return statusPercentages; + } + + public void setStatusPercentages(Map statusPercentages) { + this.statusPercentages = statusPercentages; + } + + public CategorizedSubscriptionResult getDevices() { + return devices; + } + + public void setDevices(CategorizedSubscriptionResult devices) { + this.devices = devices; + } - public void setRoleName(String roleName) { this.roleName = roleName; } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionResponseDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionResponseDTO.java new file mode 100644 index 0000000000..03967ec94d --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionResponseDTO.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common.dto; + +import java.util.List; + +public class SubscriptionResponseDTO { + + private String UUID; + private List subscriptions; + private List DevicesOperations; + + public String getUUID() { + return UUID; + } + + public void setUUID(String UUID) { + this.UUID = UUID; + } + + public List getDevicesOperations() { + return DevicesOperations; + } + + public void setDevicesOperations(List devicesOperations) { + DevicesOperations = devicesOperations; + } + + public List getSubscriptions() { + return subscriptions; + } + + public void setSubscriptions(List subscriptions) { + this.subscriptions = subscriptions; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionsDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionsDTO.java new file mode 100644 index 0000000000..cb127696e3 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionsDTO.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common.dto; + +import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult; + +import java.sql.Timestamp; +import java.util.Map; + +public class SubscriptionsDTO { + private int id; + private String owner; + private String name; + private String subscribedBy; + private Timestamp subscribedTimestamp; + private boolean unsubscribed; + private String unsubscribedBy; + private Timestamp unsubscribedTimestamp; + private String subscribedFrom; + private int appReleaseId; + private int deviceCount; + private String deviceOwner; + private String deviceStatus; + private Map statusPercentages; + private CategorizedSubscriptionResult devices; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSubscribedBy() { + return subscribedBy; + } + + public void setSubscribedBy(String subscribedBy) { + this.subscribedBy = subscribedBy; + } + + public Timestamp getSubscribedTimestamp() { + return subscribedTimestamp; + } + + public void setSubscribedTimestamp(Timestamp subscribedTimestamp) { + this.subscribedTimestamp = subscribedTimestamp; + } + + public String getUnsubscribedBy() { + return unsubscribedBy; + } + + public void setUnsubscribedBy(String unsubscribedBy) { + this.unsubscribedBy = unsubscribedBy; + } + + public Timestamp getUnsubscribedTimestamp() { + return unsubscribedTimestamp; + } + + public void setUnsubscribedTimestamp(Timestamp unsubscribedTimestamp) { + this.unsubscribedTimestamp = unsubscribedTimestamp; + } + + public String getSubscribedFrom() { + return subscribedFrom; + } + + public void setSubscribedFrom(String subscribedFrom) { + this.subscribedFrom = subscribedFrom; + } + + public int getAppReleaseId() { + return appReleaseId; + } + + public void setAppReleaseId(int appReleaseId) { + this.appReleaseId = appReleaseId; + } + + public int getDeviceCount() { + return deviceCount; + } + + public void setDeviceCount(int deviceCount) { + this.deviceCount = deviceCount; + } + + public String getDeviceOwner() { + return deviceOwner; + } + + public void setDeviceOwner(String deviceOwner) { + this.deviceOwner = deviceOwner; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public Map getStatusPercentages() { + return statusPercentages; + } + + public void setStatusPercentages(Map statusPercentages) { + this.statusPercentages = statusPercentages; + } + + public CategorizedSubscriptionResult getDevices() { + return devices; + } + + public void setDevices(CategorizedSubscriptionResult devices) { + this.devices = devices; + } + + public boolean getUnsubscribed() { + return unsubscribed; + } + + public void setUnsubscribed(boolean unsubscribed) { + this.unsubscribed = unsubscribed; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java index e06a17cb9b..1cbeda5f08 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java @@ -18,11 +18,16 @@ package io.entgra.device.mgt.core.application.mgt.common.services; import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse; +import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; +import io.entgra.device.mgt.core.application.mgt.common.dto.CategorizedSubscriptionCountsDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionResponseDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; -import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; @@ -194,7 +199,7 @@ public interface SubscriptionManager { * application release for given UUID, if an error occurred while getting device details of subscribed device ids, * if an error occurred while getting subscription details of given application release UUID. */ - PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus, String action, String installedVersion) + CategorizedSubscriptionResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus, String action, String installedVersion) throws ApplicationManagementException; /*** @@ -217,4 +222,94 @@ public interface SubscriptionManager { * @throws {@link SubscriptionManagementException} Exception of the subscription management */ Activity getOperationAppDetails(String id) throws SubscriptionManagementException; + + /** + * Retrieves the group details associated with a given app release UUID. + * + * @param uuid the UUID of the app release + * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link SubscriptionsDTO} which contains the details of subscriptions. + * @throws ApplicationManagementException if an error occurs while fetching the group details + */ + List getGroupsSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, int limit) + throws ApplicationManagementException; + + /** + * Retrieves the user details associated with a given app release UUID. + * + * @param uuid the UUID of the app release + * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link SubscriptionsDTO} which contains the details of subscriptions. + * @throws ApplicationManagementException if an error occurs while fetching the user details + */ + List getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) + throws ApplicationManagementException; + + /** + * Retrieves the Role details associated with a given app release UUID. + * + * @param uuid the UUID of the app release + * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link SubscriptionsDTO} which contains the details of subscriptions. + * @throws ApplicationManagementException if an error occurs while fetching the role details + */ + List getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) + throws ApplicationManagementException; + + /** + * Retrieves the Device Subscription details associated with a given app release UUID. + * + * @param uuid the UUID of the app release + * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link DeviceSubscriptionResponseDTO} which contains the details of device subscriptions. + * @throws ApplicationManagementException if an error occurs while fetching the device subscription details + */ + DeviceSubscriptionResponseDTO getDeviceSubscriptionsDetailsByUUID(String uuid, String subscriptionStatus, int offset, int limit) + throws ApplicationManagementException; + + /** + * Retrieves the All Device details associated with a given app release UUID. + * + * @param uuid the UUID of the app release + * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link DeviceSubscriptionResponseDTO} which contains the details of device subscriptions. + * @throws ApplicationManagementException if an error occurs while fetching the subscription details + */ + DeviceSubscriptionResponseDTO getAllSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, int limit) + throws ApplicationManagementException; + + /** + * This method is responsible for retrieving device subscription details related to the given UUID. + * + * @param deviceId the deviceId of the device that need to get operation details. + * @param uuid the UUID of the application release. + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. + * @throws SubscriptionManagementException if there is an error while fetching the details. + */ + List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit) + throws ApplicationManagementException; + + /** + * This method is responsible for retrieving device counts details related to the given UUID. + * + * @param uuid the UUID of the application release. + * @return {@link List} which contains counts of subscriptions + and unsubscription for each subscription type. + * @throws SubscriptionManagementException if there is an error while fetching the details. + */ + List getSubscriptionCountsByUUID(String uuid) + throws ApplicationManagementException; + } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java index 3213db3484..88465a4533 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java @@ -18,8 +18,11 @@ package io.entgra.device.mgt.core.application.mgt.core.dao; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; @@ -312,4 +315,201 @@ public interface SubscriptionDAO { * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data */ void deleteScheduledSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the details of group subscriptions related to a appReleaseId. + * + * @param appReleaseId the appReleaseId of the application release. + * @param unsubscribe the Status of the subscription. + * @param tenantId id of the current tenant. + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link GroupSubscriptionDTO} which contains the details of group subscriptions. + * @throws ApplicationManagementDAOException if connection establishment fails. + */ + List getGroupsSubscriptionDetailsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) + throws ApplicationManagementDAOException; + + /** + * This method is used to get the details of user subscriptions related to a appReleaseId. + * + * @param appReleaseId the appReleaseId of the application release. + * @param unsubscribe the Status of the subscription. + * @param tenantId id of the current tenant. + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link SubscriptionsDTO} which contains the details of subscriptions. + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + List getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, + int offset, int limit) throws ApplicationManagementDAOException; + + /** + * This method is used to get the details of role subscriptions related to a appReleaseId. + * + * @param appReleaseId the appReleaseId of the application release. + * @param unsubscribe the Status of the subscription. + * @param tenantId id of the current tenant. + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link SubscriptionsDTO} which contains the details of subscriptions. + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + List getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) + throws ApplicationManagementDAOException; + + /** + * This method is used to get the details of device subscriptions related to a appReleaseId. + * + * @param appReleaseId the appReleaseId of the application release. + * @param unsubscribe the Status of the subscription. + * @param tenantId id of the current tenant. + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link DeviceSubscriptionDTO} which contains the details of device subscriptions. + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + List getDeviceSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) + throws ApplicationManagementDAOException; + + /** + * This method is used to get the details of device subscriptions related to a UUID. + * + * @param appReleaseId the appReleaseId of the application release. + * @param deviceId the deviceId of the device that need to get operation details. + * @param tenantId id of the current tenant. + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + List getSubscriptionOperationsByAppReleaseIDAndDeviceID(int appReleaseId, int deviceId, int tenantId, int offset, int limit) + throws ApplicationManagementDAOException; + + /** + * This method is used to get the details of device subscriptions related to a UUID. + * + * @param appReleaseId the appReleaseId of the application release. + * @param unsubscribe the Status of the subscription. + * @param tenantId id of the current tenant. + * @param deviceIds deviceIds deviceIds to retrieve data. + * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + List getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId, List deviceIds) + throws ApplicationManagementDAOException; + + /** + * This method is used to get the details of device subscriptions related to a UUID. + * + * @param appReleaseId the appReleaseId of the application release. + * @param unsubscribe the Status of the subscription. + * @param tenantId id of the current tenant. + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + List getAllSubscriptionsDetails(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) + throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of all subscription types related to a UUID. + * + * @param appReleaseId the appReleaseId of the application release. + * @param tenantId id of the current tenant. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int getAllSubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of all unsubscription types related to a UUID. + * + * @param appReleaseId the UUID of the application release. + * @param tenantId id of the current tenant. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int getAllUnsubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of device subscriptions related to a UUID. + * + * @param appReleaseId the UUID of the application release. + * @param tenantId id of the current tenant. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int getDeviceSubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of device unsubscription related to a UUID. + * + * @param appReleaseId the UUID of the application release. + * @param tenantId id of the current tenant. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int getDeviceUnsubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of group subscriptions related to a UUID. + * + * @param appReleaseId the UUID of the application release. + * @param tenantId id of the current tenant. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int getGroupSubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of group unsubscription related to a UUID. + * + * @param appReleaseId the UUID of the application release. + * @param tenantId id of the current tenant. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int getGroupUnsubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of role subscriptions related to a UUID. + * + * @param appReleaseId the UUID of the application release. + * @param tenantId id of the current tenant. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int getRoleSubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of role unsubscription related to a UUID. + * + * @param appReleaseId the UUID of the application release. + * @param tenantId id of the current tenant. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int getRoleUnsubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of user subscriptions related to a UUID. + * + * @param appReleaseId the UUID of the application release. + * @param tenantId id of the current tenant. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int getUserSubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of user unsubscription related to a UUID. + * + * @param appReleaseId the UUID of the application release. + * @param tenantId id of the current tenant. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int getUserUnsubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index cc3a289a4b..8737c99d7c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -17,6 +17,9 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription; +import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO; import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; @@ -44,6 +47,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringJoiner; +import java.util.stream.Collectors; public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements SubscriptionDAO { private static final Log log = LogFactory.getLog(GenericSubscriptionDAOImpl.class); @@ -1635,4 +1639,803 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc throw new ApplicationManagementDAOException(msg, e); } } + + @Override + public List getGroupsSubscriptionDetailsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to get groups related to the given AppReleaseID."); + } + try { + Connection conn = this.getDBConnection(); + List groupDetails = new ArrayList<>(); + + String subscriptionStatusTime = unsubscribe ? "GS.UNSUBSCRIBED_TIMESTAMP" : "GS.SUBSCRIBED_TIMESTAMP"; + String sql = "SELECT GS.GROUP_NAME, GS.SUBSCRIBED_BY, GS.SUBSCRIBED_TIMESTAMP, GS.UNSUBSCRIBED, " + + "GS.UNSUBSCRIBED_BY, GS.UNSUBSCRIBED_TIMESTAMP, GS.AP_APP_RELEASE_ID " + + "FROM AP_GROUP_SUBSCRIPTION GS " + + "WHERE GS.AP_APP_RELEASE_ID = ? AND GS.UNSUBSCRIBED = ? AND GS.TENANT_ID = ? " + + "ORDER BY " + subscriptionStatusTime + " DESC " + + "LIMIT ? OFFSET ?"; + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setBoolean(2, unsubscribe); + ps.setInt(3, tenantId); + ps.setInt(4, limit); + ps.setInt(5, offset); + + try (ResultSet rs = ps.executeQuery()) { + GroupSubscriptionDTO groupDetail; + while (rs.next()) { + groupDetail = new GroupSubscriptionDTO(); + groupDetail.setGroupName(rs.getString("GROUP_NAME")); + groupDetail.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + groupDetail.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); + groupDetail.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); + groupDetail.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + groupDetail.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); + groupDetail.setAppReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + + groupDetails.add(groupDetail); + } + } + return groupDetails; + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection to get groups for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "SQL Error occurred while getting groups for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public List getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, + int offset, int limit) throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to get user subscriptions related to the given UUID."); + } + try { + Connection conn = this.getDBConnection(); + List userSubscriptions = new ArrayList<>(); + + String subscriptionStatusTime = unsubscribe ? "US.UNSUBSCRIBED_TIMESTAMP" : "US.SUBSCRIBED_TIMESTAMP"; + String sql = "SELECT US.USER_NAME, US.SUBSCRIBED_BY, US.SUBSCRIBED_TIMESTAMP, US.UNSUBSCRIBED, " + + "US.UNSUBSCRIBED_BY, US.UNSUBSCRIBED_TIMESTAMP, US.AP_APP_RELEASE_ID " + + "FROM AP_USER_SUBSCRIPTION US " + + "WHERE US.AP_APP_RELEASE_ID = ? AND US.UNSUBSCRIBED = ? AND US.TENANT_ID = ? " + + "ORDER BY " + subscriptionStatusTime + " DESC " + + "LIMIT ? OFFSET ?"; + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setBoolean(2, unsubscribe); + ps.setInt(3, tenantId); + ps.setInt(4, limit); + ps.setInt(5, offset); + try (ResultSet rs = ps.executeQuery()) { + while (rs.next()) { + SubscriptionsDTO userSubscription; + userSubscription = new SubscriptionsDTO(); + userSubscription.setName(rs.getString("USER_NAME")); + userSubscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + userSubscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); + userSubscription.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); + userSubscription.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + userSubscription.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); + userSubscription.setAppReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + + userSubscriptions.add(userSubscription); + } + } + return userSubscriptions; + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection to get user subscriptions for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "SQL Error occurred while getting user subscriptions for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public List getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, + int limit) throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to get role subscriptions related to the given AppReleaseID."); + } + try { + Connection conn = this.getDBConnection(); + List roleSubscriptions = new ArrayList<>(); + + String subscriptionStatusTime = unsubscribe ? "ARS.UNSUBSCRIBED_TIMESTAMP" : "ARS.SUBSCRIBED_TIMESTAMP"; + String sql = "SELECT ARS.ROLE_NAME, ARS.SUBSCRIBED_BY, ARS.SUBSCRIBED_TIMESTAMP, ARS.UNSUBSCRIBED, " + + "ARS.UNSUBSCRIBED_BY, ARS.UNSUBSCRIBED_TIMESTAMP, ARS.AP_APP_RELEASE_ID " + + "FROM AP_ROLE_SUBSCRIPTION ARS " + + "WHERE ARS.AP_APP_RELEASE_ID = ? AND ARS.UNSUBSCRIBED = ? AND ARS.TENANT_ID = ? " + + "ORDER BY " + subscriptionStatusTime + " DESC " + + "LIMIT ? OFFSET ?"; + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setBoolean(2, unsubscribe); + ps.setInt(3, tenantId); + ps.setInt(4, limit); + ps.setInt(5, offset); + try (ResultSet rs = ps.executeQuery()) { + SubscriptionsDTO roleSubscription; + while (rs.next()) { + roleSubscription = new SubscriptionsDTO(); + roleSubscription.setName(rs.getString("ROLE_NAME")); + roleSubscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + roleSubscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); + roleSubscription.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); + roleSubscription.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + roleSubscription.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); + roleSubscription.setAppReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + + roleSubscriptions.add(roleSubscription); + } + } + return roleSubscriptions; + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection to get role subscriptions for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "SQL Error occurred while getting role subscriptions for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public List getDeviceSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to get device subscriptions related to the given AppReleaseID."); + } + try { + Connection conn = this.getDBConnection(); + List deviceSubscriptions = new ArrayList<>(); + + String subscriptionStatusTime = unsubscribe ? "DS.UNSUBSCRIBED_TIMESTAMP" : "DS.SUBSCRIBED_TIMESTAMP"; + String sql = "SELECT DS.DM_DEVICE_ID, " + + "DS.SUBSCRIBED_BY, " + + "DS.SUBSCRIBED_TIMESTAMP, " + + "DS.STATUS, " + + "DS.UNSUBSCRIBED, " + + "DS.UNSUBSCRIBED_BY, " + + "DS.UNSUBSCRIBED_TIMESTAMP, " + + "DS.AP_APP_RELEASE_ID " + + "FROM AP_DEVICE_SUBSCRIPTION DS " + + "WHERE DS.AP_APP_RELEASE_ID = ? " + + "AND DS.UNSUBSCRIBED = ? " + + "AND DS.TENANT_ID = ? " + + "AND DS.ACTION_TRIGGERED_FROM = 'DEVICE' " + + "ORDER BY " + subscriptionStatusTime + " DESC " + + "LIMIT ? OFFSET ?"; + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setBoolean(2, unsubscribe); + ps.setInt(3, tenantId); + ps.setInt(4, limit); + ps.setInt(5, offset); + try (ResultSet rs = ps.executeQuery()) { + DeviceSubscriptionDTO deviceSubscription; + while (rs.next()) { + deviceSubscription = new DeviceSubscriptionDTO(); + deviceSubscription.setDeviceId(rs.getInt("DM_DEVICE_ID")); + deviceSubscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + deviceSubscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); + deviceSubscription.setStatus(rs.getString("STATUS")); + deviceSubscription.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); + deviceSubscription.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + deviceSubscription.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); + deviceSubscription.setAppReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + + deviceSubscriptions.add(deviceSubscription); + } + } + return deviceSubscriptions; + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection to get device subscriptions for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "SQL Error occurred while getting device subscriptions for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public List getSubscriptionOperationsByAppReleaseIDAndDeviceID( + int appReleaseId, int deviceId, int tenantId, int offset, int limit) throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to get device subscriptions related to the given AppReleaseID and DeviceID."); + } + try { + Connection conn = this.getDBConnection(); + List deviceSubscriptions = new ArrayList<>(); + String sql = "SELECT " + + " ads.DM_DEVICE_ID, " + + " aasom.OPERATION_ID, " + + " ads.STATUS, " + + " ads.ACTION_TRIGGERED_FROM, " + + " ads.SUBSCRIBED_TIMESTAMP AS ACTION_TRIGGERED_AT, " + + " ads.AP_APP_RELEASE_ID " + + "FROM AP_APP_SUB_OP_MAPPING aasom " + + "JOIN AP_DEVICE_SUBSCRIPTION ads " + + "ON aasom.AP_DEVICE_SUBSCRIPTION_ID = ads.ID " + + "WHERE ads.AP_APP_RELEASE_ID = ? " + + "AND ads.DM_DEVICE_ID = ? " + + "AND ads.TENANT_ID = ? " + + "LIMIT ? OFFSET ?"; + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, deviceId); + ps.setInt(3, tenantId); + ps.setInt(4, limit); + ps.setInt(5, offset); + try (ResultSet rs = ps.executeQuery()) { + DeviceOperationDTO deviceSubscription; + while (rs.next()) { + deviceSubscription = new DeviceOperationDTO(); + deviceSubscription.setDeviceId(rs.getInt("DM_DEVICE_ID")); + deviceSubscription.setStatus(rs.getString("STATUS")); + deviceSubscription.setOperationId(rs.getInt("OPERATION_ID")); + deviceSubscription.setActionTriggeredFrom(rs.getString("ACTION_TRIGGERED_FROM")); + deviceSubscription.setActionTriggeredAt(rs.getTimestamp("ACTION_TRIGGERED_AT")); + deviceSubscription.setAppReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + + deviceSubscriptions.add(deviceSubscription); + } + } + } + return deviceSubscriptions; + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection to get device subscriptions for the given AppReleaseID and DeviceID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "SQL Error occurred while getting device subscriptions for the given AppReleaseID and DeviceID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public List getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId, List deviceIds) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting device subscriptions for the application release id " + appReleaseId + + " and device ids " + deviceIds + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String subscriptionStatusTime = unsubscribe ? "DS.UNSUBSCRIBED_TIMESTAMP" : "DS.SUBSCRIBED_TIMESTAMP"; + String sql = "SELECT " + + "DS.ID AS ID, " + + "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, " + + "DS.SUBSCRIBED_TIMESTAMP AS SUBSCRIBED_AT, " + + "DS.UNSUBSCRIBED AS IS_UNSUBSCRIBED, " + + "DS.UNSUBSCRIBED_BY AS UNSUBSCRIBED_BY, " + + "DS.UNSUBSCRIBED_TIMESTAMP AS UNSUBSCRIBED_AT, " + + "DS.ACTION_TRIGGERED_FROM AS ACTION_TRIGGERED_FROM, " + + "DS.STATUS AS STATUS, " + + "DS.DM_DEVICE_ID AS DEVICE_ID " + + "FROM AP_DEVICE_SUBSCRIPTION DS " + + "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.UNSUBSCRIBED = ? AND DS.TENANT_ID = ? AND DS.DM_DEVICE_ID IN (" + + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ") " + + "ORDER BY " + subscriptionStatusTime + " DESC"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setBoolean(2, unsubscribe); + ps.setInt(3, tenantId); + for (int i = 0; i < deviceIds.size(); i++) { + ps.setInt(4 + i, deviceIds.get(i)); + } + try (ResultSet rs = ps.executeQuery()) { + if (log.isDebugEnabled()) { + log.debug("Successfully retrieved device subscriptions for application release id " + + appReleaseId + " and device ids " + deviceIds); + } + List subscriptions = new ArrayList<>(); + while (rs.next()) { + DeviceSubscriptionDTO subscription = new DeviceSubscriptionDTO(); + subscription.setId(rs.getInt("ID")); + subscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + subscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_AT")); + subscription.setUnsubscribed(rs.getBoolean("IS_UNSUBSCRIBED")); + subscription.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + subscription.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_AT")); + subscription.setActionTriggeredFrom(rs.getString("ACTION_TRIGGERED_FROM")); + subscription.setStatus(rs.getString("STATUS")); + subscription.setDeviceId(rs.getInt("DEVICE_ID")); + subscriptions.add(subscription); + } + return subscriptions; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get device subscription data for application ID: " + appReleaseId + + " and device ids: " + deviceIds + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting device subscriptions for " + + "application Id: " + appReleaseId + " and device ids: " + deviceIds + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + + } + + @Override + public List getAllSubscriptionsDetails(int appReleaseId, boolean unsubscribe, int tenantId, + int offset, int limit) throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting device subscriptions for the application release id " + appReleaseId + + " from the database"); + } + + String subscriptionStatusTime = unsubscribe ? "DS.UNSUBSCRIBED_TIMESTAMP" : "DS.SUBSCRIBED_TIMESTAMP"; + String sql = "SELECT " + + "DS.ID AS ID, " + + "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, " + + "DS.SUBSCRIBED_TIMESTAMP AS SUBSCRIBED_AT, " + + "DS.UNSUBSCRIBED AS IS_UNSUBSCRIBED, " + + "DS.UNSUBSCRIBED_BY AS UNSUBSCRIBED_BY, " + + "DS.UNSUBSCRIBED_TIMESTAMP AS UNSUBSCRIBED_AT, " + + "DS.ACTION_TRIGGERED_FROM AS ACTION_TRIGGERED_FROM, " + + "DS.STATUS AS STATUS," + + "DS.DM_DEVICE_ID AS DEVICE_ID " + + "FROM AP_DEVICE_SUBSCRIPTION DS " + + "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.UNSUBSCRIBED = ? AND DS.TENANT_ID=? " + + "ORDER BY " + subscriptionStatusTime + " DESC " + + "LIMIT ? OFFSET ?"; + + try { + Connection conn = this.getDBConnection(); + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setBoolean(2, unsubscribe); + ps.setInt(3, tenantId); + ps.setInt(4, limit); + ps.setInt(5, offset); + try (ResultSet rs = ps.executeQuery()) { + if (log.isDebugEnabled()) { + log.debug("Successfully retrieved device subscriptions for application release id " + + appReleaseId); + } + List deviceSubscriptions = new ArrayList<>(); + + while (rs.next()) { + DeviceSubscriptionDTO subscription = new DeviceSubscriptionDTO(); + subscription.setId(rs.getInt("ID")); + subscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + subscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_AT")); + subscription.setUnsubscribed(rs.getBoolean("IS_UNSUBSCRIBED")); + subscription.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + subscription.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_AT")); + subscription.setActionTriggeredFrom(rs.getString("ACTION_TRIGGERED_FROM")); + subscription.setStatus(rs.getString("STATUS")); + subscription.setDeviceId(rs.getInt("DEVICE_ID")); + + deviceSubscriptions.add(subscription); + } + return deviceSubscriptions; + } + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting device subscription for " + + "application Id: " + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while while running SQL to get device subscription data for application ID: " + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public int getAllSubscriptionCount(int appReleaseId, int tenantId) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting all subscriptions count for the application appReleaseId " + appReleaseId + + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) AS count " + + "FROM AP_DEVICE_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND UNSUBSCRIBED = FALSE"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt("count"); + } + return 0; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get all subscriptions count for application appReleaseId: " + + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting all subscriptions count for appReleaseId: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public int getAllUnsubscriptionCount(int appReleaseId, int tenantId) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting all unsubscription count for the application appReleaseId " + appReleaseId + + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) AS count " + + "FROM AP_DEVICE_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND UNSUBSCRIBED = TRUE"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt("count"); + } + return 0; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get all unsubscription count for application appReleaseId: " + + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting all unsubscription count for appReleaseId: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public int getDeviceSubscriptionCount(int appReleaseId, int tenantId) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting device subscriptions count for the application appReleaseId " + appReleaseId + + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) AS count " + + "FROM AP_DEVICE_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND UNSUBSCRIBED = FALSE " + + "AND ACTION_TRIGGERED_FROM = 'DEVICE'"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt("count"); + } + return 0; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get device subscriptions count for application appReleaseId: " + + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting device subscriptions count for appReleaseId: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public int getDeviceUnsubscriptionCount(int appReleaseId, int tenantId) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting device unsubscriptions count for the application appReleaseId " + appReleaseId + + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) AS count " + + "FROM AP_DEVICE_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND UNSUBSCRIBED = TRUE " + + "AND ACTION_TRIGGERED_FROM = 'DEVICE'"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt("count"); + } + return 0; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get device unsubscription count for application appReleaseId: " + + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting device unsubscription count for appReleaseId: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public int getGroupSubscriptionCount(int appReleaseId, int tenantId) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting group subscriptions count for the application appReleaseId " + appReleaseId + + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) AS count " + + "FROM AP_GROUP_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND UNSUBSCRIBED = FALSE"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt("count"); + } + return 0; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get group subscriptions count for application appReleaseId: " + + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting group subscriptions count for appReleaseId: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public int getGroupUnsubscriptionCount(int appReleaseId, int tenantId) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting group unsubscriptions count for the application appReleaseId " + appReleaseId + + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) AS count " + + "FROM AP_GROUP_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND UNSUBSCRIBED = TRUE"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt("count"); + } + return 0; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get group unsubscription count for application appReleaseId: " + + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting group unsubscription count for appReleaseId: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public int getRoleSubscriptionCount(int appReleaseId, int tenantId) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting role subscriptions count for the application appReleaseId " + appReleaseId + + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) AS count " + + "FROM AP_ROLE_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND UNSUBSCRIBED = FALSE"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt("count"); + } + return 0; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get role subscriptions count for application appReleaseId: " + + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting role subscriptions count for appReleaseId: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public int getRoleUnsubscriptionCount(int appReleaseId, int tenantId) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting role unsubscription count for the application appReleaseId " + appReleaseId + + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) AS count " + + "FROM AP_ROLE_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND UNSUBSCRIBED = TRUE"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt("count"); + } + return 0; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get role unsubscription count for application appReleaseId: " + + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting role unsubscription count for appReleaseId: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public int getUserSubscriptionCount(int appReleaseId, int tenantId) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting user subscriptions count for the application appReleaseId " + appReleaseId + + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) AS count " + + "FROM AP_USER_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND UNSUBSCRIBED = FALSE"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt("count"); + } + return 0; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get user subscriptions count for application appReleaseId: " + + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting user subscriptions count for appReleaseId: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public int getUserUnsubscriptionCount(int appReleaseId, int tenantId) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting user unsubscription count for the application appReleaseId " + appReleaseId + + " from the database"); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) AS count " + + "FROM AP_USER_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND UNSUBSCRIBED = TRUE"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt("count"); + } + return 0; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get user unsubscription count for application appReleaseId: " + + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting user unsubscription count for appReleaseId: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 931c45ddcf..0ade616d52 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -19,17 +19,44 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; import com.google.gson.Gson; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationSubscriptionInfo; +import io.entgra.device.mgt.core.application.mgt.common.ApplicationType; +import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult; +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData; +import io.entgra.device.mgt.core.application.mgt.common.dto.CategorizedSubscriptionCountsDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionResponseDTO; +import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; +import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; +import io.entgra.device.mgt.core.application.mgt.common.SubAction; +import io.entgra.device.mgt.core.application.mgt.common.SubscribingDeviceIdHolder; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; +import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationPolicyDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.VppAssetDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.VppUserDTO; import io.entgra.device.mgt.core.application.mgt.common.services.VPPApplicationManager; +import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.VppApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO; +import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO; import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dto.OperationDTO; +import io.entgra.device.mgt.core.device.mgt.core.dto.OwnerWithDeviceDTO; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; import io.entgra.device.mgt.core.notification.logger.impl.EntgraAppInstallLoggerImpl; -import org.apache.commons.httpclient.HttpClient; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpResponse; @@ -45,20 +72,6 @@ import org.json.JSONObject; import io.entgra.device.mgt.core.apimgt.application.extension.dto.ApiApplicationKey; import io.entgra.device.mgt.core.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationSubscriptionInfo; -import io.entgra.device.mgt.core.application.mgt.common.ApplicationType; -import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData; -import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; -import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; -import io.entgra.device.mgt.core.application.mgt.common.SubAction; -import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; -import io.entgra.device.mgt.core.application.mgt.common.SubscribingDeviceIdHolder; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationPolicyDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; import io.entgra.device.mgt.core.application.mgt.common.exception.LifecycleManagementException; @@ -99,6 +112,7 @@ import io.entgra.device.mgt.core.device.mgt.core.util.MDMIOSOperationUtil; import io.entgra.device.mgt.core.device.mgt.core.util.MDMWindowsOperationUtil; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.api.UserStoreManager; import javax.ws.rs.core.MediaType; import java.io.BufferedReader; @@ -113,6 +127,7 @@ import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -120,6 +135,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -131,12 +147,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager { private SubscriptionDAO subscriptionDAO; private ApplicationDAO applicationDAO; private VppApplicationDAO vppApplicationDAO; + private ApplicationReleaseDAO applicationReleaseDAO; private LifecycleStateManager lifecycleStateManager; public SubscriptionManagerImpl() { this.lifecycleStateManager = DataHolder.getInstance().getLifecycleStateManager(); this.subscriptionDAO = ApplicationManagementDAOFactory.getSubscriptionDAO(); this.applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO(); + this.applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO(); this.vppApplicationDAO = ApplicationManagementDAOFactory.getVppApplicationDAO(); } @@ -1505,16 +1523,19 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public PaginationResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus, - String action, String installedVersion) throws ApplicationManagementException { + public CategorizedSubscriptionResult getAppSubscriptionDetails(PaginationRequest request, String appUUID, String actionStatus, + String action, String installedVersion) throws ApplicationManagementException { int limitValue = request.getRowCount(); int offsetValue = request.getStartIndex(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - DeviceManagementProviderService deviceManagementProviderService = HelperUtil - .getDeviceManagementProviderService(); + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); + List installedDevices = new ArrayList<>(); + List pendingDevices = new ArrayList<>(); + List errorDevices = new ArrayList<>(); + if (offsetValue < 0 || limitValue <= 0) { - String msg = "Found incompatible values for offset and limit. Hence please check the request and resend. " - + "Offset " + offsetValue + " limit " + limitValue; + String msg = "Found incompatible values for offset and limit. Hence please check the request and resend. " + + "Offset " + offsetValue + " limit " + limitValue; log.error(msg); throw new BadRequestException(msg); } @@ -1532,31 +1553,26 @@ public class SubscriptionManagerImpl implements SubscriptionManager { List deviceSubscriptionDTOS = subscriptionDAO .getDeviceSubscriptions(applicationReleaseId, tenantId, actionStatus, action); if (deviceSubscriptionDTOS.isEmpty()) { - PaginationResult paginationResult = new PaginationResult(); - paginationResult.setData(new ArrayList<>()); - paginationResult.setRecordsFiltered(0); - paginationResult.setRecordsTotal(0); - return paginationResult; + return new CategorizedSubscriptionResult(new ArrayList<>(), new ArrayList<>(), new ArrayList<>()); } List deviceIdList = deviceSubscriptionDTOS.stream().map(DeviceSubscriptionDTO::getDeviceId) .collect(Collectors.toList()); - Map currentVersionsMap = subscriptionDAO.getCurrentInstalledAppVersion(applicationDTO.getId(),deviceIdList, installedVersion); + Map currentVersionsMap = + subscriptionDAO.getCurrentInstalledAppVersion(applicationDTO.getId(), deviceIdList, installedVersion); try { - //pass the device id list to device manager service method - PaginationResult paginationResult = deviceManagementProviderService.getAppSubscribedDevices - (request, deviceIdList); - List deviceSubscriptionDataList = new ArrayList<>(); + // Pass the device id list to device manager service method + PaginationResult paginationResult = deviceManagementProviderService.getAppSubscribedDevices(request, deviceIdList); if (!paginationResult.getData().isEmpty()) { List devices = (List) paginationResult.getData(); for (Device device : devices) { - if(installedVersion != null && !installedVersion.isEmpty() && !currentVersionsMap.containsKey(device.getId())){ + if (installedVersion != null && !installedVersion.isEmpty() && !currentVersionsMap.containsKey(device.getId())) { continue; } DeviceSubscriptionData deviceSubscriptionData = new DeviceSubscriptionData(); - if(currentVersionsMap.containsKey(device.getId())){ + if (currentVersionsMap.containsKey(device.getId())) { deviceSubscriptionData.setCurrentInstalledVersion(currentVersionsMap.get(device.getId())); - }else{ + } else { deviceSubscriptionData.setCurrentInstalledVersion("-"); } for (DeviceSubscriptionDTO subscription : deviceSubscriptionDTOS) { @@ -1565,39 +1581,51 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (subscription.isUnsubscribed()) { deviceSubscriptionData.setAction(Constants.UNSUBSCRIBED); deviceSubscriptionData.setActionTriggeredBy(subscription.getUnsubscribedBy()); - deviceSubscriptionData - .setActionTriggeredTimestamp(subscription.getUnsubscribedTimestamp().getTime() / 1000); + deviceSubscriptionData.setActionTriggeredTimestamp(subscription.getUnsubscribedTimestamp()); } else { deviceSubscriptionData.setAction(Constants.SUBSCRIBED); deviceSubscriptionData.setActionTriggeredBy(subscription.getSubscribedBy()); - deviceSubscriptionData - .setActionTriggeredTimestamp(subscription.getSubscribedTimestamp().getTime() / 1000); + deviceSubscriptionData.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); } deviceSubscriptionData.setActionType(subscription.getActionTriggeredFrom()); deviceSubscriptionData.setStatus(subscription.getStatus()); deviceSubscriptionData.setSubId(subscription.getId()); - deviceSubscriptionDataList.add(deviceSubscriptionData); + + // Categorize the subscription data based on its status + switch (subscription.getStatus()) { + case "COMPLETED": + installedDevices.add(deviceSubscriptionData); + break; + case "ERROR": + case "INVALID": + case "UNAUTHORIZED": + errorDevices.add(deviceSubscriptionData); + break; + case "IN_PROGRESS": + case "PENDING": + case "REPEATED": + pendingDevices.add(deviceSubscriptionData); + break; + } break; } } } } - paginationResult.setData(deviceSubscriptionDataList); - return paginationResult; + return new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices); } catch (DeviceManagementException e) { - String msg = "service error occurred while getting device data from the device management service. " - + "Device ids " + deviceIdList; + String msg = "Service error occurred while getting device data from the device management service. " + + "Device ids " + deviceIdList; log.error(msg, e); throw new ApplicationManagementException(msg, e); } } catch (ApplicationManagementDAOException e) { - String msg = - "Error occurred when getting application release data for application release UUID: " + appUUID; + String msg = "Error occurred when getting application release data for application release UUID: " + appUUID; log.error(msg, e); throw new ApplicationManagementException(msg, e); } catch (DBConnectionException e) { - String msg = "DB Connection error occurred while trying to get subscription data of application which has " - + "application release UUID " + appUUID; + String msg = "DB Connection error occurred while trying to get subscription data of application which has " + + "application release UUID " + appUUID; log.error(msg, e); throw new ApplicationManagementException(msg, e); } finally { @@ -1675,4 +1703,986 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } } + @Override + public List getGroupsSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, + int limit) throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); + String groupName; + String status; + + try { + ConnectionManagerUtil.openDBConnection(); + + ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + uuid; + log.error(msg); + throw new NotFoundException(msg); + } + int appReleaseId = applicationReleaseDTO.getId(); + + List groupDetailsWithDevices = new ArrayList<>(); + + List groupDetails = + subscriptionDAO.getGroupsSubscriptionDetailsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); + if (groupDetails == null) { + throw new ApplicationManagementException("Group details not found for appReleaseId: " + appReleaseId); + } + + GroupManagementProviderService groupManagementProviderService = HelperUtil.getGroupManagementProviderService(); + + for (GroupSubscriptionDTO groupDetail : groupDetails) { + groupName = groupDetail.getGroupName(); + + // Retrieve group details and device IDs for the group using the service layer + GroupDetailsDTO groupDetailWithDevices = + groupManagementProviderService.getGroupDetailsWithDevices(groupName, offset, limit); + + SubscriptionsDTO groupDetailDTO = new SubscriptionsDTO(); + groupDetailDTO.setId(groupDetailWithDevices.getGroupId()); + groupDetailDTO.setName(groupDetail.getGroupName()); + groupDetailDTO.setOwner(groupDetailWithDevices.getGroupOwner()); + groupDetailDTO.setSubscribedBy(groupDetail.getSubscribedBy()); + groupDetailDTO.setSubscribedTimestamp(groupDetail.getSubscribedTimestamp()); + groupDetailDTO.setUnsubscribed(groupDetail.isUnsubscribed()); + groupDetailDTO.setUnsubscribedBy(groupDetail.getUnsubscribedBy()); + groupDetailDTO.setUnsubscribedTimestamp(groupDetail.getUnsubscribedTimestamp()); + groupDetailDTO.setAppReleaseId(groupDetail.getAppReleaseId()); + groupDetailDTO.setDeviceCount(groupDetailWithDevices.getDeviceCount()); + + // Fetch device subscriptions for each device ID in the group + List pendingDevices = new ArrayList<>(); + List installedDevices = new ArrayList<>(); + List errorDevices = new ArrayList<>(); + List newDevices = new ArrayList<>(); + List subscribedDevices = new ArrayList<>(); + + List deviceIds = groupDetailWithDevices.getDeviceIds(); + Map statusCounts = new HashMap<>(); + statusCounts.put("PENDING", 0); + statusCounts.put("COMPLETED", 0); + statusCounts.put("ERROR", 0); + statusCounts.put("NEW", 0); + statusCounts.put("SUBSCRIBED", 0); + + // Get subscribed devices if unsubscribed devices are requested + List subscribedDeviceSubscriptions = new ArrayList<>(); + if (unsubscribe) { + subscribedDeviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( + appReleaseId, !unsubscribe, tenantId, deviceIds); + } + + for (Integer deviceId : deviceIds) { + List deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( + groupDetail.getAppReleaseId(), unsubscribe, tenantId, deviceIds); + boolean isNewDevice = true; + for (DeviceSubscriptionDTO subscription : deviceSubscriptions) { + if (subscription.getDeviceId() == deviceId) { + DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); + deviceDetail.setDeviceId(subscription.getDeviceId()); + deviceDetail.setStatus(subscription.getStatus()); + deviceDetail.setActionType(subscription.getActionTriggeredFrom()); + deviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId)); + deviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId)); + deviceDetail.setDeviceName(groupDetailWithDevices.getDeviceNames().get(deviceId)); + deviceDetail.setSubId(subscription.getId()); + deviceDetail.setActionTriggeredBy(subscription.getSubscribedBy()); + deviceDetail.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); + deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); + deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); + deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); + + status = subscription.getStatus(); + switch (status) { + case "COMPLETED": + installedDevices.add(deviceDetail); + statusCounts.put("COMPLETED", statusCounts.get("COMPLETED") + 1); + break; + case "ERROR": + case "INVALID": + case "UNAUTHORIZED": + errorDevices.add(deviceDetail); + statusCounts.put("ERROR", statusCounts.get("ERROR") + 1); + break; + case "IN_PROGRESS": + case "PENDING": + case "REPEATED": + pendingDevices.add(deviceDetail); + statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); + break; + } + isNewDevice = false; + } + } + if (isNewDevice) { + boolean isSubscribedDevice = false; + for (DeviceSubscriptionDTO subscribedDevice : subscribedDeviceSubscriptions) { + if (subscribedDevice.getDeviceId() == deviceId) { + DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); + subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); + subscribedDeviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId)); + subscribedDeviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId)); + subscribedDeviceDetail.setDeviceName(groupDetailWithDevices.getDeviceNames().get(deviceId)); + subscribedDeviceDetail.setSubId(subscribedDevice.getId()); + subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); + subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); + subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); + subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); + subscribedDevices.add(subscribedDeviceDetail); + statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); + isSubscribedDevice = true; + break; + } + } + if (!isSubscribedDevice) { + DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); + newDeviceDetail.setDeviceId(deviceId); + newDeviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId)); + newDeviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId)); + newDeviceDetail.setDeviceName(groupDetailWithDevices.getDeviceNames().get(deviceId)); + newDevices.add(newDeviceDetail); + statusCounts.put("NEW", statusCounts.get("NEW") + 1); + } + } + } + + int totalDevices = deviceIds.size(); + Map statusPercentages = new HashMap<>(); + for (Map.Entry entry : statusCounts.entrySet()) { + double percentage = ((double) entry.getValue() / totalDevices) * 100; + String formattedPercentage = String.format("%.2f", percentage); + statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); + } + + CategorizedSubscriptionResult categorizedSubscriptionResult; + if (subscribedDevices.isEmpty()) { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + } else { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); + } + groupDetailDTO.setDevices(categorizedSubscriptionResult); + groupDetailDTO.setStatusPercentages(statusPercentages); + + groupDetailsWithDevices.add(groupDetailDTO); + } + + return groupDetailsWithDevices; + } catch (ApplicationManagementDAOException e) { + String msg = "Error occurred while fetching groups and devices for UUID: " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DBConnectionException e) { + String msg = "DB Connection error occurred while fetching groups and devices for UUID: " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (GroupManagementException e) { + String msg = "Error occurred while fetching group details and device IDs: " + e.getMessage(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public List getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) + throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); + String userName; + String status; + + try { + ConnectionManagerUtil.openDBConnection(); + + ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + uuid; + log.error(msg); + throw new NotFoundException(msg); + } + int appReleaseId = applicationReleaseDTO.getId(); + + List userSubscriptionsWithDevices = new ArrayList<>(); + + List userSubscriptions = + subscriptionDAO.getUserSubscriptionsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); + if (userSubscriptions == null) { + throw new ApplicationManagementException("User details not found for appReleaseId: " + appReleaseId); + } + + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); + + for (SubscriptionsDTO userSubscription : userSubscriptions) { + userName = userSubscription.getName(); + + // Retrieve owner details and device IDs for the user using the service layer + OwnerWithDeviceDTO ownerDetailsWithDevices = + deviceManagementProviderService.getOwnersWithDeviceIds(userName); + + SubscriptionsDTO userSubscriptionDTO = new SubscriptionsDTO(); + userSubscriptionDTO.setName(userSubscription.getName()); + userSubscriptionDTO.setSubscribedBy(userSubscription.getSubscribedBy()); + userSubscriptionDTO.setSubscribedTimestamp(userSubscription.getSubscribedTimestamp()); + userSubscriptionDTO.setUnsubscribed(userSubscription.getUnsubscribed()); + userSubscriptionDTO.setUnsubscribedBy(userSubscription.getUnsubscribedBy()); + userSubscriptionDTO.setUnsubscribedTimestamp(userSubscription.getUnsubscribedTimestamp()); + userSubscriptionDTO.setAppReleaseId(userSubscription.getAppReleaseId()); + + userSubscriptionDTO.setDeviceCount(ownerDetailsWithDevices.getDeviceCount()); + + // Fetch device subscriptions for each device ID associated with the user + List pendingDevices = new ArrayList<>(); + List installedDevices = new ArrayList<>(); + List errorDevices = new ArrayList<>(); + List newDevices = new ArrayList<>(); + List subscribedDevices = new ArrayList<>(); + + List deviceIds = ownerDetailsWithDevices.getDeviceIds(); + Map statusCounts = new HashMap<>(); + statusCounts.put("PENDING", 0); + statusCounts.put("COMPLETED", 0); + statusCounts.put("ERROR", 0); + statusCounts.put("NEW", 0); + statusCounts.put("SUBSCRIBED", 0); + + List subscribedDeviceSubscriptions = new ArrayList<>(); + if (unsubscribe) { + subscribedDeviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( + appReleaseId, !unsubscribe, tenantId, deviceIds); + } + + for (Integer deviceId : deviceIds) { + List deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( + userSubscription.getAppReleaseId(), unsubscribe, tenantId, deviceIds); + boolean isNewDevice = true; + for (DeviceSubscriptionDTO subscription : deviceSubscriptions) { + if (subscription.getDeviceId() == deviceId) { + DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); + deviceDetail.setDeviceId(subscription.getDeviceId()); + deviceDetail.setSubId(subscription.getId()); + deviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); + deviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + deviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); + deviceDetail.setActionType(subscription.getActionTriggeredFrom()); + deviceDetail.setStatus(subscription.getStatus()); + deviceDetail.setActionType(subscription.getActionTriggeredFrom()); + deviceDetail.setActionTriggeredBy(subscription.getSubscribedBy()); + deviceDetail.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); + deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); + deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); + deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); + + status = subscription.getStatus(); + switch (status) { + case "COMPLETED": + installedDevices.add(deviceDetail); + statusCounts.put("COMPLETED", statusCounts.get("COMPLETED") + 1); + break; + case "ERROR": + case "INVALID": + case "UNAUTHORIZED": + errorDevices.add(deviceDetail); + statusCounts.put("ERROR", statusCounts.get("ERROR") + 1); + break; + case "IN_PROGRESS": + case "PENDING": + case "REPEATED": + pendingDevices.add(deviceDetail); + statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); + break; + } + isNewDevice = false; + } + } + if (isNewDevice) { + boolean isSubscribedDevice = false; + for (DeviceSubscriptionDTO subscribedDevice : subscribedDeviceSubscriptions) { + if (subscribedDevice.getDeviceId() == deviceId) { + DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); + subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); + subscribedDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); + subscribedDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); + subscribedDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + subscribedDeviceDetail.setSubId(subscribedDevice.getId()); + subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); + subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); + subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); + subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); + subscribedDevices.add(subscribedDeviceDetail); + statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); + isSubscribedDevice = true; + break; + } + } + if (!isSubscribedDevice) { + DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); + newDeviceDetail.setDeviceId(deviceId); + newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); + newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); + newDevices.add(newDeviceDetail); + statusCounts.put("NEW", statusCounts.get("NEW") + 1); + } + } + } + + int totalDevices = deviceIds.size(); + Map statusPercentages = new HashMap<>(); + for (Map.Entry entry : statusCounts.entrySet()) { + double percentage = ((double) entry.getValue() / totalDevices) * 100; + String formattedPercentage = String.format("%.2f", percentage); + statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); + } + + CategorizedSubscriptionResult categorizedSubscriptionResult; + if (subscribedDevices.isEmpty()) { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + } else { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); + } + userSubscriptionDTO.setDevices(categorizedSubscriptionResult); + userSubscriptionDTO.setStatusPercentages(statusPercentages); + + userSubscriptionsWithDevices.add(userSubscriptionDTO); + } + + return userSubscriptionsWithDevices; + } catch (ApplicationManagementDAOException e) { + String msg = "Error occurred while getting user subscriptions for the application release UUID: " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DBConnectionException e) { + String msg = "DB Connection error occurred while getting user subscriptions for UUID: " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DeviceManagementDAOException e) { + throw new RuntimeException(e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public List getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) + throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); + String roleName; + String status; + + try { + ConnectionManagerUtil.openDBConnection(); + + ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + uuid; + log.error(msg); + throw new NotFoundException(msg); + } + int appReleaseId = applicationReleaseDTO.getId(); + + List roleSubscriptionsWithDevices = new ArrayList<>(); + + List roleSubscriptions = + subscriptionDAO.getRoleSubscriptionsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); + if (roleSubscriptions == null) { + throw new ApplicationManagementException("Role details not found for appReleaseId: " + appReleaseId); + } + + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); + + for (SubscriptionsDTO roleSubscription : roleSubscriptions) { + roleName = roleSubscription.getName(); + + SubscriptionsDTO roleSubscriptionDTO = new SubscriptionsDTO(); + roleSubscriptionDTO.setName(roleSubscription.getName()); + roleSubscriptionDTO.setSubscribedBy(roleSubscription.getSubscribedBy()); + roleSubscriptionDTO.setSubscribedTimestamp(roleSubscription.getSubscribedTimestamp()); + roleSubscriptionDTO.setUnsubscribed(roleSubscription.getUnsubscribed()); + roleSubscriptionDTO.setUnsubscribedBy(roleSubscription.getUnsubscribedBy()); + roleSubscriptionDTO.setUnsubscribedTimestamp(roleSubscription.getUnsubscribedTimestamp()); + roleSubscriptionDTO.setAppReleaseId(roleSubscription.getAppReleaseId()); + + List pendingDevices = new ArrayList<>(); + List installedDevices = new ArrayList<>(); + List errorDevices = new ArrayList<>(); + List newDevices = new ArrayList<>(); + List subscribedDevices = new ArrayList<>(); + + Map statusCounts = new HashMap<>(); + statusCounts.put("PENDING", 0); + statusCounts.put("COMPLETED", 0); + statusCounts.put("ERROR", 0); + statusCounts.put("NEW", 0); + statusCounts.put("SUBSCRIBED", 0); + + List users = this.getUsersForRole(roleName); + + for (String user : users) { + OwnerWithDeviceDTO ownerDetailsWithDevices; + try { + ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(user); + } catch (DeviceManagementDAOException e) { + throw new ApplicationManagementException("Error retrieving owner details with devices for user: " + user, e); + } + + List deviceIds = ownerDetailsWithDevices.getDeviceIds(); + for (Integer deviceId : deviceIds) { + + List subscribedDeviceSubscriptions = new ArrayList<>(); + if (unsubscribe) { + subscribedDeviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( + appReleaseId, !unsubscribe, tenantId, deviceIds); + } + + List deviceSubscriptions; + try { + deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( + roleSubscription.getAppReleaseId(), unsubscribe, tenantId, deviceIds); + } catch (ApplicationManagementDAOException e) { + throw new ApplicationManagementException("Error retrieving device subscriptions", e); + } + + boolean isNewDevice = true; + for (DeviceSubscriptionDTO deviceSubscription : deviceSubscriptions) { + if (deviceSubscription.getDeviceId() == deviceId) { + DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); + deviceDetail.setDeviceId(deviceSubscription.getDeviceId()); + deviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); + deviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); + deviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + deviceDetail.setActionType(deviceSubscription.getActionTriggeredFrom()); + deviceDetail.setStatus(deviceSubscription.getStatus()); + deviceDetail.setActionType(deviceSubscription.getActionTriggeredFrom()); + deviceDetail.setActionTriggeredBy(deviceSubscription.getSubscribedBy()); + deviceDetail.setSubId(deviceSubscription.getId()); + deviceDetail.setActionTriggeredTimestamp(deviceSubscription.getSubscribedTimestamp()); + deviceDetail.setUnsubscribed(deviceSubscription.isUnsubscribed()); + deviceDetail.setUnsubscribedBy(deviceSubscription.getUnsubscribedBy()); + deviceDetail.setUnsubscribedTimestamp(deviceSubscription.getUnsubscribedTimestamp()); + + status = deviceSubscription.getStatus(); + switch (status) { + case "COMPLETED": + installedDevices.add(deviceDetail); + statusCounts.put("COMPLETED", statusCounts.get("COMPLETED") + 1); + break; + case "ERROR": + case "INVALID": + case "UNAUTHORIZED": + errorDevices.add(deviceDetail); + statusCounts.put("ERROR", statusCounts.get("ERROR") + 1); + break; + case "IN_PROGRESS": + case "PENDING": + case "REPEATED": + pendingDevices.add(deviceDetail); + statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); + break; + } + isNewDevice = false; + } + } + if (isNewDevice) { + boolean isSubscribedDevice = false; + for (DeviceSubscriptionDTO subscribedDevice : subscribedDeviceSubscriptions) { + if (subscribedDevice.getDeviceId() == deviceId) { + DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); + subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); + subscribedDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); + subscribedDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); + subscribedDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + subscribedDeviceDetail.setSubId(subscribedDevice.getId()); + subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); + subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); + subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); + subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); + subscribedDevices.add(subscribedDeviceDetail); + statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); + isSubscribedDevice = true; + break; + } + } + if (!isSubscribedDevice) { + DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); + newDeviceDetail.setDeviceId(deviceId); + newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); + newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); + newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + newDevices.add(newDeviceDetail); + statusCounts.put("NEW", statusCounts.get("NEW") + 1); + } + } + } + } + + int totalDevices = + pendingDevices.size() + installedDevices.size() + errorDevices.size() + newDevices.size() + subscribedDevices.size(); + Map statusPercentages = new HashMap<>(); + for (Map.Entry entry : statusCounts.entrySet()) { + double percentage = totalDevices == 0 ? 0.0 : ((double) entry.getValue() / totalDevices) * 100; + String formattedPercentage = String.format("%.2f", percentage); + statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); + } + + CategorizedSubscriptionResult categorizedSubscriptionResult; + if (subscribedDevices.isEmpty()) { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + } else { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); + } + roleSubscriptionDTO.setDevices(categorizedSubscriptionResult); + roleSubscriptionDTO.setStatusPercentages(statusPercentages); + roleSubscriptionDTO.setDeviceCount(totalDevices); + + roleSubscriptionsWithDevices.add(roleSubscriptionDTO); + } + + return roleSubscriptionsWithDevices; + } catch (ApplicationManagementDAOException e) { + String msg = "Error occurred in retrieving role subscriptions with devices"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DBConnectionException e) { + String msg = "Error occurred while retrieving the database connection"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (UserStoreException e) { + String msg = "Error occurred while retrieving users for role"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + // Get user list for each role + public List getUsersForRole(String roleName) throws UserStoreException { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + int tenantId = ctx.getTenantId(); + UserStoreManager userStoreManager = DataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId).getUserStoreManager(); + String[] users = userStoreManager.getUserListOfRole(roleName); + return Arrays.asList(users); + } + + @Override + public DeviceSubscriptionResponseDTO getDeviceSubscriptionsDetailsByUUID(String uuid, String subscriptionStatus, int offset, + int limit) throws ApplicationManagementException { + + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); + + try { + ConnectionManagerUtil.openDBConnection(); + + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + uuid; + log.error(msg); + throw new NotFoundException(msg); + } + int appReleaseId = applicationReleaseDTO.getId(); + + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); + List deviceSubscriptions = + subscriptionDAO.getDeviceSubscriptionsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); + + // empty response for no device subscriptions + if (deviceSubscriptions.isEmpty()) { + return new DeviceSubscriptionResponseDTO(0, Collections.emptyMap(), + new CategorizedSubscriptionResult(Collections.emptyList(), + Collections.emptyList(), Collections.emptyList(), Collections.emptyList())); + } + + List allDevices = + deviceManagementProviderService.getDevicesByTenantId(tenantId); + + List deviceIds = allDevices.stream() + .map(DeviceDetailsDTO::getDeviceId) + .collect(Collectors.toList()); + + Map statusCounts = new HashMap<>(); + statusCounts.put("PENDING", 0); + statusCounts.put("COMPLETED", 0); + statusCounts.put("ERROR", 0); + statusCounts.put("NEW", 0); + statusCounts.put("SUBSCRIBED", 0); + + List installedDevices = new ArrayList<>(); + List pendingDevices = new ArrayList<>(); + List errorDevices = new ArrayList<>(); + List newDevices = new ArrayList<>(); + List subscribedDevices = new ArrayList<>(); + + Map deviceSubscriptionMap = deviceSubscriptions.stream() + .collect(Collectors.toMap(DeviceSubscriptionDTO::getDeviceId, Function.identity())); + Map allDevicesMap = allDevices.stream() + .collect(Collectors.toMap(DeviceDetailsDTO::getDeviceId, Function.identity())); + + List allSubscriptionsForUnSubscribed = + subscriptionDAO.getSubscriptionDetailsByDeviceIds(appReleaseId, !unsubscribe, tenantId, deviceIds); + List allSubscriptionsForSubscribed = + subscriptionDAO.getSubscriptionDetailsByDeviceIds(appReleaseId, unsubscribe, tenantId, deviceIds); + Map allSubscriptionForUnSubscribedMap = allSubscriptionsForUnSubscribed.stream() + .collect(Collectors.toMap(DeviceSubscriptionDTO::getDeviceId, Function.identity())); + Map allSubscriptionForSubscribedMap = allSubscriptionsForSubscribed.stream() + .collect(Collectors.toMap(DeviceSubscriptionDTO::getDeviceId, Function.identity())); + + for (DeviceDetailsDTO device : allDevices) { + Integer deviceId = device.getDeviceId(); + OwnerWithDeviceDTO ownerWithDevice = + deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId); + if (ownerWithDevice == null) { + continue; + } + + if (deviceSubscriptionMap.containsKey(deviceId)) { + DeviceSubscriptionDTO subscription = deviceSubscriptionMap.get(deviceId); + DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); + deviceDetail.setDeviceId(subscription.getDeviceId()); + deviceDetail.setSubId(subscription.getId()); + deviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); + deviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); + deviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); + deviceDetail.setActionType(subscription.getActionTriggeredFrom()); + deviceDetail.setStatus(subscription.getStatus()); + deviceDetail.setActionTriggeredBy(subscription.getSubscribedBy()); + deviceDetail.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); + deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); + deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); + deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); + + String status = subscription.getStatus(); + switch (status) { + case "COMPLETED": + installedDevices.add(deviceDetail); + statusCounts.put("COMPLETED", statusCounts.get("COMPLETED") + 1); + break; + case "ERROR": + case "INVALID": + case "UNAUTHORIZED": + errorDevices.add(deviceDetail); + statusCounts.put("ERROR", statusCounts.get("ERROR") + 1); + break; + case "IN_PROGRESS": + case "PENDING": + case "REPEATED": + pendingDevices.add(deviceDetail); + statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); + break; + } + } else if (unsubscribe && allSubscriptionForUnSubscribedMap.containsKey(deviceId) && !deviceSubscriptionMap.containsKey(deviceId)) { + // Check if the device subscription has unsubscribed status set to false + DeviceSubscriptionDTO allSubscription = allSubscriptionForUnSubscribedMap.get(deviceId); + if (!allSubscription.isUnsubscribed()) { + DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); + subscribedDeviceDetail.setDeviceId(allSubscription.getDeviceId()); + subscribedDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); + subscribedDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); + subscribedDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); + subscribedDeviceDetail.setSubId(allSubscription.getId()); + subscribedDeviceDetail.setActionTriggeredBy(allSubscription.getSubscribedBy()); + subscribedDeviceDetail.setActionTriggeredTimestamp(allSubscription.getSubscribedTimestamp()); + subscribedDeviceDetail.setActionType(allSubscription.getActionTriggeredFrom()); + subscribedDeviceDetail.setStatus(allSubscription.getStatus()); + subscribedDevices.add(subscribedDeviceDetail); + statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); + } + } else if (unsubscribe && !allSubscriptionForUnSubscribedMap.containsKey(deviceId) && !deviceSubscriptionMap.containsKey(deviceId) + && (allDevicesMap.containsKey(deviceId))) { + DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); + newDeviceDetail.setDeviceId(deviceId); + newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); + newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); + newDevices.add(newDeviceDetail); + statusCounts.put("NEW", statusCounts.get("NEW") + 1); + } else if (!unsubscribe && !allSubscriptionForSubscribedMap.containsKey(deviceId) && !deviceSubscriptionMap.containsKey(deviceId) + && (allDevicesMap.containsKey(deviceId))) { + DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); + newDeviceDetail.setDeviceId(deviceId); + newDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); + newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); + newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); + newDevices.add(newDeviceDetail); + statusCounts.put("NEW", statusCounts.get("NEW") + 1); + } + } + + int totalDevices = allDevices.size(); + Map statusPercentages = new HashMap<>(); + for (Map.Entry entry : statusCounts.entrySet()) { + double percentage = ((double) entry.getValue() / totalDevices) * 100; + String formattedPercentage = String.format("%.2f", percentage); + statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); + } + + CategorizedSubscriptionResult categorizedSubscriptionResult; + if (subscribedDevices.isEmpty()) { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + } else { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); + } + DeviceSubscriptionResponseDTO deviceSubscriptionResponse = + new DeviceSubscriptionResponseDTO(totalDevices, statusPercentages, categorizedSubscriptionResult); + + return deviceSubscriptionResponse; + + } catch (ApplicationManagementDAOException e) { + String msg = "Error occurred while getting device subscriptions for the application release UUID: " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DBConnectionException e) { + String msg = "DB Connection error occurred while getting device subscriptions for UUID: " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DeviceManagementDAOException e) { + throw new RuntimeException(e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public DeviceSubscriptionResponseDTO getAllSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, int limit) + throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); + + try { + ConnectionManagerUtil.openDBConnection(); + + ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + uuid; + log.error(msg); + throw new NotFoundException(msg); + } + int appReleaseId = applicationReleaseDTO.getId(); + + List allSubscriptions = + subscriptionDAO.getAllSubscriptionsDetails(appReleaseId, unsubscribe, tenantId, offset, limit); + + // empty response for no subscriptions + if (allSubscriptions.isEmpty()) { + return new DeviceSubscriptionResponseDTO(0, Collections.emptyMap(), + new CategorizedSubscriptionResult(Collections.emptyList(), + Collections.emptyList(), Collections.emptyList(), Collections.emptyList())); + } + + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); + + Map allSubscriptionMap = allSubscriptions.stream() + .collect(Collectors.toMap(DeviceSubscriptionDTO::getDeviceId, Function.identity())); + + List pendingDevices = new ArrayList<>(); + List installedDevices = new ArrayList<>(); + List errorDevices = new ArrayList<>(); + List newDevices = new ArrayList<>(); + + Map statusCounts = new HashMap<>(); + statusCounts.put("PENDING", 0); + statusCounts.put("COMPLETED", 0); + statusCounts.put("ERROR", 0); + statusCounts.put("NEW", 0); + + List allDevices = + deviceManagementProviderService.getDevicesByTenantId(tenantId); + + for (DeviceDetailsDTO device : allDevices) { + Integer deviceId = device.getDeviceId(); + OwnerWithDeviceDTO ownerWithDevice = + deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId); + if (ownerWithDevice == null) { + continue; + } + + if (allSubscriptionMap.containsKey(deviceId)) { + DeviceSubscriptionDTO subscription = allSubscriptionMap.get(deviceId); + DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); + deviceDetail.setDeviceId(subscription.getDeviceId()); + deviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); + deviceDetail.setSubId(subscription.getId()); + deviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); + deviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); + deviceDetail.setActionType(subscription.getActionTriggeredFrom()); + deviceDetail.setStatus(subscription.getStatus()); + deviceDetail.setActionTriggeredBy(subscription.getSubscribedBy()); + deviceDetail.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); + deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); + deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); + deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); + + String status = subscription.getStatus(); + switch (status) { + case "COMPLETED": + installedDevices.add(deviceDetail); + statusCounts.put("COMPLETED", statusCounts.get("COMPLETED") + 1); + break; + case "ERROR": + case "INVALID": + case "UNAUTHORIZED": + errorDevices.add(deviceDetail); + statusCounts.put("ERROR", statusCounts.get("ERROR") + 1); + break; + case "IN_PROGRESS": + case "PENDING": + case "REPEATED": + pendingDevices.add(deviceDetail); + statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); + break; + } + } else { + DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); + newDeviceDetail.setDeviceId(deviceId); + newDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); + newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); + newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); + newDevices.add(newDeviceDetail); + statusCounts.put("NEW", statusCounts.get("NEW") + 1); + } + } + + int totalDevices = allDevices.size(); + Map statusPercentages = new HashMap<>(); + for (Map.Entry entry : statusCounts.entrySet()) { + double percentage = ((double) entry.getValue() / totalDevices) * 100; + String formattedPercentage = String.format("%.2f", percentage); + statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); + } + + CategorizedSubscriptionResult categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + DeviceSubscriptionResponseDTO result = + new DeviceSubscriptionResponseDTO(totalDevices, statusPercentages, categorizedSubscriptionResult); + + return result; + } catch (ApplicationManagementDAOException e) { + String msg = "Error occurred while getting user subscriptions for the application release UUID: " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DBConnectionException e) { + String msg = "DB Connection error occurred while getting user subscriptions for UUID: " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DeviceManagementDAOException e) { + throw new RuntimeException(e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit) + throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + if (uuid == null || uuid.isEmpty()) { + throw new IllegalArgumentException("UUID cannot be null or empty."); + } + try { + ConnectionManagerUtil.openDBConnection(); + + ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + uuid; + log.error(msg); + throw new NotFoundException(msg); + } + int appReleaseId = applicationReleaseDTO.getId(); + + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); + List deviceSubscriptions = + subscriptionDAO.getSubscriptionOperationsByAppReleaseIDAndDeviceID(appReleaseId, deviceId, tenantId, offset, limit); + for (DeviceOperationDTO deviceSubscription : deviceSubscriptions) { + Integer operationId = deviceSubscription.getOperationId(); + if (operationId != null) { + OperationDTO operationDetails = deviceManagementProviderService.getOperationDetailsById(operationId); + if (operationDetails != null) { + deviceSubscription.setOperationCode(operationDetails.getOperationCode()); + deviceSubscription.setOperationDetails(operationDetails.getOperationDetails()); + deviceSubscription.setOperationProperties(operationDetails.getOperationProperties()); + deviceSubscription.setOperationResponses(operationDetails.getOperationResponses()); + } + } + } + return deviceSubscriptions; + } catch (ApplicationManagementDAOException e) { + String msg = "Error occurred while retrieving device subscriptions for UUID: " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DBConnectionException e) { + String msg = "Error occurred while retrieving the database connection"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (OperationManagementException e) { + throw new RuntimeException(e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public List getSubscriptionCountsByUUID(String uuid) + throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + if (uuid == null || uuid.isEmpty()) { + throw new IllegalArgumentException("UUID cannot be null or empty."); + } + + try { + ConnectionManagerUtil.openDBConnection(); + + ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + uuid; + log.error(msg); + throw new NotFoundException(msg); + } + int appReleaseId = applicationReleaseDTO.getId(); + + List subscriptionCounts = new ArrayList<>(); + + subscriptionCounts.add(new CategorizedSubscriptionCountsDTO( + "All", + subscriptionDAO.getAllSubscriptionCount(appReleaseId, tenantId), + subscriptionDAO.getAllUnsubscriptionCount(appReleaseId, tenantId))); + subscriptionCounts.add(new CategorizedSubscriptionCountsDTO( + "Device", + subscriptionDAO.getDeviceSubscriptionCount(appReleaseId, tenantId), + subscriptionDAO.getDeviceUnsubscriptionCount(appReleaseId, tenantId))); + subscriptionCounts.add(new CategorizedSubscriptionCountsDTO( + "Group", + subscriptionDAO.getGroupSubscriptionCount(appReleaseId, tenantId), + subscriptionDAO.getGroupUnsubscriptionCount(appReleaseId, tenantId))); + subscriptionCounts.add(new CategorizedSubscriptionCountsDTO( + "Role", + subscriptionDAO.getRoleSubscriptionCount(appReleaseId, tenantId), + subscriptionDAO.getRoleUnsubscriptionCount(appReleaseId, tenantId))); + subscriptionCounts.add(new CategorizedSubscriptionCountsDTO( + "User", + subscriptionDAO.getUserSubscriptionCount(appReleaseId, tenantId), + subscriptionDAO.getUserUnsubscriptionCount(appReleaseId, tenantId))); + + return subscriptionCounts; + } catch (ApplicationManagementDAOException e) { + String msg = "Error occurred while retrieving subscriptions counts for UUID: " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DBConnectionException e) { + String msg = "Error occurred while retrieving the database connection"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/BaseTestCase.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/BaseTestCase.java index 9243cb8930..7251a0d19e 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/BaseTestCase.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/BaseTestCase.java @@ -37,6 +37,7 @@ import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManag import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import org.wso2.carbon.registry.core.config.RegistryContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.internal.RegistryDataHolder; @@ -96,6 +97,7 @@ public abstract class BaseTestCase { ConnectionManagerUtil.init(dataSource); DeviceManagementDAOFactory.init(dataSource); MetadataManagementDAOFactory.init(dataSource); + OperationManagementDAOFactory.init(dataSource); // PolicyManagementDAOFactory.init(dataSource); // OperationManagementDAOFactory.init(dataSource); // GroupManagementDAOFactory.init(dataSource); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java index e42d5c1524..93c456f929 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java @@ -21,9 +21,12 @@ import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo.Status; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO; +import io.entgra.device.mgt.core.device.mgt.core.dto.OwnerWithDeviceDTO; import java.sql.Timestamp; import java.util.List; +import java.util.Map; public interface EnrollmentDAO { @@ -94,5 +97,33 @@ public interface EnrollmentDAO { */ boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException; + /** + * Retrieves owners and the list of device IDs related to an owner. + * + * @param owner the owner whose device IDs need to be retrieved + * @param tenantId the ID of the tenant + * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user + * @throws DeviceManagementDAOException if an error occurs while fetching the data + */ + OwnerWithDeviceDTO getOwnersWithDevices(String owner, int tenantId) throws DeviceManagementDAOException; + /** + * Retrieves a list of device IDs with owners and device status. + * + * @param deviceId the deviceId of the device which user need to be retrieved + * @param tenantId the ID of the tenant + * @return {@link OwnerWithDeviceDTO} which contains a list of devices + * @throws DeviceManagementDAOException if an error occurs while fetching the data + */ + OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, int tenantId) + throws DeviceManagementDAOException; + + /** + * Retrieves owners and the list of device IDs with device status. + * + * @param tenantId the ID of the tenant + * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user + * @throws DeviceManagementDAOException if an error occurs while fetching the data + */ + List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index b3c4321df3..5071f7a400 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -21,9 +21,9 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.ReportManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; +import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO; import java.util.List; import java.util.Map; @@ -469,4 +469,17 @@ public interface GroupDAO { List groupNames) throws GroupManagementDAOException; + /** + * Get group details and list of device IDs related to the group. + * + * @param groupName Group name + * @param tenantId Tenant ID + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link GroupDetailsDTO} which containing group details and a list of device IDs + * @throws GroupManagementDAOException if an error occurs while retrieving the group details and devices + */ + GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int tenantId, int offset, int limit) + throws GroupManagementDAOException; + } \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index 8bde335227..dff096c933 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -18,6 +18,9 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; @@ -26,6 +29,8 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOExceptio import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.EnrollmentDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import io.entgra.device.mgt.core.device.mgt.core.dto.OwnerWithDeviceDTO; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO; import java.sql.Connection; import java.sql.PreparedStatement; @@ -33,11 +38,12 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; -import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.ArrayList; public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { + private static final Log log = LogFactory.getLog(AbstractEnrollmentDAOImpl.class); @Override public EnrolmentInfo addEnrollment(int deviceId, DeviceIdentifier deviceIdentifier, EnrolmentInfo enrolmentInfo, @@ -557,4 +563,109 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { return enrolmentInfo; } + @Override + public OwnerWithDeviceDTO getOwnersWithDevices(String owner, int tenantId) + throws DeviceManagementDAOException { + Connection conn = null; + OwnerWithDeviceDTO ownerDetails = new OwnerWithDeviceDTO(); + List deviceIds = new ArrayList<>(); + int deviceCount = 0; + + String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME " + + "FROM DM_ENROLMENT e " + + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + + "WHERE e.OWNER = ? AND e.TENANT_ID = ?"; + try { + conn = this.getConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, owner); + stmt.setInt(2, tenantId); + + try (ResultSet rs = stmt.executeQuery()) { + while (rs.next()) { + if (ownerDetails.getUserName() == null) { + ownerDetails.setUserName(rs.getString("OWNER")); + } + deviceIds.add(rs.getInt("DEVICE_ID")); + deviceCount++; + } + } + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving owners and device IDs for owner: " + owner; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + + ownerDetails.setDeviceIds(deviceIds); + ownerDetails.setDeviceStatus("DEVICE_STATUS"); + ownerDetails.setDeviceNames("DEVICE_NAME"); + ownerDetails.setDeviceCount(deviceCount); + return ownerDetails; + } + + @Override + public OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, int tenantId) + throws DeviceManagementDAOException { + OwnerWithDeviceDTO deviceOwnerWithStatus = new OwnerWithDeviceDTO(); + Connection conn = null; + String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME " + + "FROM DM_ENROLMENT e " + + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + + "WHERE e.DEVICE_ID = ? AND e.TENANT_ID = ?"; + try { + conn = this.getConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setInt(1, deviceId); + stmt.setInt(2, tenantId); + + try (ResultSet rs = stmt.executeQuery()) { + if (rs.next()) { + deviceOwnerWithStatus.setUserName(rs.getString("OWNER")); + deviceOwnerWithStatus.setDeviceStatus(rs.getString("DEVICE_STATUS")); + List deviceIds = new ArrayList<>(); + deviceIds.add(rs.getInt("DEVICE_ID")); + deviceOwnerWithStatus.setDeviceIds(deviceIds); + deviceOwnerWithStatus.setDeviceNames(rs.getString("DEVICE_NAME")); + } + } + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving owner and status for device ID: " + deviceId; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + return deviceOwnerWithStatus; + } + + @Override + public List getDevicesByTenantId(int tenantId) + throws DeviceManagementDAOException { + List devices = new ArrayList<>(); + String sql = "SELECT DEVICE_ID, OWNER, STATUS FROM DM_ENROLMENT WHERE TENANT_ID = ?"; + Connection conn = null; + + try { + conn = this.getConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setInt(1, tenantId); + + try (ResultSet rs = stmt.executeQuery()) { + while (rs.next()) { + DeviceDetailsDTO device = new DeviceDetailsDTO(); + device.setDeviceId(rs.getInt("DEVICE_ID")); + device.setOwner(rs.getString("OWNER")); + device.setStatus(rs.getString("STATUS")); + devices.add(device); + } + } + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving devices for tenant ID: " + tenantId; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + return devices; + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index c65692870d..c3aa38539d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -26,6 +26,7 @@ import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; +import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; @@ -164,7 +165,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } catch (SQLException e) { String msg = "Error occurred while retrieving groups of groups IDs " + deviceGroupIds.toString() - + " in tenant: " + tenantId; + + " in tenant: " + tenantId; log.error(msg); throw new GroupManagementDAOException(msg, e); } @@ -184,7 +185,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { for (int i = 0; i < deviceGroupIdsCount; i++) { sql += (deviceGroupIdsCount - 1 != i) ? "?," : "?"; } - sql += ")"; + sql += ")"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIndex = 1; stmt.setInt(paramIndex++, tenantId); @@ -202,7 +203,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } catch (SQLException e) { String msg = "Error occurred while retrieving groups of groups IDs " + deviceGroupIds - + " in tenant: " + tenantId; + + " in tenant: " + tenantId; log.error(msg); throw new GroupManagementDAOException(msg, e); } @@ -227,7 +228,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { sql += " AND OWNER LIKE ?"; } if (StringUtils.isNotBlank(request.getParentPath())) { - if(isWithParentPath){ + if (isWithParentPath) { sql += " AND PARENT_PATH LIKE ?"; } } @@ -250,7 +251,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(paramIndex++, request.getOwner() + "%"); } if (StringUtils.isNotBlank(request.getParentPath())) { - if(isWithParentPath){ + if (isWithParentPath) { stmt.setString(paramIndex++, request.getParentPath()); } } @@ -271,7 +272,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } } catch (SQLException e) { String msg = "Error occurred while retrieving groups of groups IDs " + deviceGroupIds.toString() - + " in tenant: " + tenantId; + + " in tenant: " + tenantId; log.error(msg); throw new GroupManagementDAOException(msg, e); } @@ -484,7 +485,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { Connection conn = GroupManagementDAOFactory.getConnection(); String sql = "UPDATE DM_GROUP SET DESCRIPTION = ?, GROUP_NAME = ?, OWNER = ?, STATUS = ?, " + "PARENT_PATH = ?, PARENT_GROUP_ID = ? WHERE ID = ? AND TENANT_ID = ?"; - try (PreparedStatement stmt = conn.prepareStatement(sql)){ + try (PreparedStatement stmt = conn.prepareStatement(sql)) { for (DeviceGroup deviceGroup : deviceGroups) { stmt.setString(1, deviceGroup.getDescription()); stmt.setString(2, deviceGroup.getName()); @@ -609,6 +610,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throw new GroupManagementDAOException(msg, e); } } + @Override public void deleteGroups(List groupIds, int tenantId) throws GroupManagementDAOException { try { @@ -1166,7 +1168,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { if (StringUtils.isNotBlank(parentPath)) { sql += " AND g.PARENT_PATH = ? "; } - sql += "GROUP BY g.ID"; + sql += "GROUP BY g.ID"; stmt = conn.prepareStatement(sql); int index = 0; while (index++ < rolesCount) { @@ -1279,7 +1281,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { return devices; } Connection conn = GroupManagementDAOFactory.getConnection(); - StringJoiner joiner = new StringJoiner(",","SELECT " + StringJoiner joiner = new StringJoiner(",", "SELECT " + "d1.DEVICE_ID, " + "d1.DESCRIPTION, " + "d1.NAME AS DEVICE_NAME, " @@ -1437,4 +1439,72 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } return groupUnassignedDeviceList; } -} + + @Override + public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int tenantId, int offset, int limit) + throws GroupManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to get group details and device IDs for group: " + groupName); + } + GroupDetailsDTO groupDetails = new GroupDetailsDTO(); + List deviceIds = new ArrayList<>(); + Map deviceOwners = new HashMap<>(); + Map deviceStatuses = new HashMap<>(); + Map deviceNames = new HashMap<>(); + + String sql = + "SELECT " + + " g.ID AS GROUP_ID, " + + " g.GROUP_NAME, " + + " g.OWNER AS GROUP_OWNER, " + + " e.OWNER AS DEVICE_OWNER, " + + " e.STATUS AS DEVICE_STATUS, " + + " dgm.DEVICE_ID, " + + " d.NAME AS DEVICE_NAME " + + "FROM " + + " DM_GROUP g " + + " JOIN DM_DEVICE_GROUP_MAP dgm ON g.ID = dgm.GROUP_ID " + + " JOIN DM_ENROLMENT e ON dgm.DEVICE_ID = e.DEVICE_ID " + + " JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + + "WHERE " + + " g.GROUP_NAME = ? " + + " AND g.TENANT_ID = ? " + + "LIMIT ? OFFSET ?"; + + Connection conn = null; + try { + conn = GroupManagementDAOFactory.getConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, groupName); + stmt.setInt(2, tenantId); + stmt.setInt(3, limit); + stmt.setInt(4, offset); + + try (ResultSet rs = stmt.executeQuery()) { + while (rs.next()) { + if (groupDetails.getGroupId() == 0) { + groupDetails.setGroupId(rs.getInt("GROUP_ID")); + groupDetails.setGroupName(rs.getString("GROUP_NAME")); + groupDetails.setGroupOwner(rs.getString("GROUP_OWNER")); + } + int deviceId = rs.getInt("DEVICE_ID"); + deviceIds.add(deviceId); + deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER")); + deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS")); + deviceNames.put(deviceId, rs.getString("DEVICE_NAME")); + } + } + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; + log.error(msg, e); + throw new GroupManagementDAOException(msg, e); + } + groupDetails.setDeviceIds(deviceIds); + groupDetails.setDeviceCount(deviceIds.size()); + groupDetails.setDeviceOwners(deviceOwners); + groupDetails.setDeviceStatuses(deviceStatuses); + groupDetails.setDeviceNames(deviceNames); + return groupDetails; + } +} \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java new file mode 100644 index 0000000000..2457e0bd3b --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.dto; + +public class DeviceDetailsDTO { + private int deviceId; + private String owner; + private String status; + + public int getDeviceId() { + return deviceId; + } + + public void setDeviceId(int deviceId) { + this.deviceId = deviceId; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/GroupDetailsDTO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/GroupDetailsDTO.java new file mode 100644 index 0000000000..289fcfd472 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/GroupDetailsDTO.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.dto; + +import java.util.List; +import java.util.Map; + +public class GroupDetailsDTO { + private int groupId; + private String groupName; + private String groupOwner; + private List deviceIds; + private int deviceCount; + private String deviceOwner; + private String deviceStatus; + private Map deviceOwners; + private Map deviceStatuses; + private Map deviceNames; + + public int getGroupId() { + return groupId; + } + + public void setGroupId(int groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getGroupOwner() { + return groupOwner; + } + + public void setGroupOwner(String groupOwner) { + this.groupOwner = groupOwner; + } + + public List getDeviceIds() { + return deviceIds; + } + + public void setDeviceIds(List deviceIds) { + this.deviceIds = deviceIds; + } + + public int getDeviceCount() { + return deviceCount; + } + + public void setDeviceCount(int deviceCount) { + this.deviceCount = deviceCount; + } + + public String getDeviceOwner() { + return deviceOwner; + } + + public void setDeviceOwner(String deviceOwner) { + this.deviceOwner = deviceOwner; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public Map getDeviceOwners() { + return deviceOwners; + } + + public void setDeviceOwners(Map deviceOwners) { + this.deviceOwners = deviceOwners; + } + + public Map getDeviceStatuses() { + return deviceStatuses; + } + + public void setDeviceStatuses(Map deviceStatuses) { + this.deviceStatuses = deviceStatuses; + } + + public Map getDeviceNames() { + return deviceNames; + } + + public void setDeviceNames(Map deviceNames) { + this.deviceNames = deviceNames; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OperationDTO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OperationDTO.java new file mode 100644 index 0000000000..05530e231b --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OperationDTO.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018 - 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.device.mgt.core.dto; + +import org.json.JSONObject; +import java.util.List; + +public class OperationDTO { + private int operationId; + private String operationCode; + private JSONObject operationDetails; + private JSONObject operationProperties; + private List operationResponses; + + // Getters and Setters + + public int getOperationId() { + return operationId; + } + + public void setOperationId(int operationId) { + this.operationId = operationId; + } + + public String getOperationCode() { + return operationCode; + } + + public void setOperationCode(String operationCode) { + this.operationCode = operationCode; + } + + public JSONObject getOperationDetails() { + return operationDetails; + } + + public void setOperationDetails(JSONObject operationDetails) { + this.operationDetails = operationDetails; + } + + public JSONObject getOperationProperties() { + return operationProperties; + } + + public void setOperationProperties(JSONObject operationProperties) { + this.operationProperties = operationProperties; + } + + public List getOperationResponses() { + return operationResponses; + } + + public void setOperationResponses(List operationResponses) { + this.operationResponses = operationResponses; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/UserSubscriptionDTO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OperationResponseDTO.java similarity index 55% rename from components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/UserSubscriptionDTO.java rename to components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OperationResponseDTO.java index 4df7e4e64d..b52404ca0e 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/UserSubscriptionDTO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OperationResponseDTO.java @@ -16,17 +16,28 @@ * under the License. */ -package io.entgra.device.mgt.core.application.mgt.common.dto; +package io.entgra.device.mgt.core.device.mgt.core.dto; import java.sql.Timestamp; -public class UserSubscriptionDTO { - private int id; - private String subscribedBy; - private Timestamp subscribedTimestamp; - private boolean isUnsubscribed; - private String unsubscribedBy; - private Timestamp unsubscribedTimestamp; - private String subscribedFrom; - private String userName; +public class OperationResponseDTO { + private String operationResponse; + private Timestamp responseTimeStamp; + + public String getOperationResponse() { + return operationResponse; + } + + public void setOperationResponse(String operationResponse) { + this.operationResponse = operationResponse; + } + + public Timestamp getResponseTimeStamp() { + return responseTimeStamp; + } + + public void setResponseTimeStamp(Timestamp responseTimeStamp) { + this.responseTimeStamp = responseTimeStamp; + } } + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OwnerWithDeviceDTO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OwnerWithDeviceDTO.java new file mode 100644 index 0000000000..9d644b1930 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OwnerWithDeviceDTO.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.dto; + +import java.util.List; + +public class OwnerWithDeviceDTO { + + private String userName; + private List deviceIds; + private int deviceCount; + private String deviceStatus; + private String deviceNames; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public List getDeviceIds() { + return deviceIds; + } + + public void setDeviceIds(List deviceIds) { + this.deviceIds = deviceIds; + } + + public int getDeviceCount() { + return deviceCount; + } + + public void setDeviceCount(int deviceCount) { + this.deviceCount = deviceCount; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public String getDeviceNames() { + return deviceNames; + } + + public void setDeviceNames(String deviceNames) { + this.deviceNames = deviceNames; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java index 4abaf40022..c874283a76 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java @@ -23,6 +23,8 @@ import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationResponse; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.DeviceActivity; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dto.OperationDTO; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.OperationResponseMeta; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationMapping; @@ -124,4 +126,15 @@ public interface OperationDAO { int getDeviceActivitiesCount(ActivityPaginationRequest activityPaginationRequest) throws OperationManagementDAOException; + + /** + * This method is used to get the details of device subscriptions related to a UUID. + * + * @param operationId the operationId of the operation to be retrieved. + * @param tenantId id of the current tenant. + * @return {@link OperationDTO} which contains the details of device operations. + * @throws OperationManagementDAOException if connection establishment or SQL execution fails. + */ + OperationDTO getOperationDetailsById(int operationId, int tenantId) + throws OperationManagementDAOException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index 8322905a5e..50ec3f1071 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -17,32 +17,36 @@ */ package io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl; -import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ProfileOperation; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.ActivityPaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; -import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.DeviceActivity; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityHolder; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.ActivityStatus; +import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.DeviceActivity; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.OperationResponse; import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; +import io.entgra.device.mgt.core.device.mgt.core.dto.OperationDTO; +import io.entgra.device.mgt.core.device.mgt.core.dto.OperationResponseDTO; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.OperationResponseMeta; +import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ProfileOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.OperationMapping; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationDAO; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; +import org.wso2.carbon.context.PrivilegedCarbonContext; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; +import java.sql.Blob; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -2774,4 +2778,66 @@ public class GenericOperationDAOImpl implements OperationDAO { } return 0; } + + @Override + public OperationDTO getOperationDetailsById(int operationId, int tenantId) + throws OperationManagementDAOException { + OperationDTO operationDetails = new OperationDTO(); + + String sql = "SELECT o.ID, " + + "o.OPERATION_CODE, " + + "o.OPERATION_DETAILS, " + + "o.OPERATION_PROPERTIES, " + + "r.OPERATION_RESPONSE, " + + "r.RECEIVED_TIMESTAMP " + + "FROM DM_OPERATION o " + + "LEFT JOIN DM_DEVICE_OPERATION_RESPONSE r " + + "ON o.ID = r.OPERATION_ID " + + "WHERE o.ID = ? " + + "AND o.TENANT_ID = ?"; + + try { + Connection conn = OperationManagementDAOFactory.getConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setInt(1, operationId); + stmt.setInt(2, tenantId); + + try (ResultSet rs = stmt.executeQuery()) { + List responses = new ArrayList<>(); + while (rs.next()) { + if (operationDetails.getOperationId() == 0) { + operationDetails.setOperationId(rs.getInt("ID")); + operationDetails.setOperationCode(rs.getString("OPERATION_CODE")); + Blob detailsBlob = rs.getBlob("OPERATION_DETAILS"); + if (detailsBlob != null) { + JSONObject operationDetailsJson = OperationDAOUtil.convertBlobToJsonObject(detailsBlob); + operationDetails.setOperationDetails(operationDetailsJson); + } + Blob propertiesBlob = rs.getBlob("OPERATION_PROPERTIES"); + if (propertiesBlob != null) { + JSONObject operationPropertiesJson = OperationDAOUtil.convertBlobToJsonObject(propertiesBlob); + operationDetails.setOperationProperties(operationPropertiesJson); + } + } + + String response = rs.getString("OPERATION_RESPONSE"); + Timestamp responseTimestamp = rs.getTimestamp("RECEIVED_TIMESTAMP"); + if (response != null && responseTimestamp != null) { + OperationResponseDTO operationResponse = new OperationResponseDTO(); + operationResponse.setOperationResponse(response); + operationResponse.setResponseTimeStamp(responseTimestamp); + responses.add(operationResponse); + } + } + operationDetails.setOperationResponses(responses); + } + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving operation details for operation ID: " + operationId; + log.error(msg, e); + throw new OperationManagementDAOException(msg, e); + } + + return operationDetails; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java index 6561868060..3aef7ea447 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java @@ -33,10 +33,14 @@ import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.PolicyOperation; import io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.ProfileOperation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; +import org.json.JSONObject; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.ObjectInputStream; +import java.sql.Blob; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; @@ -387,4 +391,53 @@ public class OperationDAOUtil { return operation; } + /** + * @param blob + * @return + * @throws SQLException + */ + public static JSONObject convertBlobToJsonObject(Blob blob) throws SQLException { + String jsonString; + try (InputStream inputStream = blob.getBinaryStream(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + int bytesRead; + byte[] buffer = new byte[4096]; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + byte[] blobBytes = outputStream.toByteArray(); + + // Check if the blob data is a serialized Java object + if (blobBytes.length > 2 && (blobBytes[0] & 0xFF) == 0xAC && (blobBytes[1] & 0xFF) == 0xED) { + // Deserialize the object + try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(blobBytes))) { + Object obj = ois.readObject(); + if (obj instanceof String) { + jsonString = (String) obj; + } else { + jsonString = new JSONObject(obj).toString(); + } + } catch (ClassNotFoundException e) { + String msg = "Failed to deserialize object from BLOB"; + log.error(msg, e); + throw new SQLException(msg, e); + } + } else { + // If not serialized, treat it as plain JSON string + jsonString = new String(blobBytes, "UTF-8"); + } + } catch (IOException e) { + String msg = "Failed to convert BLOB to JSON string"; + log.error(msg, e); + throw new SQLException(msg, e); + } + // Convert JSON string to JSONObject + if (jsonString == null || jsonString.isEmpty()) { + String msg = "Converted JSON string is null or empty"; + log.error(msg); + throw new SQLException(msg); + } + return new JSONObject(jsonString); + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index 689fc1b243..f7b72f0275 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -19,6 +19,9 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO; +import io.entgra.device.mgt.core.device.mgt.core.dto.OperationDTO; +import io.entgra.device.mgt.core.device.mgt.core.dto.OwnerWithDeviceDTO; import org.apache.commons.collections.map.SingletonMap; import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; @@ -1073,4 +1076,39 @@ public interface DeviceManagementProviderService { List getEnrolledDevicesSince(Date since) throws DeviceManagementException; List getEnrolledDevicesPriorTo(Date before) throws DeviceManagementException; void deleteDeviceDataByTenantDomain(String tenantDomain) throws DeviceManagementException; + + /** + * Get owner details and device IDs for a given owner and tenant. + * + * @param owner the name of the owner. + * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user. + * @throws DeviceManagementException if an error occurs while fetching owner details. + */ + OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner) throws DeviceManagementDAOException; + + /** + * Get owner details and device IDs for a given owner and tenant. + * + * @param deviceId the deviceId of the device. + * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user. + * @throws DeviceManagementException if an error occurs while fetching owner details. + */ + OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId) throws DeviceManagementDAOException; + + /** + * Get owner details and device IDs for a given owner and tenant. + * @param tenantId the tenant id which devices need to be retried + * @return {@link DeviceDetailsDTO} which contains devices details. + * @throws DeviceManagementException if an error occurs while fetching owner details. + */ + List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException; + + /** + * Get operation details by operation code. + * + * @param operationId the id of the operation. + * @return {@link OperationDTO} which contains operation details. + * @throws OperationManagementException if an error occurs while fetching the operation details. + */ + OperationDTO getOperationDetailsById(int operationId) throws OperationManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 75f3836a34..aee7f67e02 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -22,6 +22,11 @@ import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import io.entgra.device.mgt.core.device.mgt.core.dao.TenantDAO; +import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO; +import io.entgra.device.mgt.core.device.mgt.core.dto.OwnerWithDeviceDTO; +import io.entgra.device.mgt.core.device.mgt.core.dto.OperationDTO; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext; import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceEnrolmentLoggerImpl; @@ -120,6 +125,7 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceStatusDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceTypeDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.EnrollmentDAO; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.DeviceInformationManager; @@ -173,6 +179,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv private final DeviceDAO deviceDAO; private final DeviceTypeDAO deviceTypeDAO; private final EnrollmentDAO enrollmentDAO; + private final OperationDAO operationDAO; private final ApplicationDAO applicationDAO; private MetadataDAO metadataDAO; private final DeviceStatusDAO deviceStatusDAO; @@ -185,6 +192,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv this.applicationDAO = DeviceManagementDAOFactory.getApplicationDAO(); this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); this.enrollmentDAO = DeviceManagementDAOFactory.getEnrollmentDAO(); + this.operationDAO = OperationManagementDAOFactory.getOperationDAO(); this.metadataDAO = MetadataManagementDAOFactory.getMetadataDAO(); this.deviceStatusDAO = DeviceManagementDAOFactory.getDeviceStatusDAO(); this.tenantDao = DeviceManagementDAOFactory.getTenantDAO(); @@ -5339,4 +5347,106 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.closeConnection(); } } + + @Override + public OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner) throws DeviceManagementDAOException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + OwnerWithDeviceDTO ownerWithDeviceDTO; + + try { + DeviceManagementDAOFactory.openConnection(); + ownerWithDeviceDTO = this.enrollmentDAO.getOwnersWithDevices(owner, tenantId); + if (ownerWithDeviceDTO == null) { + String msg = "No data found for owner: " + owner; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } + List deviceIds = ownerWithDeviceDTO.getDeviceIds(); + if (deviceIds != null) { + ownerWithDeviceDTO.setDeviceCount(deviceIds.size()); + } else { + ownerWithDeviceDTO.setDeviceCount(0); + } + } catch (DeviceManagementDAOException | SQLException e) { + String msg = "Error occurred while retrieving device IDs for owner: " + owner; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + return ownerWithDeviceDTO; + } + + + @Override + public OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId) throws DeviceManagementDAOException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + OwnerWithDeviceDTO deviceOwnerWithStatus; + + try { + DeviceManagementDAOFactory.openConnection(); + deviceOwnerWithStatus = enrollmentDAO.getOwnerWithDeviceByDeviceId(deviceId, tenantId); + if (deviceOwnerWithStatus == null) { + throw new DeviceManagementDAOException("No data found for device ID: " + deviceId); + } + List deviceIds = deviceOwnerWithStatus.getDeviceIds(); + if (deviceIds != null) { + deviceOwnerWithStatus.setDeviceCount(deviceIds.size()); + } else { + deviceOwnerWithStatus.setDeviceCount(0); + } + } catch (DeviceManagementDAOException | SQLException e) { + String msg = "Error occurred while retrieving owner and status for device ID: " + deviceId; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + return deviceOwnerWithStatus; + } + + @Override + public List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException { + List devices; + try { + DeviceManagementDAOFactory.openConnection(); + devices = enrollmentDAO.getDevicesByTenantId(tenantId); + if (devices == null || devices.isEmpty()) { + String msg = "No devices found for tenant ID: " + tenantId; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } + } catch (DeviceManagementDAOException | SQLException e) { + String msg = "Error occurred while retrieving devices for tenant ID: " + tenantId; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + return devices; + } + + + @Override + public OperationDTO getOperationDetailsById(int operationId) throws OperationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + OperationDTO operationDetails; + try { + OperationManagementDAOFactory.openConnection(); + operationDetails = this.operationDAO.getOperationDetailsById(operationId, tenantId); + if (operationDetails == null) { + String msg = "No operation details found for operation ID: " + operationId; + log.error(msg); + throw new OperationManagementException(msg); + } + } catch (SQLException | OperationManagementDAOException e) { + String msg = "Error occurred while retrieving operation details for operation ID: " + operationId; + log.error(msg, e); + throw new OperationManagementException(msg, e); + } finally { + OperationManagementDAOFactory.closeConnection(); + } + return operationDetails; + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index 2c741730bd..fac06bfccf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -30,6 +30,7 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistEx import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO; import org.wso2.carbon.user.api.AuthorizationManager; import org.wso2.carbon.user.api.UserStoreManager; @@ -371,4 +372,16 @@ public interface GroupManagementProviderService { DeviceTypesOfGroups getDeviceTypesOfGroups(List identifiers) throws GroupManagementException; DeviceGroup getUserOwnGroup(int groupId, boolean requireGroupProps, int depth) throws GroupManagementException; + + /** + * Get group details and device IDs for a given group name. + * + * @param groupName the name of the group. + * @param offset the offset for the data set + * @param limit the limit for the data set + * @return {@link GroupDetailsDTO} which containing group details and a list of device IDs + * @throws GroupManagementException if an error occurs while fetching group details. + */ + GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int offset, int limit) throws GroupManagementException; + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 88aad71dcd..c42feed9b8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -26,13 +26,13 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistEx import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -1629,6 +1629,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid createGroupWithChildren(nextParentGroup, childrenGroups, requireGroupProps, tenantId, depth, counter); } } + @Override public DeviceTypesOfGroups getDeviceTypesOfGroups(List identifiers) throws GroupManagementException { DeviceTypesOfGroups deviceTypesOfGroups = new DeviceTypesOfGroups(); @@ -1685,4 +1686,37 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid return deviceTypesOfGroups; } + + @Override + public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int offset, int limit) + throws GroupManagementException { + if (log.isDebugEnabled()) { + log.debug("Retrieving group details and device IDs for group: " + groupName); + } + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + GroupDetailsDTO groupDetailsWithDevices; + + try { + GroupManagementDAOFactory.openConnection(); + groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, tenantId, offset, limit); + } catch (GroupManagementDAOException | SQLException e) { + String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + + if (groupDetailsWithDevices != null) { + List deviceIds = groupDetailsWithDevices.getDeviceIds(); + if (deviceIds != null) { + groupDetailsWithDevices.setDeviceCount(deviceIds.size()); + } else { + groupDetailsWithDevices.setDeviceCount(0); + } + } + + return groupDetailsWithDevices; + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/BaseExtensionsTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/BaseExtensionsTest.java index aff8d17eda..992969aa92 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/BaseExtensionsTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/BaseExtensionsTest.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.template; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import org.apache.tomcat.jdbc.pool.PoolProperties; import org.mockito.Mockito; import org.testng.annotations.BeforeSuite; @@ -131,6 +132,7 @@ public class BaseExtensionsTest { readDataSourceConfig(datasourceLocation + DATASOURCE_EXT)); DeviceManagementDAOFactory.init(dataSource); MetadataManagementDAOFactory.init(dataSource); + OperationManagementDAOFactory.init(dataSource); } protected DataSourceConfig readDataSourceConfig(String configLocation) throws DeviceManagementException { From e024283f25f2dbb4b3954fa9558dfce1c26736ee Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Thu, 27 Jun 2024 22:11:30 +0530 Subject: [PATCH 217/343] Return device type and identifier with subscription list --- .../mgt/common/DeviceSubscriptionData.java | 18 ++++++++++ .../core/impl/SubscriptionManagerImpl.java | 30 +++++++++++++++++ .../dao/impl/AbstractEnrollmentDAOImpl.java | 4 ++- .../core/dao/impl/AbstractGroupDAOImpl.java | 33 +++++++++++-------- .../device/mgt/core/dto/GroupDetailsDTO.java | 18 ++++++++++ .../mgt/core/dto/OwnerWithDeviceDTO.java | 18 ++++++++++ 6 files changed, 107 insertions(+), 14 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java index 465db48c53..b77b2ba599 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionData.java @@ -40,6 +40,8 @@ public class DeviceSubscriptionData { private String unsubscribedBy; private Timestamp unsubscribedTimestamp; private String deviceName; + private String deviceIdentifier; + private String type; public String getAction() { return action; @@ -168,4 +170,20 @@ public class DeviceSubscriptionData { public void setDeviceName(String deviceName) { this.deviceName = deviceName; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDeviceIdentifier() { + return deviceIdentifier; + } + + public void setDeviceIdentifier(String deviceIdentifier) { + this.deviceIdentifier = deviceIdentifier; + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 0ade616d52..669cdb7745 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1792,6 +1792,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); + deviceDetail.setType(groupDetailWithDevices.getDeviceTypes().get(deviceId)); + deviceDetail.setDeviceIdentifier(groupDetailWithDevices.getDeviceIdentifiers().get(deviceId)); status = subscription.getStatus(); switch (status) { @@ -1829,6 +1831,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); + subscribedDeviceDetail.setType(groupDetailWithDevices.getDeviceTypes().get(deviceId)); + subscribedDeviceDetail.setDeviceIdentifier(groupDetailWithDevices.getDeviceIdentifiers().get(deviceId)); subscribedDevices.add(subscribedDeviceDetail); statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); isSubscribedDevice = true; @@ -1841,6 +1845,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { newDeviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId)); newDeviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId)); newDeviceDetail.setDeviceName(groupDetailWithDevices.getDeviceNames().get(deviceId)); + newDeviceDetail.setType(groupDetailWithDevices.getDeviceTypes().get(deviceId)); + newDeviceDetail.setDeviceIdentifier(groupDetailWithDevices.getDeviceIdentifiers().get(deviceId)); newDevices.add(newDeviceDetail); statusCounts.put("NEW", statusCounts.get("NEW") + 1); } @@ -1975,6 +1981,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); + deviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); + deviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); status = subscription.getStatus(); switch (status) { @@ -2012,6 +2020,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); + subscribedDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); + subscribedDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); subscribedDevices.add(subscribedDeviceDetail); statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); isSubscribedDevice = true; @@ -2024,6 +2034,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); + newDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); + newDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); newDevices.add(newDeviceDetail); statusCounts.put("NEW", statusCounts.get("NEW") + 1); } @@ -2166,6 +2178,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceDetail.setUnsubscribed(deviceSubscription.isUnsubscribed()); deviceDetail.setUnsubscribedBy(deviceSubscription.getUnsubscribedBy()); deviceDetail.setUnsubscribedTimestamp(deviceSubscription.getUnsubscribedTimestamp()); + deviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); + deviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); status = deviceSubscription.getStatus(); switch (status) { @@ -2203,6 +2217,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); + subscribedDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); + subscribedDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); subscribedDevices.add(subscribedDeviceDetail); statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); isSubscribedDevice = true; @@ -2215,6 +2231,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + newDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); + newDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); newDevices.add(newDeviceDetail); statusCounts.put("NEW", statusCounts.get("NEW") + 1); } @@ -2359,6 +2377,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); + deviceDetail.setType(ownerWithDevice.getDeviceTypes()); + deviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); String status = subscription.getStatus(); switch (status) { @@ -2393,6 +2413,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { subscribedDeviceDetail.setActionTriggeredTimestamp(allSubscription.getSubscribedTimestamp()); subscribedDeviceDetail.setActionType(allSubscription.getActionTriggeredFrom()); subscribedDeviceDetail.setStatus(allSubscription.getStatus()); + subscribedDeviceDetail.setType(ownerWithDevice.getDeviceTypes()); + subscribedDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); subscribedDevices.add(subscribedDeviceDetail); statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); } @@ -2402,6 +2424,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { newDeviceDetail.setDeviceId(deviceId); newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); + newDeviceDetail.setType(ownerWithDevice.getDeviceTypes()); + newDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); newDevices.add(newDeviceDetail); statusCounts.put("NEW", statusCounts.get("NEW") + 1); } else if (!unsubscribe && !allSubscriptionForSubscribedMap.containsKey(deviceId) && !deviceSubscriptionMap.containsKey(deviceId) @@ -2411,6 +2435,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { newDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); + newDeviceDetail.setType(ownerWithDevice.getDeviceTypes()); + newDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); newDevices.add(newDeviceDetail); statusCounts.put("NEW", statusCounts.get("NEW") + 1); } @@ -2521,6 +2547,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); + deviceDetail.setType(ownerWithDevice.getDeviceTypes()); + deviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); String status = subscription.getStatus(); switch (status) { @@ -2547,6 +2575,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { newDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); + newDeviceDetail.setType(ownerWithDevice.getDeviceTypes()); + newDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); newDevices.add(newDeviceDetail); statusCounts.put("NEW", statusCounts.get("NEW") + 1); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index dff096c933..2ee345fd77 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -571,7 +571,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { List deviceIds = new ArrayList<>(); int deviceCount = 0; - String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME " + + String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE AS DEVICE_TYPE, e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + "WHERE e.OWNER = ? AND e.TENANT_ID = ?"; @@ -600,6 +600,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { ownerDetails.setDeviceIds(deviceIds); ownerDetails.setDeviceStatus("DEVICE_STATUS"); ownerDetails.setDeviceNames("DEVICE_NAME"); + ownerDetails.setDeviceTypes("DEVICE_TYPE"); + ownerDetails.setDeviceIdentifiers("DEVICE_IDENTIFICATION"); ownerDetails.setDeviceCount(deviceCount); return ownerDetails; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index c3aa38539d..3c5d836f49 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1451,6 +1451,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { Map deviceOwners = new HashMap<>(); Map deviceStatuses = new HashMap<>(); Map deviceNames = new HashMap<>(); + Map deviceTypes = new HashMap<>(); + Map deviceIdentifiers = new HashMap<>(); String sql = "SELECT " + @@ -1459,6 +1461,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { " g.OWNER AS GROUP_OWNER, " + " e.OWNER AS DEVICE_OWNER, " + " e.STATUS AS DEVICE_STATUS, " + + " e.DEVICE_TYPE AS DEVICE_TYPE, " + + " e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + " dgm.DEVICE_ID, " + " d.NAME AS DEVICE_NAME " + "FROM " + @@ -1480,19 +1484,20 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setInt(3, limit); stmt.setInt(4, offset); - try (ResultSet rs = stmt.executeQuery()) { - while (rs.next()) { - if (groupDetails.getGroupId() == 0) { - groupDetails.setGroupId(rs.getInt("GROUP_ID")); - groupDetails.setGroupName(rs.getString("GROUP_NAME")); - groupDetails.setGroupOwner(rs.getString("GROUP_OWNER")); - } - int deviceId = rs.getInt("DEVICE_ID"); - deviceIds.add(deviceId); - deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER")); - deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS")); - deviceNames.put(deviceId, rs.getString("DEVICE_NAME")); + try (ResultSet rs = stmt.executeQuery()) { + while (rs.next()) { + if (groupDetails.getGroupId() == 0) { + groupDetails.setGroupId(rs.getInt("GROUP_ID")); + groupDetails.setGroupName(rs.getString("GROUP_NAME")); + groupDetails.setGroupOwner(rs.getString("GROUP_OWNER")); } + int deviceId = rs.getInt("DEVICE_ID"); + deviceIds.add(deviceId); + deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER")); + deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS")); + deviceNames.put(deviceId, rs.getString("DEVICE_NAME")); + deviceTypes.put(deviceId, rs.getString("DEVICE_TYPE")); + deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION")); } } } catch (SQLException e) { @@ -1505,6 +1510,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { groupDetails.setDeviceOwners(deviceOwners); groupDetails.setDeviceStatuses(deviceStatuses); groupDetails.setDeviceNames(deviceNames); + groupDetails.setDeviceTypes(deviceTypes); + groupDetails.setDeviceIdentifiers(deviceIdentifiers); return groupDetails; } -} \ No newline at end of file +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/GroupDetailsDTO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/GroupDetailsDTO.java index 289fcfd472..c3a20d5217 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/GroupDetailsDTO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/GroupDetailsDTO.java @@ -32,6 +32,8 @@ public class GroupDetailsDTO { private Map deviceOwners; private Map deviceStatuses; private Map deviceNames; + private Map deviceTypes; + private Map deviceIdentifiers; public int getGroupId() { return groupId; @@ -112,4 +114,20 @@ public class GroupDetailsDTO { public void setDeviceNames(Map deviceNames) { this.deviceNames = deviceNames; } + + public Map getDeviceTypes() { + return deviceTypes; + } + + public void setDeviceTypes(Map deviceTypes) { + this.deviceTypes = deviceTypes; + } + + public Map getDeviceIdentifiers() { + return deviceIdentifiers; + } + + public void setDeviceIdentifiers(Map deviceIdentifiers) { + this.deviceIdentifiers = deviceIdentifiers; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OwnerWithDeviceDTO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OwnerWithDeviceDTO.java index 9d644b1930..be6f63702a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OwnerWithDeviceDTO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/OwnerWithDeviceDTO.java @@ -27,6 +27,8 @@ public class OwnerWithDeviceDTO { private int deviceCount; private String deviceStatus; private String deviceNames; + private String deviceTypes; + private String deviceIdentifiers; public String getUserName() { return userName; @@ -67,4 +69,20 @@ public class OwnerWithDeviceDTO { public void setDeviceNames(String deviceNames) { this.deviceNames = deviceNames; } + + public String getDeviceTypes() { + return deviceTypes; + } + + public void setDeviceTypes(String deviceTypes) { + this.deviceTypes = deviceTypes; + } + + public String getDeviceIdentifiers() { + return deviceIdentifiers; + } + + public void setDeviceIdentifiers(String deviceIdentifiers) { + this.deviceIdentifiers = deviceIdentifiers; + } } From aa9f3da380f878837611bca8ddea46c7af60d378 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Sun, 30 Jun 2024 14:05:04 +0530 Subject: [PATCH 218/343] Fix issues in returning type in allsubscriptions --- .../dao/impl/AbstractEnrollmentDAOImpl.java | 10 ++++++++-- .../device/mgt/core/dto/DeviceDetailsDTO.java | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index 2ee345fd77..e831e68a2e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -611,7 +611,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { throws DeviceManagementDAOException { OwnerWithDeviceDTO deviceOwnerWithStatus = new OwnerWithDeviceDTO(); Connection conn = null; - String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME " + + String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + "WHERE e.DEVICE_ID = ? AND e.TENANT_ID = ?"; @@ -629,6 +629,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { deviceIds.add(rs.getInt("DEVICE_ID")); deviceOwnerWithStatus.setDeviceIds(deviceIds); deviceOwnerWithStatus.setDeviceNames(rs.getString("DEVICE_NAME")); + deviceOwnerWithStatus.setDeviceTypes(rs.getString("DEVICE_TYPE")); + deviceOwnerWithStatus.setDeviceIdentifiers(rs.getString("DEVICE_IDENTIFICATION")); } } } @@ -644,7 +646,9 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { public List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException { List devices = new ArrayList<>(); - String sql = "SELECT DEVICE_ID, OWNER, STATUS FROM DM_ENROLMENT WHERE TENANT_ID = ?"; + String sql = "SELECT DEVICE_ID, OWNER, STATUS, DEVICE_TYPE, DEVICE_IDENTIFICATION " + + "FROM DM_ENROLMENT " + + "WHERE TENANT_ID = ?"; Connection conn = null; try { @@ -658,6 +662,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { device.setDeviceId(rs.getInt("DEVICE_ID")); device.setOwner(rs.getString("OWNER")); device.setStatus(rs.getString("STATUS")); + device.setType(rs.getString("DEVICE_TYPE")); + device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION")); devices.add(device); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java index 2457e0bd3b..bb25d55c52 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dto/DeviceDetailsDTO.java @@ -22,6 +22,8 @@ public class DeviceDetailsDTO { private int deviceId; private String owner; private String status; + private String type; + private String deviceIdentifier; public int getDeviceId() { return deviceId; @@ -46,4 +48,20 @@ public class DeviceDetailsDTO { public void setStatus(String status) { this.status = status; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDeviceIdentifier() { + return deviceIdentifier; + } + + public void setDeviceIdentifier(String deviceIdentifier) { + this.deviceIdentifier = deviceIdentifier; + } } From 2021a0b37ac8ab0c955d66960dfcfbb5c7f0133a Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Mon, 1 Jul 2024 01:24:29 +0530 Subject: [PATCH 219/343] Fix issues in get devices method --- .../core/dao/impl/AbstractGroupDAOImpl.java | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 3c5d836f49..780ba43cc6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1484,34 +1484,35 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setInt(3, limit); stmt.setInt(4, offset); - try (ResultSet rs = stmt.executeQuery()) { - while (rs.next()) { - if (groupDetails.getGroupId() == 0) { - groupDetails.setGroupId(rs.getInt("GROUP_ID")); - groupDetails.setGroupName(rs.getString("GROUP_NAME")); - groupDetails.setGroupOwner(rs.getString("GROUP_OWNER")); + try (ResultSet rs = stmt.executeQuery()) { + while (rs.next()) { + if (groupDetails.getGroupId() == 0) { + groupDetails.setGroupId(rs.getInt("GROUP_ID")); + groupDetails.setGroupName(rs.getString("GROUP_NAME")); + groupDetails.setGroupOwner(rs.getString("GROUP_OWNER")); + } + int deviceId = rs.getInt("DEVICE_ID"); + deviceIds.add(deviceId); + deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER")); + deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS")); + deviceNames.put(deviceId, rs.getString("DEVICE_NAME")); + deviceTypes.put(deviceId, rs.getString("DEVICE_TYPE")); + deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION")); } - int deviceId = rs.getInt("DEVICE_ID"); - deviceIds.add(deviceId); - deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER")); - deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS")); - deviceNames.put(deviceId, rs.getString("DEVICE_NAME")); - deviceTypes.put(deviceId, rs.getString("DEVICE_TYPE")); - deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION")); } - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; - log.error(msg, e); - throw new GroupManagementDAOException(msg, e); + groupDetails.setDeviceIds(deviceIds); + groupDetails.setDeviceCount(deviceIds.size()); + groupDetails.setDeviceOwners(deviceOwners); + groupDetails.setDeviceStatuses(deviceStatuses); + groupDetails.setDeviceNames(deviceNames); + groupDetails.setDeviceTypes(deviceTypes); + groupDetails.setDeviceIdentifiers(deviceIdentifiers); + return groupDetails; } - groupDetails.setDeviceIds(deviceIds); - groupDetails.setDeviceCount(deviceIds.size()); - groupDetails.setDeviceOwners(deviceOwners); - groupDetails.setDeviceStatuses(deviceStatuses); - groupDetails.setDeviceNames(deviceNames); - groupDetails.setDeviceTypes(deviceTypes); - groupDetails.setDeviceIdentifiers(deviceIdentifiers); - return groupDetails; + } catch (SQLException e) { + String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; + log.error(msg, e); + throw new GroupManagementDAOException(msg, e); + } } } From ea10eb1f3cbc6d609f647995d195a142224cfb33 Mon Sep 17 00:00:00 2001 From: ashvini Date: Wed, 12 Jun 2024 09:42:34 +0530 Subject: [PATCH 220/343] Fix web apps not installing via user, group, role issue Add case to handle web clip uninstallation Add license Refactor code Remove hard-coded value --- .../device/mgt/common/MDMAppConstants.java | 2 + .../app/mgt/windows/WebClipApplication.java | 76 +++++++++++++++++++ .../core/util/MDMWindowsOperationUtil.java | 24 +++++- 3 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/app/mgt/windows/WebClipApplication.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/MDMAppConstants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/MDMAppConstants.java index da042f8d93..60d9503c97 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/MDMAppConstants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/MDMAppConstants.java @@ -58,6 +58,8 @@ public class MDMAppConstants { } public static final String INSTALL_ENTERPRISE_APPLICATION = "INSTALL_ENTERPRISE_APPLICATION"; public static final String UNINSTALL_ENTERPRISE_APPLICATION = "UNINSTALL_ENTERPRISE_APPLICATION"; + public static final String INSTALL_WEB_CLIP_APPLICATION = "INSTALL_WEB_CLIP"; + public static final String UNINSTALL_WEB_CLIP_APPLICATION = "UNINSTALL_WEB_CLIP"; //App type constants related to window device type public static final String MSI = "MSI"; public static final String APPX = "APPX"; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/app/mgt/windows/WebClipApplication.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/app/mgt/windows/WebClipApplication.java new file mode 100644 index 0000000000..be4feae54e --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/app/mgt/windows/WebClipApplication.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.common.app.mgt.windows; +import com.google.gson.Gson; + +import java.util.Properties; + +public class WebClipApplication { + + private String url; + private String name; + private String icon; + private String type; + private Properties properties; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } + + public String toJSON() { + Gson gson = new Gson(); + return gson.toJson(this); + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java index 932e2a6837..a1f0e0e31d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java @@ -30,6 +30,7 @@ import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows.EnterpriseApplication; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows.HostedAppxApplication; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows.HostedMSIApplication; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows.WebClipApplication; import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnknownApplicationTypeException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.ProfileOperation; @@ -54,7 +55,6 @@ public class MDMWindowsOperationUtil { public static Operation createInstallAppOperation(App application) throws UnknownApplicationTypeException { ProfileOperation operation = new ProfileOperation(); - operation.setCode(MDMAppConstants.WindowsConstants.INSTALL_ENTERPRISE_APPLICATION); operation.setType(Operation.Type.PROFILE); String appType = windowsAppType(application.getName()); String metaData = application.getMetaData(); @@ -62,6 +62,7 @@ public class MDMWindowsOperationUtil { switch (application.getType()) { case ENTERPRISE: + operation.setCode(MDMAppConstants.WindowsConstants.INSTALL_ENTERPRISE_APPLICATION); EnterpriseApplication enterpriseApplication = new EnterpriseApplication(); if (appType.equalsIgnoreCase(MDMAppConstants.WindowsConstants.APPX)) { HostedAppxApplication hostedAppxApplication = new HostedAppxApplication(); @@ -111,6 +112,16 @@ public class MDMWindowsOperationUtil { } operation.setPayLoad(enterpriseApplication.toJSON()); break; + case WEB_CLIP: + operation.setCode(MDMAppConstants.WindowsConstants.INSTALL_WEB_CLIP_APPLICATION); + WebClipApplication webClipApplication = new WebClipApplication(); + webClipApplication.setUrl(application.getLocation()); + webClipApplication.setName(application.getName()); + webClipApplication.setIcon(application.getIconImage()); + webClipApplication.setProperties(application.getProperties()); + webClipApplication.setType(application.getType().toString()); + operation.setPayLoad(webClipApplication.toJSON()); + break; default: String msg = "Application type " + application.getType() + " is not supported"; log.error(msg); @@ -130,7 +141,6 @@ public class MDMWindowsOperationUtil { public static Operation createUninstallAppOperation(App application) throws UnknownApplicationTypeException { ProfileOperation operation = new ProfileOperation(); - operation.setCode(MDMAppConstants.WindowsConstants.UNINSTALL_ENTERPRISE_APPLICATION); operation.setType(Operation.Type.PROFILE); String appType = windowsAppType(application.getName()); String metaData = application.getMetaData(); @@ -138,6 +148,7 @@ public class MDMWindowsOperationUtil { switch (application.getType()) { case ENTERPRISE: + operation.setCode(MDMAppConstants.WindowsConstants.UNINSTALL_ENTERPRISE_APPLICATION); EnterpriseApplication enterpriseApplication = new EnterpriseApplication(); if (appType.equalsIgnoreCase(MDMAppConstants.WindowsConstants.APPX)) { HostedAppxApplication hostedAppxApplication = new HostedAppxApplication(); @@ -187,6 +198,15 @@ public class MDMWindowsOperationUtil { } operation.setPayLoad(enterpriseApplication.toJSON()); break; + case WEB_CLIP: + operation.setCode(MDMAppConstants.WindowsConstants.UNINSTALL_WEB_CLIP_APPLICATION); + WebClipApplication webClipApplication = new WebClipApplication(); + webClipApplication.setUrl(application.getLocation()); + webClipApplication.setName(application.getName()); + webClipApplication.setIcon(application.getIconImage()); + webClipApplication.setProperties(application.getProperties()); + webClipApplication.setType(application.getType().toString()); + operation.setPayLoad(webClipApplication.toJSON()); default: String msg = "Application type " + application.getType() + " is not supported"; log.error(msg); From 0a19d8ee0cd95e3815bb0f67740f29090949dc93 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Tue, 25 Jun 2024 06:59:36 +0530 Subject: [PATCH 221/343] Fix incorrect device status updates --- .../task/impl/DeviceStatusMonitoringTask.java | 95 ++++++++++++++----- 1 file changed, 69 insertions(+), 26 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java index fd9958782b..9ef7d0bb48 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/status/task/impl/DeviceStatusMonitoringTask.java @@ -37,10 +37,15 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; import io.entgra.device.mgt.core.device.mgt.core.status.task.DeviceStatusTaskException; import io.entgra.device.mgt.core.device.mgt.core.task.impl.DynamicPartitionedScheduleTask; import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.core.service.RealmService; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * This implements the Task service which monitors the device activity periodically & update the device-status if @@ -92,33 +97,70 @@ public class DeviceStatusMonitoringTask extends DynamicPartitionedScheduleTask { try { List enrolmentInfoTobeUpdated = new ArrayList<>(); List allDevicesForMonitoring = getAllDevicesForMonitoring(); - long timeMillis = System.currentTimeMillis(); - for (DeviceMonitoringData monitoringData : allDevicesForMonitoring) { - long lastUpdatedTime = (timeMillis - monitoringData - .getLastUpdatedTime()) / 1000; - - EnrolmentInfo enrolmentInfo = monitoringData.getDevice().getEnrolmentInfo(); - EnrolmentInfo.Status status = null; - if (lastUpdatedTime >= deviceStatusTaskPluginConfig - .getIdleTimeToMarkInactive()) { - status = EnrolmentInfo.Status.INACTIVE; - } else if (lastUpdatedTime >= deviceStatusTaskPluginConfig - .getIdleTimeToMarkUnreachable()) { - status = EnrolmentInfo.Status.UNREACHABLE; - } - - if (status != null) { - enrolmentInfo.setStatus(status); - enrolmentInfoTobeUpdated.add(enrolmentInfo); - DeviceIdentifier deviceIdentifier = - new DeviceIdentifier(monitoringData.getDevice() - .getDeviceIdentifier(), deviceType); - monitoringData.getDevice().setEnrolmentInfo(enrolmentInfo); - DeviceCacheManagerImpl.getInstance().addDeviceToCache(deviceIdentifier, - monitoringData.getDevice(), monitoringData.getTenantId()); + Map> tenantDevicesMap = new HashMap<>(); + List tenantMonitoringData = null; + //Delegate the devices in each tenant to a separate list to be updated the statuses. + //This improvement has been done since the tenants maintain a separate caches and the task is running + //in the super-tenant space. Hence, the device status updates are not reflected in the tenant caches. + //Refer to https://roadmap.entgra.net/issues/11386 for more information. + for (DeviceMonitoringData deviceMonitoringData : allDevicesForMonitoring) { + tenantMonitoringData = tenantDevicesMap.get(deviceMonitoringData.getTenantId()); + if (tenantMonitoringData == null) { + tenantMonitoringData = new ArrayList<>(); } + tenantMonitoringData.add(deviceMonitoringData); + tenantDevicesMap.put(deviceMonitoringData.getTenantId(), tenantMonitoringData); } + List monitoringDevices = null; + long timeMillis = System.currentTimeMillis(); + //Retrieving the devices belongs for each tenants and updating the status of the devices. + for (Map.Entry> entry : tenantDevicesMap.entrySet()) { + Integer tenantId = entry.getKey(); + RealmService realmService = DeviceManagementDataHolder.getInstance().getRealmService(); + if (realmService != null) { + String domain = realmService.getTenantManager().getDomain(tenantId); + if (domain != null) { + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(domain, true); + monitoringDevices = entry.getValue(); + for (DeviceMonitoringData monitoringData : monitoringDevices) { + long lastUpdatedTime = (timeMillis - monitoringData + .getLastUpdatedTime()) / 1000; + + EnrolmentInfo enrolmentInfo = monitoringData.getDevice().getEnrolmentInfo(); + EnrolmentInfo.Status status = null; + if (lastUpdatedTime >= deviceStatusTaskPluginConfig + .getIdleTimeToMarkInactive()) { + status = EnrolmentInfo.Status.INACTIVE; + } else if (lastUpdatedTime >= deviceStatusTaskPluginConfig + .getIdleTimeToMarkUnreachable()) { + status = EnrolmentInfo.Status.UNREACHABLE; + } + + if (status != null) { + enrolmentInfo.setStatus(status); + enrolmentInfoTobeUpdated.add(enrolmentInfo); + DeviceIdentifier deviceIdentifier = + new DeviceIdentifier(monitoringData.getDevice() + .getDeviceIdentifier(), deviceType); + monitoringData.getDevice().setEnrolmentInfo(enrolmentInfo); + DeviceCacheManagerImpl.getInstance().addDeviceToCache(deviceIdentifier, + monitoringData.getDevice(), monitoringData.getTenantId()); + } + } + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } else { + log.error("Failed while running the device status update task. Failed while " + + "extracting tenant domain of the tenant id : " + tenantId); + } + } else { + log.error("Failed while running the device status update task. RealmService is not initiated"); + } + } if (!enrolmentInfoTobeUpdated.isEmpty()) { try { this.updateDeviceStatus(enrolmentInfoTobeUpdated); @@ -127,11 +169,12 @@ public class DeviceStatusMonitoringTask extends DynamicPartitionedScheduleTask { "device-status of devices of type '" + deviceType + "'", e); } } - - } catch (DeviceManagementException e) { String msg = "Error occurred while retrieving devices list for monitoring."; log.error(msg, e); + } catch (UserStoreException e) { + String msg = "Error occurred while retrieving RealmService instance for updating device status."; + log.error(msg, e); } } From fa7628e47a810328932fdca8c5f60307d4b9d37a Mon Sep 17 00:00:00 2001 From: builder Date: Tue, 2 Jul 2024 12:30:42 +0530 Subject: [PATCH 222/343] [maven-release-plugin] prepare release v5.1.0 --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.common/pom.xml | 2 +- .../cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml | 2 +- components/cea-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/cea-mgt-feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 146 files changed, 148 insertions(+), 148 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index c8011c08f3..b96e91729c 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index ad2b76aea8..95582ebd6b 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 2d708f2e34..4aa70101fc 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 1687efce72..59fa342129 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 00d4c90659..10fe59a34a 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../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 062250c578..9886e61ff4 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 io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index e3f137438d..20b5c4324d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index fb993c89e1..7e337bfdca 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 9715d49004..16467e09db 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml 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 153009c3e8..92157f73f6 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 io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 3a0bbffa59..8c8403ede4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 9d9fc52a3c..2bbd19fea3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index a668025519..be422aef4e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 8120dc4f6a..ff40c737a7 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index ffb8a053df..c1bfbce8db 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index ed00b9b0f9..e90032bbe2 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 360dad0a6c..33be106dce 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index 254c6ad535..28a00dc7a8 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index 2e6e9efc5b..ba9a8e9943 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core cea-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index ec906b7507..8ce039da67 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index 09822882ff..e0f730bb36 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index 665b30df0c..8697527c8e 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 29bef57226..407acfc5d4 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 03b8374637..27d230b6d5 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 53c8057109..631c7a157b 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 62ba9f87aa..50b6920f09 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 07e7b949c5..e8bd7dbda2 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index 55aea2d343..a5eb3aaa1a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index 92cbacef55..d6c015887a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index cce520cc68..016f389361 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index 34427cb7de..7b8f24fef3 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 90e4d05ed7..4f5bb9ceee 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index ffb529ef29..5b0ee2ec5f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 8909230131..df99655356 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 167b1dcc67..71110ce768 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 6546e5d8f2..4e527035f2 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index efe179f503..9171d411ad 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 4c0f550469..56e1e2424a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 5912b6f830..02716e8ea0 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index d975ad3715..bf83767329 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index a472beedad..baf06a2cae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 115bdc04a6..057ae68f19 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index fe7df106e3..e2a699309d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 5d5d3d252f..59f8d9c9a2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index a99497bcb7..41d68606cc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index e3ff16a185..c577def34d 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index d4a1423579..9049c71c78 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 144a391a6f..678f970dab 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index f9e469335b..969ad6687e 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 3c44fc89af..70b417608c 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 9d9d13a9eb..9a2c35e8fa 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 26e29d584d..bdfbee20fd 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.0.42-SNAPSHOT + 5.1.0 io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 28f050bcd1..f682bdf0d1 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index a1f8fd8ca1..79f556d3f9 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 57d6048b31..675c298b3d 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index e979327e53..e58bc3c803 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index f9d89bdcab..c9c47f6f97 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 7e6c53db05..014592233b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 1b25b8d1d1..194969e877 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 44c54eddd7..a6e954f4ba 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 69bce27091..fb0c24a182 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 51dc884b45..41619ee5f6 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 4b447f0e38..bca951721b 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 3f47201bf8..5904ec17ce 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 583e05bfeb..b27e4ca856 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 6904bc1898..a4472a5932 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 9b3679a880..4e7833f77f 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 9fe0b11e7c..8fa9a8520d 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 2dd5078116..a0ba3681d7 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 7eafae8b99..febcd07def 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index b4e13f6292..40b00f5d5f 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 7e2afe4f69..2987130461 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 1b663db64e..98531f90a6 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index e28aeb6f30..15b6599fb5 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index c911c571a4..cc98e4a100 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index eec782a9aa..da30a7c04b 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 740d1b7ae5..5313acd0b2 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 63db59b599..a3df10cd7c 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 83f664e143..8e9cf239fa 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index cc51666724..ee3f795ed7 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index b52526e02a..dfd9f2e9e8 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 0ede892b7f..0e77a4df8c 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 8f1745bb78..87b5c67829 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 4b128c1cb3..4cceba90a2 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 46349cd1ae..a860aa1da6 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 569422c9de..40922f9e5d 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../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 3f06938008..20b01348cb 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index ea792fb1f6..dd1f250ea5 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index ca37184ea3..93fe1a568f 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index f96d462b4e..b935f76219 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 2f015d97d3..c1f833f54a 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index ef44e37db0..ded68a6175 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 514dfdd2f4..9654095f94 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index f639dbdaf4..6a073be917 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index 14e01f52b4..91e7cfe782 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index 8d8397ae01..ef883a1e6b 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index ddfd8381c9..9e39d669e3 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index 54dec9a0a7..d43ff59a7e 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index a4cd54ecb8..4f980b5819 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index c29d15d221..e47d1b7bf6 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 3ed731f10e..bfcf8fcae9 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index d9b0d5fedc..dddb181844 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index 49509d8695..b5bf99b9bb 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 4.0.0 diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index 37e9e2ac4a..09e9116738 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 94d691700b..cf35fba2f6 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index a8ea392725..c9bd15a4d4 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index d4ba060b68..447c9d971a 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 399761b3f0..31b025d52f 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 2e9351f5ca..294732261e 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index a04e0a0933..7e657dbfea 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 66ac3b6eb8..43fe408382 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index bc35f8e7c1..b761a6d70c 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 240077996f..fbdb9d74c6 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 3baff87eb1..7f3c717d6a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 6f21b990a7..9c92eeb91c 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 2e69e4991e..b67a7fc642 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index ca7591b012..d812804f54 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index fecbd4b026..64b5767b4a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index dd09fa4aae..00ae703334 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 92cc4ed0a6..4e5255a56f 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 77db508369..db28c49061 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 47d3eba794..b074c88064 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 13352c3ac9..52b06d0260 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 13dfee7c04..96ea6461f7 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index d618a48143..999142c9ca 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 51e22389d6..452ba00a3b 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 6eaf76b03a..35076e1272 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 27e6f9f338..d1f033a74c 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index b8ad61c8c1..1dec711fe6 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 545cbf5983..013f868281 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 1d9a686b44..8815dadb3f 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 910eb1dd01..56dd396107 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 847891c371..f065bcad1e 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 11c9910d26..215f6476fd 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 1905e1c77f..c3e1e3abc2 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 5fdfd06406..dd40842175 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 3a8cad8254..54d591d994 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index d8ef07065e..da8925589b 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index ba79eec348..6b43fc836e 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 8a8d12575f..4d8249ece8 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 29a6377f7a..47b57fa98f 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 4695bfd1a7..0371eab2f8 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index af85499d51..60e4745826 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index ad5a36dc35..a800bc5c06 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.0.42-SNAPSHOT + 5.1.0 ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index b790add82e..7fa3ed21c6 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.42-SNAPSHOT + 5.1.0 ../../pom.xml diff --git a/pom.xml b/pom.xml index 680a4ced22..6295c05774 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.0.42-SNAPSHOT + 5.1.0 WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1923,7 +1923,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.1.0 @@ -2128,7 +2128,7 @@ 1.2.11.wso2v10 - 5.0.42-SNAPSHOT + 5.1.0 4.7.35 From 15afde08ac5ea76f64291abd875e626fe0478a94 Mon Sep 17 00:00:00 2001 From: builder Date: Tue, 2 Jul 2024 12:30:47 +0530 Subject: [PATCH 223/343] [maven-release-plugin] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.common/pom.xml | 2 +- .../cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml | 2 +- components/cea-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/cea-mgt-feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 146 files changed, 148 insertions(+), 148 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index b96e91729c..da8cd560b1 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 95582ebd6b..6eb144dac9 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 4aa70101fc..4a50a25749 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 59fa342129..1b3143afce 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 10fe59a34a..8f8b773e04 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-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 9886e61ff4..08521c3ee7 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 io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 20b5c4324d..aee9a07d60 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 7e337bfdca..320ed352a4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 16467e09db..0e072f261c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml 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 92157f73f6..ee586e66c0 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 io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 8c8403ede4..316a029fa8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 2bbd19fea3..b5a30e4a43 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index be422aef4e..57a433696b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index ff40c737a7..f9919af1ec 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index c1bfbce8db..179902e678 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index e90032bbe2..057345defc 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 33be106dce..59a8b05a89 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index 28a00dc7a8..243bcb838a 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index ba9a8e9943..e3a91006a3 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core cea-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index 8ce039da67..7f316508e3 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index e0f730bb36..20ba656317 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index 8697527c8e..1018889057 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 407acfc5d4..a40690ca2a 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 27d230b6d5..aa7b0037b5 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 631c7a157b..89e38b65cc 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 50b6920f09..c75fc3ff7d 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index e8bd7dbda2..e45887eae1 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index a5eb3aaa1a..947b82651c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index d6c015887a..8f25ed645f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 016f389361..a9c6dcf699 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index 7b8f24fef3..5ca85ea9a1 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 4f5bb9ceee..f5ba1b5cd2 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 5b0ee2ec5f..674cd1b501 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index df99655356..2d0b0d20a8 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 71110ce768..3773eb8195 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 4e527035f2..de081c6388 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index 9171d411ad..1ab8ab1f7b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 56e1e2424a..0f6c63d1cc 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 02716e8ea0..2b289ebb09 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index bf83767329..50df01ad3c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index baf06a2cae..59dc725854 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 057ae68f19..24a9bc1629 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index e2a699309d..7fc5c023b0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 59f8d9c9a2..1cc6f77123 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 41d68606cc..4d770d2e5c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index c577def34d..9cd43d3578 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 9049c71c78..a9fe99c45d 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 678f970dab..e21c822120 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 969ad6687e..e9f9dbb1e1 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 70b417608c..29747b2058 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 9a2c35e8fa..9ed35dfa33 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index bdfbee20fd..d950e541b0 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.1.0 + 5.1.1-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index f682bdf0d1..1103b9fb96 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 79f556d3f9..486a5ba040 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 675c298b3d..dc97e13ce3 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index e58bc3c803..bfbcf59b5f 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index c9c47f6f97..0a8e6a1bb3 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 014592233b..603622f1ef 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 194969e877..55129571a9 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index a6e954f4ba..1afbf4948a 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index fb0c24a182..9584b927d2 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 41619ee5f6..85fb31d80d 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index bca951721b..efd3eea629 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 5904ec17ce..0961711356 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index b27e4ca856..00bef3c430 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index a4472a5932..b7b2a2b024 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 4e7833f77f..2d1fd1a9a6 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 8fa9a8520d..0522067f1c 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index a0ba3681d7..ad762d1fe4 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index febcd07def..33d4c9969c 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 40b00f5d5f..b99f174c7a 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 2987130461..91492147c5 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 98531f90a6..dd5efb2d0a 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 15b6599fb5..21e45095f2 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index cc98e4a100..ec89a59da1 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index da30a7c04b..f28613b4dc 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 5313acd0b2..7c76e5c2b3 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index a3df10cd7c..c98060e315 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 8e9cf239fa..99ae34c17c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index ee3f795ed7..5c5a6a94d7 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index dfd9f2e9e8..4fc832717f 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 0e77a4df8c..2263db3f51 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 87b5c67829..0d318113f8 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 4cceba90a2..fb2eec07f7 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index a860aa1da6..edc2e90404 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 40922f9e5d..a0506a21f9 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-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 20b01348cb..3602a6dbaf 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index dd1f250ea5..29e7d8d367 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 93fe1a568f..41808f5783 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index b935f76219..ac282a877c 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index c1f833f54a..91047707bc 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index ded68a6175..cac65f28d3 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 9654095f94..9091285299 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 6a073be917..c3c0fb268a 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index 91e7cfe782..3fe28dedd8 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index ef883a1e6b..ac629006af 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index 9e39d669e3..6c247959bd 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index d43ff59a7e..da70f7b701 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 4f980b5819..a18820192a 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index e47d1b7bf6..138e225f51 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index bfcf8fcae9..e368689f28 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index dddb181844..7c00475326 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index b5bf99b9bb..644192d911 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT 4.0.0 diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index 09e9116738..ce8f238c49 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index cf35fba2f6..c0510455c2 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index c9bd15a4d4..c8579334eb 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 447c9d971a..d0f2d96da0 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 31b025d52f..7282116954 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 294732261e..ac4d7912c5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 7e657dbfea..48eadd764e 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 43fe408382..7a09ba02f2 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index b761a6d70c..c3680bc49c 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index fbdb9d74c6..048bb6753b 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 7f3c717d6a..e06d6c44fc 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 9c92eeb91c..743c4d1b8b 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index b67a7fc642..14d9d37435 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index d812804f54..63b2c0ccc5 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 64b5767b4a..1cc4b8e1fa 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 00ae703334..91c20ad21f 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 4e5255a56f..f0796f2527 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index db28c49061..91c7122eeb 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index b074c88064..d8e780f2dc 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 52b06d0260..a1173b092f 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 96ea6461f7..22e05065be 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index 999142c9ca..87d1e7b273 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 452ba00a3b..8831489b50 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 35076e1272..0da144fc89 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index d1f033a74c..4431526805 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 1dec711fe6..68e1e94a71 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 013f868281..9ad917b1e1 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 8815dadb3f..7d5247fa69 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 56dd396107..3a7d018a63 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index f065bcad1e..c0e3e5a94a 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 215f6476fd..e1d82784f3 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index c3e1e3abc2..30a21a4f4e 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index dd40842175..fbbd343a15 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 54d591d994..6145c54614 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index da8925589b..fc36c9c5c1 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 6b43fc836e..3f255c77ca 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 4d8249ece8..9fd27e221a 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 47b57fa98f..8da131ed0e 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 0371eab2f8..84f61d3c9b 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 60e4745826..984702a61f 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index a800bc5c06..cb50916b33 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.1.0 + 5.1.1-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 7fa3ed21c6..50dcf3a78a 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.0 + 5.1.1-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 6295c05774..90835d054e 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.1.0 + 5.1.1-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1923,7 +1923,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.1.0 + HEAD @@ -2128,7 +2128,7 @@ 1.2.11.wso2v10 - 5.1.0 + 5.1.1-SNAPSHOT 4.7.35 From c51b3c49fa2c985b1e1ce5a1d535cb453c5031cf Mon Sep 17 00:00:00 2001 From: Nipuni Kavindya Date: Thu, 4 Jul 2024 02:38:06 +0000 Subject: [PATCH 224/343] Add backend implementation to get devices not in a group Purpose: https://roadmap.entgra.net/issues/11349 Co-authored-by: Nipuni Kavindya Co-committed-by: Nipuni Kavindya --- .../service/api/DeviceManagementService.java | 6 + .../impl/DeviceManagementServiceImpl.java | 18 +- .../impl/DeviceManagementServiceImplTest.java | 34 ++-- .../core/device/mgt/core/dao/DeviceDAO.java | 20 ++ .../core/dao/impl/AbstractDeviceDAOImpl.java | 108 +++++++++++ .../dao/impl/device/GenericDeviceDAOImpl.java | 172 +++++++++++++++++- .../DeviceManagementProviderService.java | 14 ++ .../DeviceManagementProviderServiceImpl.java | 54 ++++++ 8 files changed, 406 insertions(+), 20 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index a028654cdc..5c41168bcb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -310,6 +310,12 @@ public interface DeviceManagementService { required = false) @QueryParam("groupId") int groupId, + @ApiParam( + name = "excludeGroupId", + value = "Id of the group that needs to get the devices that are not belong.", + required = false) + @QueryParam("excludeGroupId") + int excludeGroupId, @ApiParam( name = "since", value = "Checks if the requested variant was created since the specified date-time.\n" + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 58259e19c8..4a141ca30c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -147,6 +147,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @QueryParam("customProperty") String customProperty, @QueryParam("status") List status, @QueryParam("groupId") int groupId, + @QueryParam("excludeGroupId") int excludeGroupId, @QueryParam("since") String since, @HeaderParam("If-Modified-Since") String ifModifiedSince, @QueryParam("requireDeviceInfo") boolean requireDeviceInfo, @@ -209,7 +210,22 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { request.setStatusList(status); } } - // this is the user who initiates the request + + if (excludeGroupId != 0) { + request.setGroupId(excludeGroupId); + + if (user != null && !user.isEmpty()) { + request.setOwner(MultitenantUtils.getTenantAwareUsername(user)); + } else if (userPattern != null && !userPattern.isEmpty()) { + request.setOwnerPattern(userPattern); + } + + result = dms.getDevicesNotInGroup(request, requireDeviceInfo); + devices.setList((List) result.getData()); + devices.setCount(result.getRecordsTotal()); + return Response.status(Response.Status.OK).entity(devices).build(); + } + String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername(); if (groupId != 0) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java index 63bb401d61..b66773e84d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java @@ -157,7 +157,7 @@ public class DeviceManagementServiceImplTest { .toReturn(this.deviceAccessAuthorizationService); Response response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, false, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -177,22 +177,22 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null,null, DEFAULT_STATUS_LIST, 1, null, null, false, + null,null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, null, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, false, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, null, null, null, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, false, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, null, null, null, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, true, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, true, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -307,7 +307,7 @@ public class DeviceManagementServiceImplTest { Mockito.when(deviceAccessAuthorizationService.isDeviceAdminUser()).thenReturn(true); deviceManagementService.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null,null, DEFAULT_STATUS_LIST, 1, - null, null, false, 10, 5); + 0, null, null, false, 10, 5); } @Test(description = "Testing get devices when user is the device admin") @@ -326,11 +326,11 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP - , null, null, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + , null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, null, DEFAULT_USERNAME, DEFAULT_ROLE, DEFAULT_OWNERSHIP - , null, null, DEFAULT_STATUS_LIST, 1, null, null, false, 10, 5); + , null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -352,7 +352,7 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, "newuser", null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 0, null, null, false, + null, null, DEFAULT_STATUS_LIST, 0, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode()); Mockito.reset(this.deviceAccessAuthorizationService); @@ -374,17 +374,17 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, false, + null, null, DEFAULT_STATUS_LIST, 0, 0, null, ifModifiedSince, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 0, null, ifModifiedSince, true, + null, null, DEFAULT_STATUS_LIST, 0, 0, null, ifModifiedSince, true, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 0, null, "ErrorModifiedSince", + null, null, DEFAULT_STATUS_LIST, 0, 0, null, "ErrorModifiedSince", false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -405,17 +405,17 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null,DEFAULT_STATUS_LIST, 0, since, null, false, + null, null,DEFAULT_STATUS_LIST, 0, 0, since, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null,DEFAULT_STATUS_LIST, 0, since, null, true, + null, null,DEFAULT_STATUS_LIST, 0, 0, since, null, true, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null,DEFAULT_STATUS_LIST, 0, "ErrorSince", null, false, + null, null,DEFAULT_STATUS_LIST, 0, 0, "ErrorSince", null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -438,7 +438,7 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, false, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); Mockito.reset(this.deviceManagementProviderService); @@ -461,7 +461,7 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, null, null, false, + null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); Mockito.reset(this.deviceAccessAuthorizationService); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java index 731bb11d59..b71b6cd640 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java @@ -844,4 +844,24 @@ public interface DeviceDAO { List getAgentVersions(int tenantId) throws DeviceManagementDAOException; List getDevicesEnrolledSince(Date since) throws DeviceManagementDAOException; List getDevicesEnrolledPriorTo(Date priorTo) throws DeviceManagementDAOException; + + /** + * This method is used to search for devices that are not in a specific group. + * + * @param request PaginationRequest object holding the data for pagination + * @param tenantId tenant id. + * @return returns paginated list of devices. + * @throws DeviceManagementDAOException + */ + List searchDevicesNotInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException; + + /** + * This method is used to get device count that are not within a specific group. + * + * @param request PaginationRequest object holding the data for pagination + * @param tenantId tenant id + * @return Device count + * @throws DeviceManagementDAOException + */ + int getCountOfDevicesNotInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index ec03136c6b..6ca1095faf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -3190,4 +3190,112 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { public abstract void refactorDeviceStatus (Connection conn, List validDevices) throws DeviceManagementDAOException; + @Override + public int getCountOfDevicesNotInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException { + int deviceCount = 0; + int groupId = request.getGroupId(); + String deviceType = request.getDeviceType(); + boolean isDeviceTypeProvided = false; + String deviceName = request.getDeviceName(); + boolean isDeviceNameProvided = false; + String owner = request.getOwner(); + boolean isOwnerProvided = false; + String ownerPattern = request.getOwnerPattern(); + boolean isOwnerPatternProvided = false; + String ownership = request.getOwnership(); + boolean isOwnershipProvided = false; + List statusList = request.getStatusList(); + boolean isStatusProvided = false; + Date since = request.getSince(); + boolean isSinceProvided = false; + + try { + Connection conn = getConnection(); + String sql = "SELECT COUNT(d1.DEVICE_ID) AS DEVICE_COUNT " + + "FROM DM_ENROLMENT e, " + + "(SELECT gd.ID AS DEVICE_ID, " + + "gd.DESCRIPTION, " + + "gd.NAME, " + + "gd.DEVICE_IDENTIFICATION " + + "FROM DM_DEVICE gd " + + "WHERE gd.ID NOT IN (SELECT dgm.DEVICE_ID " + + "FROM DM_DEVICE_GROUP_MAP dgm " + + "WHERE dgm.GROUP_ID = ?) " + + "AND gd.TENANT_ID = ?"; + + if (deviceName != null && !deviceName.isEmpty()) { + sql += " AND gd.NAME LIKE ?"; + isDeviceNameProvided = true; + } + sql += " AND 1=1"; + + if (since != null) { + sql += " AND gd.LAST_UPDATED_TIMESTAMP > ?"; + isSinceProvided = true; + } + sql += " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND e.TENANT_ID = ?"; + + if (deviceType != null && !deviceType.isEmpty()) { + sql += " AND e.DEVICE_TYPE = ?"; + isDeviceTypeProvided = true; + } + + if (ownership != null && !ownership.isEmpty()) { + sql += " AND e.OWNERSHIP = ?"; + isOwnershipProvided = true; + } + + if (owner != null && !owner.isEmpty()) { + sql += " AND e.OWNER = ?"; + isOwnerProvided = true; + } else if (ownerPattern != null && !ownerPattern.isEmpty()) { + sql += " AND e.OWNER LIKE ?"; + isOwnerPatternProvided = true; + } + if (statusList != null && !statusList.isEmpty()) { + sql += buildStatusQuery(statusList); + isStatusProvided = true; + } + + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + int paramIdx = 1; + stmt.setInt(paramIdx++, groupId); + stmt.setInt(paramIdx++, tenantId); + if (isDeviceNameProvided) { + stmt.setString(paramIdx++, "%" + deviceName + "%"); + } + if (isSinceProvided) { + stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); + } + stmt.setInt(paramIdx++, tenantId); + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, deviceType); + } + if (isOwnershipProvided) { + stmt.setString(paramIdx++, ownership); + } + if (isOwnerProvided) { + stmt.setString(paramIdx++, owner); + } else if (isOwnerPatternProvided) { + stmt.setString(paramIdx++, ownerPattern + "%"); + } + if (isStatusProvided) { + for (String status : statusList) { + stmt.setString(paramIdx++, status); + } + } + + try (ResultSet rs = stmt.executeQuery()) { + if (rs.next()) { + deviceCount = rs.getInt("DEVICE_COUNT"); + } + return deviceCount; + } + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving count of devices not in group: " + groupId; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index d1ea236645..e2063761db 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -724,7 +724,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } //Add the query for owner if (owner != null && !owner.isEmpty()) { - sql = sql + " AND e.OWNER = ?"; + sql = sql + " AND e.OWNER LIKE ?"; isOwnerProvided = true; } else if (ownerPattern != null && !ownerPattern.isEmpty()) { sql = sql + " AND e.OWNER LIKE ?"; @@ -776,7 +776,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, ownership); } if (isOwnerProvided) { - stmt.setString(paramIdx++, owner); + stmt.setString(paramIdx++, "%" + owner + "%"); } else if (isOwnerPatternProvided) { stmt.setString(paramIdx++, ownerPattern + "%"); } @@ -1689,4 +1689,172 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } } + @Override + public List searchDevicesNotInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException { + List devices = null; + int groupId = request.getGroupId(); + String deviceType = request.getDeviceType(); + boolean isDeviceTypeProvided = false; + String deviceName = request.getDeviceName(); + boolean isDeviceNameProvided = false; + String owner = request.getOwner(); + boolean isOwnerProvided = false; + String ownerPattern = request.getOwnerPattern(); + boolean isOwnerPatternProvided = false; + String ownership = request.getOwnership(); + boolean isOwnershipProvided = false; + List statusList = request.getStatusList(); + boolean isStatusProvided = false; + Date since = request.getSince(); + boolean isSinceProvided = false; + String serial = request.getSerialNumber(); + boolean isSerialProvided = false; + + try { + Connection conn = getConnection(); + String sql = "SELECT d1.DEVICE_ID, " + + "d1.DESCRIPTION, " + + "d1.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE, " + + "d1.DEVICE_IDENTIFICATION, " + + "d1.LAST_UPDATED_TIMESTAMP, " + + "e.OWNER, " + + "e.OWNERSHIP, " + + "e.STATUS, " + + "e.IS_TRANSFERRED, " + + "e.DATE_OF_LAST_UPDATE, " + + "e.DATE_OF_ENROLMENT, " + + "e.ID AS ENROLMENT_ID " + + "FROM DM_ENROLMENT e, " + + "(SELECT gd.DEVICE_ID, " + + "gd.DESCRIPTION, " + + "gd.NAME, " + + "gd.DEVICE_IDENTIFICATION, " + + "gd.LAST_UPDATED_TIMESTAMP " + + "FROM " + + "(SELECT d.ID AS DEVICE_ID, " + + "d.DESCRIPTION, " + + "d.NAME, " + + "d.DEVICE_IDENTIFICATION, " + + "d.LAST_UPDATED_TIMESTAMP " + + "FROM DM_DEVICE d " + + "WHERE d.ID NOT IN " + + "(SELECT dgm.DEVICE_ID " + + "FROM DM_DEVICE_GROUP_MAP dgm " + + "WHERE dgm.GROUP_ID = ?) " + + "AND d.TENANT_ID = ?"; + + if (deviceName != null && !deviceName.isEmpty()) { + sql = sql + " AND d.NAME LIKE ?"; + isDeviceNameProvided = true; + } + sql = sql + ") gd"; + sql = sql + " WHERE 1 = 1"; + + if (since != null) { + sql = sql + " AND gd.LAST_UPDATED_TIMESTAMP > ?"; + isSinceProvided = true; + } + sql = sql + " ) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND e.TENANT_ID = ? "; + + if (deviceType != null && !deviceType.isEmpty()) { + sql = sql + " AND e.DEVICE_TYPE = ?"; + isDeviceTypeProvided = true; + } + + if (ownership != null && !ownership.isEmpty()) { + sql = sql + " AND e.OWNERSHIP = ?"; + isOwnershipProvided = true; + } + + if (owner != null && !owner.isEmpty()) { + sql = sql + " AND e.OWNER LIKE ?"; + isOwnerProvided = true; + } else if (ownerPattern != null && !ownerPattern.isEmpty()) { + sql = sql + " AND e.OWNER LIKE ?"; + isOwnerPatternProvided = true; + } + if (statusList != null && !statusList.isEmpty()) { + sql += buildStatusQuery(statusList); + isStatusProvided = true; + } + + if (serial != null || !request.getCustomProperty().isEmpty()) { + if (serial != null) { + sql += "AND EXISTS (" + + "SELECT VALUE_FIELD " + + "FROM DM_DEVICE_INFO di " + + "WHERE di.DEVICE_ID = d1.DEVICE_ID " + + "AND di.KEY_FIELD = 'serial' " + + "AND di.VALUE_FIELD LIKE ?) "; + isSerialProvided = true; + } + if (!request.getCustomProperty().isEmpty()) { + for (Map.Entry entry : request.getCustomProperty().entrySet()) { + sql += "AND EXISTS (" + + "SELECT VALUE_FIELD " + + "FROM DM_DEVICE_INFO di2 " + + "WHERE di2.DEVICE_ID = d1.DEVICE_ID " + + "AND di2.KEY_FIELD = '" + entry.getKey() + "' " + + "AND di2.VALUE_FIELD LIKE ?)"; + } + } + } + sql = sql + " LIMIT ? OFFSET ?"; + + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + int paramIdx = 1; + stmt.setInt(paramIdx++, groupId); + stmt.setInt(paramIdx++, tenantId); + if (isDeviceNameProvided) { + stmt.setString(paramIdx++, "%" + deviceName + "%"); + } + if (isSinceProvided) { + stmt.setTimestamp(paramIdx++, new Timestamp(since.getTime())); + } + stmt.setInt(paramIdx++, tenantId); + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, deviceType); + } + if (isOwnershipProvided) { + stmt.setString(paramIdx++, ownership); + } + if (isOwnerProvided) { + stmt.setString(paramIdx++, "%" + owner + "%"); + } else if (isOwnerPatternProvided) { + stmt.setString(paramIdx++, "%" + ownerPattern + "%"); + } + if (isStatusProvided) { + for (String status : statusList) { + stmt.setString(paramIdx++, status); + } + } + if (isSerialProvided) { + stmt.setString(paramIdx++, "%" + serial + "%"); + } + if (!request.getCustomProperty().isEmpty()) { + for (Map.Entry entry : request.getCustomProperty().entrySet()) { + stmt.setString(paramIdx++, "%" + entry.getValue() + "%"); + } + } + stmt.setInt(paramIdx++, request.getRowCount()); + stmt.setInt(paramIdx, request.getStartIndex()); + + try (ResultSet rs = stmt.executeQuery()) { + devices = new ArrayList<>(); + while (rs.next()) { + Device device = DeviceManagementDAOUtil.loadDevice(rs); + devices.add(device); + } + return devices; + } + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving information of" + + " devices not belonging to group : " + groupId; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index f7b72f0275..48c0c48b5e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -1111,4 +1111,18 @@ public interface DeviceManagementProviderService { * @throws OperationManagementException if an error occurs while fetching the operation details. */ OperationDTO getOperationDetailsById(int operationId) throws OperationManagementException; + + + /** + * Method to retrieve all the devices that are not in a group with pagination support. + * + * @param request PaginationRequest object holding the data for pagination + * @param requireDeviceInfo - A boolean indicating whether the device-info (location, app-info etc) is also required + * along with the device data. + * @return PaginationResult - Result including the required parameters necessary to do pagination. + * @throws DeviceManagementException If some unusual behaviour is observed while fetching the + * devices. + */ + PaginationResult getDevicesNotInGroup(PaginationRequest request, boolean requireDeviceInfo) + throws DeviceManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index aee7f67e02..7bacbef5c6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -5449,4 +5449,58 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return operationDetails; } + @Override + public PaginationResult getDevicesNotInGroup(PaginationRequest request, boolean requireDeviceInfo) + throws DeviceManagementException { + if (request == null) { + String msg = "Received incomplete pagination request for method getDevicesNotInGroup"; + log.error(msg); + throw new DeviceManagementException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Get devices not in group with pagination " + request.toString() + + " and requiredDeviceInfo: " + requireDeviceInfo); + } + PaginationResult paginationResult = new PaginationResult(); + List devicesNotInGroup = null; + int count = 0; + int tenantId = this.getTenantId(); + DeviceManagerUtil.validateDeviceListPageSize(request); + + try { + DeviceManagementDAOFactory.openConnection(); + if (request.getGroupId() != 0) { + devicesNotInGroup = deviceDAO.searchDevicesNotInGroup(request, tenantId); + count = deviceDAO.getCountOfDevicesNotInGroup(request, tenantId); + } else { + String msg = "Group ID is not provided for method getDevicesNotInGroup"; + log.error(msg); + throw new DeviceManagementException(msg); + } + } catch (DeviceManagementDAOException e) { + String msg = "Error occurred while retrieving device list that are not in the specified group for the current tenant"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in getDevicesNotInGroup"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + + if (requireDeviceInfo && devicesNotInGroup != null && !devicesNotInGroup.isEmpty()) { + paginationResult.setData(populateAllDeviceInfo(devicesNotInGroup)); + } else { + paginationResult.setData(devicesNotInGroup); + } + + paginationResult.setRecordsFiltered(count); + paginationResult.setRecordsTotal(count); + return paginationResult; + } } From d1ed100f2f0f2ab41b6de0fcb685365aca20ca5b Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Thu, 4 Jul 2024 10:42:29 +0530 Subject: [PATCH 225/343] Fix device status,name not loading --- .../device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index e831e68a2e..dad35f0795 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -585,6 +585,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { while (rs.next()) { if (ownerDetails.getUserName() == null) { ownerDetails.setUserName(rs.getString("OWNER")); + ownerDetails.setDeviceStatus(rs.getString("DEVICE_STATUS")); + ownerDetails.setDeviceNames(rs.getString("DEVICE_NAME")); } deviceIds.add(rs.getInt("DEVICE_ID")); deviceCount++; @@ -598,8 +600,6 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } ownerDetails.setDeviceIds(deviceIds); - ownerDetails.setDeviceStatus("DEVICE_STATUS"); - ownerDetails.setDeviceNames("DEVICE_NAME"); ownerDetails.setDeviceTypes("DEVICE_TYPE"); ownerDetails.setDeviceIdentifiers("DEVICE_IDENTIFICATION"); ownerDetails.setDeviceCount(deviceCount); From 23d31fd38c8f7cc24e7d3740ab109dbc3ebb1ab7 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Fri, 5 Jul 2024 20:56:03 +0530 Subject: [PATCH 226/343] Fix code review suggestions --- .../provider/fcm/FCMNotificationStrategy.java | 35 +++++++++---------- .../provider/fcm/util/FCMUtil.java | 6 ++++ pom.xml | 12 +++---- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java index 033ef30293..39bd1ba7e5 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java @@ -17,11 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm; -import com.google.auth.oauth2.GoogleCredentials; import com.google.gson.JsonObject; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.ContextMetadata; -import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.PushNotificationConfiguration; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.util.FCMUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -32,18 +28,12 @@ import io.entgra.device.mgt.core.device.mgt.common.push.notification.Notificatio import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationExecutionFailedException; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.internal.FCMDataHolder; -import org.wso2.carbon.utils.CarbonUtils; -import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; -import java.util.Properties; public class FCMNotificationStrategy implements NotificationStrategy { @@ -90,13 +80,19 @@ public class FCMNotificationStrategy implements NotificationStrategy { } - + /** + * Send FCM message to the FCM server to initiate the push notification + * @param accessToken Access token to authenticate with the FCM server + * @param registrationId Registration ID of the device + * @throws IOException If an error occurs while sending the request + * @throws PushNotificationExecutionFailedException If an error occurs while sending the push notification + */ private void sendWakeUpCall(String accessToken, String registrationId) throws IOException, PushNotificationExecutionFailedException { - OutputStream os = null; HttpURLConnection conn = null; - String fcmServerEndpoint = FCMUtil.getInstance().getContextMetadataProperties().getProperty(FCM_ENDPOINT_KEY); + String fcmServerEndpoint = FCMUtil.getInstance().getContextMetadataProperties() + .getProperty(FCM_ENDPOINT_KEY); if(fcmServerEndpoint == null) { String msg = "Encountered configuration issue. " + FCM_ENDPOINT_KEY + " is not defined"; log.error(msg); @@ -112,23 +108,26 @@ public class FCMNotificationStrategy implements NotificationStrategy { conn.setRequestMethod("POST"); conn.setDoOutput(true); - os = conn.getOutputStream(); - os.write(bytes); + try (OutputStream os = conn.getOutputStream()) { + os.write(bytes); + } int status = conn.getResponseCode(); if (status != 200) { log.error("Response Status: " + status + ", Response Message: " + conn.getResponseMessage()); } } finally { - if (os != null) { - os.close(); - } if (conn != null) { conn.disconnect(); } } } + /** + * Get the FCM request as a JSON string + * @param registrationId Registration ID of the device + * @return FCM request as a JSON string + */ private static String getFCMRequest(String registrationId) { JsonObject messageObject = new JsonObject(); messageObject.addProperty("token", registrationId); diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java index 11cef37c0f..f7520801f6 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java @@ -76,6 +76,12 @@ public class FCMUtil { contextMetadataProperties = properties; } + /** + * Get the instance of FCMUtil. FCMUtil is a singleton class which should not be + * instantiating more than once. Instantiating the class requires to read the service account file from + * the filesystem and instantiation of the GoogleCredentials object which are costly operations. + * @return FCMUtil instance + */ public static FCMUtil getInstance() { if (instance == null) { synchronized (FCMUtil.class) { diff --git a/pom.xml b/pom.xml index 2c7c6c6af3..0120cb38cb 100644 --- a/pom.xml +++ b/pom.xml @@ -405,11 +405,6 @@ ${io.entgra.device.mgt.core.version} - - org.wso2.orbit.com.google.auth-library-oauth2-http - google-auth-library-oauth2-http - 1.20.0.wso2v1 - org.wso2.carbon @@ -1923,7 +1918,7 @@ com.google.auth google-auth-library-oauth2-http - 1.20.0 + ${com.google.auth.library.auth2.http.version} org.wso2.orbit.com.google.http-client @@ -1933,7 +1928,7 @@ org.wso2.orbit.com.google.auth-library-oauth2-http google-auth-library-oauth2-http - ${com.google.auth.library.auth2.http.version} + ${com.google.auth.library.wso2.auth2.http.version} org.wso2.orbit.io.opencensus @@ -2356,7 +2351,8 @@ 1.4.199.wso2v1 1.1.3 - 1.20.0.wso2v1 + 1.20.0.wso2v1 + 1.20.0 1.41.2.wso2v2 1.0.1 1.43.3 From 529d1aec01e8a0e904b67b3235f0523e91718b44 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Fri, 5 Jul 2024 21:05:07 +0530 Subject: [PATCH 227/343] Add doc comments --- .../push/notification/provider/fcm/util/FCMUtil.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java index f7520801f6..0c6c433cc7 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java @@ -57,12 +57,17 @@ public class FCMUtil { fromStream(Files.newInputStream(serviceAccountPath)). createScoped(FCM_SCOPES); } catch (IOException e) { - log.error("Fail to initialize default OAuth application for FCM communication"); - throw new IllegalStateException(e); + String msg = "Fail to initialize default OAuth application for FCM communication"; + log.error(msg); + throw new IllegalStateException(msg, e); } } } + /** + * Initialize the context metadata properties from the cdm-config.xml. This file includes the fcm server URL + * to be invoked when sending the wakeup call to the device. + */ private void initContextConfigs() { PushNotificationConfiguration pushNotificationConfiguration = DeviceConfigurationManager.getInstance(). getDeviceManagementConfig().getPushNotificationConfiguration(); From c9763c8a1b07faa1ebce99163367c8fb29e2d815 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Thu, 4 Jul 2024 09:17:23 +0530 Subject: [PATCH 228/343] Fix jaxb dependency issue --- .../pom.xml | 5 +++++ .../pom.xml | 5 +++++ .../pom.xml | 5 +++++ .../pom.xml | 1 + .../pom.xml | 1 + .../pom.xml | 5 +++++ .../pom.xml | 15 +++++++++++++++ .../pom.xml | 4 ++++ .../pom.xml | 2 +- .../pom.xml | 1 + .../pom.xml | 5 +++++ .../pom.xml | 5 +++++ .../pom.xml | 1 + .../pom.xml | 1 + .../pom.xml | 1 + .../pom.xml | 5 +++++ 16 files changed, 61 insertions(+), 1 deletion(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 070608c73b..d04956aeec 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -361,5 +361,10 @@ guava provided + + org.wso2.orbit.javax.xml.bind + jaxb-api + provided + diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 2f67ef0a84..f09693620d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -137,6 +137,11 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.device.mgt.core + + org.wso2.orbit.javax.xml.bind + jaxb-api + provided + diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 2952cf6cc8..ca008ce943 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -443,6 +443,11 @@ org.wso2.carbon.tenant.mgt compile + + org.wso2.orbit.javax.xml.bind + jaxb-api + provided + diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index ad7269648f..dffe4d0f44 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -261,6 +261,7 @@ org.wso2.orbit.javax.xml.bind jaxb-api + provided com.googlecode.json-simple.wso2 diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 31b3c7ce9c..7cf49e4b6a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -212,6 +212,7 @@ org.wso2.orbit.javax.xml.bind jaxb-api + provided com.sun.xml.bind diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index aa4ba05adb..e4a721a259 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -119,6 +119,11 @@ jaxb-impl test + + org.wso2.orbit.javax.xml.bind + jaxb-api + provided + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 67f197aa18..8a3349474f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -172,6 +172,10 @@ org.apache.cxf cxf-rt-core + + jakarta.xml.bind + jakarta.xml.bind-api + @@ -412,6 +416,12 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.application.mgt.common provided + + + org.wso2.orbit.javax.xml.bind + jaxb-api + + io.entgra.device.mgt.core @@ -453,5 +463,10 @@ io.entgra.device.mgt.core.apimgt.webapp.publisher provided + + org.wso2.orbit.javax.xml.bind + jaxb-api + provided + \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 76cd3ba40b..50c011d7df 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -180,6 +180,10 @@ javassist javassist + + org.wso2.orbit.javax.xml.bind + jaxb-api + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 2f6099546e..1a5a4ab790 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -524,7 +524,7 @@ org.wso2.orbit.javax.xml.bind jaxb-api - compile + provided com.sun.xml.bind diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 6336824f3e..85b1d3fb46 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -150,6 +150,7 @@ org.wso2.orbit.javax.xml.bind jaxb-api + provided io.entgra.device.mgt.core diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index a236395846..fc092a0a18 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -141,6 +141,11 @@ + + org.wso2.orbit.javax.xml.bind + jaxb-api + provided + diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 4c8e429033..5f98c2e822 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -284,6 +284,11 @@ io.entgra.device.mgt.core.notification.logger provided + + org.wso2.orbit.javax.xml.bind + jaxb-api + provided + diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index a86aacc026..4cb496a2fd 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -146,6 +146,7 @@ org.wso2.orbit.javax.xml.bind jaxb-api + provided diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 7f65f94ae2..91b1607f27 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -139,6 +139,7 @@ org.wso2.orbit.javax.xml.bind jaxb-api + provided diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 5218e514a5..a7765a4767 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -104,6 +104,7 @@ org.wso2.orbit.javax.xml.bind jaxb-api + provided diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index b5e4f2203c..f5ba545fae 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -137,6 +137,11 @@ io.entgra.device.mgt.core.device.mgt.common provided + + org.wso2.orbit.javax.xml.bind + jaxb-api + provided + From 9a99b5804f6302dffed32f30816d2cd3fa632d3c Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Wed, 10 Jul 2024 09:54:26 +0530 Subject: [PATCH 229/343] Fix user, role app installations failing --- .../core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 6ca1095faf..a04da1dd27 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -982,7 +982,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { + "e.TENANT_ID = ? AND " + "LOWER(e.OWNER) = LOWER(?) AND " + "e.STATUS IN (", - ")) e1 ORDER BY e1.DATE_OF_LAST_UPDATE DESC"); + ")) e1 WHERE d.ID = e1.DEVICE_ID ORDER BY e1.DATE_OF_LAST_UPDATE DESC"); deviceStatuses.stream().map(ignored -> "?").forEach(joiner::add); String query = joiner.toString(); From 8e33eebbf6ea7087a519353eb6bf46f1bdfb45a0 Mon Sep 17 00:00:00 2001 From: ashvini Date: Fri, 28 Jun 2024 12:38:35 +0530 Subject: [PATCH 230/343] Add tenant application artifact deletion configuration Fix code errors Remove spaces Refactor code --- .../common/services/ApplicationManager.java | 1 + .../mgt/core/impl/ApplicationManagerImpl.java | 37 ++++++++++++------- .../api/admin/UserManagementAdminService.java | 11 ++++-- .../admin/UserManagementAdminServiceImpl.java | 5 ++- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java index 4a1be2ea1e..bf3bdc5d40 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java @@ -547,4 +547,5 @@ public interface ApplicationManager { */ void deleteApplicationDataOfTenant(int tenantId) throws ApplicationManagementException; void deleteApplicationDataByTenantDomain(String tenantDomain) throws ApplicationManagementException; + void deleteApplicationArtifactsByTenantDomain(String tenantDomain) throws ApplicationManagementException; } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index efb55e60cb..f6d0fc228f 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -4424,7 +4424,6 @@ public class ApplicationManagerImpl implements ApplicationManager { spApplicationDAO.deleteSPApplicationMappingByTenant(tenantId); spApplicationDAO.deleteIdentityServerByTenant(tenantId); applicationDAO.deleteApplicationsByTenant(tenantId); - APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId); ConnectionManagerUtil.commitDBTransaction(); } catch (DBConnectionException e) { @@ -4449,12 +4448,6 @@ public class ApplicationManagerImpl implements ApplicationManager { + " of tenant ID: " + tenantId ; log.error(msg, e); throw new ApplicationManagementException(msg, e); - } catch (ApplicationStorageManagementException e) { - ConnectionManagerUtil.rollbackDBTransaction(); - String msg = "Error occurred while deleting App folder of tenant" - + " of tenant ID: " + tenantId ; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -4499,7 +4492,6 @@ public class ApplicationManagerImpl implements ApplicationManager { spApplicationDAO.deleteSPApplicationMappingByTenant(tenantId); spApplicationDAO.deleteIdentityServerByTenant(tenantId); applicationDAO.deleteApplicationsByTenant(tenantId); - APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId); ConnectionManagerUtil.commitDBTransaction(); } catch (DBConnectionException e) { @@ -4524,15 +4516,32 @@ public class ApplicationManagerImpl implements ApplicationManager { + " of tenant ID: " + tenantId ; log.error(msg, e); throw new ApplicationManagementException(msg, e); - } catch (ApplicationStorageManagementException e) { - ConnectionManagerUtil.rollbackDBTransaction(); - String msg = "Error occurred while deleting App folder of tenant" - + " of tenant ID: " + tenantId ; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } + } + @Override + public void deleteApplicationArtifactsByTenantDomain(String tenantDomain) throws ApplicationManagementException { + int tenantId; + try{ + TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService(); + TenantInfoBean tenantInfoBean = tenantMgtAdminService.getTenant(tenantDomain); + tenantId = tenantInfoBean.getTenantId(); + + } catch (Exception e) { + String msg = "Error getting tenant ID from domain: " + + tenantDomain + "when trying to delete application artifacts of tenant"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } + try { + APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId); + } catch (ApplicationStorageManagementException e) { + String msg = "Error occurred while deleting Application folders of tenant" + + " of tenant ID: " + tenantId ; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java index 5d324aeb02..08b51ac9c4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java @@ -298,8 +298,13 @@ public interface UserManagementAdminService { name = "tenantDomain", value = "The domain of the tenant to be deleted.", required = true) - @PathParam("tenantDomain") - String tenantDomain); - + String tenantDomain, + @ApiParam( + name = "deleteAppArtifacts", + value = "Flag to indicate whether to delete application artifacts.", + required = false) + @QueryParam("deleteAppArtifacts") + @DefaultValue("false") + boolean deleteAppArtifacts); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java index d4f34d8e4a..d0e82d7fb3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java @@ -91,7 +91,7 @@ public class UserManagementAdminServiceImpl implements UserManagementAdminServic @DELETE @Path("/domain/{tenantDomain}") @Override - public Response deleteTenantByDomain(@PathParam("tenantDomain") String tenantDomain) { + public Response deleteTenantByDomain(@PathParam("tenantDomain") String tenantDomain, @QueryParam("deleteAppArtifacts") boolean deleteAppArtifacts) { try { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); if (tenantId != MultitenantConstants.SUPER_TENANT_ID){ @@ -99,6 +99,9 @@ public class UserManagementAdminServiceImpl implements UserManagementAdminServic log.error(msg); return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build(); } else { + if(deleteAppArtifacts){ + DeviceMgtAPIUtils.getApplicationManager().deleteApplicationArtifactsByTenantDomain(tenantDomain); + } DeviceMgtAPIUtils.getApplicationManager().deleteApplicationDataByTenantDomain(tenantDomain); DeviceMgtAPIUtils.getDeviceManagementService().deleteDeviceDataByTenantDomain(tenantDomain); TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService(); From 61a21edb9d285b8209e302b9b1e28c5f12d6982d Mon Sep 17 00:00:00 2001 From: nipuni Date: Fri, 5 Jul 2024 13:49:31 +0530 Subject: [PATCH 231/343] Fix Device renaming is not working issue#11452 --- .../impl/DeviceManagementServiceImpl.java | 51 +++++++++++++----- .../common/exceptions/ConflictException.java | 32 +++++++++++ .../DeviceManagementProviderService.java | 14 +++++ .../DeviceManagementProviderServiceImpl.java | 53 +++++++++++++++++++ 4 files changed, 138 insertions(+), 12 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/ConflictException.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 4a141ca30c..b514277817 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -557,22 +557,49 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @Path("/type/{deviceType}/id/{deviceId}/rename") public Response renameDevice(Device device, @PathParam("deviceType") String deviceType, @PathParam("deviceId") String deviceId) { + if (device == null) { + String msg = "Required values are not set to rename device"; + log.error(msg); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + if (StringUtils.isEmpty(device.getName())) { + String msg = "Device name is not set to rename device"; + log.error(msg); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } DeviceManagementProviderService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceManagementService(); try { - Device persistedDevice = deviceManagementProviderService.getDevice(new DeviceIdentifier - (deviceId, deviceType), true); - persistedDevice.setName(device.getName()); - System.out.println("This is rename device"); - boolean responseOfmodifyEnrollment = deviceManagementProviderService.modifyEnrollment(persistedDevice); - boolean responseOfDeviceNameChanged = deviceManagementProviderService.sendDeviceNameChangedNotification( - persistedDevice); - boolean response = responseOfmodifyEnrollment && responseOfDeviceNameChanged; - - return Response.status(Response.Status.CREATED).entity(response).build(); - } catch (DeviceManagementException e) { - String msg = "Error encountered while updating requested device of type : " + deviceType ; + Device updatedDevice = deviceManagementProviderService.updateDeviceName(device, deviceType, deviceId); + if (updatedDevice != null) { + boolean notificationResponse = deviceManagementProviderService.sendDeviceNameChangedNotification(updatedDevice); + if (notificationResponse) { + return Response.status(Response.Status.CREATED).entity(updatedDevice).build(); + } else { + String msg = "Device updated successfully, but failed to send notification."; + log.warn(msg); + return Response.status(Response.Status.CREATED).entity(updatedDevice).header("Warning", msg).build(); + } + } else { + String msg = "Device update failed for device of type : " + deviceType; + log.error(msg); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } catch (BadRequestException e) { + String msg = "Bad request: " + e.getMessage(); log.error(msg, e); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } catch (DeviceNotFoundException e) { + String msg = "Device not found: " + e.getMessage(); + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } catch (DeviceManagementException e) { + String msg = "Error encountered while updating requested device of type : " + deviceType; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (ConflictException e) { + String msg = "Conflict encountered while updating requested device of type : " + deviceType; + log.error(msg, e); + return Response.status(Response.Status.CONFLICT).entity(msg).build(); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/ConflictException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/ConflictException.java new file mode 100644 index 0000000000..5dec1fc431 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/ConflictException.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.common.exceptions; + +public class ConflictException extends Exception { + + private static final long serialVersionUID = -4998775497944307646L; + + public ConflictException(String message) { + super(message); + } + + public ConflictException(String message, Throwable cause) { + super(message, cause); + } +} \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index 48c0c48b5e..9ab44929a1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.ConflictException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO; import io.entgra.device.mgt.core.device.mgt.core.dto.OperationDTO; import io.entgra.device.mgt.core.device.mgt.core.dto.OwnerWithDeviceDTO; @@ -1125,4 +1126,17 @@ public interface DeviceManagementProviderService { */ PaginationResult getDevicesNotInGroup(PaginationRequest request, boolean requireDeviceInfo) throws DeviceManagementException; + + /** + * This method is to update devices names + * @param device {@link Device} + * @param deviceType the type of the device. + * @param deviceId ID of the device. + * @return boolean value of the update status. + * @throws DeviceManagementException if any service level or DAO level error occurs. + * @throws DeviceManagementException if service level null device error occurs. + * @throws ConflictException if service level data conflicts occurs. + */ + Device updateDeviceName(Device device, String deviceType, String deviceId) + throws DeviceManagementException, DeviceNotFoundException, ConflictException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 7bacbef5c6..a3039ba356 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.core.service; import com.google.common.reflect.TypeToken; import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.ConflictException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import io.entgra.device.mgt.core.device.mgt.core.dao.TenantDAO; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO; @@ -3917,6 +3918,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceCacheManagerImpl.getInstance().removeDeviceFromCache(deviceIdentifier, this.getTenantId()); } + private void updateDeviceInCache(DeviceIdentifier deviceIdentifier, Device device) { + DeviceCacheManagerImpl.getInstance().updateDeviceInCache(deviceIdentifier, device, this.getTenantId()); + } + /*** * This method removes a given list of devices from the cache * @param deviceList list of DeviceCacheKey objects @@ -5503,4 +5508,52 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv paginationResult.setRecordsTotal(count); return paginationResult; } + + @Override + public Device updateDeviceName(Device device, String deviceType, String deviceId) + throws DeviceManagementException, DeviceNotFoundException, ConflictException { + Device persistedDevice = this.getDevice(new DeviceIdentifier(deviceId, deviceType), true); + if (persistedDevice == null) { + String msg = "Device not found for the given deviceId and deviceType"; + log.error(msg); + throw new DeviceNotFoundException(msg); + } + if (persistedDevice.getName().equals(device.getName())) { + String msg = "Device names are the same."; + log.info(msg); + throw new ConflictException(msg); + } + persistedDevice.setName(device.getName()); + if (log.isDebugEnabled()) { + log.debug("Rename Device name of: " + persistedDevice.getId() + " of type '" + persistedDevice.getType() + "'"); + } + DeviceManager deviceManager = this.getDeviceManager(persistedDevice.getType()); + if (deviceManager == null) { + String msg = "Device Manager associated with the device type '" + persistedDevice.getType() + "' is null. " + + "Therefore, not attempting method 'modifyEnrolment'"; + log.error(msg); + throw new DeviceManagementException(msg); + } + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(persistedDevice.getDeviceIdentifier(), persistedDevice.getType()); + try { + DeviceManagementDAOFactory.beginTransaction(); + int tenantId = this.getTenantId(); + deviceDAO.updateDevice(persistedDevice, tenantId); + DeviceManagementDAOFactory.commitTransaction(); + this.updateDeviceInCache(deviceIdentifier, persistedDevice); + return persistedDevice; + } catch (DeviceManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while renaming the device '" + persistedDevice.getId() + "'"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (TransactionManagementException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while initiating transaction to rename device: " + persistedDevice.getId(); + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } } From 1576ef86d06f93984e7209748d30722d1e9fcbf2 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Tue, 30 Apr 2024 08:14:23 +0530 Subject: [PATCH 232/343] App publishing improvements --- .../mgt/common/ApplicationArtifact.java | 36 ++ .../services/ApplicationStorageManager.java | 10 + .../mgt/core/impl/ApplicationManagerImpl.java | 364 +++++++++--------- .../impl/ApplicationStorageManagerImpl.java | 13 +- .../core/util/ApplicationManagementUtil.java | 5 + .../util/FileTransferServiceHelperUtil.java | 57 +++ .../common/util/StorageManagementUtil.java | 16 +- 7 files changed, 306 insertions(+), 195 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationArtifact.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationArtifact.java index 371d022ec9..cbec13d3d3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationArtifact.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ApplicationArtifact.java @@ -25,16 +25,52 @@ public class ApplicationArtifact { private String installerName; private InputStream installerStream; + private String installerPath; private String bannerName; private InputStream bannerStream; + private String bannerPath; private String iconName; private InputStream iconStream; + private String iconPath; private Map screenshots; + private Map screenshotPaths; + + public String getInstallerPath() { + return installerPath; + } + + public void setInstallerPath(String installerPath) { + this.installerPath = installerPath; + } + + public String getBannerPath() { + return bannerPath; + } + + public void setBannerPath(String bannerPath) { + this.bannerPath = bannerPath; + } + + public String getIconPath() { + return iconPath; + } + + public void setIconPath(String iconPath) { + this.iconPath = iconPath; + } + + public Map getScreenshotPaths() { + return screenshotPaths; + } + + public void setScreenshotPaths(Map screenshotPaths) { + this.screenshotPaths = screenshotPaths; + } public String getInstallerName() { return installerName; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationStorageManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationStorageManager.java index 698c57f55a..bab015e97e 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationStorageManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationStorageManager.java @@ -140,4 +140,14 @@ public interface ApplicationStorageManager { * @throws ApplicationStorageManagementException thrown if */ void deleteAppFolderOfTenant(int tenantId) throws ApplicationStorageManagementException; + + /** + * Get absolute path of a file describe by hashVal, folder, file name and tenantId + * @param hashVal Hash value of the application release. + * @param folderName Folder name file resides. + * @param fileName File name of the file. + * @param tenantId Tenant ID + * @return Absolute path + */ + String getAbsolutePathOfFile(String hashVal, String folderName, String fileName, int tenantId); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index efb55e60cb..60b61dab93 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -102,11 +102,15 @@ import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.core.Response; +import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -727,20 +731,23 @@ public class ApplicationManagerImpl implements ApplicationManager { throws ResourceManagementException, ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager(); - byte[] content = getByteContentOfApp(applicationArtifact); - String md5OfApp = generateMD5OfApp(applicationArtifact, content); - validateReleaseBinaryFileHash(md5OfApp); - releaseDTO.setUuid(UUID.randomUUID().toString()); - releaseDTO.setAppHashValue(md5OfApp); - releaseDTO.setInstallerName(applicationArtifact.getInstallerName()); + try { + String md5OfApp = applicationStorageManager.getMD5(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath()))); + validateReleaseBinaryFileHash(md5OfApp); + releaseDTO.setUuid(UUID.randomUUID().toString()); + releaseDTO.setAppHashValue(md5OfApp); + releaseDTO.setInstallerName(applicationArtifact.getInstallerName()); - try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { - applicationStorageManager.uploadReleaseArtifact(releaseDTO, deviceType, - binaryDuplicate, tenantId); + applicationStorageManager.uploadReleaseArtifact(releaseDTO, deviceType, + Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), tenantId); } catch (IOException e) { String msg = "Error occurred when uploading release artifact into the server"; log.error(msg); throw new ApplicationManagementException(msg, e); + } catch (StorageManagementException e) { + String msg = "Error occurred while md5sum value retrieving process: application UUID " + + releaseDTO.getUuid(); + log.error(msg, e); } return addImageArtifacts(releaseDTO, applicationArtifact, tenantId); } @@ -856,82 +863,77 @@ public class ApplicationManagerImpl implements ApplicationManager { String uuid = UUID.randomUUID().toString(); applicationReleaseDTO.setUuid(uuid); - // The application executable artifacts such as apks are uploaded. try { - byte[] content = IOUtils.toByteArray(applicationArtifact.getInstallerStream()); applicationReleaseDTO.setInstallerName(applicationArtifact.getInstallerName()); - try (ByteArrayInputStream binary = new ByteArrayInputStream(content)) { - if (!DeviceTypes.WINDOWS.toString().equalsIgnoreCase(deviceType)) { - ApplicationInstaller applicationInstaller = applicationStorageManager - .getAppInstallerData(binary, deviceType); - applicationReleaseDTO.setVersion(applicationInstaller.getVersion()); - applicationReleaseDTO.setPackageName(applicationInstaller.getPackageName()); - } else { - String windowsInstallerName = applicationArtifact.getInstallerName(); - String extension = windowsInstallerName.substring(windowsInstallerName.lastIndexOf(".") + 1); - if (!extension.equalsIgnoreCase(Constants.MSI) && - !extension.equalsIgnoreCase(Constants.APPX)) { - String msg = "Application Type doesn't match with supporting application types of " + - deviceType + "platform which are APPX and MSI"; - log.error(msg); - throw new BadRequestException(msg); - } - } - - String packageName = applicationReleaseDTO.getPackageName(); - try { - ConnectionManagerUtil.openDBConnection(); - if (!isNewRelease && applicationReleaseDAO - .isActiveReleaseExisitForPackageName(packageName, tenantId, - lifecycleStateManager.getEndState())) { - String msg = "Application release is already exist for the package name: " + packageName - + ". Either you can delete all application releases for package " + packageName + " or " - + "you can add this app release as an new application release, under the existing " - + "application."; - log.error(msg); - throw new ApplicationManagementException(msg); - } - String md5OfApp = applicationStorageManager.getMD5(new ByteArrayInputStream(content)); - if (md5OfApp == null) { - String msg = "Error occurred while md5sum value retrieving process: application UUID " - + applicationReleaseDTO.getUuid(); - log.error(msg); - throw new ApplicationStorageManagementException(msg); - } - if (this.applicationReleaseDAO.verifyReleaseExistenceByHash(md5OfApp, tenantId)) { - String msg = - "Application release exists for the uploaded binary file. Device Type: " + deviceType; - log.error(msg); - throw new BadRequestException(msg); - } - applicationReleaseDTO.setAppHashValue(md5OfApp); - - try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { - applicationStorageManager - .uploadReleaseArtifact(applicationReleaseDTO, deviceType, binaryDuplicate, tenantId); - } - } catch (StorageManagementException e) { - String msg = "Error occurred while md5sum value retrieving process: application UUID " - + applicationReleaseDTO.getUuid(); - log.error(msg, e); - throw new ApplicationStorageManagementException(msg, e); - } catch (DBConnectionException e) { - String msg = "Error occurred when getting database connection for verifying app release data."; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (ApplicationManagementDAOException e) { - String msg = - "Error occurred when executing the query for verifying application release existence for " - + "the package."; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } finally { - ConnectionManagerUtil.closeDBConnection(); + if (!DeviceTypes.WINDOWS.toString().equalsIgnoreCase(deviceType)) { + ApplicationInstaller applicationInstaller = applicationStorageManager + .getAppInstallerData(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), deviceType); + applicationReleaseDTO.setVersion(applicationInstaller.getVersion()); + applicationReleaseDTO.setPackageName(applicationInstaller.getPackageName()); + } else { + String windowsInstallerName = applicationArtifact.getInstallerName(); + String extension = windowsInstallerName.substring(windowsInstallerName.lastIndexOf(".") + 1); + if (!extension.equalsIgnoreCase(Constants.MSI) && + !extension.equalsIgnoreCase(Constants.APPX)) { + String msg = "Application Type doesn't match with supporting application types of " + + deviceType + "platform which are APPX and MSI"; + log.error(msg); + throw new BadRequestException(msg); } } + + String packageName = applicationReleaseDTO.getPackageName(); + try { + ConnectionManagerUtil.openDBConnection(); + if (!isNewRelease && applicationReleaseDAO + .isActiveReleaseExisitForPackageName(packageName, tenantId, + lifecycleStateManager.getEndState())) { + String msg = "Application release is already exist for the package name: " + packageName + + ". Either you can delete all application releases for package " + packageName + " or " + + "you can add this app release as an new application release, under the existing " + + "application."; + log.error(msg); + throw new ApplicationManagementException(msg); + } + String md5OfApp = applicationStorageManager.getMD5(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath()))); + if (md5OfApp == null) { + String msg = "Error occurred while md5sum value retrieving process: application UUID " + + applicationReleaseDTO.getUuid(); + log.error(msg); + throw new ApplicationStorageManagementException(msg); + } + if (this.applicationReleaseDAO.verifyReleaseExistenceByHash(md5OfApp, tenantId)) { + String msg = + "Application release exists for the uploaded binary file. Device Type: " + deviceType; + log.error(msg); + throw new BadRequestException(msg); + } + applicationReleaseDTO.setAppHashValue(md5OfApp); + + applicationStorageManager + .uploadReleaseArtifact(applicationReleaseDTO, deviceType, + Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), tenantId); + } catch (StorageManagementException e) { + String msg = "Error occurred while md5sum value retrieving process: application UUID " + + applicationReleaseDTO.getUuid(); + log.error(msg, e); + throw new ApplicationStorageManagementException(msg, e); + } catch (DBConnectionException e) { + String msg = "Error occurred when getting database connection for verifying app release data."; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (ApplicationManagementDAOException e) { + String msg = + "Error occurred when executing the query for verifying application release existence for " + + "the package."; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } } catch (IOException e) { - String msg = "Error occurred when getting byte array of binary file. Installer name: " + applicationArtifact + String msg = "Error occurred when getting file input stream. Installer name: " + applicationArtifact .getInstallerName(); log.error(msg, e); throw new ApplicationStorageManagementException(msg, e); @@ -957,73 +959,64 @@ public class ApplicationManagerImpl implements ApplicationManager { // The application executable artifacts such as apks are uploaded. try { - byte[] content = IOUtils.toByteArray(applicationArtifact.getInstallerStream()); + String md5OfApp = applicationStorageManager.getMD5(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath()))); + if (md5OfApp == null) { + String msg = "Error occurred while retrieving md5sum value from the binary file for application " + + "release UUID " + applicationReleaseDTO.getUuid(); + log.error(msg); + throw new ApplicationStorageManagementException(msg); + } - try (ByteArrayInputStream binaryClone = new ByteArrayInputStream(content)) { - String md5OfApp = applicationStorageManager.getMD5(binaryClone); + if (!applicationReleaseDTO.getAppHashValue().equals(md5OfApp)) { + applicationReleaseDTO.setInstallerName(applicationArtifact.getInstallerName()); + ApplicationInstaller applicationInstaller = applicationStorageManager + .getAppInstallerData(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), deviceType); + String packageName = applicationInstaller.getPackageName(); - if (md5OfApp == null) { - String msg = "Error occurred while retrieving md5sum value from the binary file for application " - + "release UUID " + applicationReleaseDTO.getUuid(); - log.error(msg); - throw new ApplicationStorageManagementException(msg); - } - if (!applicationReleaseDTO.getAppHashValue().equals(md5OfApp)) { - applicationReleaseDTO.setInstallerName(applicationArtifact.getInstallerName()); - - try (ByteArrayInputStream binary = new ByteArrayInputStream(content)) { - ApplicationInstaller applicationInstaller = applicationStorageManager - .getAppInstallerData(binary, deviceType); - String packageName = applicationInstaller.getPackageName(); - - try { - ConnectionManagerUtil.getDBConnection(); - if (this.applicationReleaseDAO.verifyReleaseExistenceByHash(md5OfApp, tenantId)) { - String msg = "Same binary file is in the server. Hence you can't add same file into the " - + "server. Device Type: " + deviceType + " and package name: " + packageName; - log.error(msg); - throw new BadRequestException(msg); - } - if (applicationReleaseDTO.getPackageName() == null){ - String msg = "Found null value for application release package name for application " - + "release which has UUID: " + applicationReleaseDTO.getUuid(); - log.error(msg); - throw new ApplicationManagementException(msg); - } - if (!applicationReleaseDTO.getPackageName().equals(packageName)){ - String msg = "Package name of the new artifact does not match with the package name of " - + "the exiting application release. Package name of the existing app release " - + applicationReleaseDTO.getPackageName() + " and package name of the new " - + "application release " + packageName; - log.error(msg); - throw new BadRequestException(msg); - } - - applicationReleaseDTO.setVersion(applicationInstaller.getVersion()); - applicationReleaseDTO.setPackageName(packageName); - String deletingAppHashValue = applicationReleaseDTO.getAppHashValue(); - applicationReleaseDTO.setAppHashValue(md5OfApp); - try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { - applicationStorageManager - .uploadReleaseArtifact(applicationReleaseDTO, deviceType, binaryDuplicate, - tenantId); - applicationStorageManager.copyImageArtifactsAndDeleteInstaller(deletingAppHashValue, - applicationReleaseDTO, tenantId); - } - } catch (DBConnectionException e) { - String msg = "Error occurred when getting database connection for verifying application " - + "release existing for new app hash value."; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (ApplicationManagementDAOException e) { - String msg = "Error occurred when executing the query for verifying application release " - + "existence for the new app hash value."; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } finally { - ConnectionManagerUtil.closeDBConnection(); - } + try { + ConnectionManagerUtil.getDBConnection(); + if (this.applicationReleaseDAO.verifyReleaseExistenceByHash(md5OfApp, tenantId)) { + String msg = "Same binary file is in the server. Hence you can't add same file into the " + + "server. Device Type: " + deviceType + " and package name: " + packageName; + log.error(msg); + throw new BadRequestException(msg); } + if (applicationReleaseDTO.getPackageName() == null){ + String msg = "Found null value for application release package name for application " + + "release which has UUID: " + applicationReleaseDTO.getUuid(); + log.error(msg); + throw new ApplicationManagementException(msg); + } + if (!applicationReleaseDTO.getPackageName().equals(packageName)){ + String msg = "Package name of the new artifact does not match with the package name of " + + "the exiting application release. Package name of the existing app release " + + applicationReleaseDTO.getPackageName() + " and package name of the new " + + "application release " + packageName; + log.error(msg); + throw new BadRequestException(msg); + } + + applicationReleaseDTO.setVersion(applicationInstaller.getVersion()); + applicationReleaseDTO.setPackageName(packageName); + String deletingAppHashValue = applicationReleaseDTO.getAppHashValue(); + applicationReleaseDTO.setAppHashValue(md5OfApp); + applicationStorageManager.uploadReleaseArtifact(applicationReleaseDTO, deviceType, + Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), + tenantId); + applicationStorageManager.copyImageArtifactsAndDeleteInstaller(deletingAppHashValue, + applicationReleaseDTO, tenantId); + } catch (DBConnectionException e) { + String msg = "Error occurred when getting database connection for verifying application " + + "release existing for new app hash value."; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (ApplicationManagementDAOException e) { + String msg = "Error occurred when executing the query for verifying application release " + + "existence for the new app hash value."; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); } } } catch (StorageManagementException e) { @@ -1032,7 +1025,7 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg, e); throw new ApplicationStorageManagementException(msg, e); } catch (IOException e) { - String msg = "Error occurred when getting byte array of binary file. Installer name: " + applicationArtifact + String msg = "Error occurred when getting file input stream. Installer name: " + applicationArtifact .getInstallerName(); log.error(msg, e); throw new ApplicationStorageManagementException(msg, e); @@ -3607,52 +3600,49 @@ public class ApplicationManagerImpl implements ApplicationManager { DeviceType deviceTypeObj = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId()); // The application executable artifacts such as deb are uploaded. try { - byte[] content = IOUtils.toByteArray(applicationArtifact.getInstallerStream()); - try (ByteArrayInputStream binaryClone = new ByteArrayInputStream(content)) { - String md5OfApp = applicationStorageManager.getMD5(binaryClone); - if (md5OfApp == null) { - String msg = "Error occurred while retrieving md5sum value from the binary file for " - + "application release UUID " + applicationReleaseDTO.get().getUuid(); - log.error(msg); - throw new ApplicationStorageManagementException(msg); - } - if (!applicationReleaseDTO.get().getAppHashValue().equals(md5OfApp)) { - try { - ConnectionManagerUtil.getDBConnection(); - if (this.applicationReleaseDAO.verifyReleaseExistenceByHash(md5OfApp, tenantId)) { - String msg = - "Same binary file is in the server. Hence you can't add same file into the " - + "server. Device Type: " + deviceTypeObj.getName() - + " and package name: " + applicationDTO.getApplicationReleaseDTOs() - .get(0).getPackageName(); - log.error(msg); - throw new BadRequestException(msg); - } + String md5OfApp = applicationStorageManager.getMD5( + Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath()))); + if (md5OfApp == null) { + String msg = "Error occurred while retrieving md5sum value from the binary file for " + + "application release UUID " + applicationReleaseDTO.get().getUuid(); + log.error(msg); + throw new ApplicationStorageManagementException(msg); + } - applicationReleaseDTO.get().setInstallerName(applicationArtifact.getInstallerName()); - String deletingAppHashValue = applicationReleaseDTO.get().getAppHashValue(); - applicationReleaseDTO.get().setAppHashValue(md5OfApp); - try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { - applicationStorageManager - .uploadReleaseArtifact(applicationReleaseDTO.get(), deviceTypeObj.getName(), - binaryDuplicate, tenantId); - applicationStorageManager.copyImageArtifactsAndDeleteInstaller(deletingAppHashValue, - applicationReleaseDTO.get(), tenantId); - } - } catch (DBConnectionException e) { - String msg = "Error occurred when getting database connection for verifying application" - + " release existing for new app hash value."; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (ApplicationManagementDAOException e) { + if (!applicationReleaseDTO.get().getAppHashValue().equals(md5OfApp)) { + try { + ConnectionManagerUtil.getDBConnection(); + if (this.applicationReleaseDAO.verifyReleaseExistenceByHash(md5OfApp, tenantId)) { String msg = - "Error occurred when executing the query for verifying application release " - + "existence for the new app hash value."; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } finally { - ConnectionManagerUtil.closeDBConnection(); + "Same binary file is in the server. Hence you can't add same file into the " + + "server. Device Type: " + deviceTypeObj.getName() + + " and package name: " + applicationDTO.getApplicationReleaseDTOs() + .get(0).getPackageName(); + log.error(msg); + throw new BadRequestException(msg); } + + applicationReleaseDTO.get().setInstallerName(applicationArtifact.getInstallerName()); + String deletingAppHashValue = applicationReleaseDTO.get().getAppHashValue(); + applicationReleaseDTO.get().setAppHashValue(md5OfApp); + applicationStorageManager. + uploadReleaseArtifact(applicationReleaseDTO.get(), deviceTypeObj.getName(), + Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), tenantId); + applicationStorageManager.copyImageArtifactsAndDeleteInstaller(deletingAppHashValue, + applicationReleaseDTO.get(), tenantId); + } catch (DBConnectionException e) { + String msg = "Error occurred when getting database connection for verifying application" + + " release existing for new app hash value."; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (ApplicationManagementDAOException e) { + String msg = + "Error occurred when executing the query for verifying application release " + + "existence for the new app hash value."; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); } } } catch (StorageManagementException e) { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java index 158361232c..167ebd84dc 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -37,6 +37,7 @@ import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagem import io.entgra.device.mgt.core.device.mgt.core.common.util.StorageManagementUtil; import java.io.*; +import java.nio.file.Paths; import java.util.List; import static io.entgra.device.mgt.core.device.mgt.core.common.util.StorageManagementUtil.saveFile; @@ -155,13 +156,13 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager public void uploadReleaseArtifact(ApplicationReleaseDTO applicationReleaseDTO, String deviceType, InputStream binaryFile, int tenantId) throws ResourceManagementException { try { - byte [] content = IOUtils.toByteArray(binaryFile); + //byte [] content = IOUtils.toByteArray(binaryFile); String artifactDirectoryPath = storagePath + tenantId + File.separator + applicationReleaseDTO.getAppHashValue() + File.separator + Constants.APP_ARTIFACT; StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath); String artifactPath = artifactDirectoryPath + File.separator + applicationReleaseDTO.getInstallerName(); - saveFile(new ByteArrayInputStream(content), artifactPath); + saveFile(binaryFile, artifactPath); } catch (IOException e) { String msg = "IO Exception while saving the release artifacts in the server for the application UUID " + applicationReleaseDTO.getUuid(); @@ -324,4 +325,12 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } } } + + @Override + public String getAbsolutePathOfFile(String hashVal, String folderName, String fileName, int tenantId) { + String filePath = + storagePath + tenantId + File.separator + hashVal + File.separator + folderName + File.separator + + fileName; + return Paths.get(filePath).toAbsolutePath().toString(); + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java index 846777c794..6374aadb13 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java @@ -181,6 +181,7 @@ public class ApplicationManagementUtil { fileDescriptor = FileDownloaderServiceProvider.getFileDownloaderService(artifactLinkUrl).download(artifactLinkUrl); applicationArtifact.setInstallerName(fileDescriptor.getFullQualifiedName()); applicationArtifact.setInstallerStream(fileDescriptor.getFile()); + applicationArtifact.setInstallerPath(fileDescriptor.getAbsolutePath()); } if (iconLink != null) { @@ -188,6 +189,7 @@ public class ApplicationManagementUtil { fileDescriptor = FileDownloaderServiceProvider.getFileDownloaderService(iconLinkUrl).download(iconLinkUrl); applicationArtifact.setIconName(fileDescriptor.getFullQualifiedName()); applicationArtifact.setIconStream(fileDescriptor.getFile()); + applicationArtifact.setIconPath(fileDescriptor.getAbsolutePath()); } if (bannerLink != null) { @@ -195,10 +197,12 @@ public class ApplicationManagementUtil { fileDescriptor = FileDownloaderServiceProvider.getFileDownloaderService(bannerLinkUrl).download(bannerLinkUrl); applicationArtifact.setBannerName(fileDescriptor.getFullQualifiedName()); applicationArtifact.setBannerStream(fileDescriptor.getFile()); + applicationArtifact.setBannerPath(fileDescriptor.getAbsolutePath()); } if (screenshotLinks != null) { Map screenshotData = new TreeMap<>(); + Map screenshotPaths = new TreeMap<>(); // This is to handle cases in which multiple screenshots have the same name Map screenshotNameCount = new HashMap<>(); URL screenshotLinkUrl; @@ -209,6 +213,7 @@ public class ApplicationManagementUtil { screenshotNameCount.put(screenshotName, screenshotNameCount.getOrDefault(screenshotName, 0) + 1); screenshotName = FileUtil.generateDuplicateFileName(screenshotName, screenshotNameCount.get(screenshotName)); screenshotData.put(screenshotName, fileDescriptor.getFile()); + screenshotPaths.put(screenshotName, fileDescriptor.getAbsolutePath()); } applicationArtifact.setScreenshots(screenshotData); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java index 570998ebef..1a44848b87 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java @@ -23,7 +23,9 @@ import com.google.gson.Gson; import io.entgra.device.mgt.core.application.mgt.common.ChunkDescriptor; import io.entgra.device.mgt.core.application.mgt.common.FileDescriptor; import io.entgra.device.mgt.core.application.mgt.common.FileMetaEntry; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationStorageManagementException; import io.entgra.device.mgt.core.application.mgt.core.exception.FileTransferServiceHelperUtilException; +import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; import io.entgra.device.mgt.core.device.mgt.common.exceptions.NotFoundException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -175,6 +177,12 @@ public class FileTransferServiceHelperUtil { } String []urlPathSegments = downloadUrl.getPath().split("/"); + + FileDescriptor fileDescriptorResolvedFromRelease = resolve(urlPathSegments); + if (fileDescriptorResolvedFromRelease != null) { + return fileDescriptorResolvedFromRelease; + } + if (urlPathSegments.length < 2) { if (log.isDebugEnabled()) { log.debug("URL patch segments contain less than 2 segments"); @@ -234,4 +242,53 @@ public class FileTransferServiceHelperUtil { throw new FileTransferServiceHelperUtilException("Error encountered while creating artifact file", e); } } + + private static FileDescriptor resolve(String []urlSegments) throws FileTransferServiceHelperUtilException { + if (urlSegments.length < 4) { + if (log.isDebugEnabled()) { + log.debug("URL path segments contain less than 2 segments"); + } + return null; + } + + int tenantId; + try { + tenantId = Integer.parseInt(urlSegments[urlSegments.length - 4]); + } catch (NumberFormatException e) { + if (log.isDebugEnabled()) { + log.debug("URL isn't pointing to a file resides in the default storage path"); + } + return null; + } + + String fileName = urlSegments[urlSegments.length - 1]; + String folderName = urlSegments[urlSegments.length - 2]; + String appHash = urlSegments[urlSegments.length - 3]; + + try { + InputStream fileStream = DataHolder.getInstance(). + getApplicationStorageManager().getFileStream(appHash, folderName, fileName, tenantId); + if (fileStream == null) { + if (log.isDebugEnabled()) { + log.debug("Could not found the file " + fileName); + } + return null; + } + + String []fileNameSegments = fileName.split("\\.(?=[^.]+$)"); + if (fileNameSegments.length < 2) { + throw new FileTransferServiceHelperUtilException("Invalid full qualified name encountered :" + fileName); + } + FileDescriptor fileDescriptor = new FileDescriptor(); + fileDescriptor.setFile(fileStream); + fileDescriptor.setFullQualifiedName(fileName); + fileDescriptor.setExtension(fileNameSegments[fileNameSegments.length - 1]); + fileDescriptor.setFileName(fileNameSegments[fileNameSegments.length - 2]); + fileDescriptor.setAbsolutePath(DataHolder.getInstance(). + getApplicationStorageManager().getAbsolutePathOfFile(appHash, folderName, fileName, tenantId)); + return fileDescriptor; + } catch (ApplicationStorageManagementException e) { + throw new FileTransferServiceHelperUtilException("Error encountered while getting file input stream", e); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/StorageManagementUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/StorageManagementUtil.java index 979a514db5..bf37d0bab6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/StorageManagementUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/util/StorageManagementUtil.java @@ -23,6 +23,8 @@ import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Base64File; import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagementException; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -31,6 +33,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.file.Files; +import java.nio.file.Paths; /** * This is a util class that handles Storage Management related tasks. @@ -87,13 +90,14 @@ public class StorageManagementUtil { * @param path Path the file need to be saved in. */ public static void saveFile(InputStream inputStream, String path) throws IOException { - try (OutputStream outStream = new FileOutputStream(new File(path))) { - byte[] buffer = new byte[inputStream.available()]; - if (inputStream.read(buffer) != -1) { - outStream.write(buffer); + try (BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(Files.newOutputStream(Paths.get(path))); + BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)) { + byte []buffer = new byte[8192]; + int n; + while ((n = bufferedInputStream.read(buffer)) != -1) { + bufferedOutputStream.write(buffer, 0, n); } - } finally { - inputStream.close(); + bufferedOutputStream.flush(); } } From 2eb73213f3137aed5620f2de66b19da3ca67d2a1 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Sat, 25 May 2024 07:00:05 +0530 Subject: [PATCH 233/343] Add requested changes --- .../mgt/core/impl/ApplicationManagerImpl.java | 50 ++++++++++--------- .../impl/ApplicationStorageManagerImpl.java | 1 - .../core/impl/FileTransferServiceImpl.java | 10 +++- .../util/FileTransferServiceHelperUtil.java | 3 +- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index 60b61dab93..f560d8ce82 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -727,19 +727,20 @@ public class ApplicationManagerImpl implements ApplicationManager { * @throws ResourceManagementException if error occurred while uploading */ private ApplicationReleaseDTO uploadCustomAppReleaseArtifacts(ApplicationReleaseDTO releaseDTO, ApplicationArtifact applicationArtifact, - String deviceType) + String deviceType) throws ResourceManagementException, ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager(); try { - String md5OfApp = applicationStorageManager.getMD5(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath()))); + String md5OfApp = applicationStorageManager. + getMD5(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath()))); validateReleaseBinaryFileHash(md5OfApp); releaseDTO.setUuid(UUID.randomUUID().toString()); releaseDTO.setAppHashValue(md5OfApp); releaseDTO.setInstallerName(applicationArtifact.getInstallerName()); - applicationStorageManager.uploadReleaseArtifact(releaseDTO, deviceType, - Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), tenantId); + applicationStorageManager.uploadReleaseArtifact(releaseDTO, deviceType, + Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), tenantId); } catch (IOException e) { String msg = "Error occurred when uploading release artifact into the server"; log.error(msg); @@ -748,6 +749,7 @@ public class ApplicationManagerImpl implements ApplicationManager { String msg = "Error occurred while md5sum value retrieving process: application UUID " + releaseDTO.getUuid(); log.error(msg, e); + throw new ApplicationManagementException(msg, e); } return addImageArtifacts(releaseDTO, applicationArtifact, tenantId); } @@ -896,7 +898,8 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ApplicationManagementException(msg); } - String md5OfApp = applicationStorageManager.getMD5(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath()))); + String md5OfApp = applicationStorageManager. + getMD5(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath()))); if (md5OfApp == null) { String msg = "Error occurred while md5sum value retrieving process: application UUID " + applicationReleaseDTO.getUuid(); @@ -910,10 +913,9 @@ public class ApplicationManagerImpl implements ApplicationManager { throw new BadRequestException(msg); } applicationReleaseDTO.setAppHashValue(md5OfApp); - - applicationStorageManager - .uploadReleaseArtifact(applicationReleaseDTO, deviceType, - Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), tenantId); + applicationStorageManager + .uploadReleaseArtifact(applicationReleaseDTO, deviceType, + Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), tenantId); } catch (StorageManagementException e) { String msg = "Error occurred while md5sum value retrieving process: application UUID " + applicationReleaseDTO.getUuid(); @@ -969,9 +971,9 @@ public class ApplicationManagerImpl implements ApplicationManager { if (!applicationReleaseDTO.getAppHashValue().equals(md5OfApp)) { applicationReleaseDTO.setInstallerName(applicationArtifact.getInstallerName()); - ApplicationInstaller applicationInstaller = applicationStorageManager - .getAppInstallerData(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), deviceType); - String packageName = applicationInstaller.getPackageName(); + ApplicationInstaller applicationInstaller = applicationStorageManager + .getAppInstallerData(Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), deviceType); + String packageName = applicationInstaller.getPackageName(); try { ConnectionManagerUtil.getDBConnection(); @@ -981,13 +983,13 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new BadRequestException(msg); } - if (applicationReleaseDTO.getPackageName() == null){ + if (applicationReleaseDTO.getPackageName() == null) { String msg = "Found null value for application release package name for application " + "release which has UUID: " + applicationReleaseDTO.getUuid(); log.error(msg); throw new ApplicationManagementException(msg); } - if (!applicationReleaseDTO.getPackageName().equals(packageName)){ + if (!applicationReleaseDTO.getPackageName().equals(packageName)) { String msg = "Package name of the new artifact does not match with the package name of " + "the exiting application release. Package name of the existing app release " + applicationReleaseDTO.getPackageName() + " and package name of the new " @@ -1000,11 +1002,11 @@ public class ApplicationManagerImpl implements ApplicationManager { applicationReleaseDTO.setPackageName(packageName); String deletingAppHashValue = applicationReleaseDTO.getAppHashValue(); applicationReleaseDTO.setAppHashValue(md5OfApp); - applicationStorageManager.uploadReleaseArtifact(applicationReleaseDTO, deviceType, - Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), - tenantId); - applicationStorageManager.copyImageArtifactsAndDeleteInstaller(deletingAppHashValue, - applicationReleaseDTO, tenantId); + applicationStorageManager.uploadReleaseArtifact(applicationReleaseDTO, deviceType, + Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), + tenantId); + applicationStorageManager.copyImageArtifactsAndDeleteInstaller(deletingAppHashValue, + applicationReleaseDTO, tenantId); } catch (DBConnectionException e) { String msg = "Error occurred when getting database connection for verifying application " + "release existing for new app hash value."; @@ -3625,11 +3627,11 @@ public class ApplicationManagerImpl implements ApplicationManager { applicationReleaseDTO.get().setInstallerName(applicationArtifact.getInstallerName()); String deletingAppHashValue = applicationReleaseDTO.get().getAppHashValue(); applicationReleaseDTO.get().setAppHashValue(md5OfApp); - applicationStorageManager. - uploadReleaseArtifact(applicationReleaseDTO.get(), deviceTypeObj.getName(), - Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), tenantId); - applicationStorageManager.copyImageArtifactsAndDeleteInstaller(deletingAppHashValue, - applicationReleaseDTO.get(), tenantId); + applicationStorageManager. + uploadReleaseArtifact(applicationReleaseDTO.get(), deviceTypeObj.getName(), + Files.newInputStream(Paths.get(applicationArtifact.getInstallerPath())), tenantId); + applicationStorageManager.copyImageArtifactsAndDeleteInstaller(deletingAppHashValue, + applicationReleaseDTO.get(), tenantId); } catch (DBConnectionException e) { String msg = "Error occurred when getting database connection for verifying application" + " release existing for new app hash value."; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java index 167ebd84dc..ad1906ede1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -156,7 +156,6 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager public void uploadReleaseArtifact(ApplicationReleaseDTO applicationReleaseDTO, String deviceType, InputStream binaryFile, int tenantId) throws ResourceManagementException { try { - //byte [] content = IOUtils.toByteArray(binaryFile); String artifactDirectoryPath = storagePath + tenantId + File.separator + applicationReleaseDTO.getAppHashValue() + File.separator + Constants.APP_ARTIFACT; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileTransferServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileTransferServiceImpl.java index 52789308fd..8af3324c67 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileTransferServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileTransferServiceImpl.java @@ -31,6 +31,7 @@ import io.entgra.device.mgt.core.device.mgt.common.exceptions.NotFoundException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.nio.file.FileSystems; @@ -103,8 +104,13 @@ public class FileTransferServiceImpl implements FileTransferService { @Override public boolean isExistsOnLocal(URL downloadUrl) throws FileTransferServiceException { try { - return FileTransferServiceHelperUtil.resolve(downloadUrl) != null; - } catch (FileTransferServiceHelperUtilException e) { + FileDescriptor fileDescriptor = FileTransferServiceHelperUtil.resolve(downloadUrl); + if (fileDescriptor != null && fileDescriptor.getFile() != null) { + fileDescriptor.getFile().close(); + return true; + } + return false; + } catch (FileTransferServiceHelperUtilException | IOException e) { String msg = "Error occurred while checking the existence of artifact on the local environment"; log.error(msg, e); throw new FileTransferServiceException(msg, e); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java index 1a44848b87..856faf4944 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java @@ -244,9 +244,10 @@ public class FileTransferServiceHelperUtil { } private static FileDescriptor resolve(String []urlSegments) throws FileTransferServiceHelperUtilException { + // check the possibility of url is pointing to a file resides in the default storage path if (urlSegments.length < 4) { if (log.isDebugEnabled()) { - log.debug("URL path segments contain less than 2 segments"); + log.debug("URL path segments contain less than 4 segments"); } return null; } From 7c90b43485761486bcef24ad8c189157c53b4162 Mon Sep 17 00:00:00 2001 From: nipuni Date: Wed, 10 Jul 2024 21:30:45 +0530 Subject: [PATCH 234/343] Fix issues with adding operation log of a subscription --- .../mgt/common/services/SubscriptionManager.java | 4 +--- .../mgt/core/application/mgt/core/dao/SubscriptionDAO.java | 4 +--- .../dao/impl/subscription/GenericSubscriptionDAOImpl.java | 7 +++---- .../application/mgt/core/impl/SubscriptionManagerImpl.java | 4 ++-- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java index 1cbeda5f08..de9f2977e6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java @@ -293,12 +293,10 @@ public interface SubscriptionManager { * * @param deviceId the deviceId of the device that need to get operation details. * @param uuid the UUID of the application release. - * @param offset the offset for the data set - * @param limit the limit for the data set * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @throws SubscriptionManagementException if there is an error while fetching the details. */ - List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit) + List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid) throws ApplicationManagementException; /** diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java index 88465a4533..3bc8918fcc 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java @@ -378,12 +378,10 @@ public interface SubscriptionDAO { * @param appReleaseId the appReleaseId of the application release. * @param deviceId the deviceId of the device that need to get operation details. * @param tenantId id of the current tenant. - * @param offset the offset for the data set - * @param limit the limit for the data set * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. */ - List getSubscriptionOperationsByAppReleaseIDAndDeviceID(int appReleaseId, int deviceId, int tenantId, int offset, int limit) + List getSubscriptionOperationsByAppReleaseIDAndDeviceID(int appReleaseId, int deviceId, int tenantId) throws ApplicationManagementDAOException; /** diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 8737c99d7c..fb2e2cffd6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -1857,7 +1857,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc @Override public List getSubscriptionOperationsByAppReleaseIDAndDeviceID( - int appReleaseId, int deviceId, int tenantId, int offset, int limit) throws ApplicationManagementDAOException { + int appReleaseId, int deviceId, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get device subscriptions related to the given AppReleaseID and DeviceID."); } @@ -1877,13 +1877,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc "WHERE ads.AP_APP_RELEASE_ID = ? " + "AND ads.DM_DEVICE_ID = ? " + "AND ads.TENANT_ID = ? " + - "LIMIT ? OFFSET ?"; + "ORDER BY aasom.OPERATION_ID DESC " + + "LIMIT 1"; try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, deviceId); ps.setInt(3, tenantId); - ps.setInt(4, limit); - ps.setInt(5, offset); try (ResultSet rs = ps.executeQuery()) { DeviceOperationDTO deviceSubscription; while (rs.next()) { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 669cdb7745..498abe0b02 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -2612,7 +2612,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit) + public List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); if (uuid == null || uuid.isEmpty()) { @@ -2631,7 +2631,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); List deviceSubscriptions = - subscriptionDAO.getSubscriptionOperationsByAppReleaseIDAndDeviceID(appReleaseId, deviceId, tenantId, offset, limit); + subscriptionDAO.getSubscriptionOperationsByAppReleaseIDAndDeviceID(appReleaseId, deviceId, tenantId); for (DeviceOperationDTO deviceSubscription : deviceSubscriptions) { Integer operationId = deviceSubscription.getOperationId(); if (operationId != null) { From f9cea050aefb7b559ac78a7b899b8cf2a19fcebc Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Wed, 10 Jul 2024 11:22:17 +0530 Subject: [PATCH 235/343] Fix user,role removed devices --- .../core/device/mgt/core/dao/EnrollmentDAO.java | 3 ++- .../dao/impl/AbstractEnrollmentDAOImpl.java | 17 ++++++++++++++--- .../DeviceManagementProviderServiceImpl.java | 7 ++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java index 93c456f929..df812fc62f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java @@ -101,11 +101,12 @@ public interface EnrollmentDAO { * Retrieves owners and the list of device IDs related to an owner. * * @param owner the owner whose device IDs need to be retrieved + * @param allowingDeviceStatuses statuses of devices need to be retrieved * @param tenantId the ID of the tenant * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - OwnerWithDeviceDTO getOwnersWithDevices(String owner, int tenantId) throws DeviceManagementDAOException; + OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId) throws DeviceManagementDAOException; /** * Retrieves a list of device IDs with owners and device status. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index dad35f0795..7e02bd7ac0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -564,23 +564,34 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } @Override - public OwnerWithDeviceDTO getOwnersWithDevices(String owner, int tenantId) + public OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId) throws DeviceManagementDAOException { Connection conn = null; OwnerWithDeviceDTO ownerDetails = new OwnerWithDeviceDTO(); List deviceIds = new ArrayList<>(); int deviceCount = 0; + StringBuilder deviceFilters = new StringBuilder(); + for (int i = 0; i < allowingDeviceStatuses.size(); i++) { + deviceFilters.append("?"); + if (i < allowingDeviceStatuses.size() - 1) { + deviceFilters.append(","); + } + } + String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE AS DEVICE_TYPE, e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + - "WHERE e.OWNER = ? AND e.TENANT_ID = ?"; + "WHERE e.OWNER = ? AND e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ")"; + try { conn = this.getConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, owner); stmt.setInt(2, tenantId); - + for (int i = 0; i < allowingDeviceStatuses.size(); i++) { + stmt.setString(3 + i, allowingDeviceStatuses.get(i)); + } try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { if (ownerDetails.getUserName() == null) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index a3039ba356..d2d73dc92a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -5358,9 +5358,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); OwnerWithDeviceDTO ownerWithDeviceDTO; + List allowingDeviceStatuses = new ArrayList<>(); + allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.INACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); + try { DeviceManagementDAOFactory.openConnection(); - ownerWithDeviceDTO = this.enrollmentDAO.getOwnersWithDevices(owner, tenantId); + ownerWithDeviceDTO = this.enrollmentDAO.getOwnersWithDevices(owner, allowingDeviceStatuses, tenantId); if (ownerWithDeviceDTO == null) { String msg = "No data found for owner: " + owner; log.error(msg); From 68a4de92d654ea38244610d51358b0896c0258c3 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Thu, 11 Jul 2024 00:49:59 +0530 Subject: [PATCH 236/343] Fix all,device,group removed devices --- .../device/mgt/core/dao/EnrollmentDAO.java | 2 +- .../core/device/mgt/core/dao/GroupDAO.java | 2 +- .../dao/impl/AbstractEnrollmentDAOImpl.java | 23 +++++++-- .../core/dao/impl/AbstractGroupDAOImpl.java | 49 ++++++++++++------- .../DeviceManagementProviderServiceImpl.java | 6 ++- .../GroupManagementProviderServiceImpl.java | 12 ++--- 6 files changed, 64 insertions(+), 30 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java index df812fc62f..4a4be1e0c3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java @@ -126,5 +126,5 @@ public interface EnrollmentDAO { * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException; + List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 5071f7a400..3e3fde8205 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -479,7 +479,7 @@ public interface GroupDAO { * @return {@link GroupDetailsDTO} which containing group details and a list of device IDs * @throws GroupManagementDAOException if an error occurs while retrieving the group details and devices */ - GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int tenantId, int offset, int limit) + GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowingDeviceStatuses, int tenantId, int offset, int limit) throws GroupManagementDAOException; } \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index 7e02bd7ac0..b8ad6f86df 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -654,18 +654,34 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } @Override - public List getDevicesByTenantId(int tenantId) + public List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses) throws DeviceManagementDAOException { List devices = new ArrayList<>(); + if (allowingDeviceStatuses.isEmpty()) { + return devices; + } + + StringBuilder deviceFilters = new StringBuilder(); + for (int i = 0; i < allowingDeviceStatuses.size(); i++) { + deviceFilters.append("?"); + if (i < allowingDeviceStatuses.size() - 1) { + deviceFilters.append(","); + } + } + String sql = "SELECT DEVICE_ID, OWNER, STATUS, DEVICE_TYPE, DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT " + - "WHERE TENANT_ID = ?"; + "WHERE TENANT_ID = ? AND STATUS IN (" + deviceFilters.toString() + ")"; Connection conn = null; try { conn = this.getConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, tenantId); + int index = 1; + stmt.setInt(index++, tenantId); + for (String status : allowingDeviceStatuses) { + stmt.setString(index++, status); + } try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { @@ -687,4 +703,5 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { return devices; } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 780ba43cc6..1d9084eb7b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1441,7 +1441,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } @Override - public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int tenantId, int offset, int limit) + public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowedStatuses, int tenantId, int offset, int limit) throws GroupManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get group details and device IDs for group: " + groupName); @@ -1454,6 +1454,14 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { Map deviceTypes = new HashMap<>(); Map deviceIdentifiers = new HashMap<>(); + StringBuilder deviceFilters = new StringBuilder(); + for (int i = 0; i < allowedStatuses.size(); i++) { + deviceFilters.append("?"); + if (i < allowedStatuses.size() - 1) { + deviceFilters.append(","); + } + } + String sql = "SELECT " + " g.ID AS GROUP_ID, " + @@ -1473,16 +1481,21 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { "WHERE " + " g.GROUP_NAME = ? " + " AND g.TENANT_ID = ? " + + " AND e.STATUS IN (" + deviceFilters.toString() + ") " + "LIMIT ? OFFSET ?"; Connection conn = null; try { conn = GroupManagementDAOFactory.getConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, groupName); - stmt.setInt(2, tenantId); - stmt.setInt(3, limit); - stmt.setInt(4, offset); + int index = 1; + stmt.setString(index++, groupName); + stmt.setInt(index++, tenantId); + for (String status : allowedStatuses) { + stmt.setString(index++, status); + } + stmt.setInt(index++, limit); + stmt.setInt(index++, offset); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { @@ -1500,19 +1513,19 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION")); } } - groupDetails.setDeviceIds(deviceIds); - groupDetails.setDeviceCount(deviceIds.size()); - groupDetails.setDeviceOwners(deviceOwners); - groupDetails.setDeviceStatuses(deviceStatuses); - groupDetails.setDeviceNames(deviceNames); - groupDetails.setDeviceTypes(deviceTypes); - groupDetails.setDeviceIdentifiers(deviceIdentifiers); - return groupDetails; + groupDetails.setDeviceIds(deviceIds); + groupDetails.setDeviceCount(deviceIds.size()); + groupDetails.setDeviceOwners(deviceOwners); + groupDetails.setDeviceStatuses(deviceStatuses); + groupDetails.setDeviceNames(deviceNames); + groupDetails.setDeviceTypes(deviceTypes); + groupDetails.setDeviceIdentifiers(deviceIdentifiers); + return groupDetails; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; + log.error(msg, e); + throw new GroupManagementDAOException(msg, e); } - } catch (SQLException e) { - String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; - log.error(msg, e); - throw new GroupManagementDAOException(msg, e); - } } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index d2d73dc92a..5d33953a56 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -5418,9 +5418,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override public List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException { List devices; + List allowingDeviceStatuses = new ArrayList<>(); + allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.INACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); try { DeviceManagementDAOFactory.openConnection(); - devices = enrollmentDAO.getDevicesByTenantId(tenantId); + devices = enrollmentDAO.getDevicesByTenantId(tenantId, allowingDeviceStatuses); if (devices == null || devices.isEmpty()) { String msg = "No devices found for tenant ID: " + tenantId; log.error(msg); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index c42feed9b8..bd10cac78a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.service; +import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; @@ -39,13 +40,8 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; -import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; -import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceNotFoundException; -import io.entgra.device.mgt.core.device.mgt.common.GroupPaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.core.event.config.GroupAssignmentEventOperationExecutor; import io.entgra.device.mgt.core.device.mgt.core.geo.task.GeoFenceEventOperationManager; @@ -1695,10 +1691,14 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); GroupDetailsDTO groupDetailsWithDevices; + List allowingDeviceStatuses = new ArrayList<>(); + allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.INACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); try { GroupManagementDAOFactory.openConnection(); - groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, tenantId, offset, limit); + groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, allowingDeviceStatuses, tenantId, offset, limit); } catch (GroupManagementDAOException | SQLException e) { String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; log.error(msg, e); From d566cf966a1c68ae353a5fabff7e995b04210ca3 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Sat, 6 Jul 2024 15:49:41 +0530 Subject: [PATCH 237/343] Add Microsoft Store integration for Windows devices --- .../mgt/core/impl/ApplicationManagerImpl.java | 2 + .../application/mgt/core/util/Constants.java | 1 + .../device/mgt/common/MDMAppConstants.java | 2 + .../app/mgt/windows/AppStoreApplication.java | 49 +++++ .../core/util/MDMWindowsOperationUtil.java | 184 ++++++++---------- .../src/main/resources/conf/mdm-ui-config.xml | 1 + 6 files changed, 139 insertions(+), 100 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/app/mgt/windows/AppStoreApplication.java diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index efb55e60cb..721ab4decb 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -769,6 +769,8 @@ public class ApplicationManagerImpl implements ApplicationManager { return Constants.GOOGLE_PLAY_STORE_URL; } else if (DeviceTypes.IOS.toString().equalsIgnoreCase(deviceType)) { return Constants.APPLE_STORE_URL; + } else if (DeviceTypes.WINDOWS.toString().equalsIgnoreCase(deviceType)) { + return Constants.MICROSOFT_STORE_URL; } else { throw new IllegalArgumentException("No such device with the name " + deviceType); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java index b5b5fd5154..0b22db0668 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java @@ -74,6 +74,7 @@ public class Constants { public static final String IS_USER_ABLE_TO_VIEW_ALL_ROLES = "isUserAbleToViewAllRoles"; public static final String GOOGLE_PLAY_STORE_URL = "https://play.google.com/store/apps/details?id="; public static final String APPLE_STORE_URL = "https://itunes.apple.com/country/app/app-name/id"; + public static final String MICROSOFT_STORE_URL = "https://apps.microsoft.com/detail/"; public static final String GOOGLE_PLAY_SYNCED_APP = "GooglePlaySyncedApp"; // Subscription task related constants diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/MDMAppConstants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/MDMAppConstants.java index 60d9503c97..da1714ede0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/MDMAppConstants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/MDMAppConstants.java @@ -58,6 +58,8 @@ public class MDMAppConstants { } public static final String INSTALL_ENTERPRISE_APPLICATION = "INSTALL_ENTERPRISE_APPLICATION"; public static final String UNINSTALL_ENTERPRISE_APPLICATION = "UNINSTALL_ENTERPRISE_APPLICATION"; + public static final String INSTALL_STORE_APPLICATION = "INSTALL_STORE_APPLICATION"; + public static final String UNINSTALL_STORE_APPLICATION = "UNINSTALL_STORE_APPLICATION"; public static final String INSTALL_WEB_CLIP_APPLICATION = "INSTALL_WEB_CLIP"; public static final String UNINSTALL_WEB_CLIP_APPLICATION = "UNINSTALL_WEB_CLIP"; //App type constants related to window device type diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/app/mgt/windows/AppStoreApplication.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/app/mgt/windows/AppStoreApplication.java new file mode 100644 index 0000000000..85a6cbd9a1 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/app/mgt/windows/AppStoreApplication.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.common.app.mgt.windows; + +import com.google.gson.Gson; +import java.io.Serializable; + +public class AppStoreApplication implements Serializable { + + private String type; + private String packageIdentifier; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getPackageIdentifier() { + return packageIdentifier; + } + + public void setPackageIdentifier(String packageIdentifier) { + this.packageIdentifier = packageIdentifier; + } + + public String toJSON() { + Gson gson = new Gson(); + return gson.toJson(this); + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java index a1f0e0e31d..14050b6ea4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/MDMWindowsOperationUtil.java @@ -27,6 +27,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows.AppStoreApplication; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows.EnterpriseApplication; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows.HostedAppxApplication; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows.HostedMSIApplication; @@ -62,64 +63,26 @@ public class MDMWindowsOperationUtil { switch (application.getType()) { case ENTERPRISE: - operation.setCode(MDMAppConstants.WindowsConstants.INSTALL_ENTERPRISE_APPLICATION); EnterpriseApplication enterpriseApplication = new EnterpriseApplication(); - if (appType.equalsIgnoreCase(MDMAppConstants.WindowsConstants.APPX)) { - HostedAppxApplication hostedAppxApplication = new HostedAppxApplication(); - List dependencyPackageList = new ArrayList<>(); - for (int i = 0; i < metaJsonArray.size(); i++) { - JsonElement metaElement = metaJsonArray.get(i); - JsonObject metaObject = metaElement.getAsJsonObject(); - - if (MDMAppConstants.WindowsConstants.APPX_PACKAGE_URI.equals(metaObject.get("key").getAsString())) { - hostedAppxApplication.setPackageUri(metaObject.get("value").getAsString().trim()); - } - else if (MDMAppConstants.WindowsConstants.APPX_PACKAGE_FAMILY_NAME.equals(metaObject.get("key").getAsString())) { - hostedAppxApplication.setPackageFamilyName(metaObject.get("value").getAsString().trim()); - } - else if (MDMAppConstants.WindowsConstants.APPX_DEPENDENCY_PACKAGE_URL.equals(metaObject.get("key").getAsString()) - && metaObject.has("value")) { - dependencyPackageList.add(metaObject.get("value").getAsString().trim()); - hostedAppxApplication.setDependencyPackageUri(dependencyPackageList); - } - else if (MDMAppConstants.WindowsConstants.APPX_CERTIFICATE_HASH.equals(metaObject.get("key").getAsString()) - && metaObject.has("value")) { - hostedAppxApplication.setCertificateHash(metaObject.get("value").getAsString().trim()); - } - else if (MDMAppConstants.WindowsConstants.APPX_ENCODED_CERT_CONTENT.equals(metaObject.get("key").getAsString()) - && metaObject.has("value")) { - hostedAppxApplication.setEncodedCertificate(metaObject.get("value").getAsString().trim()); - } - } - enterpriseApplication.setHostedAppxApplication(hostedAppxApplication); - - } else if (appType.equalsIgnoreCase(MDMAppConstants.WindowsConstants.MSI)) { - HostedMSIApplication hostedMSIApplication = new HostedMSIApplication(); - for (int i = 0; i < metaJsonArray.size(); i++) { - JsonElement metaElement = metaJsonArray.get(i); - JsonObject metaObject = metaElement.getAsJsonObject(); - if (MDMAppConstants.WindowsConstants.MSI_PRODUCT_ID.equals(metaObject.get("key").getAsString())) { - hostedMSIApplication.setProductId(metaObject.get("value").getAsString().trim()); - } - else if (MDMAppConstants.WindowsConstants.MSI_CONTENT_URI.equals(metaObject.get("key").getAsString())) { - hostedMSIApplication.setContentUrl(metaObject.get("value").getAsString().trim()); - } - else if (MDMAppConstants.WindowsConstants.MSI_FILE_HASH.equals(metaObject.get("key").getAsString())) { - hostedMSIApplication.setFileHash(metaObject.get("value").getAsString().trim()); - } - } - enterpriseApplication.setHostedMSIApplication(hostedMSIApplication); - } + createEnterpriseAppPayload(appType, metaJsonArray, enterpriseApplication); + operation.setCode(MDMAppConstants.WindowsConstants.INSTALL_ENTERPRISE_APPLICATION); operation.setPayLoad(enterpriseApplication.toJSON()); break; + case PUBLIC: + AppStoreApplication appStoreApplication = new AppStoreApplication(); + appStoreApplication.setType(application.getType().toString()); + appStoreApplication.setPackageIdentifier(application.getIdentifier()); + operation.setCode(MDMAppConstants.WindowsConstants.INSTALL_STORE_APPLICATION); + operation.setPayLoad(appStoreApplication.toJSON()); + break; case WEB_CLIP: - operation.setCode(MDMAppConstants.WindowsConstants.INSTALL_WEB_CLIP_APPLICATION); WebClipApplication webClipApplication = new WebClipApplication(); webClipApplication.setUrl(application.getLocation()); webClipApplication.setName(application.getName()); webClipApplication.setIcon(application.getIconImage()); webClipApplication.setProperties(application.getProperties()); webClipApplication.setType(application.getType().toString()); + operation.setCode(MDMAppConstants.WindowsConstants.INSTALL_WEB_CLIP_APPLICATION); operation.setPayLoad(webClipApplication.toJSON()); break; default: @@ -148,64 +111,26 @@ public class MDMWindowsOperationUtil { switch (application.getType()) { case ENTERPRISE: - operation.setCode(MDMAppConstants.WindowsConstants.UNINSTALL_ENTERPRISE_APPLICATION); EnterpriseApplication enterpriseApplication = new EnterpriseApplication(); - if (appType.equalsIgnoreCase(MDMAppConstants.WindowsConstants.APPX)) { - HostedAppxApplication hostedAppxApplication = new HostedAppxApplication(); - List dependencyPackageList = new ArrayList<>(); - for (int i = 0; i < metaJsonArray.size(); i++) { - JsonElement metaElement = metaJsonArray.get(i); - JsonObject metaObject = metaElement.getAsJsonObject(); - - if (MDMAppConstants.WindowsConstants.APPX_PACKAGE_URI.equals(metaObject.get("key").getAsString())) { - hostedAppxApplication.setPackageUri(metaObject.get("value").getAsString().trim()); - } - else if (MDMAppConstants.WindowsConstants.APPX_PACKAGE_FAMILY_NAME.equals(metaObject.get("key").getAsString())) { - hostedAppxApplication.setPackageFamilyName(metaObject.get("value").getAsString().trim()); - } - else if (MDMAppConstants.WindowsConstants.APPX_DEPENDENCY_PACKAGE_URL.equals(metaObject.get("key").getAsString()) - && metaObject.has("value")) { - dependencyPackageList.add(metaObject.get("value").getAsString().trim()); - hostedAppxApplication.setDependencyPackageUri(dependencyPackageList); - } - else if (MDMAppConstants.WindowsConstants.APPX_CERTIFICATE_HASH.equals(metaObject.get("key").getAsString()) - && metaObject.has("value")) { - hostedAppxApplication.setCertificateHash(metaObject.get("value").getAsString().trim()); - } - else if (MDMAppConstants.WindowsConstants.APPX_ENCODED_CERT_CONTENT.equals(metaObject.get("key").getAsString()) - && metaObject.has("value")) { - hostedAppxApplication.setEncodedCertificate(metaObject.get("value").getAsString().trim()); - } - } - enterpriseApplication.setHostedAppxApplication(hostedAppxApplication); - - } else if (appType.equalsIgnoreCase(MDMAppConstants.WindowsConstants.MSI)) { - HostedMSIApplication hostedMSIApplication = new HostedMSIApplication(); - for (int i = 0; i < metaJsonArray.size(); i++) { - JsonElement metaElement = metaJsonArray.get(i); - JsonObject metaObject = metaElement.getAsJsonObject(); - if (MDMAppConstants.WindowsConstants.MSI_PRODUCT_ID.equals(metaObject.get("key").getAsString())) { - hostedMSIApplication.setProductId(metaObject.get("value").getAsString().trim()); - } - else if (MDMAppConstants.WindowsConstants.MSI_CONTENT_URI.equals(metaObject.get("key").getAsString())) { - hostedMSIApplication.setContentUrl(metaObject.get("value").getAsString().trim()); - } - else if (MDMAppConstants.WindowsConstants.MSI_FILE_HASH.equals(metaObject.get("key").getAsString())) { - hostedMSIApplication.setFileHash(metaObject.get("value").getAsString().trim()); - } - } - enterpriseApplication.setHostedMSIApplication(hostedMSIApplication); - } + createEnterpriseAppPayload(appType, metaJsonArray, enterpriseApplication); + operation.setCode(MDMAppConstants.WindowsConstants.UNINSTALL_ENTERPRISE_APPLICATION); operation.setPayLoad(enterpriseApplication.toJSON()); break; + case PUBLIC: + AppStoreApplication appStoreApplication = new AppStoreApplication(); + appStoreApplication.setType(application.getType().toString()); + appStoreApplication.setPackageIdentifier(application.getIdentifier()); + operation.setCode(MDMAppConstants.WindowsConstants.UNINSTALL_STORE_APPLICATION); + operation.setPayLoad(appStoreApplication.toJSON()); + break; case WEB_CLIP: - operation.setCode(MDMAppConstants.WindowsConstants.UNINSTALL_WEB_CLIP_APPLICATION); WebClipApplication webClipApplication = new WebClipApplication(); webClipApplication.setUrl(application.getLocation()); webClipApplication.setName(application.getName()); webClipApplication.setIcon(application.getIconImage()); webClipApplication.setProperties(application.getProperties()); webClipApplication.setType(application.getType().toString()); + operation.setCode(MDMAppConstants.WindowsConstants.UNINSTALL_WEB_CLIP_APPLICATION); operation.setPayLoad(webClipApplication.toJSON()); default: String msg = "Application type " + application.getType() + " is not supported"; @@ -216,6 +141,67 @@ public class MDMWindowsOperationUtil { return operation; } + /** + * Helper method to create enterprise APPX and MSI app payloads for both install and uninstall operations + * @param appType contains whether the app type is APPX or MSI + * @param metaJsonArray JSON array containing metadata of APPX and MSI apps + * @param enterpriseApplication {@link EnterpriseApplication} contains operation payload content that will be sent to the device + */ + private static void createEnterpriseAppPayload(String appType, JsonArray metaJsonArray, EnterpriseApplication enterpriseApplication) { + + JsonElement metaElement; + JsonObject metaObject; + if (MDMAppConstants.WindowsConstants.APPX.equalsIgnoreCase(appType)) { + HostedAppxApplication hostedAppxApplication = new HostedAppxApplication(); + List dependencyPackageList = new ArrayList<>(); + + for (int i = 0; i < metaJsonArray.size(); i++) { + metaElement = metaJsonArray.get(i); + metaObject = metaElement.getAsJsonObject(); + + if (MDMAppConstants.WindowsConstants.APPX_PACKAGE_URI.equals(metaObject.get("key").getAsString())) { + hostedAppxApplication.setPackageUri(metaObject.get("value").getAsString().trim()); + } + else if (MDMAppConstants.WindowsConstants.APPX_PACKAGE_FAMILY_NAME.equals(metaObject.get("key").getAsString())) { + hostedAppxApplication.setPackageFamilyName(metaObject.get("value").getAsString().trim()); + } + else if (MDMAppConstants.WindowsConstants.APPX_DEPENDENCY_PACKAGE_URL.equals(metaObject.get("key").getAsString()) + && metaObject.has("value")) { + dependencyPackageList.add(metaObject.get("value").getAsString().trim()); + hostedAppxApplication.setDependencyPackageUri(dependencyPackageList); + } + else if (MDMAppConstants.WindowsConstants.APPX_CERTIFICATE_HASH.equals(metaObject.get("key").getAsString()) + && metaObject.has("value")) { + hostedAppxApplication.setCertificateHash(metaObject.get("value").getAsString().trim()); + } + else if (MDMAppConstants.WindowsConstants.APPX_ENCODED_CERT_CONTENT.equals(metaObject.get("key").getAsString()) + && metaObject.has("value")) { + hostedAppxApplication.setEncodedCertificate(metaObject.get("value").getAsString().trim()); + } + } + enterpriseApplication.setHostedAppxApplication(hostedAppxApplication); + + } else if (MDMAppConstants.WindowsConstants.MSI.equalsIgnoreCase(appType)) { + HostedMSIApplication hostedMSIApplication = new HostedMSIApplication(); + + for (int i = 0; i < metaJsonArray.size(); i++) { + metaElement = metaJsonArray.get(i); + metaObject = metaElement.getAsJsonObject(); + + if (MDMAppConstants.WindowsConstants.MSI_PRODUCT_ID.equals(metaObject.get("key").getAsString())) { + hostedMSIApplication.setProductId(metaObject.get("value").getAsString().trim()); + } + else if (MDMAppConstants.WindowsConstants.MSI_CONTENT_URI.equals(metaObject.get("key").getAsString())) { + hostedMSIApplication.setContentUrl(metaObject.get("value").getAsString().trim()); + } + else if (MDMAppConstants.WindowsConstants.MSI_FILE_HASH.equals(metaObject.get("key").getAsString())) { + hostedMSIApplication.setFileHash(metaObject.get("value").getAsString().trim()); + } + } + enterpriseApplication.setHostedMSIApplication(hostedMSIApplication); + } + } + /** * Method to get the installer file extension type for windows type apps(either appx or msi) * @@ -223,8 +209,7 @@ public class MDMWindowsOperationUtil { * @return string extension of the windows app types(either appx or msi) */ public static String windowsAppType(String installerName) { - String extension = installerName.substring(installerName.lastIndexOf(".") + 1); - return extension; + return installerName.substring(installerName.lastIndexOf(".") + 1); } /** @@ -234,8 +219,7 @@ public class MDMWindowsOperationUtil { * @return the metaData Json String as Json Array */ public static JsonArray jsonStringToArray(String metaData) { - JsonArray metaJsonArray = new JsonParser().parse(metaData).getAsJsonArray(); - return metaJsonArray; + return new JsonParser().parse(metaData).getAsJsonArray(); } diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 32dc388789..65ffa660c8 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -387,6 +387,7 @@ win:ops:device-info win:ops:security-info win:ops:firewall-info + win:microsoft-store:search admin:tenant:view dm:admin:devices:usage:view and:ops:clear-app From 953f72afdccc06439f5e3e8ffe7abc794984afdf Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Thu, 11 Jul 2024 07:56:34 +0530 Subject: [PATCH 238/343] Filter devices according to their devicetype --- .../core/impl/SubscriptionManagerImpl.java | 23 ++++++++++++------- .../device/mgt/core/dao/EnrollmentDAO.java | 6 +++-- .../core/device/mgt/core/dao/GroupDAO.java | 4 +++- .../dao/impl/AbstractEnrollmentDAOImpl.java | 19 +++++++-------- .../core/dao/impl/AbstractGroupDAOImpl.java | 4 +++- .../DeviceManagementProviderService.java | 6 +++-- .../DeviceManagementProviderServiceImpl.java | 8 +++---- .../GroupManagementProviderService.java | 3 ++- .../GroupManagementProviderServiceImpl.java | 4 ++-- 9 files changed, 47 insertions(+), 30 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 498abe0b02..6bb902d6b3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1720,8 +1720,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new NotFoundException(msg); } + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - + int deviceTypeId = applicationDTO.getDeviceTypeId(); List groupDetailsWithDevices = new ArrayList<>(); List groupDetails = @@ -1737,7 +1738,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { // Retrieve group details and device IDs for the group using the service layer GroupDetailsDTO groupDetailWithDevices = - groupManagementProviderService.getGroupDetailsWithDevices(groupName, offset, limit); + groupManagementProviderService.getGroupDetailsWithDevices(groupName, deviceTypeId, offset, limit); SubscriptionsDTO groupDetailDTO = new SubscriptionsDTO(); groupDetailDTO.setId(groupDetailWithDevices.getGroupId()); @@ -1910,8 +1911,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new NotFoundException(msg); } + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - + int deviceTypeId = applicationDTO.getDeviceTypeId(); List userSubscriptionsWithDevices = new ArrayList<>(); List userSubscriptions = @@ -1927,7 +1929,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { // Retrieve owner details and device IDs for the user using the service layer OwnerWithDeviceDTO ownerDetailsWithDevices = - deviceManagementProviderService.getOwnersWithDeviceIds(userName); + deviceManagementProviderService.getOwnersWithDeviceIds(userName, deviceTypeId); SubscriptionsDTO userSubscriptionDTO = new SubscriptionsDTO(); userSubscriptionDTO.setName(userSubscription.getName()); @@ -2097,8 +2099,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new NotFoundException(msg); } + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - + int deviceTypeId = applicationDTO.getDeviceTypeId(); List roleSubscriptionsWithDevices = new ArrayList<>(); List roleSubscriptions = @@ -2139,7 +2142,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { for (String user : users) { OwnerWithDeviceDTO ownerDetailsWithDevices; try { - ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(user); + ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(user, deviceTypeId); } catch (DeviceManagementDAOException e) { throw new ApplicationManagementException("Error retrieving owner details with devices for user: " + user, e); } @@ -2307,7 +2310,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new NotFoundException(msg); } + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); + int deviceTypeId = applicationDTO.getDeviceTypeId(); DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); List deviceSubscriptions = @@ -2321,7 +2326,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } List allDevices = - deviceManagementProviderService.getDevicesByTenantId(tenantId); + deviceManagementProviderService.getDevicesByTenantId(tenantId, deviceTypeId); List deviceIds = allDevices.stream() .map(DeviceDetailsDTO::getDeviceId) @@ -2493,7 +2498,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new NotFoundException(msg); } + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); + int deviceTypeId = applicationDTO.getDeviceTypeId(); List allSubscriptions = subscriptionDAO.getAllSubscriptionsDetails(appReleaseId, unsubscribe, tenantId, offset, limit); @@ -2522,7 +2529,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { statusCounts.put("NEW", 0); List allDevices = - deviceManagementProviderService.getDevicesByTenantId(tenantId); + deviceManagementProviderService.getDevicesByTenantId(tenantId, deviceTypeId); for (DeviceDetailsDTO device : allDevices) { Integer deviceId = device.getDeviceId(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java index 4a4be1e0c3..158b86e0a3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java @@ -106,7 +106,7 @@ public interface EnrollmentDAO { * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId) throws DeviceManagementDAOException; + OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId, int deviceTypeId) throws DeviceManagementDAOException; /** * Retrieves a list of device IDs with owners and device status. @@ -123,8 +123,10 @@ public interface EnrollmentDAO { * Retrieves owners and the list of device IDs with device status. * * @param tenantId the ID of the tenant + * @param allowingDeviceStatuses the allowed device statuses of devices + * @param deviceTypeId the device type id * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses) throws DeviceManagementDAOException; + List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses, int deviceTypeId) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 3e3fde8205..2bb6c48fb4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -473,13 +473,15 @@ public interface GroupDAO { * Get group details and list of device IDs related to the group. * * @param groupName Group name + * @param allowingDeviceStatuses the statuses of devices + * @param deviceTypeId the device type id * @param tenantId Tenant ID * @param offset the offset for the data set * @param limit the limit for the data set * @return {@link GroupDetailsDTO} which containing group details and a list of device IDs * @throws GroupManagementDAOException if an error occurs while retrieving the group details and devices */ - GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowingDeviceStatuses, int tenantId, int offset, int limit) + GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowingDeviceStatuses, int deviceTypeId, int tenantId, int offset, int limit) throws GroupManagementDAOException; } \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index b8ad6f86df..6f9d3e727f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -564,7 +564,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } @Override - public OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId) + public OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId, int deviceTypeId) throws DeviceManagementDAOException { Connection conn = null; OwnerWithDeviceDTO ownerDetails = new OwnerWithDeviceDTO(); @@ -582,15 +582,16 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE AS DEVICE_TYPE, e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + - "WHERE e.OWNER = ? AND e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ")"; + "WHERE e.OWNER = ? AND e.TENANT_ID = ? AND d.DEVICE_TYPE_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ")"; try { conn = this.getConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, owner); stmt.setInt(2, tenantId); + stmt.setInt(3, deviceTypeId); for (int i = 0; i < allowingDeviceStatuses.size(); i++) { - stmt.setString(3 + i, allowingDeviceStatuses.get(i)); + stmt.setString(4 + i, allowingDeviceStatuses.get(i)); } try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { @@ -654,7 +655,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } @Override - public List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses) + public List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses, int deviceTypeId) throws DeviceManagementDAOException { List devices = new ArrayList<>(); if (allowingDeviceStatuses.isEmpty()) { @@ -669,9 +670,10 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } } - String sql = "SELECT DEVICE_ID, OWNER, STATUS, DEVICE_TYPE, DEVICE_IDENTIFICATION " + - "FROM DM_ENROLMENT " + - "WHERE TENANT_ID = ? AND STATUS IN (" + deviceFilters.toString() + ")"; + String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION " + + "FROM DM_ENROLMENT e " + + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + + "WHERE e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ") AND d.DEVICE_TYPE_ID = ?"; Connection conn = null; try { @@ -682,6 +684,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { for (String status : allowingDeviceStatuses) { stmt.setString(index++, status); } + stmt.setInt(index++, deviceTypeId); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { @@ -702,6 +705,4 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } return devices; } - - } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 1d9084eb7b..22e9fb18aa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1441,7 +1441,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } @Override - public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowedStatuses, int tenantId, int offset, int limit) + public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowedStatuses, int deviceTypeId, int tenantId, int offset, int limit) throws GroupManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get group details and device IDs for group: " + groupName); @@ -1481,6 +1481,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { "WHERE " + " g.GROUP_NAME = ? " + " AND g.TENANT_ID = ? " + + " AND d.DEVICE_TYPE_ID = ? " + " AND e.STATUS IN (" + deviceFilters.toString() + ") " + "LIMIT ? OFFSET ?"; @@ -1491,6 +1492,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { int index = 1; stmt.setString(index++, groupName); stmt.setInt(index++, tenantId); + stmt.setInt(index++, deviceTypeId); for (String status : allowedStatuses) { stmt.setString(index++, status); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index 9ab44929a1..8a892474ff 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -1082,10 +1082,11 @@ public interface DeviceManagementProviderService { * Get owner details and device IDs for a given owner and tenant. * * @param owner the name of the owner. + * @param deviceTypeId the device type id * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user. * @throws DeviceManagementException if an error occurs while fetching owner details. */ - OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner) throws DeviceManagementDAOException; + OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner, int deviceTypeId) throws DeviceManagementDAOException; /** * Get owner details and device IDs for a given owner and tenant. @@ -1099,10 +1100,11 @@ public interface DeviceManagementProviderService { /** * Get owner details and device IDs for a given owner and tenant. * @param tenantId the tenant id which devices need to be retried + * @param deviceTypeId the device type id * @return {@link DeviceDetailsDTO} which contains devices details. * @throws DeviceManagementException if an error occurs while fetching owner details. */ - List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException; + List getDevicesByTenantId(int tenantId, int deviceTypeId) throws DeviceManagementDAOException; /** * Get operation details by operation code. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 5d33953a56..0f035a5bf9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -5354,7 +5354,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner) throws DeviceManagementDAOException { + public OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner, int deviceTypeId) throws DeviceManagementDAOException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); OwnerWithDeviceDTO ownerWithDeviceDTO; @@ -5365,7 +5365,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv try { DeviceManagementDAOFactory.openConnection(); - ownerWithDeviceDTO = this.enrollmentDAO.getOwnersWithDevices(owner, allowingDeviceStatuses, tenantId); + ownerWithDeviceDTO = this.enrollmentDAO.getOwnersWithDevices(owner, allowingDeviceStatuses, tenantId, deviceTypeId); if (ownerWithDeviceDTO == null) { String msg = "No data found for owner: " + owner; log.error(msg); @@ -5416,7 +5416,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException { + public List getDevicesByTenantId(int tenantId, int deviceTypeId) throws DeviceManagementDAOException { List devices; List allowingDeviceStatuses = new ArrayList<>(); allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); @@ -5424,7 +5424,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); try { DeviceManagementDAOFactory.openConnection(); - devices = enrollmentDAO.getDevicesByTenantId(tenantId, allowingDeviceStatuses); + devices = enrollmentDAO.getDevicesByTenantId(tenantId, allowingDeviceStatuses, deviceTypeId); if (devices == null || devices.isEmpty()) { String msg = "No devices found for tenant ID: " + tenantId; log.error(msg); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index fac06bfccf..b1200772a4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -377,11 +377,12 @@ public interface GroupManagementProviderService { * Get group details and device IDs for a given group name. * * @param groupName the name of the group. + * @param deviceTypeId the device type id * @param offset the offset for the data set * @param limit the limit for the data set * @return {@link GroupDetailsDTO} which containing group details and a list of device IDs * @throws GroupManagementException if an error occurs while fetching group details. */ - GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int offset, int limit) throws GroupManagementException; + GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int deviceTypeId, int offset, int limit) throws GroupManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index bd10cac78a..0d0e23cc48 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -1684,7 +1684,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } @Override - public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int offset, int limit) + public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int deviceTypeId, int offset, int limit) throws GroupManagementException { if (log.isDebugEnabled()) { log.debug("Retrieving group details and device IDs for group: " + groupName); @@ -1698,7 +1698,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid try { GroupManagementDAOFactory.openConnection(); - groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, allowingDeviceStatuses, tenantId, offset, limit); + groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, allowingDeviceStatuses, deviceTypeId, tenantId, offset, limit); } catch (GroupManagementDAOException | SQLException e) { String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; log.error(msg, e); From e1a47c68fbbf3822cf47669b6aef2197d2d16aad Mon Sep 17 00:00:00 2001 From: ashvini Date: Tue, 2 Jul 2024 14:20:57 +0530 Subject: [PATCH 239/343] Get TenantMgtAdminService as an osgi service Resolve comments Remove source reference Change error messages Make changes in code Add license Resolve comments Add java doc comments Resolve comments Resolve comment --- .../common/services/ApplicationManager.java | 14 +++++ .../pom.xml | 5 ++ .../mgt/core/impl/ApplicationManagerImpl.java | 57 +++++++------------ ...ApplicationManagementServiceComponent.java | 24 ++++++++ .../mgt/core/internal/DataHolder.java | 11 ++++ .../admin/UserManagementAdminServiceImpl.java | 14 ++--- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 19 +++++++ .../common/spi/TenantManagerAdminService.java | 27 +++++++++ .../pom.xml | 1 + .../core/tenant/mgt/core/TenantManager.java | 1 + .../impl/TenantManagerAdminServiceImpl.java | 57 +++++++++++++++++++ .../internal/TenantMgtServiceComponent.java | 9 ++- .../listener/DeviceMgtTenantListener.java | 8 --- 13 files changed, 195 insertions(+), 52 deletions(-) create mode 100644 components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/src/main/java/io/entgra/device/mgt/core/tenant/mgt/common/spi/TenantManagerAdminService.java create mode 100644 components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerAdminServiceImpl.java diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java index bf3bdc5d40..7e13353980 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java @@ -546,6 +546,20 @@ public interface ApplicationManager { * @throws ApplicationManagementException thrown if an error occurs when deleting data */ void deleteApplicationDataOfTenant(int tenantId) throws ApplicationManagementException; + + /** + * Delete all application related data of a tenant by tenant Domain + * + * @param tenantDomain Domain of the Tenant + * @throws ApplicationManagementException thrown if an error occurs when deleting data + */ void deleteApplicationDataByTenantDomain(String tenantDomain) throws ApplicationManagementException; + + /** + * Delete all Application artifacts related to a tenant by Tenant Domain + * + * @param tenantDomain Domain of the Tenant + * @throws ApplicationManagementException thrown if an error occurs when deleting app folders + */ void deleteApplicationArtifactsByTenantDomain(String tenantDomain) throws ApplicationManagementException; } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 057345defc..b273d85a82 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -81,6 +81,7 @@ com.dd.*, io.entgra.device.mgt.core.identity.jwt.client.extension.*, io.entgra.device.mgt.core.apimgt.application.extension.*, + io.entgra.device.mgt.core.tenant.mgt.common.*, org.apache.commons.httpclient, org.apache.commons.httpclient.methods, org.apache.commons.validator.routines @@ -389,6 +390,10 @@ org.wso2.carbon.tenant.mgt compile + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.tenant.mgt.common + diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index f6d0fc228f..5131eeeed8 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -30,6 +30,7 @@ import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringEscapeUtils; @@ -96,8 +97,6 @@ import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementEx import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.stratos.common.beans.TenantInfoBean; -import org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; @@ -4456,19 +4455,9 @@ public class ApplicationManagerImpl implements ApplicationManager { @Override public void deleteApplicationDataByTenantDomain(String tenantDomain) throws ApplicationManagementException { int tenantId; - try{ - TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService(); - TenantInfoBean tenantInfoBean = tenantMgtAdminService.getTenant(tenantDomain); - tenantId = tenantInfoBean.getTenantId(); - - } catch (Exception e) { - String msg = "Error getting tenant ID from domain: " - + tenantDomain; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } - try { + tenantId = DataHolder.getInstance().getTenantManagerAdminService().getTenantId(tenantDomain); + ConnectionManagerUtil.beginDBTransaction(); vppApplicationDAO.deleteAssociationByTenant(tenantId); @@ -4495,51 +4484,49 @@ public class ApplicationManagerImpl implements ApplicationManager { ConnectionManagerUtil.commitDBTransaction(); } catch (DBConnectionException e) { - String msg = "Error occurred while observing the database connection to delete applications for tenant with ID: " - + tenantId; + String msg = "Error occurred while observing the database connection to delete applications for tenant with " + + "domain: " + tenantDomain; log.error(msg, e); throw new ApplicationManagementException(msg, e); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - String msg = "Database access error is occurred when getting applications for tenant with ID: " + tenantId; + String msg = "Database access error is occurred when getting applications for tenant with domain: " + + tenantDomain; log.error(msg, e); throw new ApplicationManagementException(msg, e); } catch (LifeCycleManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); String msg = "Error occurred while deleting life-cycle state data of application releases of the tenant" - + " of ID: " + tenantId ; + + " of domain: " + tenantDomain ; log.error(msg, e); throw new ApplicationManagementException(msg, e); } catch (ReviewManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); String msg = "Error occurred while deleting reviews of application releases of the applications" - + " of tenant ID: " + tenantId ; + + " of tenant of domain: " + tenantDomain ; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (Exception e) { + String msg = "Error getting tenant ID from domain: " + + tenantDomain; log.error(msg, e); throw new ApplicationManagementException(msg, e); - } finally { - ConnectionManagerUtil.closeDBConnection(); } } @Override public void deleteApplicationArtifactsByTenantDomain(String tenantDomain) throws ApplicationManagementException { int tenantId; - try{ - TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService(); - TenantInfoBean tenantInfoBean = tenantMgtAdminService.getTenant(tenantDomain); - tenantId = tenantInfoBean.getTenantId(); - - } catch (Exception e) { - String msg = "Error getting tenant ID from domain: " - + tenantDomain + "when trying to delete application artifacts of tenant"; + try { + tenantId = DataHolder.getInstance().getTenantManagerAdminService().getTenantId(tenantDomain); + DataHolder.getInstance().getApplicationStorageManager().deleteAppFolderOfTenant(tenantId); + } catch (ApplicationStorageManagementException e) { + String msg = "Error deleting app artifacts of tenant of domain: " + tenantDomain ; log.error(msg, e); throw new ApplicationManagementException(msg, e); - } - try { - APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId); - } catch (ApplicationStorageManagementException e) { - String msg = "Error occurred while deleting Application folders of tenant" - + " of tenant ID: " + tenantId ; + } catch (TenantMgtException e) { + String msg = "Error getting tenant ID from domain: " + + tenantDomain + " when trying to delete application artifacts of tenant"; log.error(msg, e); throw new ApplicationManagementException(msg, e); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java index 20cd9febbc..d1b8ff8288 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java @@ -33,7 +33,9 @@ import io.entgra.device.mgt.core.application.mgt.core.impl.FileTransferServiceIm import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; import io.entgra.device.mgt.core.application.mgt.core.task.ScheduledAppSubscriptionTaskManager; import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil; +import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -71,6 +73,12 @@ import java.util.List; * policy="dynamic" * bind="setTaskService" * unbind="unsetTaskService" + * @scr.reference name="io.entgra.device.mgt.core.tenant.manager" + * interface="io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService" + * cardinality="0..1" + * policy="dynamic" + * bind="setTenantManagementAdminService" + * unbind="unsetTenantManagementAdminService" */ @SuppressWarnings("unused") public class ApplicationManagementServiceComponent { @@ -196,4 +204,20 @@ public class ApplicationManagementServiceComponent { } DataHolder.getInstance().setTaskService(null); } + + @SuppressWarnings("unused") + protected void setTenantManagementAdminService(TenantManagerAdminService tenantManagerAdminService) { + if (log.isDebugEnabled()) { + log.debug("Setting Tenant management admin Service"); + } + DataHolder.getInstance().setTenantManagerAdminService(tenantManagerAdminService); + } + + @SuppressWarnings("unused") + protected void unsetTenantManagementAdminService(TenantManagerAdminService tenantManagerAdminService) { + if (log.isDebugEnabled()) { + log.debug("Un setting Tenant management admin service"); + } + DataHolder.getInstance().setTenantManagerAdminService(null); + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java index 80416dcd59..c67db70fb6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java @@ -27,6 +27,8 @@ import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionMan import io.entgra.device.mgt.core.application.mgt.common.services.VPPApplicationManager; import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.user.core.service.RealmService; @@ -57,6 +59,7 @@ public class DataHolder { private TaskService taskService; private FileTransferService fileTransferService; + private TenantManagerAdminService tenantManagerAdminService; private static final DataHolder applicationMgtDataHolder = new DataHolder(); @@ -163,4 +166,12 @@ public class DataHolder { public void setFileTransferService(FileTransferService fileTransferService) { this.fileTransferService = fileTransferService; } + + public TenantManagerAdminService getTenantManagerAdminService() { + return tenantManagerAdminService; + } + + public void setTenantManagerAdminService(TenantManagerAdminService tenantManagerAdminService) { + this.tenantManagerAdminService = tenantManagerAdminService; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java index d0e82d7fb3..91ed3f6d42 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; @@ -29,9 +30,6 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.CredentialManagementR import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.stratos.common.exception.StratosException; -import org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService; -import org.wso2.carbon.user.api.UserStoreException; import javax.validation.constraints.Size; import javax.ws.rs.*; @@ -99,18 +97,20 @@ public class UserManagementAdminServiceImpl implements UserManagementAdminServic log.error(msg); return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build(); } else { - if(deleteAppArtifacts){ + if (deleteAppArtifacts) { DeviceMgtAPIUtils.getApplicationManager().deleteApplicationArtifactsByTenantDomain(tenantDomain); } DeviceMgtAPIUtils.getApplicationManager().deleteApplicationDataByTenantDomain(tenantDomain); DeviceMgtAPIUtils.getDeviceManagementService().deleteDeviceDataByTenantDomain(tenantDomain); - TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService(); - tenantMgtAdminService.deleteTenant(tenantDomain); + DeviceMgtAPIUtils.getTenantManagerAdminService().deleteTenant(tenantDomain); String msg = "Tenant Deletion process has been initiated for tenant:" + tenantDomain; + if (log.isDebugEnabled()) { + log.debug(msg); + } return Response.status(Response.Status.OK).entity(msg).build(); } - } catch (StratosException | UserStoreException e) { + } catch (TenantMgtException e) { String msg = "Error deleting tenant: " + tenantDomain; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index 885d521389..5451572519 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -24,6 +24,7 @@ import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionMan import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuthorizationService; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; +import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; import org.apache.axis2.AxisFault; import org.apache.axis2.client.Options; import org.apache.axis2.java.security.SSLProtocolSocketFactory; @@ -163,6 +164,7 @@ public class DeviceMgtAPIUtils { private static volatile ApplicationManager applicationManager; private static volatile APIPublisherService apiPublisher; + private static volatile TenantManagerAdminService tenantManagerAdminService; static { String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); @@ -1243,4 +1245,21 @@ public class DeviceMgtAPIUtils { } return isPermitted; } + + public static TenantManagerAdminService getTenantManagerAdminService(){ + if(tenantManagerAdminService == null) { + synchronized (DeviceMgtAPIUtils.class) { + if (tenantManagerAdminService == null) { + tenantManagerAdminService = (TenantManagerAdminService) PrivilegedCarbonContext.getThreadLocalCarbonContext(). + getOSGiService(TenantManagerAdminService.class, null); + if (tenantManagerAdminService == null) { + String msg = "Tenant Manager Admin Service is null"; + log.error(msg); + throw new IllegalStateException(msg); + } + } + } + } + return tenantManagerAdminService; + } } diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/src/main/java/io/entgra/device/mgt/core/tenant/mgt/common/spi/TenantManagerAdminService.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/src/main/java/io/entgra/device/mgt/core/tenant/mgt/common/spi/TenantManagerAdminService.java new file mode 100644 index 0000000000..0b93e7ca5b --- /dev/null +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/src/main/java/io/entgra/device/mgt/core/tenant/mgt/common/spi/TenantManagerAdminService.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018 - 2024, 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.tenant.mgt.common.spi; + +import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException; + +public interface TenantManagerAdminService { + + void deleteTenant(String tenantDomain) throws TenantMgtException; + int getTenantId(String tenantDomain) throws TenantMgtException; +} diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 33d4c9969c..f89aa3cf39 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -60,6 +60,7 @@ org.wso2.carbon.stratos.common.beans, org.wso2.carbon.stratos.common.exception, org.wso2.carbon.stratos.common.listeners, + org.wso2.carbon.tenant.mgt.services, io.entgra.device.mgt.core.device.mgt.common.metadata.mgt, io.entgra.device.mgt.core.device.mgt.common.exceptions, io.entgra.device.mgt.core.device.mgt.common.permission.mgt, diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/TenantManager.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/TenantManager.java index ac3ee406f9..ea26974300 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/TenantManager.java +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/TenantManager.java @@ -57,4 +57,5 @@ public interface TenantManager { * @throws TenantMgtException Throws when deleting Tenant related device data */ void deleteTenantDeviceData(int tenantId) throws TenantMgtException; + } diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerAdminServiceImpl.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerAdminServiceImpl.java new file mode 100644 index 0000000000..b96535da25 --- /dev/null +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerAdminServiceImpl.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018 - 2024, 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.tenant.mgt.core.impl; + +import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException; +import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.stratos.common.exception.StratosException; +import org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService; +import org.wso2.carbon.user.api.UserStoreException; + + +public class TenantManagerAdminServiceImpl implements TenantManagerAdminService { + + private static final Log log = LogFactory.getLog(TenantManagerAdminServiceImpl.class); + + private static final TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService(); + + @Override + public void deleteTenant(String tenantDomain) throws TenantMgtException { + try { + tenantMgtAdminService.deleteTenant(tenantDomain); + } catch (StratosException | UserStoreException e) { + String msg = "Error occurred while deleting tenant of domain: " + tenantDomain; + log.error(msg, e); + throw new TenantMgtException(msg, e); + } + } + + @Override + public int getTenantId(String tenantDomain) throws TenantMgtException { + try { + return tenantMgtAdminService.getTenant(tenantDomain).getTenantId(); + } catch (Exception e){ + String msg = "Error occurred while getting tenant ID of domain: " + tenantDomain; + log.error(msg, e); + throw new TenantMgtException(msg, e); + } + } +} diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java index fa2f26c972..c6ad710cb8 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java @@ -20,8 +20,10 @@ package io.entgra.device.mgt.core.tenant.mgt.core.internal; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.DeviceStatusManagementServiceImpl; +import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerService; import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; +import io.entgra.device.mgt.core.tenant.mgt.core.impl.TenantManagerAdminServiceImpl; import io.entgra.device.mgt.core.tenant.mgt.core.impl.TenantManagerImpl; import io.entgra.device.mgt.core.tenant.mgt.core.impl.TenantManagerServiceImpl; import io.entgra.device.mgt.core.tenant.mgt.core.listener.DeviceMgtTenantListener; @@ -59,11 +61,14 @@ public class TenantMgtServiceComponent { try { TenantManagerService tenantManagerService = new TenantManagerServiceImpl(); componentContext.getBundleContext(). - registerService(TenantManagerServiceImpl.class.getName(), tenantManagerService, null); + registerService(TenantManagerService.class.getName(), tenantManagerService, null); + TenantManagerAdminService tenantManagerAdminService = new TenantManagerAdminServiceImpl(); + componentContext.getBundleContext(). + registerService(TenantManagerAdminService.class.getName(), tenantManagerAdminService, null); TenantManager tenantManager = new TenantManagerImpl(); TenantMgtDataHolder.getInstance().setTenantManager(tenantManager); WhiteLabelManagementService whiteLabelManagementService = new WhiteLabelManagementServiceImpl(); - componentContext.getBundleContext().registerService(WhiteLabelManagementServiceImpl.class.getName(), + componentContext.getBundleContext().registerService(WhiteLabelManagementService.class.getName(), whiteLabelManagementService, null); TenantMgtDataHolder.getInstance().setWhiteLabelManagementService(whiteLabelManagementService); DeviceStatusManagementService deviceStatusManagementService = new DeviceStatusManagementServiceImpl(); diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java index 257206f84f..978e69b0e4 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java @@ -88,13 +88,5 @@ public class DeviceMgtTenantListener implements TenantMgtListener { @Override public void onPreDelete(int i) throws StratosException { // Any work to be performed before a tenant is deleted - TenantManager tenantManager = TenantMgtDataHolder.getInstance().getTenantManager(); - try{ - tenantManager.deleteTenantDeviceData(i); - tenantManager.deleteTenantApplicationData(i); - } catch (TenantMgtException e) { - String msg = "Error occurred while deleting tenant data"; - log.error(msg, e); - } } } From 1a1df9725333bcf8abbe9bfc4c87d6311284f14a Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Thu, 11 Jul 2024 12:32:39 +0530 Subject: [PATCH 240/343] Resolve comments --- .../mgt/core/impl/SubscriptionManagerImpl.java | 16 ++++++---------- .../core/device/mgt/core/dao/EnrollmentDAO.java | 6 ++++-- .../mgt/core/device/mgt/core/dao/GroupDAO.java | 3 ++- .../mgt/core/dao/impl/AbstractGroupDAOImpl.java | 3 ++- .../GroupManagementProviderServiceImpl.java | 3 ++- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 6bb902d6b3..203740c6da 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1722,7 +1722,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - int deviceTypeId = applicationDTO.getDeviceTypeId(); List groupDetailsWithDevices = new ArrayList<>(); List groupDetails = @@ -1738,7 +1737,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { // Retrieve group details and device IDs for the group using the service layer GroupDetailsDTO groupDetailWithDevices = - groupManagementProviderService.getGroupDetailsWithDevices(groupName, deviceTypeId, offset, limit); + groupManagementProviderService.getGroupDetailsWithDevices(groupName, applicationDTO.getDeviceTypeId(), + offset, limit); SubscriptionsDTO groupDetailDTO = new SubscriptionsDTO(); groupDetailDTO.setId(groupDetailWithDevices.getGroupId()); @@ -1913,7 +1913,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - int deviceTypeId = applicationDTO.getDeviceTypeId(); List userSubscriptionsWithDevices = new ArrayList<>(); List userSubscriptions = @@ -1929,7 +1928,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { // Retrieve owner details and device IDs for the user using the service layer OwnerWithDeviceDTO ownerDetailsWithDevices = - deviceManagementProviderService.getOwnersWithDeviceIds(userName, deviceTypeId); + deviceManagementProviderService.getOwnersWithDeviceIds(userName, applicationDTO.getDeviceTypeId()); SubscriptionsDTO userSubscriptionDTO = new SubscriptionsDTO(); userSubscriptionDTO.setName(userSubscription.getName()); @@ -2101,7 +2100,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - int deviceTypeId = applicationDTO.getDeviceTypeId(); List roleSubscriptionsWithDevices = new ArrayList<>(); List roleSubscriptions = @@ -2142,7 +2140,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { for (String user : users) { OwnerWithDeviceDTO ownerDetailsWithDevices; try { - ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(user, deviceTypeId); + ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(user, applicationDTO.getDeviceTypeId()); } catch (DeviceManagementDAOException e) { throw new ApplicationManagementException("Error retrieving owner details with devices for user: " + user, e); } @@ -2312,7 +2310,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - int deviceTypeId = applicationDTO.getDeviceTypeId(); DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); List deviceSubscriptions = @@ -2326,7 +2323,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } List allDevices = - deviceManagementProviderService.getDevicesByTenantId(tenantId, deviceTypeId); + deviceManagementProviderService.getDevicesByTenantId(tenantId, applicationDTO.getDeviceTypeId()); List deviceIds = allDevices.stream() .map(DeviceDetailsDTO::getDeviceId) @@ -2500,7 +2497,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - int deviceTypeId = applicationDTO.getDeviceTypeId(); List allSubscriptions = subscriptionDAO.getAllSubscriptionsDetails(appReleaseId, unsubscribe, tenantId, offset, limit); @@ -2529,7 +2525,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { statusCounts.put("NEW", 0); List allDevices = - deviceManagementProviderService.getDevicesByTenantId(tenantId, deviceTypeId); + deviceManagementProviderService.getDevicesByTenantId(tenantId, applicationDTO.getDeviceTypeId()); for (DeviceDetailsDTO device : allDevices) { Integer deviceId = device.getDeviceId(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java index 158b86e0a3..e7419aa013 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java @@ -106,7 +106,8 @@ public interface EnrollmentDAO { * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId, int deviceTypeId) throws DeviceManagementDAOException; + OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId, int deviceTypeId) + throws DeviceManagementDAOException; /** * Retrieves a list of device IDs with owners and device status. @@ -128,5 +129,6 @@ public interface EnrollmentDAO { * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses, int deviceTypeId) throws DeviceManagementDAOException; + List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses, int deviceTypeId) + throws DeviceManagementDAOException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 2bb6c48fb4..abb12a6ea0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -481,7 +481,8 @@ public interface GroupDAO { * @return {@link GroupDetailsDTO} which containing group details and a list of device IDs * @throws GroupManagementDAOException if an error occurs while retrieving the group details and devices */ - GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowingDeviceStatuses, int deviceTypeId, int tenantId, int offset, int limit) + GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowingDeviceStatuses, int deviceTypeId, + int tenantId, int offset, int limit) throws GroupManagementDAOException; } \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 22e9fb18aa..7b9e918000 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1441,7 +1441,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } @Override - public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowedStatuses, int deviceTypeId, int tenantId, int offset, int limit) + public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowedStatuses, int deviceTypeId, + int tenantId, int offset, int limit) throws GroupManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get group details and device IDs for group: " + groupName); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 0d0e23cc48..d6114b5c04 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -1698,7 +1698,8 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid try { GroupManagementDAOFactory.openConnection(); - groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, allowingDeviceStatuses, deviceTypeId, tenantId, offset, limit); + groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, allowingDeviceStatuses, + deviceTypeId, tenantId, offset, limit); } catch (GroupManagementDAOException | SQLException e) { String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; log.error(msg, e); From 2006d7e97db474ddd533a7ec49bbc5687e813901 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Thu, 11 Jul 2024 23:33:16 +0530 Subject: [PATCH 241/343] Add policy type conversion from BLOB to Text DB scripts --- .../src/test/resources/carbon-home/dbscripts/dm-db-h2.sql | 2 +- .../src/test/resources/sql/h2.sql | 2 +- .../src/test/resources/sql/h2.sql | 2 +- .../src/test/resources/sql-files/h2.sql | 2 +- .../src/test/resources/carbon-home/dbscripts/dm-db-h2.sql | 2 +- .../src/test/resources/sql/CreateH2TestDB.sql | 2 +- .../src/test/resources/sql/CreateMySqlTestDB.sql | 2 +- .../src/test/resources/carbon-home/dbscripts/dm-db-h2.sql | 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 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 13ac69dfc6..29d1a225b2 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -329,7 +329,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED DEVICE_ID INT NOT NULL, ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL, - POLICY_CONTENT BLOB NULL, + POLICY_CONTENT TEXT NULL, TENANT_ID INT NOT NULL, APPLIED TINYINT(1) NULL, CREATED_TIME TIMESTAMP NULL, diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql index a842fdf2ab..f998695f58 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql @@ -336,7 +336,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( DEVICE_ID INT NOT NULL , ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , - POLICY_CONTENT BLOB NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID INT NOT NULL, APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index aea2602f2e..5f94591885 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -336,7 +336,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( DEVICE_ID INT NOT NULL , ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , - POLICY_CONTENT BLOB NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID INT NOT NULL, APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql index d69d5e354b..ed810f8308 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql @@ -242,7 +242,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( DEVICE_ID INT NOT NULL , ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , - POLICY_CONTENT BLOB NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID INT NOT NULL, APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 0c547b11a4..17f334c78f 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -288,7 +288,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( DEVICE_ID INT NOT NULL , ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , - POLICY_CONTENT BLOB NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID INT NOT NULL, APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index a9fa35a6fb..0086d545d2 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -322,7 +322,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( DEVICE_ID INT NOT NULL , ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , - POLICY_CONTENT BLOB NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID INT NOT NULL, APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateMySqlTestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateMySqlTestDB.sql index be7bf40b7d..feab172d0e 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateMySqlTestDB.sql +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateMySqlTestDB.sql @@ -161,7 +161,7 @@ CREATE TABLE IF NOT EXISTS `WSO2CDM`.`DM_DEVICE_POLICY_APPLIED` ( `ID` INT(11) NOT NULL AUTO_INCREMENT, `DEVICE_ID` INT(11) NOT NULL, `POLICY_ID` INT(11) NOT NULL, - `POLICY_CONTENT` BLOB NULL DEFAULT NULL, + `POLICY_CONTENT` TEXT NULL DEFAULT NULL, `APPLIED` TINYINT(1) NULL DEFAULT NULL, `CREATED_TIME` TIMESTAMP NULL DEFAULT NULL, `UPDATED_TIME` TIMESTAMP NULL DEFAULT NULL, diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql index 046cfbec1d..8ed0e91922 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql @@ -289,7 +289,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( DEVICE_ID INT NOT NULL , ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , - POLICY_CONTENT BLOB NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID INT NOT NULL, APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index f34d6183e2..342c330376 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -304,7 +304,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( DEVICE_ID INT NOT NULL , ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , - POLICY_CONTENT BLOB NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID INT NOT NULL, APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index dc05a39464..f6f3232e13 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -369,7 +369,7 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[D DEVICE_ID INTEGER NOT NULL , ENROLMENT_ID INTEGER NOT NULL, POLICY_ID INTEGER NOT NULL , - POLICY_CONTENT VARBINARY(MAX) NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID INTEGER NOT NULL, APPLIED BIT NULL , CREATED_TIME DATETIME2 NULL , diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index cd28fb74f1..4390f6a40d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -355,7 +355,7 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( DEVICE_ID INT NOT NULL , ENROLMENT_ID INT(11) NOT NULL, POLICY_ID INT NOT NULL , - POLICY_CONTENT BLOB NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID INT NOT NULL, APPLIED TINYINT(1) NULL , CREATED_TIME TIMESTAMP NULL , diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index e500c55046..d5a442c69e 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -509,7 +509,7 @@ CREATE TABLE DM_DEVICE_POLICY_APPLIED ( DEVICE_ID NUMBER(10) NOT NULL , ENROLMENT_ID NUMBER(10) NOT NULL, POLICY_ID NUMBER(10) NOT NULL , - POLICY_CONTENT BLOB NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID NUMBER(10) NOT NULL, APPLIED NUMBER(1) DEFAULT 0, CREATED_TIME TIMESTAMP(0) NULL , diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index c0368f5826..354925efe5 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -365,7 +365,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( DEVICE_ID INTEGER NOT NULL , ENROLMENT_ID INTEGER NOT NULL, POLICY_ID INTEGER NOT NULL , - POLICY_CONTENT BYTEA NULL , + POLICY_CONTENT TEXT NULL , TENANT_ID INTEGER NOT NULL, APPLIED SMALLINT NULL , CREATED_TIME TIMESTAMP(0) NULL , From de1d79f27c2f2ef2d9f8802d2efcc88b35b25839 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Thu, 11 Jul 2024 23:53:34 +0530 Subject: [PATCH 242/343] Fix same device data loading for subscriptions --- .../core/impl/SubscriptionManagerImpl.java | 76 +++++++++++-------- .../dao/impl/AbstractEnrollmentDAOImpl.java | 12 +-- 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 203740c6da..174e317ee6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1929,6 +1929,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { // Retrieve owner details and device IDs for the user using the service layer OwnerWithDeviceDTO ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(userName, applicationDTO.getDeviceTypeId()); + log.info("line no 1932 device ids : " + ownerDetailsWithDevices.getDeviceIds()); + log.info("line no 1933 device identifiers : " + ownerDetailsWithDevices.getDeviceIdentifiers()); + log.info("line no 1934 device names : " + ownerDetailsWithDevices.getDeviceNames()); SubscriptionsDTO userSubscriptionDTO = new SubscriptionsDTO(); userSubscriptionDTO.setName(userSubscription.getName()); @@ -1965,15 +1968,20 @@ public class SubscriptionManagerImpl implements SubscriptionManager { for (Integer deviceId : deviceIds) { List deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( userSubscription.getAppReleaseId(), unsubscribe, tenantId, deviceIds); + OwnerWithDeviceDTO ownerWithDeviceByDeviceId = + deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId); + if (ownerWithDeviceByDeviceId == null) { + continue; + } boolean isNewDevice = true; for (DeviceSubscriptionDTO subscription : deviceSubscriptions) { if (subscription.getDeviceId() == deviceId) { DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); deviceDetail.setDeviceId(subscription.getDeviceId()); deviceDetail.setSubId(subscription.getId()); - deviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - deviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); - deviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); + deviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + deviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); + deviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); deviceDetail.setActionType(subscription.getActionTriggeredFrom()); deviceDetail.setStatus(subscription.getStatus()); deviceDetail.setActionType(subscription.getActionTriggeredFrom()); @@ -1982,8 +1990,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); - deviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - deviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + deviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + deviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); status = subscription.getStatus(); switch (status) { @@ -2013,16 +2021,16 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (subscribedDevice.getDeviceId() == deviceId) { DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); - subscribedDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); - subscribedDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - subscribedDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + subscribedDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); + subscribedDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + subscribedDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); subscribedDeviceDetail.setSubId(subscribedDevice.getId()); subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); - subscribedDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - subscribedDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + subscribedDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + subscribedDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); subscribedDevices.add(subscribedDeviceDetail); statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); isSubscribedDevice = true; @@ -2032,11 +2040,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (!isSubscribedDevice) { DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); newDeviceDetail.setDeviceId(deviceId); - newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); - newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); - newDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - newDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + newDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + newDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); + newDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); + newDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + newDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); newDevices.add(newDeviceDetail); statusCounts.put("NEW", statusCounts.get("NEW") + 1); } @@ -2153,7 +2161,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager { subscribedDeviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( appReleaseId, !unsubscribe, tenantId, deviceIds); } - + OwnerWithDeviceDTO ownerWithDeviceByDeviceId = + deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId); + if (ownerWithDeviceByDeviceId == null) { + continue; + } List deviceSubscriptions; try { deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( @@ -2167,9 +2179,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (deviceSubscription.getDeviceId() == deviceId) { DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); deviceDetail.setDeviceId(deviceSubscription.getDeviceId()); - deviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); - deviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - deviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + deviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); + deviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + deviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); deviceDetail.setActionType(deviceSubscription.getActionTriggeredFrom()); deviceDetail.setStatus(deviceSubscription.getStatus()); deviceDetail.setActionType(deviceSubscription.getActionTriggeredFrom()); @@ -2179,8 +2191,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceDetail.setUnsubscribed(deviceSubscription.isUnsubscribed()); deviceDetail.setUnsubscribedBy(deviceSubscription.getUnsubscribedBy()); deviceDetail.setUnsubscribedTimestamp(deviceSubscription.getUnsubscribedTimestamp()); - deviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - deviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + deviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + deviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); status = deviceSubscription.getStatus(); switch (status) { @@ -2210,16 +2222,16 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (subscribedDevice.getDeviceId() == deviceId) { DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); - subscribedDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); - subscribedDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - subscribedDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + subscribedDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); + subscribedDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + subscribedDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); subscribedDeviceDetail.setSubId(subscribedDevice.getId()); subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); - subscribedDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - subscribedDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + subscribedDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + subscribedDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); subscribedDevices.add(subscribedDeviceDetail); statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); isSubscribedDevice = true; @@ -2229,11 +2241,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (!isSubscribedDevice) { DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); newDeviceDetail.setDeviceId(deviceId); - newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); - newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); - newDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - newDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + newDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); + newDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + newDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); + newDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + newDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); newDevices.add(newDeviceDetail); statusCounts.put("NEW", statusCounts.get("NEW") + 1); } @@ -2266,7 +2278,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } return roleSubscriptionsWithDevices; - } catch (ApplicationManagementDAOException e) { + } catch (ApplicationManagementDAOException | DeviceManagementDAOException e) { String msg = "Error occurred in retrieving role subscriptions with devices"; log.error(msg, e); throw new ApplicationManagementException(msg, e); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index 6f9d3e727f..9a25164a5b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -597,9 +597,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { while (rs.next()) { if (ownerDetails.getUserName() == null) { ownerDetails.setUserName(rs.getString("OWNER")); - ownerDetails.setDeviceStatus(rs.getString("DEVICE_STATUS")); - ownerDetails.setDeviceNames(rs.getString("DEVICE_NAME")); } + ownerDetails.setDeviceStatus(rs.getString("DEVICE_STATUS")); + ownerDetails.setDeviceNames(rs.getString("DEVICE_NAME")); + ownerDetails.setDeviceTypes("DEVICE_TYPE"); + ownerDetails.setDeviceIdentifiers("DEVICE_IDENTIFICATION"); deviceIds.add(rs.getInt("DEVICE_ID")); deviceCount++; } @@ -610,11 +612,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } - ownerDetails.setDeviceIds(deviceIds); - ownerDetails.setDeviceTypes("DEVICE_TYPE"); - ownerDetails.setDeviceIdentifiers("DEVICE_IDENTIFICATION"); ownerDetails.setDeviceCount(deviceCount); + log.info("line no 617 device ids : " + ownerDetails.getDeviceIds()); + log.info("line no 618 device identifiers : " + ownerDetails.getDeviceIdentifiers()); + log.info("line no 619 device names : " + ownerDetails.getDeviceNames()); return ownerDetails; } From 11bca0f4ae99a17363b257a6a270c6900011af12 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Thu, 11 Jul 2024 23:57:14 +0530 Subject: [PATCH 243/343] Remove unnecessary logs --- .../application/mgt/core/impl/SubscriptionManagerImpl.java | 3 --- .../device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java | 3 --- 2 files changed, 6 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 174e317ee6..6d90d22272 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1929,9 +1929,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager { // Retrieve owner details and device IDs for the user using the service layer OwnerWithDeviceDTO ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(userName, applicationDTO.getDeviceTypeId()); - log.info("line no 1932 device ids : " + ownerDetailsWithDevices.getDeviceIds()); - log.info("line no 1933 device identifiers : " + ownerDetailsWithDevices.getDeviceIdentifiers()); - log.info("line no 1934 device names : " + ownerDetailsWithDevices.getDeviceNames()); SubscriptionsDTO userSubscriptionDTO = new SubscriptionsDTO(); userSubscriptionDTO.setName(userSubscription.getName()); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index 9a25164a5b..98ef10ebe6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -614,9 +614,6 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } ownerDetails.setDeviceIds(deviceIds); ownerDetails.setDeviceCount(deviceCount); - log.info("line no 617 device ids : " + ownerDetails.getDeviceIds()); - log.info("line no 618 device identifiers : " + ownerDetails.getDeviceIdentifiers()); - log.info("line no 619 device names : " + ownerDetails.getDeviceNames()); return ownerDetails; } From 8a82d1666c5add4bb056e4d41813aa4fe0a0e462 Mon Sep 17 00:00:00 2001 From: ashvini Date: Tue, 13 Feb 2024 12:49:53 +0530 Subject: [PATCH 244/343] Add capability to search policies by device type Resolve comments Resolve comments Remove unnecessary changes --- .../service/api/PolicyManagementService.java | 6 ++ .../impl/PolicyManagementServiceImpl.java | 4 ++ .../mgt/common/PolicyPaginationRequest.java | 9 +++ .../impl/policy/AbstractPolicyDAOImpl.java | 63 +++++++++++++++++++ .../dao/impl/policy/GenericPolicyDAOImpl.java | 25 +++++--- .../dao/impl/policy/OraclePolicyDAOImpl.java | 25 +++++--- .../impl/policy/PostgreSQLPolicyDAOImpl.java | 25 +++++--- .../impl/policy/SQLServerPolicyDAOImpl.java | 25 +++++--- .../mgt/core/mgt/impl/PolicyManagerImpl.java | 6 ++ 9 files changed, 160 insertions(+), 28 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/PolicyManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/PolicyManagementService.java index 8cce7e92b3..4abcf68617 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/PolicyManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/PolicyManagementService.java @@ -934,6 +934,12 @@ public interface PolicyManagementService { required = false) @QueryParam("status") String status, + @ApiParam( + name = "deviceType", + value = "The device type of the policy that needs filtering.", + required = false) + @QueryParam("deviceType") + String deviceType, @ApiParam( name = "If-Modified-Since", value = "Checks if the requested variant was modified, since the specified date-time. \n" + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java index 311b4292a7..d882018073 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java @@ -488,6 +488,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { @QueryParam("name") String name, @QueryParam("type") String type, @QueryParam("status") String status, + @QueryParam("deviceType") String deviceType, @HeaderParam("If-Modified-Since") String ifModifiedSince, @QueryParam("offset") int offset, @QueryParam("limit") int limit) { @@ -505,6 +506,9 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { if (status != null){ request.setStatus(status); } + if (deviceType != null) { + request.setDeviceType(deviceType); + } try { PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP(); policies = policyAdministratorPoint.getPolicyList(request); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PolicyPaginationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PolicyPaginationRequest.java index 8a0a2f3bd4..ddbc3a51a7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PolicyPaginationRequest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PolicyPaginationRequest.java @@ -24,6 +24,7 @@ public class PolicyPaginationRequest { private String name; private String type; private String status; + private String deviceType; public PolicyPaginationRequest(int start, int rowCount) { this.startIndex = start; @@ -70,6 +71,14 @@ public class PolicyPaginationRequest { this.status = status; } + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + @Override public String toString() { return "Group Name '" + this.name + "' num of rows: " + this.rowCount + " start index: " + this.startIndex; diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java index 85bd77d859..524e127a14 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/AbstractPolicyDAOImpl.java @@ -26,6 +26,7 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.CorrectiveAction; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.DeviceGroupWrapper; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Policy; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyCriterion; +import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; import io.entgra.device.mgt.core.policy.mgt.common.Criterion; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyDAO; import io.entgra.device.mgt.core.policy.mgt.core.dao.PolicyManagementDAOFactory; @@ -1844,4 +1845,66 @@ public abstract class AbstractPolicyDAOImpl implements PolicyDAO { } return policies; } + + /** + * Extracts a list of Policy objects with associated Profile objects from the given ResultSet + * + * @param resultSet The ResultSet containing the policy and profile data + * @param tenantId The tenant ID + * @return A list of Policy objects populated with data from the ResultSet + * @throws SQLException If an SQL error occurs while processing the ResultSet + */ + protected List extractPolicyListWithProfileFromDbResult(ResultSet resultSet, int tenantId) throws SQLException { + List policies = new ArrayList<>(); + while (resultSet.next()) { + Policy policy = createPolicyFromResultSet(resultSet, tenantId); + Profile profile = createProfileFromResultSet(resultSet, tenantId); + policy.setProfile(profile); + policies.add(policy); + } + return policies; + } + + /** + * Creates a Policy object from the current row in the given ResultSet + * + * @param resultSet The ResultSet containing the policy data + * @param tenantId The tenant ID + * @return A Policy object populated with data from the ResultSet + * @throws SQLException If an SQL error occurs while processing the ResultSet + */ + private Policy createPolicyFromResultSet(ResultSet resultSet, int tenantId) throws SQLException { + Policy policy = new Policy(); + policy.setId(resultSet.getInt("ID")); + policy.setProfileId(resultSet.getInt("PROFILE_ID")); + policy.setPolicyName(resultSet.getString("NAME")); + policy.setTenantId(tenantId); + policy.setPriorityId(resultSet.getInt("PRIORITY")); + policy.setCompliance(resultSet.getString("COMPLIANCE")); + policy.setOwnershipType(resultSet.getString("OWNERSHIP_TYPE")); + policy.setUpdated(PolicyManagerUtil.convertIntToBoolean(resultSet.getInt("UPDATED"))); + policy.setActive(PolicyManagerUtil.convertIntToBoolean(resultSet.getInt("ACTIVE"))); + policy.setDescription(resultSet.getString("DESCRIPTION")); + policy.setPolicyType(resultSet.getString("POLICY_TYPE")); + policy.setPolicyPayloadVersion(resultSet.getString("PAYLOAD_VERSION")); + return policy; + } + + /** + * Creates a Profile object from the current row in the given ResultSet + * + * @param resultSet The ResultSet containing the profile data + * @param tenantId The tenant ID + * @return A Profile object populated with data from the ResultSet + * @throws SQLException If an SQL error occurs while processing the ResultSet + */ + private Profile createProfileFromResultSet(ResultSet resultSet, int tenantId) throws SQLException { + Profile profile = new Profile(); + profile.setProfileId(resultSet.getInt("PROFILE_ID")); + profile.setProfileName(resultSet.getString("PROFILE_NAME")); + profile.setTenantId(tenantId); + profile.setDeviceType(resultSet.getString("DEVICE_TYPE")); + return profile; + } + } diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/GenericPolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/GenericPolicyDAOImpl.java index 2e7b3aa87f..772bdbd31d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/GenericPolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/GenericPolicyDAOImpl.java @@ -48,24 +48,27 @@ public class GenericPolicyDAOImpl extends AbstractPolicyDAOImpl { String name = request.getName(); String type = request.getType(); String status = request.getStatus(); + String deviceType = request.getDeviceType(); int statusValue = 0; boolean isPolicyNameProvided = false; boolean isPolicyTypeProvided = false; boolean isPolicyStatusProvided = false; + boolean isDeviceTypeProvided = false; try { conn = this.getConnection(); String query = "SELECT * " + - "FROM DM_POLICY " + - "WHERE TENANT_ID = ? "; + "FROM DM_POLICY P " + + "LEFT JOIN DM_PROFILE PR ON P.PROFILE_ID = PR.ID " + + "WHERE P.TENANT_ID = ? "; if (name != null && !name.isEmpty()) { - query += "AND NAME LIKE ? " ; + query += "AND P.NAME LIKE ? " ; isPolicyNameProvided = true; } if (type != null && !type.isEmpty()) { - query += "AND POLICY_TYPE = ? " ; + query += "AND P.POLICY_TYPE = ? " ; isPolicyTypeProvided = true; } @@ -73,11 +76,16 @@ public class GenericPolicyDAOImpl extends AbstractPolicyDAOImpl { if (status.equals("ACTIVE")) { statusValue = 1; } - query += "AND ACTIVE = ? " ; + query += "AND P.ACTIVE = ? " ; isPolicyStatusProvided = true; } - query += "ORDER BY ID LIMIT ?,?"; + if (deviceType != null && !deviceType.isEmpty()) { + query += "AND PR.DEVICE_TYPE = ? "; + isDeviceTypeProvided = true; + } + + query += "ORDER BY P.ID LIMIT ?,?"; try (PreparedStatement stmt = conn.prepareStatement(query)) { int paramIdx = 1; @@ -91,10 +99,13 @@ public class GenericPolicyDAOImpl extends AbstractPolicyDAOImpl { if (isPolicyStatusProvided) { stmt.setInt(paramIdx++, statusValue); } + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, deviceType); + } stmt.setInt(paramIdx++, request.getStartIndex()); stmt.setInt(paramIdx++, request.getRowCount()); try (ResultSet resultSet = stmt.executeQuery()) { - return this.extractPolicyListFromDbResult(resultSet, tenantId); + return this.extractPolicyListWithProfileFromDbResult(resultSet, tenantId); } } } catch (SQLException e) { diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/OraclePolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/OraclePolicyDAOImpl.java index 19642f162e..bbc6d1a57a 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/OraclePolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/OraclePolicyDAOImpl.java @@ -47,24 +47,27 @@ public class OraclePolicyDAOImpl extends AbstractPolicyDAOImpl { String name = request.getName(); String type = request.getType(); String status = request.getStatus(); + String deviceType = request.getDeviceType(); int statusValue = 0; boolean isPolicyNameProvided = false; boolean isPolicyTypeProvided = false; boolean isPolicyStatusProvided = false; + boolean isDeviceTypeProvided = false; try { conn = this.getConnection(); String query = "SELECT * " + - "FROM DM_POLICY " + - "WHERE TENANT_ID = ? "; + "FROM DM_POLICY P " + + "LEFT JOIN DM_PROFILE PR ON P.PROFILE_ID = PR.ID " + + "WHERE P.TENANT_ID = ? "; if (name != null && !name.isEmpty()) { - query += "AND NAME LIKE ? " ; + query += "AND P.NAME LIKE ? " ; isPolicyNameProvided = true; } if (type != null && !type.isEmpty()) { - query += "AND POLICY_TYPE = ? " ; + query += "AND P.POLICY_TYPE = ? " ; isPolicyTypeProvided = true; } @@ -72,11 +75,16 @@ public class OraclePolicyDAOImpl extends AbstractPolicyDAOImpl { if (status.equals("ACTIVE")) { statusValue = 1; } - query += "AND ACTIVE = ? " ; + query += "AND P.ACTIVE = ? " ; isPolicyStatusProvided = true; } - query += "ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + if (deviceType != null && !deviceType.isEmpty()) { + query += "AND PR.DEVICE_TYPE = ? "; + isDeviceTypeProvided = true; + } + + query += "ORDER BY P.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement stmt = conn.prepareStatement(query)) { int paramIdx = 1; @@ -90,10 +98,13 @@ public class OraclePolicyDAOImpl extends AbstractPolicyDAOImpl { if (isPolicyStatusProvided) { stmt.setInt(paramIdx++, statusValue); } + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, deviceType); + } stmt.setInt(paramIdx++, request.getStartIndex()); stmt.setInt(paramIdx++, request.getRowCount()); try (ResultSet resultSet = stmt.executeQuery()) { - return this.extractPolicyListFromDbResult(resultSet, tenantId); + return this.extractPolicyListWithProfileFromDbResult(resultSet, tenantId); } } } catch (SQLException e) { diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/PostgreSQLPolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/PostgreSQLPolicyDAOImpl.java index 26b211e6e2..01baefd69a 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/PostgreSQLPolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/PostgreSQLPolicyDAOImpl.java @@ -47,24 +47,27 @@ public class PostgreSQLPolicyDAOImpl extends AbstractPolicyDAOImpl { String name = request.getName(); String type = request.getType(); String status = request.getStatus(); + String deviceType = request.getDeviceType(); int statusValue = 0; boolean isPolicyNameProvided = false; boolean isPolicyTypeProvided = false; boolean isPolicyStatusProvided = false; + boolean isDeviceTypeProvided = false; try { conn = this.getConnection(); String query = "SELECT * " + - "FROM DM_POLICY " + - "WHERE TENANT_ID = ? "; + "FROM DM_POLICY P " + + "LEFT JOIN DM_PROFILE PR ON P.PROFILE_ID = PR.ID " + + "WHERE P.TENANT_ID = ? "; if (name != null && !name.isEmpty()) { - query += "AND NAME LIKE ? " ; + query += "AND P.NAME LIKE ? " ; isPolicyNameProvided = true; } if (type != null && !type.isEmpty()) { - query += "AND POLICY_TYPE = ? " ; + query += "AND P.POLICY_TYPE = ? " ; isPolicyTypeProvided = true; } @@ -72,11 +75,16 @@ public class PostgreSQLPolicyDAOImpl extends AbstractPolicyDAOImpl { if (status.equals("ACTIVE")) { statusValue = 1; } - query += "AND ACTIVE = ? " ; + query += "AND P.ACTIVE = ? " ; isPolicyStatusProvided = true; } - query += "ORDER BY ID LIMIT ? OFFSET ?"; + if (deviceType != null && !deviceType.isEmpty()) { + query += "AND PR.DEVICE_TYPE = ?"; + isDeviceTypeProvided = true; + } + + query += "ORDER BY P.ID LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(query)) { int paramIdx = 1; @@ -90,10 +98,13 @@ public class PostgreSQLPolicyDAOImpl extends AbstractPolicyDAOImpl { if (isPolicyStatusProvided) { stmt.setInt(paramIdx++, statusValue); } + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, deviceType); + } stmt.setInt(paramIdx++, request.getStartIndex()); stmt.setInt(paramIdx++, request.getRowCount()); try (ResultSet resultSet = stmt.executeQuery()) { - return this.extractPolicyListFromDbResult(resultSet, tenantId); + return this.extractPolicyListWithProfileFromDbResult(resultSet, tenantId); } } } catch (SQLException e) { diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/SQLServerPolicyDAOImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/SQLServerPolicyDAOImpl.java index 6e4df5cb15..5f59491ca5 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/SQLServerPolicyDAOImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/dao/impl/policy/SQLServerPolicyDAOImpl.java @@ -47,24 +47,27 @@ public class SQLServerPolicyDAOImpl extends AbstractPolicyDAOImpl { String name = request.getName(); String type = request.getType(); String status = request.getStatus(); + String deviceType = request.getDeviceType(); int statusValue = 0; boolean isPolicyNameProvided = false; boolean isPolicyTypeProvided = false; boolean isPolicyStatusProvided = false; + boolean isDeviceTypeProvided = false; try { conn = this.getConnection(); String query = "SELECT * " + - "FROM DM_POLICY " + - "WHERE TENANT_ID = ? "; + "FROM DM_POLICY P " + + "LEFT JOIN DM_PROFILE PR ON P.PROFILE_ID = PR.ID " + + "WHERE P.TENANT_ID = ? "; if (name != null && !name.isEmpty()) { - query += "AND NAME LIKE ? " ; + query += "AND P.NAME LIKE ? " ; isPolicyNameProvided = true; } if (type != null && !type.isEmpty()) { - query += "AND POLICY_TYPE = ? " ; + query += "AND P.POLICY_TYPE = ? " ; isPolicyTypeProvided = true; } @@ -72,11 +75,16 @@ public class SQLServerPolicyDAOImpl extends AbstractPolicyDAOImpl { if (status.equals("ACTIVE")) { statusValue = 1; } - query += "AND ACTIVE = ? " ; + query += "AND P.ACTIVE = ? " ; isPolicyStatusProvided = true; } - query += "ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + if (deviceType != null && !deviceType.isEmpty()) { + query += "AND PR.DEVICE_TYPE = ?"; + isDeviceTypeProvided = true; + } + + query += "ORDER BY P.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement stmt = conn.prepareStatement(query)) { int paramIdx = 1; @@ -90,10 +98,13 @@ public class SQLServerPolicyDAOImpl extends AbstractPolicyDAOImpl { if (isPolicyStatusProvided) { stmt.setInt(paramIdx++, statusValue); } + if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, deviceType); + } stmt.setInt(paramIdx++, request.getStartIndex()); stmt.setInt(paramIdx++, request.getRowCount()); try (ResultSet resultSet = stmt.executeQuery()) { - return this.extractPolicyListFromDbResult(resultSet, tenantId); + return this.extractPolicyListWithProfileFromDbResult(resultSet, tenantId); } } } catch (SQLException e) { diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 9d362bcc9e..cf6e0da5a8 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -1532,6 +1532,8 @@ public class PolicyManagerImpl implements PolicyManager { for (Policy policy : policyList) { policy.setRoles(policyDAO.getPolicyAppliedRoles(policy.getId())); policy.setUsers(policyDAO.getPolicyAppliedUsers(policy.getId())); + policy.setProfile(profileDAO.getProfile(policy.getId())); + List deviceGroupWrappers = policyDAO.getDeviceGroupsOfPolicy(policy.getId()); if (!deviceGroupWrappers.isEmpty()) { deviceGroupWrappers = this.getDeviceGroupNames(deviceGroupWrappers); @@ -1551,6 +1553,10 @@ public class PolicyManagerImpl implements PolicyManager { String msg = "Error occurred while getting device groups."; log.error(msg, e); throw new PolicyManagementException(msg, e); + } catch (ProfileManagerDAOException e) { + String msg = "Error occurred while getting profiles."; + log.error(msg, e); + throw new PolicyManagementException(msg, e); } finally { PolicyManagementDAOFactory.closeConnection(); } From 22f84979525823989009e1ce238ef450ebc2ca75 Mon Sep 17 00:00:00 2001 From: nipuni Date: Fri, 12 Jul 2024 07:37:40 +0530 Subject: [PATCH 245/343] Fix Search is not working in installation details in app store --- .../common/CategorizedSubscriptionResult.java | 21 +- .../common/services/SubscriptionManager.java | 23 +- .../mgt/core/dao/SubscriptionDAO.java | 15 +- .../GenericSubscriptionDAOImpl.java | 94 ++++- .../core/impl/SubscriptionManagerImpl.java | 379 +++++++++++++----- .../device/mgt/common/PaginationRequest.java | 72 ++++ .../device/mgt/core/dao/EnrollmentDAO.java | 19 +- .../core/device/mgt/core/dao/GroupDAO.java | 8 +- .../dao/impl/AbstractEnrollmentDAOImpl.java | 157 ++++++-- .../core/dao/impl/AbstractGroupDAOImpl.java | 64 ++- .../DeviceManagementProviderService.java | 19 +- .../DeviceManagementProviderServiceImpl.java | 24 +- .../GroupManagementProviderService.java | 7 +- .../GroupManagementProviderServiceImpl.java | 12 +- 14 files changed, 710 insertions(+), 204 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java index 28cc436115..e26e567379 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java @@ -60,6 +60,26 @@ public class CategorizedSubscriptionResult { this.subscribedDevices = subscribedDevices; } + public CategorizedSubscriptionResult(List devices, String tabActionStatus) { + switch (tabActionStatus) { + case "COMPLETED": + this.installedDevices = devices; + break; + case "PENDING": + this.pendingDevices = devices; + break; + case "ERROR": + this.errorDevices = devices; + break; + case "NEW": + this.newDevices = devices; + break; + case "SUBSCRIBED": + this.subscribedDevices = devices; + break; + } + } + public List getInstalledDevices() { return installedDevices; } @@ -100,4 +120,3 @@ public class CategorizedSubscriptionResult { this.subscribedDevices = subscribedDevices; } } - diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java index de9f2977e6..c8ca40813a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java @@ -233,8 +233,9 @@ public interface SubscriptionManager { * @return {@link SubscriptionsDTO} which contains the details of subscriptions. * @throws ApplicationManagementException if an error occurs while fetching the group details */ - List getGroupsSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, int limit) - throws ApplicationManagementException; + public List getGroupsSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, + PaginationRequest request, int offset, + int limit) throws ApplicationManagementException; /** * Retrieves the user details associated with a given app release UUID. @@ -246,8 +247,8 @@ public interface SubscriptionManager { * @return {@link SubscriptionsDTO} which contains the details of subscriptions. * @throws ApplicationManagementException if an error occurs while fetching the user details */ - List getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) - throws ApplicationManagementException; + List getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, PaginationRequest request, + int offset, int limit) throws ApplicationManagementException; /** * Retrieves the Role details associated with a given app release UUID. @@ -259,8 +260,8 @@ public interface SubscriptionManager { * @return {@link SubscriptionsDTO} which contains the details of subscriptions. * @throws ApplicationManagementException if an error occurs while fetching the role details */ - List getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) - throws ApplicationManagementException; + List getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, PaginationRequest request, + int offset, int limit) throws ApplicationManagementException; /** * Retrieves the Device Subscription details associated with a given app release UUID. @@ -272,8 +273,9 @@ public interface SubscriptionManager { * @return {@link DeviceSubscriptionResponseDTO} which contains the details of device subscriptions. * @throws ApplicationManagementException if an error occurs while fetching the device subscription details */ - DeviceSubscriptionResponseDTO getDeviceSubscriptionsDetailsByUUID(String uuid, String subscriptionStatus, int offset, int limit) - throws ApplicationManagementException; + DeviceSubscriptionResponseDTO getDeviceSubscriptionsDetailsByUUID(String uuid, String subscriptionStatus, + PaginationRequest request, int offset, + int limit) throws ApplicationManagementException; /** * Retrieves the All Device details associated with a given app release UUID. @@ -285,8 +287,9 @@ public interface SubscriptionManager { * @return {@link DeviceSubscriptionResponseDTO} which contains the details of device subscriptions. * @throws ApplicationManagementException if an error occurs while fetching the subscription details */ - DeviceSubscriptionResponseDTO getAllSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, int limit) - throws ApplicationManagementException; + DeviceSubscriptionResponseDTO getAllSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, + PaginationRequest request, int offset, + int limit) throws ApplicationManagementException; /** * This method is responsible for retrieving device subscription details related to the given UUID. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java index 3bc8918fcc..ec3717391a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java @@ -390,12 +390,16 @@ public interface SubscriptionDAO { * @param appReleaseId the appReleaseId of the application release. * @param unsubscribe the Status of the subscription. * @param tenantId id of the current tenant. + * @param actionStatus Status of the action + * @param actionType type of the action + * @param actionTriggeredBy subscribed by * @param deviceIds deviceIds deviceIds to retrieve data. * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. */ - List getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId, List deviceIds) - throws ApplicationManagementDAOException; + List getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId, + List deviceIds, String actionStatus, String actionType, + String actionTriggeredBy, String tabActionStatus) throws ApplicationManagementDAOException; /** * This method is used to get the details of device subscriptions related to a UUID. @@ -403,13 +407,16 @@ public interface SubscriptionDAO { * @param appReleaseId the appReleaseId of the application release. * @param unsubscribe the Status of the subscription. * @param tenantId id of the current tenant. + * @param actionStatus Status of the action + * @param actionType type of the action + * @param actionTriggeredBy subscribed by * @param offset the offset for the data set * @param limit the limit for the data set * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. */ - List getAllSubscriptionsDetails(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) - throws ApplicationManagementDAOException; + List getAllSubscriptionsDetails(int appReleaseId, boolean unsubscribe, int tenantId, String actionStatus, String actionType, + String actionTriggeredBy, int offset, int limit) throws ApplicationManagementDAOException; /** * This method is used to get the counts of all subscription types related to a UUID. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index fb2e2cffd6..8ffb95f039 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -1911,8 +1911,9 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public List getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId, List deviceIds) - throws ApplicationManagementDAOException { + public List getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId, + List deviceIds, String actionStatus, String actionType, + String actionTriggeredBy, String tabActionStatus) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting device subscriptions for the application release id " + appReleaseId + " and device ids " + deviceIds + " from the database"); @@ -1920,7 +1921,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc try { Connection conn = this.getDBConnection(); String subscriptionStatusTime = unsubscribe ? "DS.UNSUBSCRIBED_TIMESTAMP" : "DS.SUBSCRIBED_TIMESTAMP"; - String sql = "SELECT " + StringBuilder sql = new StringBuilder("SELECT " + "DS.ID AS ID, " + "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, " + "DS.SUBSCRIBED_TIMESTAMP AS SUBSCRIBED_AT, " @@ -1932,16 +1933,39 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc + "DS.DM_DEVICE_ID AS DEVICE_ID " + "FROM AP_DEVICE_SUBSCRIPTION DS " + "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.UNSUBSCRIBED = ? AND DS.TENANT_ID = ? AND DS.DM_DEVICE_ID IN (" + - deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ") " - + "ORDER BY " + subscriptionStatusTime + " DESC"; + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ") "); - try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setInt(1, appReleaseId); - ps.setBoolean(2, unsubscribe); - ps.setInt(3, tenantId); + if (actionStatus != null && !actionStatus.isEmpty()) { + sql.append(" AND DS.STATUS = ? "); + } + if (actionType != null && !actionType.isEmpty()) { + sql.append(" AND DS.ACTION_TRIGGERED_FROM = ? "); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + sql.append(" AND DS.SUBSCRIBED_BY LIKE ? "); + } + + sql.append("ORDER BY ").append(subscriptionStatusTime).append(" DESC"); + + try (PreparedStatement ps = conn.prepareStatement(sql.toString())) { + int paramIdx = 1; + ps.setInt(paramIdx++, appReleaseId); + ps.setBoolean(paramIdx++, unsubscribe); + ps.setInt(paramIdx++, tenantId); for (int i = 0; i < deviceIds.size(); i++) { - ps.setInt(4 + i, deviceIds.get(i)); + ps.setInt(paramIdx++, deviceIds.get(i)); } + + if (actionStatus != null && !actionStatus.isEmpty()) { + ps.setString(paramIdx++, actionStatus); + } + if (actionType != null && !actionType.isEmpty()) { + ps.setString(paramIdx++, actionType); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + ps.setString(paramIdx++, "%" + actionTriggeredBy + "%"); + } + try (ResultSet rs = ps.executeQuery()) { if (log.isDebugEnabled()) { log.debug("Successfully retrieved device subscriptions for application release id " @@ -1980,6 +2004,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc @Override public List getAllSubscriptionsDetails(int appReleaseId, boolean unsubscribe, int tenantId, + String actionStatus, String actionType, String actionTriggeredBy, int offset, int limit) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting device subscriptions for the application release id " + appReleaseId @@ -1987,7 +2012,8 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } String subscriptionStatusTime = unsubscribe ? "DS.UNSUBSCRIBED_TIMESTAMP" : "DS.SUBSCRIBED_TIMESTAMP"; - String sql = "SELECT " + String actionTriggeredColumn = unsubscribe ? "DS.UNSUBSCRIBED_BY" : "DS.SUBSCRIBED_BY"; + StringBuilder sql = new StringBuilder("SELECT " + "DS.ID AS ID, " + "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, " + "DS.SUBSCRIBED_TIMESTAMP AS SUBSCRIBED_AT, " @@ -1995,21 +2021,45 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc + "DS.UNSUBSCRIBED_BY AS UNSUBSCRIBED_BY, " + "DS.UNSUBSCRIBED_TIMESTAMP AS UNSUBSCRIBED_AT, " + "DS.ACTION_TRIGGERED_FROM AS ACTION_TRIGGERED_FROM, " - + "DS.STATUS AS STATUS," + + "DS.STATUS AS STATUS, " + "DS.DM_DEVICE_ID AS DEVICE_ID " + "FROM AP_DEVICE_SUBSCRIPTION DS " - + "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.UNSUBSCRIBED = ? AND DS.TENANT_ID=? " - + "ORDER BY " + subscriptionStatusTime + " DESC " - + "LIMIT ? OFFSET ?"; + + "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.UNSUBSCRIBED = ? AND DS.TENANT_ID = ? "); + + if (actionStatus != null && !actionStatus.isEmpty()) { + sql.append(" AND DS.STATUS = ? "); + } + if (actionType != null && !actionType.isEmpty()) { + sql.append(" AND DS.ACTION_TRIGGERED_FROM = ? "); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + sql.append(" AND ").append(actionTriggeredColumn).append(" LIKE ? "); + } + + sql.append("ORDER BY ").append(subscriptionStatusTime).append(" DESC ") + .append("LIMIT ? OFFSET ?"); try { Connection conn = this.getDBConnection(); - try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setInt(1, appReleaseId); - ps.setBoolean(2, unsubscribe); - ps.setInt(3, tenantId); - ps.setInt(4, limit); - ps.setInt(5, offset); + try (PreparedStatement ps = conn.prepareStatement(sql.toString())) { + int paramIdx = 1; + ps.setInt(paramIdx++, appReleaseId); + ps.setBoolean(paramIdx++, unsubscribe); + ps.setInt(paramIdx++, tenantId); + + if (actionStatus != null && !actionStatus.isEmpty()) { + ps.setString(paramIdx++, actionStatus); + } + if (actionType != null && !actionType.isEmpty()) { + ps.setString(paramIdx++, actionType); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + ps.setString(paramIdx++, "%" + actionTriggeredBy + "%"); + } + + ps.setInt(paramIdx++, limit); + ps.setInt(paramIdx++, offset); + try (ResultSet rs = ps.executeQuery()) { if (log.isDebugEnabled()) { log.debug("Successfully retrieved device subscriptions for application release id " @@ -2040,7 +2090,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "Error occurred while while running SQL to get device subscription data for application ID: " + appReleaseId; + String msg = "Error occurred while running SQL to get device subscription data for application ID: " + appReleaseId; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 498abe0b02..a8a0a8cfa6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1704,12 +1704,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public List getGroupsSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, - int limit) throws ApplicationManagementException { + public List getGroupsSubscriptionDetailsByUUID( + String uuid, String subscriptionStatus, PaginationRequest request, int offset, int limit) + throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); - String groupName; - String status; try { ConnectionManagerUtil.openDBConnection(); @@ -1720,8 +1720,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new NotFoundException(msg); } + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - List groupDetailsWithDevices = new ArrayList<>(); List groupDetails = @@ -1733,11 +1733,18 @@ public class SubscriptionManagerImpl implements SubscriptionManager { GroupManagementProviderService groupManagementProviderService = HelperUtil.getGroupManagementProviderService(); for (GroupSubscriptionDTO groupDetail : groupDetails) { - groupName = groupDetail.getGroupName(); + + if (StringUtils.isNotBlank(request.getGroupName()) && !request.getGroupName().equals(groupDetail.getGroupName())) { + continue; + } + + String groupName = StringUtils.isNotBlank(request.getGroupName()) ? request.getGroupName() : groupDetail.getGroupName(); // Retrieve group details and device IDs for the group using the service layer GroupDetailsDTO groupDetailWithDevices = - groupManagementProviderService.getGroupDetailsWithDevices(groupName, offset, limit); + groupManagementProviderService.getGroupDetailsWithDevices( + groupName, applicationDTO.getDeviceTypeId(), request.getOwner(), + request.getDeviceName(), request.getDeviceStatus(), offset, limit); SubscriptionsDTO groupDetailDTO = new SubscriptionsDTO(); groupDetailDTO.setId(groupDetailWithDevices.getGroupId()); @@ -1760,24 +1767,29 @@ public class SubscriptionManagerImpl implements SubscriptionManager { List deviceIds = groupDetailWithDevices.getDeviceIds(); Map statusCounts = new HashMap<>(); - statusCounts.put("PENDING", 0); statusCounts.put("COMPLETED", 0); statusCounts.put("ERROR", 0); + statusCounts.put("PENDING", 0); statusCounts.put("NEW", 0); statusCounts.put("SUBSCRIBED", 0); - // Get subscribed devices if unsubscribed devices are requested - List subscribedDeviceSubscriptions = new ArrayList<>(); - if (unsubscribe) { - subscribedDeviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - appReleaseId, !unsubscribe, tenantId, deviceIds); - } - for (Integer deviceId : deviceIds) { - List deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - groupDetail.getAppReleaseId(), unsubscribe, tenantId, deviceIds); + // Get subscribed devices if unsubscribed devices are requested + List deviceSubscriptions; + if (unsubscribe) { + deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( + appReleaseId, !unsubscribe, tenantId, deviceIds, + request.getActionStatus(), request.getActionType(), request.getActionTriggeredBy(), request.getTabActionStatus()); + } else { + deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( + groupDetail.getAppReleaseId(), false, tenantId, deviceIds, + request.getActionStatus(), request.getActionType(), request.getActionTriggeredBy(), request.getTabActionStatus()); + } + List filteredDeviceSubscriptions = deviceSubscriptions.stream() + .filter(subscription -> StringUtils.isBlank(request.getTabActionStatus()) || subscription.getStatus().equals(request.getTabActionStatus())) + .collect(Collectors.toList()); boolean isNewDevice = true; - for (DeviceSubscriptionDTO subscription : deviceSubscriptions) { + for (DeviceSubscriptionDTO subscription : filteredDeviceSubscriptions) { if (subscription.getDeviceId() == deviceId) { DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); deviceDetail.setDeviceId(subscription.getDeviceId()); @@ -1795,7 +1807,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceDetail.setType(groupDetailWithDevices.getDeviceTypes().get(deviceId)); deviceDetail.setDeviceIdentifier(groupDetailWithDevices.getDeviceIdentifiers().get(deviceId)); - status = subscription.getStatus(); + String status = subscription.getStatus(); switch (status) { case "COMPLETED": installedDevices.add(deviceDetail); @@ -1813,13 +1825,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager { pendingDevices.add(deviceDetail); statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); break; + default: + newDevices.add(deviceDetail); + statusCounts.put("NEW", statusCounts.get("NEW") + 1); + break; } isNewDevice = false; } } if (isNewDevice) { boolean isSubscribedDevice = false; - for (DeviceSubscriptionDTO subscribedDevice : subscribedDeviceSubscriptions) { + for (DeviceSubscriptionDTO subscribedDevice : deviceSubscriptions) { if (subscribedDevice.getDeviceId() == deviceId) { DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); @@ -1861,17 +1877,38 @@ public class SubscriptionManagerImpl implements SubscriptionManager { statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); } - CategorizedSubscriptionResult categorizedSubscriptionResult; - if (subscribedDevices.isEmpty()) { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + List requestedDevices = new ArrayList<>(); + if (StringUtils.isNotBlank(request.getTabActionStatus())) { + switch (request.getTabActionStatus()) { + case "COMPLETED": + requestedDevices = installedDevices; + break; + case "PENDING": + requestedDevices = pendingDevices; + break; + case "ERROR": + requestedDevices = errorDevices; + break; + case "NEW": + requestedDevices = newDevices; + break; + case "SUBSCRIBED": + requestedDevices = subscribedDevices; + break; + } + groupDetailDTO.setDevices(new CategorizedSubscriptionResult(requestedDevices, request.getTabActionStatus())); } else { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); + CategorizedSubscriptionResult categorizedSubscriptionResult; + if (subscribedDevices.isEmpty()) { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + } else { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); + } + groupDetailDTO.setDevices(categorizedSubscriptionResult); } - groupDetailDTO.setDevices(categorizedSubscriptionResult); groupDetailDTO.setStatusPercentages(statusPercentages); - groupDetailsWithDevices.add(groupDetailDTO); } @@ -1894,11 +1931,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public List getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) + public List getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, + PaginationRequest request, int offset, int limit) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); - String userName; String status; try { @@ -1910,8 +1947,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new NotFoundException(msg); } + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - List userSubscriptionsWithDevices = new ArrayList<>(); List userSubscriptions = @@ -1923,11 +1960,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager { DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); for (SubscriptionsDTO userSubscription : userSubscriptions) { - userName = userSubscription.getName(); + + if (StringUtils.isNotBlank(request.getUserName()) && !request.getUserName().equals(userSubscription.getName())) { + continue; + } + + String userName = StringUtils.isNotBlank(request.getUserName()) ? request.getUserName() : userSubscription.getName(); // Retrieve owner details and device IDs for the user using the service layer OwnerWithDeviceDTO ownerDetailsWithDevices = - deviceManagementProviderService.getOwnersWithDeviceIds(userName); + deviceManagementProviderService.getOwnersWithDeviceIds(userName, applicationDTO.getDeviceTypeId(), + request.getOwner(), request.getDeviceName(), request.getDeviceStatus()); SubscriptionsDTO userSubscriptionDTO = new SubscriptionsDTO(); userSubscriptionDTO.setName(userSubscription.getName()); @@ -1958,21 +2001,29 @@ public class SubscriptionManagerImpl implements SubscriptionManager { List subscribedDeviceSubscriptions = new ArrayList<>(); if (unsubscribe) { subscribedDeviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - appReleaseId, !unsubscribe, tenantId, deviceIds); + appReleaseId, !unsubscribe, tenantId, deviceIds, request.getActionStatus(), request.getActionType(), + request.getActionTriggeredBy(), request.getTabActionStatus()); } for (Integer deviceId : deviceIds) { List deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - userSubscription.getAppReleaseId(), unsubscribe, tenantId, deviceIds); + userSubscription.getAppReleaseId(), unsubscribe, tenantId, deviceIds, request.getActionStatus(), request.getActionType(), + request.getActionTriggeredBy(), request.getTabActionStatus()); + OwnerWithDeviceDTO ownerWithDeviceByDeviceId = + deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId, request.getOwner(), request.getDeviceName(), + request.getDeviceStatus()); + if (ownerWithDeviceByDeviceId == null) { + continue; + } boolean isNewDevice = true; for (DeviceSubscriptionDTO subscription : deviceSubscriptions) { if (subscription.getDeviceId() == deviceId) { DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); deviceDetail.setDeviceId(subscription.getDeviceId()); deviceDetail.setSubId(subscription.getId()); - deviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - deviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); - deviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); + deviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + deviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); + deviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); deviceDetail.setActionType(subscription.getActionTriggeredFrom()); deviceDetail.setStatus(subscription.getStatus()); deviceDetail.setActionType(subscription.getActionTriggeredFrom()); @@ -1981,8 +2032,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); - deviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - deviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + deviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + deviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); status = subscription.getStatus(); switch (status) { @@ -2012,16 +2063,16 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (subscribedDevice.getDeviceId() == deviceId) { DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); - subscribedDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); - subscribedDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - subscribedDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + subscribedDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); + subscribedDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + subscribedDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); subscribedDeviceDetail.setSubId(subscribedDevice.getId()); subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); - subscribedDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - subscribedDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + subscribedDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + subscribedDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); subscribedDevices.add(subscribedDeviceDetail); statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); isSubscribedDevice = true; @@ -2031,11 +2082,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (!isSubscribedDevice) { DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); newDeviceDetail.setDeviceId(deviceId); - newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); - newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); - newDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - newDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + newDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + newDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); + newDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); + newDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + newDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); newDevices.add(newDeviceDetail); statusCounts.put("NEW", statusCounts.get("NEW") + 1); } @@ -2050,20 +2101,42 @@ public class SubscriptionManagerImpl implements SubscriptionManager { statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); } - CategorizedSubscriptionResult categorizedSubscriptionResult; - if (subscribedDevices.isEmpty()) { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + List requestedDevices = new ArrayList<>(); + if (StringUtils.isNotBlank(request.getTabActionStatus())) { + switch (request.getTabActionStatus()) { + case "COMPLETED": + requestedDevices = installedDevices; + break; + case "PENDING": + requestedDevices = pendingDevices; + break; + case "ERROR": + requestedDevices = errorDevices; + break; + case "NEW": + requestedDevices = newDevices; + break; + case "SUBSCRIBED": + requestedDevices = subscribedDevices; + break; + } + userSubscriptionDTO.setDevices(new CategorizedSubscriptionResult(requestedDevices, request.getTabActionStatus())); } else { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); - } - userSubscriptionDTO.setDevices(categorizedSubscriptionResult); - userSubscriptionDTO.setStatusPercentages(statusPercentages); + CategorizedSubscriptionResult categorizedSubscriptionResult; + if (subscribedDevices.isEmpty()) { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + } else { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, + subscribedDevices); + } + userSubscriptionDTO.setDevices(categorizedSubscriptionResult); + userSubscriptionDTO.setStatusPercentages(statusPercentages); + } userSubscriptionsWithDevices.add(userSubscriptionDTO); } - return userSubscriptionsWithDevices; } catch (ApplicationManagementDAOException e) { String msg = "Error occurred while getting user subscriptions for the application release UUID: " + uuid; @@ -2081,7 +2154,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public List getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) + public List getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, + PaginationRequest request, int offset, int limit) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); @@ -2097,8 +2171,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new NotFoundException(msg); } + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); - List roleSubscriptionsWithDevices = new ArrayList<>(); List roleSubscriptions = @@ -2110,7 +2184,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); for (SubscriptionsDTO roleSubscription : roleSubscriptions) { - roleName = roleSubscription.getName(); + + roleName = StringUtils.isNotBlank(request.getRoleName()) ? request.getRoleName() : roleSubscription.getName(); SubscriptionsDTO roleSubscriptionDTO = new SubscriptionsDTO(); roleSubscriptionDTO.setName(roleSubscription.getName()); @@ -2139,7 +2214,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { for (String user : users) { OwnerWithDeviceDTO ownerDetailsWithDevices; try { - ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(user); + ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(user, applicationDTO.getDeviceTypeId(), + request.getOwner(), request.getDeviceName(), request.getDeviceStatus()); } catch (DeviceManagementDAOException e) { throw new ApplicationManagementException("Error retrieving owner details with devices for user: " + user, e); } @@ -2150,13 +2226,20 @@ public class SubscriptionManagerImpl implements SubscriptionManager { List subscribedDeviceSubscriptions = new ArrayList<>(); if (unsubscribe) { subscribedDeviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - appReleaseId, !unsubscribe, tenantId, deviceIds); + appReleaseId, !unsubscribe, tenantId, deviceIds, request.getActionStatus(), request.getActionType(), + request.getActionTriggeredBy(), request.getTabActionStatus()); + } + OwnerWithDeviceDTO ownerWithDeviceByDeviceId = + deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId, request.getOwner(), request.getDeviceName(), + request.getDeviceStatus()); + if (ownerWithDeviceByDeviceId == null) { + continue; } - List deviceSubscriptions; try { deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - roleSubscription.getAppReleaseId(), unsubscribe, tenantId, deviceIds); + roleSubscription.getAppReleaseId(), unsubscribe, tenantId, deviceIds, request.getActionStatus(), + request.getActionType(), request.getActionTriggeredBy(), request.getTabActionStatus()); } catch (ApplicationManagementDAOException e) { throw new ApplicationManagementException("Error retrieving device subscriptions", e); } @@ -2166,9 +2249,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (deviceSubscription.getDeviceId() == deviceId) { DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); deviceDetail.setDeviceId(deviceSubscription.getDeviceId()); - deviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); - deviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - deviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + deviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); + deviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + deviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); deviceDetail.setActionType(deviceSubscription.getActionTriggeredFrom()); deviceDetail.setStatus(deviceSubscription.getStatus()); deviceDetail.setActionType(deviceSubscription.getActionTriggeredFrom()); @@ -2178,8 +2261,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { deviceDetail.setUnsubscribed(deviceSubscription.isUnsubscribed()); deviceDetail.setUnsubscribedBy(deviceSubscription.getUnsubscribedBy()); deviceDetail.setUnsubscribedTimestamp(deviceSubscription.getUnsubscribedTimestamp()); - deviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - deviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + deviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + deviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); status = deviceSubscription.getStatus(); switch (status) { @@ -2209,16 +2292,16 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (subscribedDevice.getDeviceId() == deviceId) { DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); - subscribedDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); - subscribedDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - subscribedDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); + subscribedDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); + subscribedDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + subscribedDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); subscribedDeviceDetail.setSubId(subscribedDevice.getId()); subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); - subscribedDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - subscribedDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + subscribedDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + subscribedDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); subscribedDevices.add(subscribedDeviceDetail); statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); isSubscribedDevice = true; @@ -2228,11 +2311,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (!isSubscribedDevice) { DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); newDeviceDetail.setDeviceId(deviceId); - newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames()); - newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); - newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); - newDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes()); - newDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers()); + newDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); + newDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); + newDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); + newDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); + newDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); newDevices.add(newDeviceDetail); statusCounts.put("NEW", statusCounts.get("NEW") + 1); } @@ -2249,23 +2332,46 @@ public class SubscriptionManagerImpl implements SubscriptionManager { statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); } - CategorizedSubscriptionResult categorizedSubscriptionResult; - if (subscribedDevices.isEmpty()) { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); - } else { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); - } - roleSubscriptionDTO.setDevices(categorizedSubscriptionResult); - roleSubscriptionDTO.setStatusPercentages(statusPercentages); - roleSubscriptionDTO.setDeviceCount(totalDevices); + List requestedDevices = new ArrayList<>(); + if (StringUtils.isNotBlank(request.getTabActionStatus())) { + switch (request.getTabActionStatus()) { + case "COMPLETED": + requestedDevices = installedDevices; + break; + case "PENDING": + requestedDevices = pendingDevices; + break; + case "ERROR": + requestedDevices = errorDevices; + break; + case "NEW": + requestedDevices = newDevices; + break; + case "SUBSCRIBED": + requestedDevices = subscribedDevices; + break; + } + roleSubscriptionDTO.setDevices(new CategorizedSubscriptionResult(requestedDevices, request.getTabActionStatus())); + } else { + CategorizedSubscriptionResult categorizedSubscriptionResult; + if (subscribedDevices.isEmpty()) { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + } else { + categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, + subscribedDevices); + } + roleSubscriptionDTO.setDevices(categorizedSubscriptionResult); + roleSubscriptionDTO.setStatusPercentages(statusPercentages); + roleSubscriptionDTO.setDeviceCount(totalDevices); + } roleSubscriptionsWithDevices.add(roleSubscriptionDTO); } return roleSubscriptionsWithDevices; - } catch (ApplicationManagementDAOException e) { + } catch (ApplicationManagementDAOException | DeviceManagementDAOException e) { String msg = "Error occurred in retrieving role subscriptions with devices"; log.error(msg, e); throw new ApplicationManagementException(msg, e); @@ -2292,7 +2398,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public DeviceSubscriptionResponseDTO getDeviceSubscriptionsDetailsByUUID(String uuid, String subscriptionStatus, int offset, + public DeviceSubscriptionResponseDTO getDeviceSubscriptionsDetailsByUUID(String uuid, String subscriptionStatus, PaginationRequest request, int offset, int limit) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); @@ -2307,6 +2413,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new NotFoundException(msg); } + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); @@ -2321,7 +2428,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } List allDevices = - deviceManagementProviderService.getDevicesByTenantId(tenantId); + deviceManagementProviderService.getDevicesByTenantId(tenantId, applicationDTO.getDeviceTypeId(), + request.getOwner(), request.getDeviceStatus()); List deviceIds = allDevices.stream() .map(DeviceDetailsDTO::getDeviceId) @@ -2346,9 +2454,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager { .collect(Collectors.toMap(DeviceDetailsDTO::getDeviceId, Function.identity())); List allSubscriptionsForUnSubscribed = - subscriptionDAO.getSubscriptionDetailsByDeviceIds(appReleaseId, !unsubscribe, tenantId, deviceIds); + subscriptionDAO.getSubscriptionDetailsByDeviceIds(appReleaseId, !unsubscribe, tenantId, deviceIds, request.getActionStatus(), + request.getActionType(), request.getActionTriggeredBy(), request.getTabActionStatus()); List allSubscriptionsForSubscribed = - subscriptionDAO.getSubscriptionDetailsByDeviceIds(appReleaseId, unsubscribe, tenantId, deviceIds); + subscriptionDAO.getSubscriptionDetailsByDeviceIds(appReleaseId, unsubscribe, tenantId, deviceIds, request.getActionStatus(), + request.getActionType(), request.getActionTriggeredBy(), request.getTabActionStatus()); Map allSubscriptionForUnSubscribedMap = allSubscriptionsForUnSubscribed.stream() .collect(Collectors.toMap(DeviceSubscriptionDTO::getDeviceId, Function.identity())); Map allSubscriptionForSubscribedMap = allSubscriptionsForSubscribed.stream() @@ -2357,7 +2467,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { for (DeviceDetailsDTO device : allDevices) { Integer deviceId = device.getDeviceId(); OwnerWithDeviceDTO ownerWithDevice = - deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId); + deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId, request.getOwner(), request.getDeviceName(), + request.getDeviceStatus()); if (ownerWithDevice == null) { continue; } @@ -2450,14 +2561,35 @@ public class SubscriptionManagerImpl implements SubscriptionManager { statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); } - CategorizedSubscriptionResult categorizedSubscriptionResult; - if (subscribedDevices.isEmpty()) { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + List requestedDevices = new ArrayList<>(); + if (StringUtils.isNotBlank(request.getTabActionStatus())) { + switch (request.getTabActionStatus()) { + case "COMPLETED": + requestedDevices = installedDevices; + break; + case "PENDING": + requestedDevices = pendingDevices; + break; + case "ERROR": + requestedDevices = errorDevices; + break; + case "NEW": + requestedDevices = newDevices; + break; + case "SUBSCRIBED": + requestedDevices = subscribedDevices; + break; + } } else { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); + requestedDevices.addAll(installedDevices); + requestedDevices.addAll(pendingDevices); + requestedDevices.addAll(errorDevices); + requestedDevices.addAll(newDevices); + requestedDevices.addAll(subscribedDevices); } + + CategorizedSubscriptionResult categorizedSubscriptionResult = + new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); DeviceSubscriptionResponseDTO deviceSubscriptionResponse = new DeviceSubscriptionResponseDTO(totalDevices, statusPercentages, categorizedSubscriptionResult); @@ -2479,8 +2611,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public DeviceSubscriptionResponseDTO getAllSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, int limit) - throws ApplicationManagementException { + public DeviceSubscriptionResponseDTO getAllSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, PaginationRequest request, + int offset, int limit) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); @@ -2493,10 +2625,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.error(msg); throw new NotFoundException(msg); } + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); int appReleaseId = applicationReleaseDTO.getId(); List allSubscriptions = - subscriptionDAO.getAllSubscriptionsDetails(appReleaseId, unsubscribe, tenantId, offset, limit); + subscriptionDAO.getAllSubscriptionsDetails(appReleaseId, unsubscribe, tenantId, request.getActionStatus(), + request.getActionType(), request.getActionTriggeredBy(), offset, limit); // empty response for no subscriptions if (allSubscriptions.isEmpty()) { @@ -2522,12 +2656,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager { statusCounts.put("NEW", 0); List allDevices = - deviceManagementProviderService.getDevicesByTenantId(tenantId); + deviceManagementProviderService.getDevicesByTenantId(tenantId, applicationDTO.getDeviceTypeId(), request.getOwner(), + request.getDeviceStatus()); for (DeviceDetailsDTO device : allDevices) { Integer deviceId = device.getDeviceId(); OwnerWithDeviceDTO ownerWithDevice = - deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId); + deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId, request.getOwner(), request.getDeviceName(), + request.getDeviceStatus()); if (ownerWithDevice == null) { continue; } @@ -2590,6 +2726,29 @@ public class SubscriptionManagerImpl implements SubscriptionManager { statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); } + List requestedDevices = new ArrayList<>(); + if (StringUtils.isNotBlank(request.getTabActionStatus())) { + switch (request.getTabActionStatus()) { + case "COMPLETED": + requestedDevices = installedDevices; + break; + case "PENDING": + requestedDevices = pendingDevices; + break; + case "ERROR": + requestedDevices = errorDevices; + break; + case "NEW": + requestedDevices = newDevices; + break; + } + } else { + requestedDevices.addAll(installedDevices); + requestedDevices.addAll(pendingDevices); + requestedDevices.addAll(errorDevices); + requestedDevices.addAll(newDevices); + } + CategorizedSubscriptionResult categorizedSubscriptionResult = new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); DeviceSubscriptionResponseDTO result = diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java index c0783fe18f..95b8a92c6c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java @@ -41,6 +41,14 @@ public class PaginationRequest { private Date since; private String filter; private String serialNumber; + private String groupName; + private String roleName; + private String userName; + private String deviceStatus; + private String tabActionStatus; + private String actionStatus; + private String actionType; + private String actionTriggeredBy; private Map customProperty = new HashMap<>(); private Map property = new HashMap<>(); private List statusList = new ArrayList<>(); @@ -220,4 +228,68 @@ public class PaginationRequest { + this.ownership + "' Status '" + this.statusList + "' owner '" + this.owner + "' groupId: " + this.groupId + " start index: " + this.startIndex + ", SortColumns: " + this.sortColumn; } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public String getActionStatus() { + return actionStatus; + } + + public void setActionStatus(String actionStatus) { + this.actionStatus = actionStatus; + } + + public String getActionType() { + return actionType; + } + + public void setActionType(String actionType) { + this.actionType = actionType; + } + + public String getActionTriggeredBy() { + return actionTriggeredBy; + } + + public void setActionTriggeredBy(String actionTriggeredBy) { + this.actionTriggeredBy = actionTriggeredBy; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getTabActionStatus() { + return tabActionStatus; + } + + public void setTabActionStatus(String tabActionStatus) { + this.tabActionStatus = tabActionStatus; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java index 93c456f929..70b791db7b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/EnrollmentDAO.java @@ -101,29 +101,42 @@ public interface EnrollmentDAO { * Retrieves owners and the list of device IDs related to an owner. * * @param owner the owner whose device IDs need to be retrieved + * @param allowingDeviceStatuses statuses of devices need to be retrieved * @param tenantId the ID of the tenant + * @param deviceOwner owner of the device + * @param deviceName name of the device + * @param deviceStatus status of the device * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - OwnerWithDeviceDTO getOwnersWithDevices(String owner, int tenantId) throws DeviceManagementDAOException; + OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId, int deviceTypeId, + String deviceOwner, String deviceName, String deviceStatus) throws DeviceManagementDAOException; /** * Retrieves a list of device IDs with owners and device status. * * @param deviceId the deviceId of the device which user need to be retrieved * @param tenantId the ID of the tenant + * @param deviceOwner owner of the device + * @param deviceName name of the device + * @param deviceStatus status of the device * @return {@link OwnerWithDeviceDTO} which contains a list of devices * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, int tenantId) + OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, int tenantId, String deviceOwner, String deviceName, String deviceStatus) throws DeviceManagementDAOException; /** * Retrieves owners and the list of device IDs with device status. * * @param tenantId the ID of the tenant + * @param allowingDeviceStatuses the allowed device statuses of devices + * @param deviceTypeId the device type id + * @param deviceOwner owner of the device + * @param deviceStatus status of the device * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user * @throws DeviceManagementDAOException if an error occurs while fetching the data */ - List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException; + List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses, int deviceTypeId, String deviceOwner, + String deviceStatus) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 5071f7a400..c5d2d700cd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -473,13 +473,19 @@ public interface GroupDAO { * Get group details and list of device IDs related to the group. * * @param groupName Group name + * @param allowingDeviceStatuses the statuses of devices + * @param deviceTypeId the device type id * @param tenantId Tenant ID + * @param deviceOwner owner of the device + * @param deviceName name of the device + * @param deviceStatus status of the device * @param offset the offset for the data set * @param limit the limit for the data set * @return {@link GroupDetailsDTO} which containing group details and a list of device IDs * @throws GroupManagementDAOException if an error occurs while retrieving the group details and devices */ - GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int tenantId, int offset, int limit) + GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowingDeviceStatuses, int deviceTypeId, + int tenantId, String deviceOwner, String deviceName, String deviceStatus, int offset, int limit) throws GroupManagementDAOException; } \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index dad35f0795..1160b4bb79 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -564,30 +564,73 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } @Override - public OwnerWithDeviceDTO getOwnersWithDevices(String owner, int tenantId) - throws DeviceManagementDAOException { + public OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId, + int deviceTypeId, String deviceOwner, String deviceName, + String deviceStatus) throws DeviceManagementDAOException { Connection conn = null; OwnerWithDeviceDTO ownerDetails = new OwnerWithDeviceDTO(); List deviceIds = new ArrayList<>(); int deviceCount = 0; - String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE AS DEVICE_TYPE, e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION " + + StringBuilder deviceFilters = new StringBuilder(); + for (int i = 0; i < allowingDeviceStatuses.size(); i++) { + deviceFilters.append("?"); + if (i < allowingDeviceStatuses.size() - 1) { + deviceFilters.append(","); + } + } + + StringBuilder sql = new StringBuilder( + "SELECT e.DEVICE_ID, " + + "e.OWNER, " + + "e.STATUS AS DEVICE_STATUS, " + + "d.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE AS DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + - "WHERE e.OWNER = ? AND e.TENANT_ID = ?"; + "WHERE e.OWNER = ? AND e.TENANT_ID = ? AND d.DEVICE_TYPE_ID = ? AND e.STATUS IN (" + deviceFilters + ")"); + + if (deviceOwner != null && !deviceOwner.isEmpty()) { + sql.append(" AND e.OWNER LIKE ?"); + } + if (deviceName != null && !deviceName.isEmpty()) { + sql.append(" AND d.NAME LIKE ?"); + } + if (deviceStatus != null && !deviceStatus.isEmpty()) { + sql.append(" AND e.STATUS = ?"); + } + try { conn = this.getConnection(); - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, owner); - stmt.setInt(2, tenantId); + try (PreparedStatement stmt = conn.prepareStatement(sql.toString())) { + int index = 1; + stmt.setString(index++, owner); + stmt.setInt(index++, tenantId); + stmt.setInt(index++, deviceTypeId); + for (String status : allowingDeviceStatuses) { + stmt.setString(index++, status); + } + + if (deviceOwner != null && !deviceOwner.isEmpty()) { + stmt.setString(index++, "%" + deviceOwner + "%"); + } + if (deviceName != null && !deviceName.isEmpty()) { + stmt.setString(index++, "%" + deviceName + "%"); + } + if (deviceStatus != null && !deviceStatus.isEmpty()) { + stmt.setString(index++, deviceStatus); + } try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { if (ownerDetails.getUserName() == null) { ownerDetails.setUserName(rs.getString("OWNER")); - ownerDetails.setDeviceStatus(rs.getString("DEVICE_STATUS")); - ownerDetails.setDeviceNames(rs.getString("DEVICE_NAME")); } + ownerDetails.setDeviceStatus(rs.getString("DEVICE_STATUS")); + ownerDetails.setDeviceNames(rs.getString("DEVICE_NAME")); + ownerDetails.setDeviceTypes(rs.getString("DEVICE_TYPE")); + ownerDetails.setDeviceIdentifiers(rs.getString("DEVICE_IDENTIFICATION")); deviceIds.add(rs.getInt("DEVICE_ID")); deviceCount++; } @@ -598,34 +641,61 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } - ownerDetails.setDeviceIds(deviceIds); - ownerDetails.setDeviceTypes("DEVICE_TYPE"); - ownerDetails.setDeviceIdentifiers("DEVICE_IDENTIFICATION"); ownerDetails.setDeviceCount(deviceCount); return ownerDetails; } @Override - public OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, int tenantId) - throws DeviceManagementDAOException { + public OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, int tenantId, String deviceOwner, String deviceName, + String deviceStatus) throws DeviceManagementDAOException { OwnerWithDeviceDTO deviceOwnerWithStatus = new OwnerWithDeviceDTO(); Connection conn = null; - String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION " + + List deviceIds = new ArrayList<>(); + + StringBuilder sql = new StringBuilder( + "SELECT e.DEVICE_ID, " + + "e.OWNER, " + + "e.STATUS AS DEVICE_STATUS, " + + "d.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE, " + + "e.DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + - "WHERE e.DEVICE_ID = ? AND e.TENANT_ID = ?"; + "WHERE e.DEVICE_ID = ? AND e.TENANT_ID = ?"); + + if (deviceOwner != null && !deviceOwner.isEmpty()) { + sql.append(" AND e.OWNER LIKE ?"); + } + if (deviceName != null && !deviceName.isEmpty()) { + sql.append(" AND d.NAME LIKE ?"); + } + if (deviceStatus != null && !deviceStatus.isEmpty()) { + sql.append(" AND e.STATUS = ?"); + } + try { conn = this.getConnection(); - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, deviceId); - stmt.setInt(2, tenantId); + try (PreparedStatement stmt = conn.prepareStatement(sql.toString())) { + int paramIndex = 1; + stmt.setInt(paramIndex++, deviceId); + stmt.setInt(paramIndex++, tenantId); + + // Set filter parameters if provided + if (deviceOwner != null && !deviceOwner.isEmpty()) { + stmt.setString(paramIndex++, "%" + deviceOwner + "%"); + } + if (deviceName != null && !deviceName.isEmpty()) { + stmt.setString(paramIndex++, "%" + deviceName + "%"); + } + if (deviceStatus != null && !deviceStatus.isEmpty()) { + stmt.setString(paramIndex++, deviceStatus); + } try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { deviceOwnerWithStatus.setUserName(rs.getString("OWNER")); deviceOwnerWithStatus.setDeviceStatus(rs.getString("DEVICE_STATUS")); - List deviceIds = new ArrayList<>(); deviceIds.add(rs.getInt("DEVICE_ID")); deviceOwnerWithStatus.setDeviceIds(deviceIds); deviceOwnerWithStatus.setDeviceNames(rs.getString("DEVICE_NAME")); @@ -643,18 +713,51 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { } @Override - public List getDevicesByTenantId(int tenantId) - throws DeviceManagementDAOException { + public List getDevicesByTenantId(int tenantId, List allowingDeviceStatuses, int deviceTypeId, + String deviceOwner, String deviceStatus) throws DeviceManagementDAOException { List devices = new ArrayList<>(); - String sql = "SELECT DEVICE_ID, OWNER, STATUS, DEVICE_TYPE, DEVICE_IDENTIFICATION " + - "FROM DM_ENROLMENT " + - "WHERE TENANT_ID = ?"; + if (allowingDeviceStatuses.isEmpty()) { + return devices; + } + + StringBuilder deviceFilters = new StringBuilder(); + for (int i = 0; i < allowingDeviceStatuses.size(); i++) { + deviceFilters.append("?"); + if (i < allowingDeviceStatuses.size() - 1) { + deviceFilters.append(","); + } + } + + StringBuilder sql = new StringBuilder("SELECT e.DEVICE_ID, e.OWNER, e.STATUS, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION " + + "FROM DM_ENROLMENT e " + + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + + "WHERE e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ") AND d.DEVICE_TYPE_ID = ?"); + + if (deviceOwner != null && !deviceOwner.isEmpty()) { + sql.append(" AND e.OWNER LIKE ?"); + } + if (deviceStatus != null && !deviceStatus.isEmpty()) { + sql.append(" AND e.STATUS = ?"); + } + Connection conn = null; try { conn = this.getConnection(); - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, tenantId); + try (PreparedStatement stmt = conn.prepareStatement(sql.toString())) { + int index = 1; + stmt.setInt(index++, tenantId); + for (String status : allowingDeviceStatuses) { + stmt.setString(index++, status); + } + stmt.setInt(index++, deviceTypeId); + + if (deviceOwner != null && !deviceOwner.isEmpty()) { + stmt.setString(index++, "%" + deviceOwner + "%"); + } + if (deviceStatus != null && !deviceStatus.isEmpty()) { + stmt.setString(index++, deviceStatus); + } try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 780ba43cc6..1eba6c1a7e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1441,7 +1441,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { } @Override - public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int tenantId, int offset, int limit) + public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, List allowedStatuses, int deviceTypeId, int tenantId, + String deviceOwner, String deviceName, String deviceStatus, int offset, int limit) throws GroupManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get group details and device IDs for group: " + groupName); @@ -1454,7 +1455,15 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { Map deviceTypes = new HashMap<>(); Map deviceIdentifiers = new HashMap<>(); - String sql = + StringBuilder statusPlaceholders = new StringBuilder(); + for (int i = 0; i < allowedStatuses.size(); i++) { + statusPlaceholders.append("?"); + if (i < allowedStatuses.size() - 1) { + statusPlaceholders.append(","); + } + } + + StringBuilder sql = new StringBuilder( "SELECT " + " g.ID AS GROUP_ID, " + " g.GROUP_NAME, " + @@ -1473,16 +1482,45 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { "WHERE " + " g.GROUP_NAME = ? " + " AND g.TENANT_ID = ? " + - "LIMIT ? OFFSET ?"; + " AND d.DEVICE_TYPE_ID = ? " + + " AND e.STATUS IN (" + statusPlaceholders + ")"); + + if (deviceOwner != null && !deviceOwner.isEmpty()) { + sql.append(" AND e.OWNER LIKE ?"); + } + if (deviceName != null && !deviceName.isEmpty()) { + sql.append(" AND d.NAME LIKE ?"); + } + if (deviceStatus != null && !deviceStatus.isEmpty()) { + sql.append(" AND e.STATUS = ?"); + } + + sql.append(" LIMIT ? OFFSET ?"); Connection conn = null; try { conn = GroupManagementDAOFactory.getConnection(); - try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, groupName); - stmt.setInt(2, tenantId); - stmt.setInt(3, limit); - stmt.setInt(4, offset); + try (PreparedStatement stmt = conn.prepareStatement(sql.toString())) { + int index = 1; + stmt.setString(index++, groupName); + stmt.setInt(index++, tenantId); + stmt.setInt(index++, deviceTypeId); + for (String status : allowedStatuses) { + stmt.setString(index++, status); + } + + if (deviceOwner != null && !deviceOwner.isEmpty()) { + stmt.setString(index++, "%" + deviceOwner + "%"); + } + if (deviceName != null && !deviceName.isEmpty()) { + stmt.setString(index++, "%" + deviceName + "%"); + } + if (deviceStatus != null && !deviceStatus.isEmpty()) { + stmt.setString(index++, deviceStatus); + } + + stmt.setInt(index++, limit); + stmt.setInt(index++, offset); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { @@ -1500,6 +1538,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION")); } } + } groupDetails.setDeviceIds(deviceIds); groupDetails.setDeviceCount(deviceIds.size()); groupDetails.setDeviceOwners(deviceOwners); @@ -1508,11 +1547,10 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { groupDetails.setDeviceTypes(deviceTypes); groupDetails.setDeviceIdentifiers(deviceIdentifiers); return groupDetails; + } catch (SQLException e) { + String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; + log.error(msg, e); + throw new GroupManagementDAOException(msg, e); } - } catch (SQLException e) { - String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; - log.error(msg, e); - throw new GroupManagementDAOException(msg, e); - } } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index 9ab44929a1..10d3598ff5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -1082,27 +1082,40 @@ public interface DeviceManagementProviderService { * Get owner details and device IDs for a given owner and tenant. * * @param owner the name of the owner. + * @param deviceTypeId the device type id] + * @param deviceOwner owner of the device + * @param deviceName name of the device + * @param deviceStatus status of the device * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user. * @throws DeviceManagementException if an error occurs while fetching owner details. */ - OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner) throws DeviceManagementDAOException; + OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner, int deviceTypeId, String deviceOwner, String deviceName, String deviceStatus) + throws DeviceManagementDAOException; /** * Get owner details and device IDs for a given owner and tenant. * * @param deviceId the deviceId of the device. + * @param deviceOwner owner of the device + * @param deviceName name of the device + * @param deviceStatus status of the device * @return {@link OwnerWithDeviceDTO} which contains a list of devices related to a user. * @throws DeviceManagementException if an error occurs while fetching owner details. */ - OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId) throws DeviceManagementDAOException; + OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, String deviceOwner, String deviceName, String deviceStatus) + throws DeviceManagementDAOException; /** * Get owner details and device IDs for a given owner and tenant. * @param tenantId the tenant id which devices need to be retried + * @param deviceTypeId the device type id + * @param deviceOwner owner of the device + * @param deviceStatus status of the device * @return {@link DeviceDetailsDTO} which contains devices details. * @throws DeviceManagementException if an error occurs while fetching owner details. */ - List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException; + List getDevicesByTenantId(int tenantId, int deviceTypeId, String deviceOwner, String deviceStatus) + throws DeviceManagementDAOException; /** * Get operation details by operation code. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index a3039ba356..b07f915e43 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -5354,13 +5354,19 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner) throws DeviceManagementDAOException { + public OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner, int deviceTypeId, String deviceOwner, String deviceName, String deviceStatus) + throws DeviceManagementDAOException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); OwnerWithDeviceDTO ownerWithDeviceDTO; + List allowingDeviceStatuses = new ArrayList<>(); + allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.INACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); + try { DeviceManagementDAOFactory.openConnection(); - ownerWithDeviceDTO = this.enrollmentDAO.getOwnersWithDevices(owner, tenantId); + ownerWithDeviceDTO = this.enrollmentDAO.getOwnersWithDevices(owner, allowingDeviceStatuses, tenantId, deviceTypeId, deviceOwner, deviceName, deviceStatus); if (ownerWithDeviceDTO == null) { String msg = "No data found for owner: " + owner; log.error(msg); @@ -5384,13 +5390,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv @Override - public OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId) throws DeviceManagementDAOException { + public OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, String deviceOwner, String deviceName, String deviceStatus) + throws DeviceManagementDAOException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); OwnerWithDeviceDTO deviceOwnerWithStatus; try { DeviceManagementDAOFactory.openConnection(); - deviceOwnerWithStatus = enrollmentDAO.getOwnerWithDeviceByDeviceId(deviceId, tenantId); + deviceOwnerWithStatus = enrollmentDAO.getOwnerWithDeviceByDeviceId(deviceId, tenantId, deviceOwner, deviceName, deviceStatus); if (deviceOwnerWithStatus == null) { throw new DeviceManagementDAOException("No data found for device ID: " + deviceId); } @@ -5411,11 +5418,16 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public List getDevicesByTenantId(int tenantId) throws DeviceManagementDAOException { + public List getDevicesByTenantId(int tenantId, int deviceTypeId, String deviceOwner, String deviceStatus) + throws DeviceManagementDAOException { List devices; + List allowingDeviceStatuses = new ArrayList<>(); + allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.INACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); try { DeviceManagementDAOFactory.openConnection(); - devices = enrollmentDAO.getDevicesByTenantId(tenantId); + devices = enrollmentDAO.getDevicesByTenantId(tenantId, allowingDeviceStatuses, deviceTypeId, deviceOwner, deviceStatus); if (devices == null || devices.isEmpty()) { String msg = "No devices found for tenant ID: " + tenantId; log.error(msg); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index fac06bfccf..3104cff169 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -377,11 +377,16 @@ public interface GroupManagementProviderService { * Get group details and device IDs for a given group name. * * @param groupName the name of the group. + * @param deviceTypeId the device type id + * @param deviceOwner owner of the device + * @param deviceName name of the device + * @param deviceStatus status of the device * @param offset the offset for the data set * @param limit the limit for the data set * @return {@link GroupDetailsDTO} which containing group details and a list of device IDs * @throws GroupManagementException if an error occurs while fetching group details. */ - GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int offset, int limit) throws GroupManagementException; + GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int deviceTypeId, String deviceOwner, String deviceName, String deviceStatus, + int offset, int limit) throws GroupManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index c42feed9b8..c2c00d55c0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.service; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupConstants; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroupRoleWrapper; @@ -1688,17 +1689,22 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid } @Override - public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int offset, int limit) - throws GroupManagementException { + public GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int deviceTypeId, String deviceOwner, String deviceName, String deviceStatus, + int offset, int limit) throws GroupManagementException { if (log.isDebugEnabled()) { log.debug("Retrieving group details and device IDs for group: " + groupName); } int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); GroupDetailsDTO groupDetailsWithDevices; + List allowingDeviceStatuses = new ArrayList<>(); + allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.INACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); try { GroupManagementDAOFactory.openConnection(); - groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, tenantId, offset, limit); + groupDetailsWithDevices = this.groupDAO.getGroupDetailsWithDevices(groupName, allowingDeviceStatuses, + deviceTypeId, tenantId, deviceOwner, deviceName, deviceStatus, offset, limit); } catch (GroupManagementDAOException | SQLException e) { String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName; log.error(msg, e); From 9561e003bf47441302ecc05e3ac26fb08c2d6f75 Mon Sep 17 00:00:00 2001 From: nipuni Date: Mon, 15 Jul 2024 09:14:20 +0530 Subject: [PATCH 246/343] Fix filtering by device name not working with all and device subscriptions --- .../mgt/core/impl/SubscriptionManagerImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index a8a0a8cfa6..065c9576bd 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -2469,10 +2469,10 @@ public class SubscriptionManagerImpl implements SubscriptionManager { OwnerWithDeviceDTO ownerWithDevice = deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId, request.getOwner(), request.getDeviceName(), request.getDeviceStatus()); - if (ownerWithDevice == null) { + if (ownerWithDevice == null || (request.getDeviceName() != null && !request.getDeviceName().isEmpty() && + (ownerWithDevice.getDeviceNames() == null || !ownerWithDevice.getDeviceNames().contains(request.getDeviceName())))) { continue; } - if (deviceSubscriptionMap.containsKey(deviceId)) { DeviceSubscriptionDTO subscription = deviceSubscriptionMap.get(deviceId); DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); @@ -2664,10 +2664,10 @@ public class SubscriptionManagerImpl implements SubscriptionManager { OwnerWithDeviceDTO ownerWithDevice = deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId, request.getOwner(), request.getDeviceName(), request.getDeviceStatus()); - if (ownerWithDevice == null) { + if (ownerWithDevice == null || (request.getDeviceName() != null && !request.getDeviceName().isEmpty() && + (ownerWithDevice.getDeviceNames() == null || !ownerWithDevice.getDeviceNames().contains(request.getDeviceName())))) { continue; } - if (allSubscriptionMap.containsKey(deviceId)) { DeviceSubscriptionDTO subscription = allSubscriptionMap.get(deviceId); DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); From 7496415ab35c79ed16131eb5c6819036181b9c72 Mon Sep 17 00:00:00 2001 From: nipuni Date: Mon, 15 Jul 2024 13:24:45 +0530 Subject: [PATCH 247/343] Add default case in CategorizedSubscriptionResult constructor. --- .../mgt/common/CategorizedSubscriptionResult.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java index e26e567379..18da5a7736 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.application.mgt.common; +import java.util.ArrayList; import java.util.List; public class CategorizedSubscriptionResult { @@ -77,6 +78,13 @@ public class CategorizedSubscriptionResult { case "SUBSCRIBED": this.subscribedDevices = devices; break; + default: + this.installedDevices = new ArrayList<>(); + this.pendingDevices = new ArrayList<>(); + this.errorDevices = new ArrayList<>(); + this.newDevices = new ArrayList<>(); + this.subscribedDevices = new ArrayList<>(); + break; } } From 0ca4d025ee5163d0fc665dd6997884729e7bc92c Mon Sep 17 00:00:00 2001 From: subodhinie Date: Mon, 15 Jul 2024 11:07:55 +0000 Subject: [PATCH 248/343] Add Windows device operation scope: os-updates-info (#406) Co-authored-by: Subodhinie Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/406 Co-authored-by: subodhinie Co-committed-by: subodhinie --- .../src/test/resources/config/operation/mdm-ui-config.xml | 1 + .../src/main/resources/conf/mdm-ui-config.xml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/operation/mdm-ui-config.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/operation/mdm-ui-config.xml index 27ee95b690..0b04668453 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/operation/mdm-ui-config.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/operation/mdm-ui-config.xml @@ -384,6 +384,7 @@ win:ops:device-info win:ops:security-info win:ops:firewall-info + win:ops:os-updates-info admin:tenant:view dm:admin:devices:usage:view and:ops:clear-app diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 65ffa660c8..da4191cff2 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -387,7 +387,10 @@ win:ops:device-info win:ops:security-info win:ops:firewall-info + win:ops:os-updates-info win:microsoft-store:search + win:updates:read + win:update:modify admin:tenant:view dm:admin:devices:usage:view and:ops:clear-app From 6d1414d09f0b041658a18506adb457207fa10d43 Mon Sep 17 00:00:00 2001 From: Jenkins Date: Tue, 16 Jul 2024 08:04:39 +0530 Subject: [PATCH 249/343] [maven-release-plugin] prepare release v5.2.0 --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.common/pom.xml | 2 +- .../cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml | 2 +- components/cea-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/cea-mgt-feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 146 files changed, 148 insertions(+), 148 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index da8cd560b1..67c1232785 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 6eb144dac9..c2c7d515d1 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 4a50a25749..2225ad5265 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 1b3143afce..8ae163dd8d 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 8f8b773e04..9923815c51 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../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 08521c3ee7..1c1bfb6970 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 io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index aee9a07d60..0ed52cc361 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 320ed352a4..e7f37a33e3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 0e072f261c..e1646389f0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml 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 ee586e66c0..ac85d25317 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 io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 316a029fa8..66841e54a2 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index b5a30e4a43..784acfc6a8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 57a433696b..1b219e13a9 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index f9919af1ec..99cc31cb02 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 179902e678..d564685d28 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index b273d85a82..fec2b21fae 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 59a8b05a89..9171161ae1 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index 243bcb838a..e75a2e16fa 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index e3a91006a3..00d6ea88c1 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core cea-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index 7f316508e3..084c05609d 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index 20ba656317..b218c811be 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index 1018889057..8ecde84fd1 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index a40690ca2a..d31cd2f481 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index aa7b0037b5..382d60d4b4 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 89e38b65cc..d9c63334f0 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index c75fc3ff7d..7717eda26b 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index e45887eae1..4845aaa521 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index 947b82651c..ee51c5d395 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index 8f25ed645f..f6ab290dec 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index a9c6dcf699..815baa7e71 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index 5ca85ea9a1..bd4d5aaa2d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index f5ba1b5cd2..412fa0d1d1 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 9bab0bcf9f..5d6a4acbc5 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 2d0b0d20a8..60cb73b862 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 3773eb8195..f38e66499c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index de081c6388..01e2a9a04c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index 1ab8ab1f7b..03e74781da 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 0f6c63d1cc..d67f045009 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 2b289ebb09..76f474de7e 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 50df01ad3c..4039f11c9a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index 59dc725854..3d18a6b979 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 24a9bc1629..93153b1736 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 7fc5c023b0..92bde3e718 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 1cc6f77123..b0e2286a24 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 4d770d2e5c..0a59ab31d9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 9cd43d3578..b21f066123 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index a9fe99c45d..39164e6f15 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index e21c822120..40d1308a8d 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index e9f9dbb1e1..3d70d9195c 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 29747b2058..563482e226 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 9ed35dfa33..50335a152b 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index d950e541b0..3f2e414378 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.1.1-SNAPSHOT + 5.2.0 io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 1103b9fb96..3ea8e6e665 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 486a5ba040..2afe3fd7e4 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index dc97e13ce3..700b6bfaab 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index bfbcf59b5f..53bb940ba3 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 0a8e6a1bb3..6b2880510b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 603622f1ef..02d670d0fc 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index d6c18ced8c..847d03d042 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 1afbf4948a..e5b710aeb9 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 9584b927d2..1a423686e9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 85fb31d80d..2764b3afb0 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index efd3eea629..fdb41e1570 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 0961711356..4a104e133c 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 00bef3c430..96753a9eb0 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index b7b2a2b024..a5461139e2 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 2d1fd1a9a6..c7668af34f 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 0522067f1c..9cbd2624a4 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index ad762d1fe4..6388ee8ade 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index f89aa3cf39..554d676729 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index b99f174c7a..9659703479 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 91492147c5..94b1f4ff0e 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index dd5efb2d0a..e4a17874a0 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 21e45095f2..3f420278c6 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index ec89a59da1..20a46f66e2 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index f28613b4dc..cb720a5874 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 7c76e5c2b3..a71c0109ab 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index c98060e315..ae5aea2624 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 99ae34c17c..5229d802aa 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 5c5a6a94d7..e9045fd1c0 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 4fc832717f..1f73630663 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 2263db3f51..3b10928f59 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 0d318113f8..ef429341ef 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index fb2eec07f7..209be35b43 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index edc2e90404..fa287e74d4 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index a0506a21f9..14e23790c5 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../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 3602a6dbaf..91ce9201b4 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index 29e7d8d367..e8bf560c1c 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 41808f5783..92b4a7cca5 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index ac282a877c..e21ca9986f 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 91047707bc..ce8ddcac89 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index cac65f28d3..73c047b2e3 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 9091285299..8ef0fe50ff 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index c3c0fb268a..e262255e18 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index 3fe28dedd8..a833d3beb0 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index ac629006af..21b90a95a5 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index 6c247959bd..b96861dd27 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index da70f7b701..1e61b1eeb9 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index a18820192a..2538cad760 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 138e225f51..94727232a4 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index e368689f28..ad22aebe4f 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 7c00475326..26ee946fa3 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index 644192d911..60f4ce99bf 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 4.0.0 diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index ce8f238c49..0322b0ae12 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index c0510455c2..a0967ae0b5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index c8579334eb..8872c062c0 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index d0f2d96da0..11ae5c66ea 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 7282116954..1c0e1f9d75 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index ac4d7912c5..5d5c28771b 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 48eadd764e..4af130107d 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 7a09ba02f2..4adaff2c0f 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index c3680bc49c..8cb582f64e 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 048bb6753b..0f15664f77 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index e06d6c44fc..ab9ba5f51e 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 743c4d1b8b..7afaab1538 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 14d9d37435..cac1fd226f 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 63b2c0ccc5..ac2ae8a738 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 1cc4b8e1fa..17ccc3284a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 91c20ad21f..f6e3df3313 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index f0796f2527..518a3efbd6 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 91c7122eeb..f43cb8922d 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index d8e780f2dc..ea1262d78e 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index a1173b092f..635721d446 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 22e05065be..5fd274e79a 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index 87d1e7b273..c421ab46d3 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 8831489b50..d931c53d88 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 0da144fc89..1ce3df13e6 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 4431526805..f26b45069b 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 68e1e94a71..b18f53e503 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 9ad917b1e1..1a99aab156 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 7d5247fa69..817a43d8c9 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 3a7d018a63..1dc9c046da 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index c0e3e5a94a..bde04a3759 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index e1d82784f3..da8166bfab 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 30a21a4f4e..09fffe7757 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index fbbd343a15..31c3781308 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 6145c54614..a6cad08e55 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index fc36c9c5c1..c44449ced6 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 3f255c77ca..408f43ca2e 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 9fd27e221a..70d4eaa797 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 8da131ed0e..1737f3f281 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 84f61d3c9b..a3f7da4ab2 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 984702a61f..ea917960d0 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index cb50916b33..5c9d58cfb6 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.1.1-SNAPSHOT + 5.2.0 ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 50dcf3a78a..9111fedc73 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.1.1-SNAPSHOT + 5.2.0 ../../pom.xml diff --git a/pom.xml b/pom.xml index f97db94c29..224125af34 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.1.1-SNAPSHOT + 5.2.0 WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1967,7 +1967,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.2.0 @@ -2172,7 +2172,7 @@ 1.2.11.wso2v10 - 5.1.1-SNAPSHOT + 5.2.0 4.7.35 From e062bf79dc15595752d3cf9e717d7a4dd399bc31 Mon Sep 17 00:00:00 2001 From: Jenkins Date: Tue, 16 Jul 2024 08:04:47 +0530 Subject: [PATCH 250/343] [maven-release-plugin] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.common/pom.xml | 2 +- .../cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml | 2 +- components/cea-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/cea-mgt-feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 146 files changed, 148 insertions(+), 148 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 67c1232785..bb84f55812 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index c2c7d515d1..d2fce540f1 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 2225ad5265..d2f75adc1c 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 8ae163dd8d..e172ba30c9 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 9923815c51..9d8d7f5128 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-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 1c1bfb6970..2076a5b8f9 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 io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 0ed52cc361..6b31c913a7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index e7f37a33e3..1dd558542e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index e1646389f0..972ddc0e4e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml 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 ac85d25317..a837bcb046 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 io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 66841e54a2..27c3fa7204 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 784acfc6a8..a4b5545299 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 1b219e13a9..e4bc150299 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 99cc31cb02..522625062c 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index d564685d28..c2ebb66863 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index fec2b21fae..df9d9fc578 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 9171161ae1..fcaf2a292d 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index e75a2e16fa..b256793a45 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index 00d6ea88c1..dea23471d7 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index 084c05609d..bef1902ec3 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index b218c811be..f12e4616d2 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index 8ecde84fd1..136bb3c064 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index d31cd2f481..24ecc877ae 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 382d60d4b4..22345f280f 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index d9c63334f0..8e5615c3ca 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 7717eda26b..6281d5be61 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 4845aaa521..ff12f5c484 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index ee51c5d395..949abeae97 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index f6ab290dec..fc3fb174d6 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 815baa7e71..e135e39924 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index bd4d5aaa2d..a71754725d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 412fa0d1d1..9ab4fc60a2 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 5d6a4acbc5..001da8a15a 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 60cb73b862..ae85054204 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index f38e66499c..1ec47c569f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 01e2a9a04c..929bb75db9 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index 03e74781da..d5b532b59b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index d67f045009..430f3e1673 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 76f474de7e..c453c91ccd 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 4039f11c9a..4c4a9049fa 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index 3d18a6b979..4fc7f685a4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 93153b1736..9bc24cefdf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 92bde3e718..e9936a2841 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index b0e2286a24..a2588f584d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 0a59ab31d9..fe99f19899 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index b21f066123..1e36bb556e 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 39164e6f15..32fe9e8614 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 40d1308a8d..4d9c218b14 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 3d70d9195c..0cd9dd8f9b 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 563482e226..efd2da7f1d 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 50335a152b..bf14726b0d 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 3f2e414378..a23770f1c3 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.2.0 + 5.2.1-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 3ea8e6e665..8c72f7b67c 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 2afe3fd7e4..f122abe746 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 700b6bfaab..b5f609af3c 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 53bb940ba3..488588889b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 6b2880510b..e0f87cc5da 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 02d670d0fc..206bc81dfe 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 847d03d042..72ed377be7 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index e5b710aeb9..a6d83132c0 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 1a423686e9..f4a291430d 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 2764b3afb0..93d932ffd5 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index fdb41e1570..4dcddb3f4d 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 4a104e133c..c7dea3252d 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 96753a9eb0..72994dc58f 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index a5461139e2..74669ea7ff 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index c7668af34f..f1ef0a4c42 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 9cbd2624a4..80868f4069 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 6388ee8ade..bf70de1620 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 554d676729..605b8d0035 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 9659703479..9809326b59 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 94b1f4ff0e..96ffca0489 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index e4a17874a0..81dffe2443 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 3f420278c6..e29e8c3274 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 20a46f66e2..130552c8cb 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index cb720a5874..ed1194b077 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index a71c0109ab..ae5d773ff3 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index ae5aea2624..681392afd7 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 5229d802aa..ca7faa575c 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index e9045fd1c0..802f76f4bc 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 1f73630663..04f0549344 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 3b10928f59..0a0cd44132 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index ef429341ef..8cea3b9b89 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 209be35b43..b368938fcd 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index fa287e74d4..c1295a1fc9 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 14e23790c5..99c71ee31d 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-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 91ce9201b4..8e29fa4084 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index e8bf560c1c..a21c8b970d 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 92b4a7cca5..b2b4679369 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index e21ca9986f..6ae536013b 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index ce8ddcac89..3a9883e5c9 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 73c047b2e3..c57281853b 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 8ef0fe50ff..66a84acf72 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index e262255e18..7cb9b51ab0 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index a833d3beb0..71711748f1 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index 21b90a95a5..c27fc3727a 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index b96861dd27..e653594725 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index 1e61b1eeb9..ce8533f710 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 2538cad760..a639649a4b 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 94727232a4..7c937f3db9 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index ad22aebe4f..0404cc3c5c 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 26ee946fa3..ec881c0238 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index 60f4ce99bf..b49fb03251 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT 4.0.0 diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index 0322b0ae12..6ed98297b5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index a0967ae0b5..78230e248c 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 8872c062c0..2df995c371 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 11ae5c66ea..db9c9257ac 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 1c0e1f9d75..02ac4c300d 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 5d5c28771b..b67d29c242 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 4af130107d..3fb3849902 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 4adaff2c0f..097653eae6 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 8cb582f64e..bb40a31aa9 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 0f15664f77..277aff34f0 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index ab9ba5f51e..5b47a25b85 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 7afaab1538..933da87343 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index cac1fd226f..6d95834e22 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index ac2ae8a738..800e4f44fe 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 17ccc3284a..e16f1b723b 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index f6e3df3313..306c966ccc 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 518a3efbd6..47a111a987 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index f43cb8922d..03b81d7a05 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index ea1262d78e..5bd102c0e8 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 635721d446..6aa152b878 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 5fd274e79a..9eb6f40dee 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index c421ab46d3..30bc3656a2 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index d931c53d88..e500a961a0 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 1ce3df13e6..b051642b15 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index f26b45069b..fc519d08be 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index b18f53e503..6ecb1d6e89 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 1a99aab156..7cd15c6f29 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 817a43d8c9..3f2761de13 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 1dc9c046da..ab54daebdd 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index bde04a3759..79421326e8 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index da8166bfab..5af3ace1d6 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 09fffe7757..9f31cdf3bb 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 31c3781308..b28e4250d3 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index a6cad08e55..3f53d62438 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index c44449ced6..e214bf2074 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 408f43ca2e..cd18d91382 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 70d4eaa797..464e3c8ecb 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 1737f3f281..8c6c403359 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index a3f7da4ab2..2ac85ad511 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index ea917960d0..16fc3fa962 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index 5c9d58cfb6..e74282a52b 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.2.0 + 5.2.1-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 9111fedc73..1dac00220f 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.0 + 5.2.1-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 224125af34..e1e29b20b2 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.2.0 + 5.2.1-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1967,7 +1967,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.2.0 + HEAD @@ -2172,7 +2172,7 @@ 1.2.11.wso2v10 - 5.2.0 + 5.2.1-SNAPSHOT 4.7.35 From 8b6eee0a97f1173d09c31e795002af48fc6bcd3c Mon Sep 17 00:00:00 2001 From: Oshani Silva Date: Wed, 17 Jul 2024 05:42:24 +0000 Subject: [PATCH 251/343] Add fix for group subscription table Co-authored-by: Oshani Silva Co-committed-by: Oshani Silva --- .../common/CategorizedSubscriptionResult.java | 87 +++++++++++++++++++ .../mgt/core/dao/SubscriptionDAO.java | 12 +++ .../GenericSubscriptionDAOImpl.java | 46 +++++++++- .../core/impl/SubscriptionManagerImpl.java | 48 +++++++++- .../core/dao/impl/AbstractGroupDAOImpl.java | 12 ++- 5 files changed, 194 insertions(+), 11 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java index 18da5a7736..e685284b77 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/CategorizedSubscriptionResult.java @@ -23,10 +23,15 @@ import java.util.List; public class CategorizedSubscriptionResult { private List installedDevices; + private int installedDevicesCount; private List pendingDevices; + private int pendingDevicesCount; private List errorDevices; + private int errorDevicesCount; private List newDevices; + private int newDevicesCount; private List subscribedDevices; + private int subscribedDevicesCount; public CategorizedSubscriptionResult(List installedDevices, List pendingDevices, @@ -61,6 +66,48 @@ public class CategorizedSubscriptionResult { this.subscribedDevices = subscribedDevices; } + public CategorizedSubscriptionResult(List installedDevices, + List pendingDevices, + List errorDevices, + List newDevices, + int installedDevicesCount, + int pendingDevicesCount, + int errorDevicesCount, + int newDevicesCount + ) { + this.installedDevices = installedDevices; + this.pendingDevices = pendingDevices; + this.errorDevices = errorDevices; + this.newDevices = newDevices; + this.subscribedDevices = null; + this.installedDevicesCount = installedDevicesCount; + this.pendingDevicesCount = pendingDevicesCount; + this.errorDevicesCount = errorDevicesCount; + this.newDevicesCount = newDevicesCount; + this.subscribedDevicesCount = 0; + } + + public CategorizedSubscriptionResult(List installedDevices, + List pendingDevices, + List errorDevices, + List newDevices, + List subscribedDevices, int installedDevicesCount, + int pendingDevicesCount, + int errorDevicesCount, + int newDevicesCount, + int subscribedDevicesCount) { + this.installedDevices = installedDevices; + this.pendingDevices = pendingDevices; + this.errorDevices = errorDevices; + this.newDevices = newDevices; + this.subscribedDevices = subscribedDevices; + this.installedDevicesCount = installedDevicesCount; + this.pendingDevicesCount = pendingDevicesCount; + this.errorDevicesCount = errorDevicesCount; + this.newDevicesCount = newDevicesCount; + this.subscribedDevicesCount = subscribedDevicesCount; + } + public CategorizedSubscriptionResult(List devices, String tabActionStatus) { switch (tabActionStatus) { case "COMPLETED": @@ -127,4 +174,44 @@ public class CategorizedSubscriptionResult { public void setSubscribedDevices(List subscribedDevices) { this.subscribedDevices = subscribedDevices; } + + public int getInstalledDevicesCount() { + return installedDevicesCount; + } + + public void setInstalledDevicesCount(int installedDevicesCount) { + this.installedDevicesCount = installedDevicesCount; + } + + public int getPendingDevicesCount() { + return pendingDevicesCount; + } + + public void setPendingDevicesCount(int pendingDevicesCount) { + this.pendingDevicesCount = pendingDevicesCount; + } + + public int getErrorDevicesCount() { + return errorDevicesCount; + } + + public void setErrorDevicesCount(int errorDevicesCount) { + this.errorDevicesCount = errorDevicesCount; + } + + public int getNewDevicesCount() { + return newDevicesCount; + } + + public void setNewDevicesCount(int newDevicesCount) { + this.newDevicesCount = newDevicesCount; + } + + public int getSubscribedDevicesCount() { + return subscribedDevicesCount; + } + + public void setSubscribedDevicesCount(int subscribedDevicesCount) { + this.subscribedDevicesCount = subscribedDevicesCount; + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java index ec3717391a..498221eb68 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java @@ -517,4 +517,16 @@ public interface SubscriptionDAO { * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. */ int getUserUnsubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + + /** + * This method is used to get the counts of devices related to a UUID. + * + * @param appReleaseId the UUID of the application release. + * @param tenantId id of the current tenant. + * @param actionStatus categorized status. + * @param actionTriggeredFrom type of the action. + * @return {@link int} which contains the count of the subscription type + * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. + */ + int countSubscriptionsByStatus(int appReleaseId, int tenantId, String actionStatus, String actionTriggeredFrom) throws ApplicationManagementDAOException; } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 8ffb95f039..2241a0b989 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -1655,14 +1655,22 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc "GS.UNSUBSCRIBED_BY, GS.UNSUBSCRIBED_TIMESTAMP, GS.AP_APP_RELEASE_ID " + "FROM AP_GROUP_SUBSCRIPTION GS " + "WHERE GS.AP_APP_RELEASE_ID = ? AND GS.UNSUBSCRIBED = ? AND GS.TENANT_ID = ? " + - "ORDER BY " + subscriptionStatusTime + " DESC " + - "LIMIT ? OFFSET ?"; + "ORDER BY " + subscriptionStatusTime + " DESC "; + + // Append limit and offset only if limit is not -1 + if (limit != -1) { + sql = sql + " LIMIT ? OFFSET ?"; + } try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setBoolean(2, unsubscribe); ps.setInt(3, tenantId); - ps.setInt(4, limit); - ps.setInt(5, offset); + + // Set limit and offset parameters only if limit is not -1 + if (limit != -1) { + ps.setInt(4, limit); + ps.setInt(5, offset); + } try (ResultSet rs = ps.executeQuery()) { GroupSubscriptionDTO groupDetail; @@ -2487,4 +2495,34 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc throw new ApplicationManagementDAOException(msg, e); } } + + public int countSubscriptionsByStatus(int appReleaseId, int tenantId, String actionStatus, String actionTriggeredFrom) throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to count device subscriptions by status and actionTriggeredFrom for the given AppReleaseID."); + } + try { + Connection conn = this.getDBConnection(); + String sql = "SELECT COUNT(*) FROM AP_DEVICE_SUBSCRIPTION WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ? AND STATUS = ? AND ACTION_TRIGGERED_FROM = ?"; + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setInt(2, tenantId); + ps.setString(3, actionStatus); + ps.setString(4, actionTriggeredFrom); + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + return rs.getInt(1); + } + } + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection to count device subscriptions by status and action trigger."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "SQL Error occurred while counting device subscriptions by status and action trigger."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + return 0; + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 065c9576bd..b7dc62a0fc 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1725,7 +1725,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { List groupDetailsWithDevices = new ArrayList<>(); List groupDetails = - subscriptionDAO.getGroupsSubscriptionDetailsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); + subscriptionDAO.getGroupsSubscriptionDetailsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, -1); if (groupDetails == null) { throw new ApplicationManagementException("Group details not found for appReleaseId: " + appReleaseId); } @@ -1744,7 +1744,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { GroupDetailsDTO groupDetailWithDevices = groupManagementProviderService.getGroupDetailsWithDevices( groupName, applicationDTO.getDeviceTypeId(), request.getOwner(), - request.getDeviceName(), request.getDeviceStatus(), offset, limit); + request.getDeviceName(), request.getDeviceStatus(), offset, -1); SubscriptionsDTO groupDetailDTO = new SubscriptionsDTO(); groupDetailDTO.setId(groupDetailWithDevices.getGroupId()); @@ -1878,33 +1878,73 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } List requestedDevices = new ArrayList<>(); + int installedCount; + int pendingCount; + int errorCount; + int newCount; + int subscribedCount; + int totalDeviceCount = + groupManagementProviderService.getDeviceCount(groupDetailWithDevices.getGroupId()); + if (StringUtils.isNotBlank(request.getTabActionStatus())) { switch (request.getTabActionStatus()) { case "COMPLETED": requestedDevices = installedDevices; + installedCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, request.getTabActionStatus(), request.getActionType()); break; case "PENDING": requestedDevices = pendingDevices; + pendingCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, request.getTabActionStatus(), request.getActionType()); break; case "ERROR": requestedDevices = errorDevices; + errorCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, request.getTabActionStatus(), request.getActionType()); break; case "NEW": requestedDevices = newDevices; break; case "SUBSCRIBED": requestedDevices = subscribedDevices; + subscribedCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, request.getTabActionStatus(), request.getActionType()); break; } groupDetailDTO.setDevices(new CategorizedSubscriptionResult(requestedDevices, request.getTabActionStatus())); } else { CategorizedSubscriptionResult categorizedSubscriptionResult; + + installedCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, "COMPLETED", request.getActionType()); + pendingCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, "PENDING", request.getActionType()); + errorCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, "ERROR", request.getActionType()); + subscribedCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, "SUBSCRIBED", request.getActionType()); + newCount = totalDeviceCount - (installedCount + pendingCount + errorCount + subscribedCount); + + List paginatedInstalledDevices = installedDevices.stream() + .skip(offset) + .limit(limit) + .collect(Collectors.toList()); + List paginatedPendingDevices = pendingDevices.stream() + .skip(offset) + .limit(limit) + .collect(Collectors.toList()); + List paginatedErrorDevices = errorDevices.stream() + .skip(offset) + .limit(limit) + .collect(Collectors.toList()); + List paginatedNewDevices = newDevices.stream() + .skip(offset) + .limit(limit) + .collect(Collectors.toList()); + List paginatedSubscribedDevices = subscribedDevices.stream() + .skip(offset) + .limit(limit) + .collect(Collectors.toList()); + if (subscribedDevices.isEmpty()) { categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); + new CategorizedSubscriptionResult(paginatedInstalledDevices, paginatedPendingDevices, paginatedErrorDevices, paginatedNewDevices, installedCount, pendingCount, errorCount, newCount); } else { categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); + new CategorizedSubscriptionResult(paginatedInstalledDevices, paginatedPendingDevices, paginatedErrorDevices, paginatedNewDevices, paginatedSubscribedDevices, installedCount, pendingCount, errorCount, newCount, subscribedCount); } groupDetailDTO.setDevices(categorizedSubscriptionResult); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 1eba6c1a7e..cfa706b0e0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1495,7 +1495,10 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { sql.append(" AND e.STATUS = ?"); } - sql.append(" LIMIT ? OFFSET ?"); + // Append limit and offset only if limit is not -1 + if (limit != -1) { + sql.append(" LIMIT ? OFFSET ?"); + } Connection conn = null; try { @@ -1519,8 +1522,11 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(index++, deviceStatus); } - stmt.setInt(index++, limit); - stmt.setInt(index++, offset); + // Set limit and offset parameters only if limit is not -1 + if (limit != -1) { + stmt.setInt(index++, limit); + stmt.setInt(index++, offset); + } try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { From 7be828a55607fd1874b519c301c1b8ac3ffe4860 Mon Sep 17 00:00:00 2001 From: waruni Date: Wed, 17 Jul 2024 11:52:35 +0530 Subject: [PATCH 252/343] Add EVENT REVOKE operation for groupIds to delete --- .../GeoLocationProviderServiceImpl.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java index 9b380f14ee..f11914d5ea 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/geo/service/GeoLocationProviderServiceImpl.java @@ -1528,7 +1528,11 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic @Override public boolean updateGeofence(GeofenceData geofenceData, int fenceId) throws GeoLocationBasedServiceException, EventConfigurationException { + EventConfigurationProviderService eventConfigService; + eventConfigService = DeviceManagementDataHolder.getInstance().getEventConfigurationService(); int tenantId; + List groupIdsToDelete = new ArrayList<>(); + List groupIdsToAdd = new ArrayList<>(); try { tenantId = DeviceManagementDAOUtil.getTenantId(); } catch (DeviceManagementDAOException e) { @@ -1543,8 +1547,6 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic int updatedRowCount = geofenceDAO.updateGeofence(geofenceData, fenceId); savedGroupIds = geofenceDAO.getGroupIdsOfGeoFence(fenceId); geofenceData.setId(fenceId); - List groupIdsToDelete = new ArrayList<>(); - List groupIdsToAdd = new ArrayList<>(); for (Integer savedGroupId : savedGroupIds) { if (!geofenceData.getGroupIds().contains(savedGroupId)) { groupIdsToDelete.add(savedGroupId); @@ -1558,6 +1560,18 @@ public class GeoLocationProviderServiceImpl implements GeoLocationProviderServic geofenceDAO.deleteGeofenceGroupMapping(groupIdsToDelete, fenceId); geofenceDAO.createGeofenceGroupMapping(geofenceData, groupIdsToAdd); EventManagementDAOFactory.commitTransaction(); + try { + if (!groupIdsToDelete.isEmpty()) { + eventConfigService.createEventOperationTask(OperationMgtConstants.OperationCodes.EVENT_REVOKE, + DeviceManagementConstants.EventServices.GEOFENCE, + new GeoFenceEventMeta(geofenceData), tenantId, groupIdsToDelete); + } + } catch (EventConfigurationException e) { + String msg = "Failed while creating EVENT_REVOKE operation creation task entry while updating geo fence " + + geofenceData.getFenceName() + " of the tenant " + tenantId; + log.error(msg, e); + throw new GeoLocationBasedServiceException(msg, e); + } if (updatedRowCount > 0) { GeoCacheManagerImpl.getInstance().updateGeoFenceInCache(geofenceData, fenceId, tenantId); } From 8a8846be5af3a93752920fd9f1dec6f785876a48 Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Thu, 18 Jul 2024 12:26:19 +0530 Subject: [PATCH 253/343] Fix devices not loading in web apps --- .../mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index 1160b4bb79..f826980fae 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -731,8 +731,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { StringBuilder sql = new StringBuilder("SELECT e.DEVICE_ID, e.OWNER, e.STATUS, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + - "WHERE e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ") AND d.DEVICE_TYPE_ID = ?"); + "WHERE e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ")"); + if (deviceTypeId != 0) { + sql.append(" AND d.DEVICE_TYPE_ID = ?"); + } if (deviceOwner != null && !deviceOwner.isEmpty()) { sql.append(" AND e.OWNER LIKE ?"); } @@ -750,7 +753,9 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { for (String status : allowingDeviceStatuses) { stmt.setString(index++, status); } - stmt.setInt(index++, deviceTypeId); + if (deviceTypeId != 0) { + stmt.setInt(index++, deviceTypeId); + } if (deviceOwner != null && !deviceOwner.isEmpty()) { stmt.setString(index++, "%" + deviceOwner + "%"); From 7b0f12b890078e6265174e8849fdf5bc22cd9c0b Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Thu, 18 Jul 2024 13:45:39 +0530 Subject: [PATCH 254/343] Fix devices not loading in web apps --- .../dao/impl/AbstractEnrollmentDAOImpl.java | 18 ++++++++++++++---- .../core/dao/impl/AbstractGroupDAOImpl.java | 9 ++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index 1160b4bb79..bca05c6b18 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -589,8 +589,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { "e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + - "WHERE e.OWNER = ? AND e.TENANT_ID = ? AND d.DEVICE_TYPE_ID = ? AND e.STATUS IN (" + deviceFilters + ")"); + "WHERE e.OWNER = ? AND e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters + ")"); + if (deviceTypeId != 0) { + sql.append(" AND d.DEVICE_TYPE_ID = ?"); + } if (deviceOwner != null && !deviceOwner.isEmpty()) { sql.append(" AND e.OWNER LIKE ?"); } @@ -607,10 +610,12 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { int index = 1; stmt.setString(index++, owner); stmt.setInt(index++, tenantId); - stmt.setInt(index++, deviceTypeId); for (String status : allowingDeviceStatuses) { stmt.setString(index++, status); } + if (deviceTypeId != 0) { + stmt.setInt(index++, deviceTypeId); + } if (deviceOwner != null && !deviceOwner.isEmpty()) { stmt.setString(index++, "%" + deviceOwner + "%"); @@ -731,8 +736,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { StringBuilder sql = new StringBuilder("SELECT e.DEVICE_ID, e.OWNER, e.STATUS, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION " + "FROM DM_ENROLMENT e " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + - "WHERE e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ") AND d.DEVICE_TYPE_ID = ?"); + "WHERE e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters.toString() + ")"); + if (deviceTypeId != 0) { + sql.append(" AND d.DEVICE_TYPE_ID = ?"); + } if (deviceOwner != null && !deviceOwner.isEmpty()) { sql.append(" AND e.OWNER LIKE ?"); } @@ -750,7 +758,9 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { for (String status : allowingDeviceStatuses) { stmt.setString(index++, status); } - stmt.setInt(index++, deviceTypeId); + if (deviceTypeId != 0) { + stmt.setInt(index++, deviceTypeId); + } if (deviceOwner != null && !deviceOwner.isEmpty()) { stmt.setString(index++, "%" + deviceOwner + "%"); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index cfa706b0e0..f747321fc4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1482,9 +1482,11 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { "WHERE " + " g.GROUP_NAME = ? " + " AND g.TENANT_ID = ? " + - " AND d.DEVICE_TYPE_ID = ? " + " AND e.STATUS IN (" + statusPlaceholders + ")"); + if (deviceTypeId != 0) { + sql.append(" AND d.DEVICE_TYPE_ID = ?"); + } if (deviceOwner != null && !deviceOwner.isEmpty()) { sql.append(" AND e.OWNER LIKE ?"); } @@ -1507,11 +1509,12 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { int index = 1; stmt.setString(index++, groupName); stmt.setInt(index++, tenantId); - stmt.setInt(index++, deviceTypeId); for (String status : allowedStatuses) { stmt.setString(index++, status); } - + if (deviceTypeId != 0) { + stmt.setInt(index++, deviceTypeId); + } if (deviceOwner != null && !deviceOwner.isEmpty()) { stmt.setString(index++, "%" + deviceOwner + "%"); } From 71eae764ce2d0d23a594341a08b0ed8bbfce2d49 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Mon, 22 Jul 2024 02:07:16 +0530 Subject: [PATCH 255/343] Fix stream corrupted exception for profile type operations --- .../mgt/api/jaxrs/beans/ApplicationUninstallation.java | 5 +++++ .../service/impl/DeviceManagementServiceImpl.java | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationUninstallation.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationUninstallation.java index f78d15966e..eee5f06c49 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationUninstallation.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/ApplicationUninstallation.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans; +import com.google.gson.Gson; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -113,4 +114,8 @@ public class ApplicationUninstallation { public void setType(String type) { this.type = type; } + + public String toJson() { + return new Gson().toJson(this); + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index b514277817..88cfe125ca 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -19,7 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse; import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; @@ -44,6 +43,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application; import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.MobileAppTypes; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException; import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationService; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceData; @@ -1112,7 +1112,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @QueryParam("version") String version, @QueryParam("user") String user) { List deviceIdentifiers = new ArrayList<>(); - Operation operation = new Operation(); try { RequestValidationUtil.validateDeviceIdentifier(type, id); Device device = DeviceMgtAPIUtils.getDeviceManagementService().getDevice(id, false); @@ -1133,11 +1132,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { //if the applications not installed via entgra store } else { if (Constants.ANDROID.equals(type)) { - ApplicationUninstallation applicationUninstallation = new ApplicationUninstallation(packageName, "PUBLIC", name, platform, version, user); - Gson gson = new Gson(); + ApplicationUninstallation applicationUninstallation = new ApplicationUninstallation(packageName, + MobileAppTypes.PUBLIC.toString(), name, platform, version, user); + ProfileOperation operation = new ProfileOperation(); operation.setCode(MDMAppConstants.AndroidConstants.UNMANAGED_APP_UNINSTALL); operation.setType(Operation.Type.PROFILE); - operation.setPayLoad(gson.toJson(applicationUninstallation)); + operation.setPayLoad(applicationUninstallation.toJson()); DeviceManagementProviderService deviceManagementProviderService = HelperUtil .getDeviceManagementProviderService(); Activity activity = deviceManagementProviderService.addOperation( From fa400f8995a7b0d2c803335f77c6bf074b985d8d Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Mon, 22 Jul 2024 09:56:37 +0530 Subject: [PATCH 256/343] Fix space in getAppCount query --- .../core/dao/impl/application/GenericApplicationDAOImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 618149cd72..86b7407378 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -313,7 +313,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic sql += " AND AP_APP_RELEASE.CURRENT_STATE = ?"; } if (deviceTypeId != -1) { - sql += "AND (AP_APP.DEVICE_TYPE_ID = ? "; + sql += " AND (AP_APP.DEVICE_TYPE_ID = ? "; if (filter.isWithWebApps()) { sql += "OR AP_APP.DEVICE_TYPE_ID = 0 "; } From 40c12875ac48e8d84e65959734d36382b94a57ce Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Mon, 22 Jul 2024 20:44:09 +0000 Subject: [PATCH 257/343] Improve APPM subscription data retrieving logic Co-authored-by: Rajitha Kumara Co-committed-by: Rajitha Kumara --- .../mgt/common/DeviceSubscription.java | 115 ++ .../DeviceSubscriptionFilterCriteria.java | 68 + .../mgt/common/SubscriptionData.java | 70 + .../mgt/common/SubscriptionEntity.java | 88 ++ .../mgt/common/SubscriptionInfo.java | 77 ++ .../mgt/common/SubscriptionMetadata.java | 68 + .../mgt/common/SubscriptionResponse.java | 63 + .../mgt/common/SubscriptionStatistics.java | 68 + .../mgt/common/dto/DeviceSubscriptionDTO.java | 27 + .../common/dto/SubscriptionStatisticDTO.java | 62 + .../common/services/SubscriptionManager.java | 89 +- .../mgt/core/dao/SubscriptionDAO.java | 23 +- .../GenericSubscriptionDAOImpl.java | 503 ++++++- .../OracleSubscriptionDAOImpl.java | 379 ++++++ .../core/impl/SubscriptionManagerImpl.java | 1150 +---------------- .../core/util/SubscriptionManagementUtil.java | 29 + .../mgt/SubscriptionManagementHelperUtil.java | 207 +++ ...SubscriptionManagementServiceProvider.java | 67 + ...bscriptionManagementHelperServiceImpl.java | 147 +++ ...bscriptionManagementHelperServiceImpl.java | 215 +++ ...bscriptionManagementHelperServiceImpl.java | 221 ++++ ...bscriptionManagementHelperServiceImpl.java | 206 +++ .../SubscriptionManagementHelperService.java | 44 + .../mgt/core/device/mgt/common/Device.java | 8 +- .../device/mgt/common/PaginationRequest.java | 9 + .../core/device/mgt/core/dao/DeviceDAO.java | 15 + .../core/device/mgt/core/dao/GroupDAO.java | 1 + .../core/dao/impl/AbstractDeviceDAOImpl.java | 275 ++++ .../dao/impl/AbstractEnrollmentDAOImpl.java | 97 +- .../core/dao/impl/AbstractGroupDAOImpl.java | 32 +- .../dao/impl/device/GenericDeviceDAOImpl.java | 154 +++ .../dao/impl/device/OracleDeviceDAOImpl.java | 161 +++ .../DeviceManagementProviderService.java | 12 + .../DeviceManagementProviderServiceImpl.java | 182 ++- .../GroupManagementProviderService.java | 3 + .../GroupManagementProviderServiceImpl.java | 14 + 36 files changed, 3673 insertions(+), 1276 deletions(-) create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscription.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionFilterCriteria.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionData.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionEntity.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionInfo.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionResponse.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionStatistics.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionStatisticDTO.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/SubscriptionManagementUtil.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementHelperUtil.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementServiceProvider.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/service/SubscriptionManagementHelperService.java diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscription.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscription.java new file mode 100644 index 0000000000..16e1d7553f --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscription.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common; + +import java.sql.Timestamp; + +public class DeviceSubscription { + private int deviceId; + private int subscriptionId; + private String deviceName; + private String deviceIdentifier; + private String deviceStatus; + private String deviceOwner; + private String deviceType; + private String ownershipType; + private Timestamp dateOfLastUpdate; + private SubscriptionData subscriptionData; + + public int getSubscriptionId() { + return subscriptionId; + } + + public void setSubscriptionId(int subscriptionId) { + this.subscriptionId = subscriptionId; + } + + public int getDeviceId() { + return deviceId; + } + + public void setDeviceId(int deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getDeviceIdentifier() { + return deviceIdentifier; + } + + public void setDeviceIdentifier(String deviceIdentifier) { + this.deviceIdentifier = deviceIdentifier; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public String getDeviceOwner() { + return deviceOwner; + } + + public void setDeviceOwner(String deviceOwner) { + this.deviceOwner = deviceOwner; + } + + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + + public String getOwnershipType() { + return ownershipType; + } + + public void setOwnershipType(String ownershipType) { + this.ownershipType = ownershipType; + } + + public Timestamp getDateOfLastUpdate() { + return dateOfLastUpdate; + } + + public void setDateOfLastUpdate(Timestamp dateOfLastUpdate) { + this.dateOfLastUpdate = dateOfLastUpdate; + } + + public SubscriptionData getSubscriptionData() { + return subscriptionData; + } + + public void setSubscriptionData(SubscriptionData subscriptionData) { + this.subscriptionData = subscriptionData; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionFilterCriteria.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionFilterCriteria.java new file mode 100644 index 0000000000..298a5221eb --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/DeviceSubscriptionFilterCriteria.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common; + +public class DeviceSubscriptionFilterCriteria { + private String name; + private String owner; + private String deviceStatus; + private String filteringDeviceSubscriptionStatus; // COMPLETE, PENDING ... + private String triggeredBy; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public String getFilteringDeviceSubscriptionStatus() { + return filteringDeviceSubscriptionStatus; + } + + public void setFilteringDeviceSubscriptionStatus(String filteringDeviceSubscriptionStatus) { + this.filteringDeviceSubscriptionStatus = filteringDeviceSubscriptionStatus; + } + + public String getTriggeredBy() { + return triggeredBy; + } + + public void setTriggeredBy(String triggeredBy) { + this.triggeredBy = triggeredBy; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionData.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionData.java new file mode 100644 index 0000000000..cef9a12508 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionData.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common; + +import java.sql.Timestamp; + +public class SubscriptionData { + private String deviceSubscriptionStatus; + private String triggeredBy; + private String subscriptionType; + private Timestamp triggeredAt; + private int subscriptionId; + + public String getDeviceSubscriptionStatus() { + return deviceSubscriptionStatus; + } + + public void setDeviceSubscriptionStatus(String deviceSubscriptionStatus) { + this.deviceSubscriptionStatus = deviceSubscriptionStatus; + } + + public String getTriggeredBy() { + return triggeredBy; + } + + public void setTriggeredBy(String triggeredBy) { + this.triggeredBy = triggeredBy; + } + + public String getSubscriptionType() { + return subscriptionType; + } + + public void setSubscriptionType(String subscriptionType) { + this.subscriptionType = subscriptionType; + } + + public Timestamp getTriggeredAt() { + return triggeredAt; + } + + public void setTriggeredAt(Timestamp triggeredAt) { + this.triggeredAt = triggeredAt; + } + + public int getSubscriptionId() { + return subscriptionId; + } + + public void setSubscriptionId(int subscriptionId) { + this.subscriptionId = subscriptionId; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionEntity.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionEntity.java new file mode 100644 index 0000000000..40c1b2f4a7 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionEntity.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common; + +import java.sql.Timestamp; + +public class SubscriptionEntity { + private String identity; + private String subscribedBy; + private Timestamp subscribedTimestamp; + private boolean unsubscribed; + private String unsubscribedBy; + private Timestamp unsubscribedTimestamp; + private int applicationReleaseId; + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + + public String getSubscribedBy() { + return subscribedBy; + } + + public void setSubscribedBy(String subscribedBy) { + this.subscribedBy = subscribedBy; + } + + public Timestamp getSubscribedTimestamp() { + return subscribedTimestamp; + } + + public void setSubscribedTimestamp(Timestamp subscribedTimestamp) { + this.subscribedTimestamp = subscribedTimestamp; + } + + public boolean getUnsubscribed() { + return unsubscribed; + } + + public void setUnsubscribed(boolean unsubscribed) { + this.unsubscribed = unsubscribed; + } + + public String getUnsubscribedBy() { + return unsubscribedBy; + } + + public void setUnsubscribedBy(String unsubscribedBy) { + this.unsubscribedBy = unsubscribedBy; + } + + public Timestamp getUnsubscribedTimestamp() { + return unsubscribedTimestamp; + } + + public void setUnsubscribedTimestamp(Timestamp unsubscribedTimestamp) { + this.unsubscribedTimestamp = unsubscribedTimestamp; + } + + public int getApplicationReleaseId() { + return applicationReleaseId; + } + + public void setApplicationReleaseId(int applicationReleaseId) { + this.applicationReleaseId = applicationReleaseId; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionInfo.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionInfo.java new file mode 100644 index 0000000000..6af03aa61a --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionInfo.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common; + +public class SubscriptionInfo { + private String applicationUUID; + private String subscriptionType; + private String deviceSubscriptionStatus; + private String identifier; + private String subscriptionStatus; + private DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria; + + public String getApplicationUUID() { + return applicationUUID; + } + + public void setApplicationUUID(String applicationUUID) { + this.applicationUUID = applicationUUID; + } + + public String getSubscriptionType() { + return subscriptionType; + } + + public void setSubscriptionType(String subscriptionType) { + this.subscriptionType = subscriptionType; + } + + public String getDeviceSubscriptionStatus() { + return deviceSubscriptionStatus; + } + + public void setDeviceSubscriptionStatus(String deviceSubscriptionStatus) { + this.deviceSubscriptionStatus = deviceSubscriptionStatus; + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public String getSubscriptionStatus() { + return subscriptionStatus; + } + + public void setSubscriptionStatus(String subscriptionStatus) { + this.subscriptionStatus = subscriptionStatus; + } + + public DeviceSubscriptionFilterCriteria getDeviceSubscriptionFilterCriteria() { + return deviceSubscriptionFilterCriteria; + } + + public void setDeviceSubscriptionFilterCriteria(DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria) { + this.deviceSubscriptionFilterCriteria = deviceSubscriptionFilterCriteria; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java new file mode 100644 index 0000000000..9e9a87d9a1 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SubscriptionMetadata { + public static final class DeviceSubscriptionStatus { + public static final String NEW = "NEW"; + public static final String PENDING = "PENDING"; + public static final String COMPLETED = "COMPLETED"; + public static final String ERROR = "ERROR"; + public static final String INVALID = "INVALID"; + public static final String UNAUTHORIZED = "UNAUTHORIZED"; + public static final String IN_PROGRESS = "IN_PROGRESS"; + public static final String REPEAT = "REPEAT"; + } + + public static final class SubscriptionTypes { + public static final String ROLE = "role"; + public static final String DEVICE = "device"; + public static final String GROUP = "group"; + public static final String USER = "user"; + } + + public static final class DBSubscriptionStatus { + public static final List COMPLETED_STATUS_LIST = + Collections.singletonList(DeviceSubscriptionStatus.COMPLETED); + public static final List ERROR_STATUS_LIST = + Arrays.asList(DeviceSubscriptionStatus.ERROR, DeviceSubscriptionStatus.INVALID, DeviceSubscriptionStatus.UNAUTHORIZED); + public static final List PENDING_STATUS_LIST = + Arrays.asList(DeviceSubscriptionStatus.PENDING, DeviceSubscriptionStatus.IN_PROGRESS, DeviceSubscriptionStatus.REPEAT); + } + + public static Map> deviceSubscriptionStatusToDBSubscriptionStatusMap; + static { + Map> statusMap = new HashMap<>(); + statusMap.put(DeviceSubscriptionStatus.COMPLETED, DBSubscriptionStatus.COMPLETED_STATUS_LIST); + statusMap.put(DeviceSubscriptionStatus.PENDING, DBSubscriptionStatus.PENDING_STATUS_LIST); + statusMap.put(DeviceSubscriptionStatus.IN_PROGRESS, DBSubscriptionStatus.PENDING_STATUS_LIST); + statusMap.put(DeviceSubscriptionStatus.REPEAT, DBSubscriptionStatus.PENDING_STATUS_LIST); + statusMap.put(DeviceSubscriptionStatus.ERROR, DBSubscriptionStatus.ERROR_STATUS_LIST); + statusMap.put(DeviceSubscriptionStatus.INVALID, DBSubscriptionStatus.ERROR_STATUS_LIST); + statusMap.put(DeviceSubscriptionStatus.UNAUTHORIZED, DBSubscriptionStatus.ERROR_STATUS_LIST); + deviceSubscriptionStatusToDBSubscriptionStatusMap = Collections.unmodifiableMap(statusMap); + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionResponse.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionResponse.java new file mode 100644 index 0000000000..aeaeba70be --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionResponse.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common; + +import java.util.List; + +public class SubscriptionResponse { + private String applicationUUID; + private int count; + private List data; + + public SubscriptionResponse(String applicationUUID, int count, List data) { + this.applicationUUID = applicationUUID; + this.count = count; + this.data = data; + } + + public SubscriptionResponse(String applicationUUID, List data) { + this.applicationUUID = applicationUUID; + this.data = data; + } + + public String getApplicationUUID() { + return applicationUUID; + } + + public void setApplicationUUID(String applicationUUID) { + this.applicationUUID = applicationUUID; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionStatistics.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionStatistics.java new file mode 100644 index 0000000000..80a10e98c5 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionStatistics.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common; + +public class SubscriptionStatistics { + private float completedPercentage; + private float failedPercentage; + private float pendingPercentage; + private float newDevicesPercentage; + + public SubscriptionStatistics() {} + public SubscriptionStatistics(float completedPercentage, float failedPercentage, float pendingPercentage, + float newDevicesPercentage) { + this.completedPercentage = completedPercentage; + this.failedPercentage = failedPercentage; + this.pendingPercentage = pendingPercentage; + this.newDevicesPercentage = newDevicesPercentage; + } + + public float getCompletedPercentage() { + return completedPercentage; + } + + public void setCompletedPercentage(float completedPercentage) { + this.completedPercentage = completedPercentage; + } + + public float getFailedPercentage() { + return failedPercentage; + } + + public void setFailedPercentage(float failedPercentage) { + this.failedPercentage = failedPercentage; + } + + public float getPendingPercentage() { + return pendingPercentage; + } + + public void setPendingPercentage(float pendingPercentage) { + this.pendingPercentage = pendingPercentage; + } + + public float getNewDevicesPercentage() { + return newDevicesPercentage; + } + + public void setNewDevicesPercentage(float newDevicesPercentage) { + this.newDevicesPercentage = newDevicesPercentage; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionDTO.java index 3306256b19..aa4f221ca3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionDTO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/DeviceSubscriptionDTO.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.application.mgt.common.dto; import java.sql.Timestamp; +import java.util.Objects; public class DeviceSubscriptionDTO { @@ -34,6 +35,19 @@ public class DeviceSubscriptionDTO { private int appReleaseId; private String appUuid; + public DeviceSubscriptionDTO() { + + } + + public DeviceSubscriptionDTO(int deviceId) { + this.deviceId = deviceId; + } + + public DeviceSubscriptionDTO(int deviceId, String status) { + this.deviceId = deviceId; + this.status = status; + } + public int getId() { return id; } @@ -121,4 +135,17 @@ public class DeviceSubscriptionDTO { public void setAppUuid(String appUuid) { this.appUuid = appUuid; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DeviceSubscriptionDTO that = (DeviceSubscriptionDTO) o; + return deviceId == that.deviceId; + } + + @Override + public int hashCode() { + return Objects.hash(deviceId); + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionStatisticDTO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionStatisticDTO.java new file mode 100644 index 0000000000..c50e47a5ac --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/dto/SubscriptionStatisticDTO.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common.dto; + +public class SubscriptionStatisticDTO { + private int completedDeviceCount = 0; + private int pendingDevicesCount = 0; + private int failedDevicesCount = 0; + + public void addToComplete(int count) { + completedDeviceCount += count; + } + + public void addToPending(int count) { + pendingDevicesCount += count; + } + + public void addToFailed(int count) { + failedDevicesCount += count ; + } + + public int getCompletedDeviceCount() { + return completedDeviceCount; + } + + public void setCompletedDeviceCount(int completedDeviceCount) { + this.completedDeviceCount = completedDeviceCount; + } + + public int getPendingDevicesCount() { + return pendingDevicesCount; + } + + public void setPendingDevicesCount(int pendingDevicesCount) { + this.pendingDevicesCount = pendingDevicesCount; + } + + public int getFailedDevicesCount() { + return failedDevicesCount; + } + + public void setFailedDevicesCount(int failedDevicesCount) { + this.failedDevicesCount = failedDevicesCount; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java index c8ca40813a..1e70f1b9d6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java @@ -19,9 +19,16 @@ package io.entgra.device.mgt.core.application.mgt.common.services; import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse; import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult; +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscription; +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionResponse; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionStatistics; import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; import io.entgra.device.mgt.core.application.mgt.common.dto.CategorizedSubscriptionCountsDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; @@ -224,72 +231,34 @@ public interface SubscriptionManager { Activity getOperationAppDetails(String id) throws SubscriptionManagementException; /** - * Retrieves the group details associated with a given app release UUID. - * - * @param uuid the UUID of the app release - * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) - * @param offset the offset for the data set - * @param limit the limit for the data set - * @return {@link SubscriptionsDTO} which contains the details of subscriptions. - * @throws ApplicationManagementException if an error occurs while fetching the group details + * Get subscription data describes by {@link SubscriptionInfo} entity + * @param subscriptionInfo {@link SubscriptionInfo} + * @param limit Limit value + * @param offset Offset value + * @return {@link SubscriptionResponse} + * @throws ApplicationManagementException Throws when error encountered while getting subscription data */ - public List getGroupsSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, - PaginationRequest request, int offset, - int limit) throws ApplicationManagementException; + SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException; /** - * Retrieves the user details associated with a given app release UUID. - * - * @param uuid the UUID of the app release - * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) - * @param offset the offset for the data set - * @param limit the limit for the data set - * @return {@link SubscriptionsDTO} which contains the details of subscriptions. - * @throws ApplicationManagementException if an error occurs while fetching the user details - */ - List getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, PaginationRequest request, - int offset, int limit) throws ApplicationManagementException; + * Get status based subscription data describes by {@link SubscriptionInfo} entity + * @param subscriptionInfo {@link SubscriptionInfo} + * @param limit Limit value + * @param offset Offset value + * @return {@link SubscriptionResponse} + * @throws ApplicationManagementException Throws when error encountered while getting subscription data + */ + SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException; /** - * Retrieves the Role details associated with a given app release UUID. - * - * @param uuid the UUID of the app release - * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) - * @param offset the offset for the data set - * @param limit the limit for the data set - * @return {@link SubscriptionsDTO} which contains the details of subscriptions. - * @throws ApplicationManagementException if an error occurs while fetching the role details + * Get subscription statistics related data describes by the {@link SubscriptionInfo} + * @param subscriptionInfo {@link SubscriptionInfo} + * @return {@link SubscriptionStatistics} + * @throws ApplicationManagementException Throws when error encountered while getting statistics */ - List getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, PaginationRequest request, - int offset, int limit) throws ApplicationManagementException; - - /** - * Retrieves the Device Subscription details associated with a given app release UUID. - * - * @param uuid the UUID of the app release - * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) - * @param offset the offset for the data set - * @param limit the limit for the data set - * @return {@link DeviceSubscriptionResponseDTO} which contains the details of device subscriptions. - * @throws ApplicationManagementException if an error occurs while fetching the device subscription details - */ - DeviceSubscriptionResponseDTO getDeviceSubscriptionsDetailsByUUID(String uuid, String subscriptionStatus, - PaginationRequest request, int offset, - int limit) throws ApplicationManagementException; - - /** - * Retrieves the All Device details associated with a given app release UUID. - * - * @param uuid the UUID of the app release - * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) - * @param offset the offset for the data set - * @param limit the limit for the data set - * @return {@link DeviceSubscriptionResponseDTO} which contains the details of device subscriptions. - * @throws ApplicationManagementException if an error occurs while fetching the subscription details - */ - DeviceSubscriptionResponseDTO getAllSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, - PaginationRequest request, int offset, - int limit) throws ApplicationManagementException; + SubscriptionStatistics getStatistics(SubscriptionInfo subscriptionInfo) throws ApplicationManagementException; /** * This method is responsible for retrieving device subscription details related to the given UUID. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java index 498221eb68..cadab204ca 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java @@ -19,6 +19,8 @@ package io.entgra.device.mgt.core.application.mgt.core.dao; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity; +import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionStatisticDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; @@ -327,7 +329,7 @@ public interface SubscriptionDAO { * @return {@link GroupSubscriptionDTO} which contains the details of group subscriptions. * @throws ApplicationManagementDAOException if connection establishment fails. */ - List getGroupsSubscriptionDetailsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) + List getGroupsSubscriptionDetailsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) throws ApplicationManagementDAOException; /** @@ -341,7 +343,7 @@ public interface SubscriptionDAO { * @return {@link SubscriptionsDTO} which contains the details of subscriptions. * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. */ - List getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, + List getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) throws ApplicationManagementDAOException; /** @@ -355,7 +357,7 @@ public interface SubscriptionDAO { * @return {@link SubscriptionsDTO} which contains the details of subscriptions. * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. */ - List getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) + List getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) throws ApplicationManagementDAOException; /** @@ -398,8 +400,11 @@ public interface SubscriptionDAO { * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. */ List getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId, - List deviceIds, String actionStatus, String actionType, - String actionTriggeredBy, String tabActionStatus) throws ApplicationManagementDAOException; + List deviceIds, List actionStatus, String actionType, + String actionTriggeredBy, int limit, int offset) throws ApplicationManagementDAOException; + int getDeviceSubscriptionCount(int appReleaseId, boolean unsubscribe, int tenantId, + List deviceIds, List actionStatus, String actionType, + String actionTriggeredBy) throws ApplicationManagementDAOException; /** * This method is used to get the details of device subscriptions related to a UUID. @@ -415,9 +420,13 @@ public interface SubscriptionDAO { * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. */ - List getAllSubscriptionsDetails(int appReleaseId, boolean unsubscribe, int tenantId, String actionStatus, String actionType, + List getAllSubscriptionsDetails(int appReleaseId, boolean unsubscribe, int tenantId, List actionStatus, String actionType, String actionTriggeredBy, int offset, int limit) throws ApplicationManagementDAOException; + int getAllSubscriptionsCount(int appReleaseId, boolean unsubscribe, int tenantId, + List actionStatus, String actionType, String actionTriggeredBy) + throws ApplicationManagementDAOException; + /** * This method is used to get the counts of all subscription types related to a UUID. * @@ -518,6 +527,8 @@ public interface SubscriptionDAO { */ int getUserUnsubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + SubscriptionStatisticDTO getSubscriptionStatistic(List deviceIds, String subscriptionType, boolean isUnsubscribed, + int tenantId) throws ApplicationManagementDAOException; /** * This method is used to get the counts of devices related to a UUID. * diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 2241a0b989..a793638d2d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -17,8 +17,11 @@ */ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionMetadata; import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity; +import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionStatisticDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO; import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; @@ -43,9 +46,11 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.StringJoiner; import java.util.stream.Collectors; @@ -1641,20 +1646,27 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public List getGroupsSubscriptionDetailsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) + public List getGroupsSubscriptionDetailsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get groups related to the given AppReleaseID."); } try { Connection conn = this.getDBConnection(); - List groupDetails = new ArrayList<>(); + List subscriptionEntities = new ArrayList<>(); String subscriptionStatusTime = unsubscribe ? "GS.UNSUBSCRIBED_TIMESTAMP" : "GS.SUBSCRIBED_TIMESTAMP"; - String sql = "SELECT GS.GROUP_NAME, GS.SUBSCRIBED_BY, GS.SUBSCRIBED_TIMESTAMP, GS.UNSUBSCRIBED, " + - "GS.UNSUBSCRIBED_BY, GS.UNSUBSCRIBED_TIMESTAMP, GS.AP_APP_RELEASE_ID " + + String sql = "SELECT GS.GROUP_NAME, " + + "GS.SUBSCRIBED_BY, " + + "GS.SUBSCRIBED_TIMESTAMP, " + + "GS.UNSUBSCRIBED, " + + "GS.UNSUBSCRIBED_BY, " + + "GS.UNSUBSCRIBED_TIMESTAMP, " + + "GS.AP_APP_RELEASE_ID " + "FROM AP_GROUP_SUBSCRIPTION GS " + - "WHERE GS.AP_APP_RELEASE_ID = ? AND GS.UNSUBSCRIBED = ? AND GS.TENANT_ID = ? " + + "WHERE GS.AP_APP_RELEASE_ID = ? " + + "AND GS.UNSUBSCRIBED = ? " + + "AND GS.TENANT_ID = ? " + "ORDER BY " + subscriptionStatusTime + " DESC "; // Append limit and offset only if limit is not -1 @@ -1673,21 +1685,21 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } try (ResultSet rs = ps.executeQuery()) { - GroupSubscriptionDTO groupDetail; + SubscriptionEntity subscriptionEntity; while (rs.next()) { - groupDetail = new GroupSubscriptionDTO(); - groupDetail.setGroupName(rs.getString("GROUP_NAME")); - groupDetail.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); - groupDetail.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); - groupDetail.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); - groupDetail.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); - groupDetail.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); - groupDetail.setAppReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + subscriptionEntity = new SubscriptionEntity(); + subscriptionEntity.setIdentity(rs.getString("GROUP_NAME")); + subscriptionEntity.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + subscriptionEntity.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); + subscriptionEntity.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + subscriptionEntity.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setApplicationReleaseId(rs.getInt("AP_APP_RELEASE_ID")); - groupDetails.add(groupDetail); + subscriptionEntities.add(subscriptionEntity); } } - return groupDetails; + return subscriptionEntities; } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get groups for the given UUID."; @@ -1701,20 +1713,27 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public List getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, + public List getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get user subscriptions related to the given UUID."); } try { Connection conn = this.getDBConnection(); - List userSubscriptions = new ArrayList<>(); + List subscriptionEntities = new ArrayList<>(); String subscriptionStatusTime = unsubscribe ? "US.UNSUBSCRIBED_TIMESTAMP" : "US.SUBSCRIBED_TIMESTAMP"; - String sql = "SELECT US.USER_NAME, US.SUBSCRIBED_BY, US.SUBSCRIBED_TIMESTAMP, US.UNSUBSCRIBED, " + - "US.UNSUBSCRIBED_BY, US.UNSUBSCRIBED_TIMESTAMP, US.AP_APP_RELEASE_ID " + + String sql = "SELECT US.USER_NAME, " + + "US.SUBSCRIBED_BY, " + + "US.SUBSCRIBED_TIMESTAMP, " + + "US.UNSUBSCRIBED, " + + "US.UNSUBSCRIBED_BY, " + + "US.UNSUBSCRIBED_TIMESTAMP, " + + "US.AP_APP_RELEASE_ID " + "FROM AP_USER_SUBSCRIPTION US " + - "WHERE US.AP_APP_RELEASE_ID = ? AND US.UNSUBSCRIBED = ? AND US.TENANT_ID = ? " + + "WHERE US.AP_APP_RELEASE_ID = ? " + + "AND US.UNSUBSCRIBED = ? " + + "AND US.TENANT_ID = ? " + "ORDER BY " + subscriptionStatusTime + " DESC " + "LIMIT ? OFFSET ?"; try (PreparedStatement ps = conn.prepareStatement(sql)) { @@ -1724,21 +1743,21 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc ps.setInt(4, limit); ps.setInt(5, offset); try (ResultSet rs = ps.executeQuery()) { + SubscriptionEntity subscriptionEntity; while (rs.next()) { - SubscriptionsDTO userSubscription; - userSubscription = new SubscriptionsDTO(); - userSubscription.setName(rs.getString("USER_NAME")); - userSubscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); - userSubscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); - userSubscription.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); - userSubscription.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); - userSubscription.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); - userSubscription.setAppReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + subscriptionEntity = new SubscriptionEntity(); + subscriptionEntity.setIdentity(rs.getString("USER_NAME")); + subscriptionEntity.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + subscriptionEntity.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); + subscriptionEntity.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + subscriptionEntity.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setApplicationReleaseId(rs.getInt("AP_APP_RELEASE_ID")); - userSubscriptions.add(userSubscription); + subscriptionEntities.add(subscriptionEntity); } } - return userSubscriptions; + return subscriptionEntities; } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get user subscriptions for the given UUID."; @@ -1752,20 +1771,27 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public List getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, - int limit) throws ApplicationManagementDAOException { + public List getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, + int limit) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get role subscriptions related to the given AppReleaseID."); } try { Connection conn = this.getDBConnection(); - List roleSubscriptions = new ArrayList<>(); + List subscriptionEntities = new ArrayList<>(); String subscriptionStatusTime = unsubscribe ? "ARS.UNSUBSCRIBED_TIMESTAMP" : "ARS.SUBSCRIBED_TIMESTAMP"; - String sql = "SELECT ARS.ROLE_NAME, ARS.SUBSCRIBED_BY, ARS.SUBSCRIBED_TIMESTAMP, ARS.UNSUBSCRIBED, " + - "ARS.UNSUBSCRIBED_BY, ARS.UNSUBSCRIBED_TIMESTAMP, ARS.AP_APP_RELEASE_ID " + + String sql = "SELECT ARS.ROLE_NAME, " + + "ARS.SUBSCRIBED_BY, " + + "ARS.SUBSCRIBED_TIMESTAMP, " + + "ARS.UNSUBSCRIBED, " + + "ARS.UNSUBSCRIBED_BY, " + + "ARS.UNSUBSCRIBED_TIMESTAMP, " + + "ARS.AP_APP_RELEASE_ID " + "FROM AP_ROLE_SUBSCRIPTION ARS " + - "WHERE ARS.AP_APP_RELEASE_ID = ? AND ARS.UNSUBSCRIBED = ? AND ARS.TENANT_ID = ? " + + "WHERE ARS.AP_APP_RELEASE_ID = ? " + + "AND ARS.UNSUBSCRIBED = ? " + + "AND ARS.TENANT_ID = ? " + "ORDER BY " + subscriptionStatusTime + " DESC " + "LIMIT ? OFFSET ?"; try (PreparedStatement ps = conn.prepareStatement(sql)) { @@ -1775,21 +1801,21 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc ps.setInt(4, limit); ps.setInt(5, offset); try (ResultSet rs = ps.executeQuery()) { - SubscriptionsDTO roleSubscription; + SubscriptionEntity subscriptionEntity; while (rs.next()) { - roleSubscription = new SubscriptionsDTO(); - roleSubscription.setName(rs.getString("ROLE_NAME")); - roleSubscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); - roleSubscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); - roleSubscription.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); - roleSubscription.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); - roleSubscription.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); - roleSubscription.setAppReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + subscriptionEntity = new SubscriptionEntity(); + subscriptionEntity.setIdentity(rs.getString("ROLE_NAME")); + subscriptionEntity.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + subscriptionEntity.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); + subscriptionEntity.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + subscriptionEntity.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setApplicationReleaseId(rs.getInt("AP_APP_RELEASE_ID")); - roleSubscriptions.add(roleSubscription); + subscriptionEntities.add(subscriptionEntity); } } - return roleSubscriptions; + return subscriptionEntities; } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get role subscriptions for the given UUID."; @@ -1918,14 +1944,20 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } } + // passed the required list for the action status @Override public List getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId, - List deviceIds, String actionStatus, String actionType, - String actionTriggeredBy, String tabActionStatus) throws ApplicationManagementDAOException { + List deviceIds, List actionStatus, String actionType, + String actionTriggeredBy, int limit, int offset) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting device subscriptions for the application release id " + appReleaseId + " and device ids " + deviceIds + " from the database"); } + + if (deviceIds == null || deviceIds.isEmpty()) { + return Collections.emptyList(); + } + try { Connection conn = this.getDBConnection(); String subscriptionStatusTime = unsubscribe ? "DS.UNSUBSCRIBED_TIMESTAMP" : "DS.SUBSCRIBED_TIMESTAMP"; @@ -1940,11 +1972,15 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc + "DS.STATUS AS STATUS, " + "DS.DM_DEVICE_ID AS DEVICE_ID " + "FROM AP_DEVICE_SUBSCRIPTION DS " - + "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.UNSUBSCRIBED = ? AND DS.TENANT_ID = ? AND DS.DM_DEVICE_ID IN (" + - deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ") "); + + "WHERE DS.AP_APP_RELEASE_ID = ? " + + "AND DS.UNSUBSCRIBED = ? " + + "AND DS.TENANT_ID = ? " + + "AND DS.DM_DEVICE_ID IN (" + + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ") "); if (actionStatus != null && !actionStatus.isEmpty()) { - sql.append(" AND DS.STATUS = ? "); + sql.append(" AND DS.STATUS IN ("). + append(actionStatus.stream().map(status -> "?").collect(Collectors.joining(","))).append(") "); } if (actionType != null && !actionType.isEmpty()) { sql.append(" AND DS.ACTION_TRIGGERED_FROM = ? "); @@ -1953,27 +1989,41 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc sql.append(" AND DS.SUBSCRIBED_BY LIKE ? "); } - sql.append("ORDER BY ").append(subscriptionStatusTime).append(" DESC"); + sql.append("ORDER BY ").append(subscriptionStatusTime). + append(" DESC "); + + if (offset >= 0 && limit >= 0) { + sql.append("LIMIT ? OFFSET ?"); + } try (PreparedStatement ps = conn.prepareStatement(sql.toString())) { int paramIdx = 1; ps.setInt(paramIdx++, appReleaseId); ps.setBoolean(paramIdx++, unsubscribe); ps.setInt(paramIdx++, tenantId); - for (int i = 0; i < deviceIds.size(); i++) { - ps.setInt(paramIdx++, deviceIds.get(i)); + for (Integer deviceId : deviceIds) { + ps.setInt(paramIdx++, deviceId); } if (actionStatus != null && !actionStatus.isEmpty()) { - ps.setString(paramIdx++, actionStatus); + for (String status : actionStatus) { + ps.setString(paramIdx++, status); + } } + if (actionType != null && !actionType.isEmpty()) { ps.setString(paramIdx++, actionType); } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { ps.setString(paramIdx++, "%" + actionTriggeredBy + "%"); } + if (offset >= 0 && limit >= 0) { + ps.setInt(paramIdx++, limit); + ps.setInt(paramIdx, offset); + } + try (ResultSet rs = ps.executeQuery()) { if (log.isDebugEnabled()) { log.debug("Successfully retrieved device subscriptions for application release id " @@ -2010,9 +2060,178 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } + @Override + public int getDeviceSubscriptionCount(int appReleaseId, boolean unsubscribe, int tenantId, + List deviceIds, List actionStatus, String actionType, + String actionTriggeredBy) throws ApplicationManagementDAOException { + int deviceCount = 0; + + if (deviceIds == null || deviceIds.isEmpty()) return deviceCount; + + try { + Connection conn = this.getDBConnection(); + StringBuilder sql = new StringBuilder("SELECT COUNT(DISTINCT DS.DM_DEVICE_ID) AS COUNT " + + "FROM AP_DEVICE_SUBSCRIPTION DS " + + "WHERE DS.AP_APP_RELEASE_ID = ? " + + "AND DS.UNSUBSCRIBED = ? " + + "AND DS.TENANT_ID = ? " + + "AND DS.DM_DEVICE_ID IN (" + + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ") "); + + if (actionStatus != null && !actionStatus.isEmpty()) { + sql.append(" AND DS.STATUS IN ("). + append(actionStatus.stream().map(status -> "?").collect(Collectors.joining(","))).append(") "); + } + + if (actionType != null && !actionType.isEmpty()) { + sql.append(" AND DS.ACTION_TRIGGERED_FROM = ? "); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + sql.append(" AND DS.SUBSCRIBED_BY LIKE ?"); + } + + try (PreparedStatement ps = conn.prepareStatement(sql.toString())) { + int paramIdx = 1; + ps.setInt(paramIdx++, appReleaseId); + ps.setBoolean(paramIdx++, unsubscribe); + ps.setInt(paramIdx++, tenantId); + for (Integer deviceId : deviceIds) { + ps.setInt(paramIdx++, deviceId); + } + + if (actionStatus != null && !actionStatus.isEmpty()) { + for (String status : actionStatus) { + ps.setString(paramIdx++, status); + } + } + + if (actionType != null && !actionType.isEmpty()) { + ps.setString(paramIdx++, actionType); + } + + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + ps.setString(paramIdx, "%" + actionTriggeredBy + "%"); + } + + try (ResultSet rs = ps.executeQuery()) { + if (log.isDebugEnabled()) { + log.debug("Successfully retrieved device subscriptions for application release id " + + appReleaseId + " and device ids " + deviceIds); + } + if (rs.next()) { + deviceCount = rs.getInt("COUNT"); + } + return deviceCount; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get device subscription data for application ID: " + appReleaseId + + " and device ids: " + deviceIds + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting device subscriptions for " + + "application Id: " + appReleaseId + " and device ids: " + deviceIds + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + +// @Override +// public List getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId, +// List deviceIds, String actionStatus, String actionType, +// String actionTriggeredBy, String tabActionStatus) throws ApplicationManagementDAOException { +// if (log.isDebugEnabled()) { +// log.debug("Getting device subscriptions for the application release id " + appReleaseId +// + " and device ids " + deviceIds + " from the database"); +// } +// try { +// Connection conn = this.getDBConnection(); +// String subscriptionStatusTime = unsubscribe ? "DS.UNSUBSCRIBED_TIMESTAMP" : "DS.SUBSCRIBED_TIMESTAMP"; +// StringBuilder sql = new StringBuilder("SELECT " +// + "DS.ID AS ID, " +// + "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, " +// + "DS.SUBSCRIBED_TIMESTAMP AS SUBSCRIBED_AT, " +// + "DS.UNSUBSCRIBED AS IS_UNSUBSCRIBED, " +// + "DS.UNSUBSCRIBED_BY AS UNSUBSCRIBED_BY, " +// + "DS.UNSUBSCRIBED_TIMESTAMP AS UNSUBSCRIBED_AT, " +// + "DS.ACTION_TRIGGERED_FROM AS ACTION_TRIGGERED_FROM, " +// + "DS.STATUS AS STATUS, " +// + "DS.DM_DEVICE_ID AS DEVICE_ID " +// + "FROM AP_DEVICE_SUBSCRIPTION DS " +// + "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.UNSUBSCRIBED = ? AND DS.TENANT_ID = ? AND DS.DM_DEVICE_ID IN (" + +// deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ") "); +// +// if (actionStatus != null && !actionStatus.isEmpty()) { +// sql.append(" AND DS.STATUS = ? "); +// } +// if (actionType != null && !actionType.isEmpty()) { +// sql.append(" AND DS.ACTION_TRIGGERED_FROM = ? "); +// } +// if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { +// sql.append(" AND DS.SUBSCRIBED_BY LIKE ? "); +// } +// +// sql.append("ORDER BY ").append(subscriptionStatusTime).append(" DESC"); +// +// try (PreparedStatement ps = conn.prepareStatement(sql.toString())) { +// int paramIdx = 1; +// ps.setInt(paramIdx++, appReleaseId); +// ps.setBoolean(paramIdx++, unsubscribe); +// ps.setInt(paramIdx++, tenantId); +// for (int i = 0; i < deviceIds.size(); i++) { +// ps.setInt(paramIdx++, deviceIds.get(i)); +// } +// +// if (actionStatus != null && !actionStatus.isEmpty()) { +// ps.setString(paramIdx++, actionStatus); +// } +// if (actionType != null && !actionType.isEmpty()) { +// ps.setString(paramIdx++, actionType); +// } +// if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { +// ps.setString(paramIdx++, "%" + actionTriggeredBy + "%"); +// } +// +// try (ResultSet rs = ps.executeQuery()) { +// if (log.isDebugEnabled()) { +// log.debug("Successfully retrieved device subscriptions for application release id " +// + appReleaseId + " and device ids " + deviceIds); +// } +// List subscriptions = new ArrayList<>(); +// while (rs.next()) { +// DeviceSubscriptionDTO subscription = new DeviceSubscriptionDTO(); +// subscription.setId(rs.getInt("ID")); +// subscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); +// subscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_AT")); +// subscription.setUnsubscribed(rs.getBoolean("IS_UNSUBSCRIBED")); +// subscription.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); +// subscription.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_AT")); +// subscription.setActionTriggeredFrom(rs.getString("ACTION_TRIGGERED_FROM")); +// subscription.setStatus(rs.getString("STATUS")); +// subscription.setDeviceId(rs.getInt("DEVICE_ID")); +// subscriptions.add(subscription); +// } +// return subscriptions; +// } +// } catch (SQLException e) { +// String msg = "Error occurred while running SQL to get device subscription data for application ID: " + appReleaseId +// + " and device ids: " + deviceIds + "."; +// log.error(msg, e); +// throw new ApplicationManagementDAOException(msg, e); +// } +// } catch (DBConnectionException e) { +// String msg = "Error occurred while obtaining the DB connection for getting device subscriptions for " +// + "application Id: " + appReleaseId + " and device ids: " + deviceIds + "."; +// log.error(msg, e); +// throw new ApplicationManagementDAOException(msg, e); +// } +// +// } + @Override public List getAllSubscriptionsDetails(int appReleaseId, boolean unsubscribe, int tenantId, - String actionStatus, String actionType, String actionTriggeredBy, + List actionStatus, String actionType, String actionTriggeredBy, int offset, int limit) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting device subscriptions for the application release id " + appReleaseId @@ -2032,11 +2251,15 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc + "DS.STATUS AS STATUS, " + "DS.DM_DEVICE_ID AS DEVICE_ID " + "FROM AP_DEVICE_SUBSCRIPTION DS " - + "WHERE DS.AP_APP_RELEASE_ID = ? AND DS.UNSUBSCRIBED = ? AND DS.TENANT_ID = ? "); + + "WHERE DS.AP_APP_RELEASE_ID = ? " + + "AND DS.UNSUBSCRIBED = ? " + + "AND DS.TENANT_ID = ? "); if (actionStatus != null && !actionStatus.isEmpty()) { - sql.append(" AND DS.STATUS = ? "); + sql.append(" AND DS.STATUS IN ("). + append(actionStatus.stream().map(status -> "?").collect(Collectors.joining(","))).append(") "); } + if (actionType != null && !actionType.isEmpty()) { sql.append(" AND DS.ACTION_TRIGGERED_FROM = ? "); } @@ -2044,8 +2267,11 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc sql.append(" AND ").append(actionTriggeredColumn).append(" LIKE ? "); } - sql.append("ORDER BY ").append(subscriptionStatusTime).append(" DESC ") - .append("LIMIT ? OFFSET ?"); + sql.append("ORDER BY ").append(subscriptionStatusTime).append(" DESC "); + + if (limit >= 0 && offset >= 0) { + sql.append("LIMIT ? OFFSET ?"); + } try { Connection conn = this.getDBConnection(); @@ -2056,17 +2282,23 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc ps.setInt(paramIdx++, tenantId); if (actionStatus != null && !actionStatus.isEmpty()) { - ps.setString(paramIdx++, actionStatus); + for (String status : actionStatus) { + ps.setString(paramIdx++, status); + } } + if (actionType != null && !actionType.isEmpty()) { ps.setString(paramIdx++, actionType); } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { ps.setString(paramIdx++, "%" + actionTriggeredBy + "%"); } - ps.setInt(paramIdx++, limit); - ps.setInt(paramIdx++, offset); + if (limit >= 0 && offset >= 0) { + ps.setInt(paramIdx++, limit); + ps.setInt(paramIdx, offset); + } try (ResultSet rs = ps.executeQuery()) { if (log.isDebugEnabled()) { @@ -2104,6 +2336,70 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } } + @Override + public int getAllSubscriptionsCount(int appReleaseId, boolean unsubscribe, int tenantId, + List actionStatus, String actionType, String actionTriggeredBy) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting device subscriptions for the application release id " + appReleaseId + + " from the database"); + } + String actionTriggeredColumn = unsubscribe ? "DS.UNSUBSCRIBED_BY" : "DS.SUBSCRIBED_BY"; + StringBuilder sql = new StringBuilder("SELECT COUNT(DISTINCT DS.DM_DEVICE_ID) AS COUNT " + + "FROM AP_DEVICE_SUBSCRIPTION DS " + + "WHERE DS.AP_APP_RELEASE_ID = ? " + + "AND DS.UNSUBSCRIBED = ? " + + "AND DS.TENANT_ID = ? "); + + if (actionStatus != null && !actionStatus.isEmpty()) { + sql.append(" AND DS.STATUS IN ("). + append(actionStatus.stream().map(status -> "?").collect(Collectors.joining(","))).append(") "); + } + if (actionType != null && !actionType.isEmpty()) { + sql.append(" AND DS.ACTION_TRIGGERED_FROM = ? "); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + sql.append(" AND ").append(actionTriggeredColumn).append(" LIKE ?"); + } + try { + Connection conn = this.getDBConnection(); + try (PreparedStatement ps = conn.prepareStatement(sql.toString())) { + int paramIdx = 1; + ps.setInt(paramIdx++, appReleaseId); + ps.setBoolean(paramIdx++, unsubscribe); + ps.setInt(paramIdx++, tenantId); + + if (actionStatus != null && !actionStatus.isEmpty()) { + for (String status : actionStatus) { + ps.setString(paramIdx++, status); + } + } + if (actionType != null && !actionType.isEmpty()) { + ps.setString(paramIdx++, actionType); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + ps.setString(paramIdx++, "%" + actionTriggeredBy + "%"); + } + try (ResultSet rs = ps.executeQuery()) { + if (log.isDebugEnabled()) { + log.debug("Successfully retrieved device subscriptions for application release id " + + appReleaseId); + } + return rs.next() ? rs.getInt("COUNT") : 0; + } + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting device subscription for " + + "application Id: " + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get device subscription data for application ID: " + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + @Override public int getAllSubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException { @@ -2496,13 +2792,85 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } } + // todo: fixed the status + @Override + public SubscriptionStatisticDTO getSubscriptionStatistic(List deviceIds, String subscriptionType, + boolean isUnsubscribed, int tenantId) + throws ApplicationManagementDAOException { + SubscriptionStatisticDTO subscriptionStatisticDTO = new SubscriptionStatisticDTO(); + if (deviceIds == null || deviceIds.isEmpty()) return subscriptionStatisticDTO; + + boolean doesAllEntriesRequired = true; + try { + Connection connection = getDBConnection(); + String sql = "SELECT COUNT(DISTINCT ID) AS COUNT, " + + "STATUS FROM AP_DEVICE_SUBSCRIPTION " + + "WHERE TENANT_ID = ? " + + "AND UNSUBSCRIBED = ?" + + "AND DM_DEVICE_ID IN (" + + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ")"; + + if (!Objects.equals(subscriptionType, SubscriptionMetadata.SubscriptionTypes.DEVICE)) { + sql += " AND ACTION_TRIGGERED_FROM = ?"; + doesAllEntriesRequired = false; + } + + sql += " GROUP BY (STATUS)"; + + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int idx = 1; + + preparedStatement.setInt(idx++, tenantId); + preparedStatement.setBoolean(idx++, isUnsubscribed); + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(idx++, deviceId); + } + + if (!doesAllEntriesRequired) { + preparedStatement.setString(idx, subscriptionType); + } + try (ResultSet resultSet = preparedStatement.executeQuery()) { + while (resultSet.next()) { + // add the error and in progress + int count = resultSet.getInt("COUNT"); + String status = resultSet.getString("STATUS"); + + if (SubscriptionMetadata.DBSubscriptionStatus.COMPLETED_STATUS_LIST.contains(status)) { + subscriptionStatisticDTO.addToComplete(count); + } + + if (SubscriptionMetadata.DBSubscriptionStatus.PENDING_STATUS_LIST.contains(status)) { + subscriptionStatisticDTO.addToPending(count); + } + if (SubscriptionMetadata.DBSubscriptionStatus.ERROR_STATUS_LIST.contains(status)) { + subscriptionStatisticDTO.addToFailed(count); + } + } + } + } + return subscriptionStatisticDTO; + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting subscription statistics"; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while running SQL for getting subscription statistics"; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + public int countSubscriptionsByStatus(int appReleaseId, int tenantId, String actionStatus, String actionTriggeredFrom) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to count device subscriptions by status and actionTriggeredFrom for the given AppReleaseID."); } try { Connection conn = this.getDBConnection(); - String sql = "SELECT COUNT(*) FROM AP_DEVICE_SUBSCRIPTION WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ? AND STATUS = ? AND ACTION_TRIGGERED_FROM = ?"; + String sql = "SELECT COUNT(*) FROM AP_DEVICE_SUBSCRIPTION " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? " + + "AND STATUS = ?" + + " AND ACTION_TRIGGERED_FROM = ?"; try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); @@ -2525,4 +2893,5 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } return 0; } + } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java index 9181b9b4de..71bd17bbc9 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java @@ -18,6 +18,8 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; @@ -28,7 +30,9 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; /** * This handles Application subscribing operations which are specific to Oracle. @@ -157,4 +161,379 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { throw new ApplicationManagementDAOException(msg, e); } } + + // passed the required list for the action status + @Override + public List getSubscriptionDetailsByDeviceIds(int appReleaseId, boolean unsubscribe, int tenantId, + List deviceIds, List actionStatus, String actionType, + String actionTriggeredBy, int limit, int offset) throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting device subscriptions for the application release id " + appReleaseId + + " and device ids " + deviceIds + " from the database"); + } + if (deviceIds == null || deviceIds.isEmpty()) { + return Collections.emptyList(); + } + try { + Connection conn = this.getDBConnection(); + String subscriptionStatusTime = unsubscribe ? "DS.UNSUBSCRIBED_TIMESTAMP" : "DS.SUBSCRIBED_TIMESTAMP"; + StringBuilder sql = new StringBuilder("SELECT " + + "DS.ID AS ID, " + + "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, " + + "DS.SUBSCRIBED_TIMESTAMP AS SUBSCRIBED_AT, " + + "DS.UNSUBSCRIBED AS IS_UNSUBSCRIBED, " + + "DS.UNSUBSCRIBED_BY AS UNSUBSCRIBED_BY, " + + "DS.UNSUBSCRIBED_TIMESTAMP AS UNSUBSCRIBED_AT, " + + "DS.ACTION_TRIGGERED_FROM AS ACTION_TRIGGERED_FROM, " + + "DS.STATUS AS STATUS, " + + "DS.DM_DEVICE_ID AS DEVICE_ID " + + "FROM AP_DEVICE_SUBSCRIPTION DS " + + "WHERE DS.AP_APP_RELEASE_ID = ? " + + "AND DS.UNSUBSCRIBED = ? " + + "AND DS.TENANT_ID = ? " + + "AND DS.DM_DEVICE_ID IN (" + + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ") "); + if (actionStatus != null && !actionStatus.isEmpty()) { + sql.append(" AND DS.STATUS IN ("). + append(actionStatus.stream().map(status -> "?").collect(Collectors.joining(","))).append(") "); + } + if (actionType != null && !actionType.isEmpty()) { + sql.append(" AND DS.ACTION_TRIGGERED_FROM = ? "); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + sql.append(" AND DS.SUBSCRIBED_BY LIKE ? "); + } + sql.append("ORDER BY ").append(subscriptionStatusTime). + append(" DESC "); + if (offset >= 0 && limit >= 0) { + sql.append("OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"); + } + try (PreparedStatement ps = conn.prepareStatement(sql.toString())) { + int paramIdx = 1; + ps.setInt(paramIdx++, appReleaseId); + ps.setBoolean(paramIdx++, unsubscribe); + ps.setInt(paramIdx++, tenantId); + for (Integer deviceId : deviceIds) { + ps.setInt(paramIdx++, deviceId); + } + if (actionStatus != null && !actionStatus.isEmpty()) { + for (String status : actionStatus) { + ps.setString(paramIdx++, status); + } + } + if (actionType != null && !actionType.isEmpty()) { + ps.setString(paramIdx++, actionType); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + ps.setString(paramIdx++, "%" + actionTriggeredBy + "%"); + } + if (offset >= 0 && limit >= 0) { + ps.setInt(paramIdx++, offset); + ps.setInt(paramIdx, limit); + } + try (ResultSet rs = ps.executeQuery()) { + if (log.isDebugEnabled()) { + log.debug("Successfully retrieved device subscriptions for application release id " + + appReleaseId + " and device ids " + deviceIds); + } + List subscriptions = new ArrayList<>(); + while (rs.next()) { + DeviceSubscriptionDTO subscription = new DeviceSubscriptionDTO(); + subscription.setId(rs.getInt("ID")); + subscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + subscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_AT")); + subscription.setUnsubscribed(rs.getBoolean("IS_UNSUBSCRIBED")); + subscription.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + subscription.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_AT")); + subscription.setActionTriggeredFrom(rs.getString("ACTION_TRIGGERED_FROM")); + subscription.setStatus(rs.getString("STATUS")); + subscription.setDeviceId(rs.getInt("DEVICE_ID")); + subscriptions.add(subscription); + } + return subscriptions; + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get device subscription data for application ID: " + appReleaseId + + " and device ids: " + deviceIds + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting device subscriptions for " + + "application Id: " + appReleaseId + " and device ids: " + deviceIds + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public List getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, + int limit) throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to get role subscriptions related to the given AppReleaseID."); + } + try { + Connection conn = this.getDBConnection(); + List subscriptionEntities = new ArrayList<>(); + + String subscriptionStatusTime = unsubscribe ? "ARS.UNSUBSCRIBED_TIMESTAMP" : "ARS.SUBSCRIBED_TIMESTAMP"; + String sql = "SELECT ARS.ROLE_NAME, " + + "ARS.SUBSCRIBED_BY, " + + "ARS.SUBSCRIBED_TIMESTAMP, " + + "ARS.UNSUBSCRIBED, " + + "ARS.UNSUBSCRIBED_BY, " + + "ARS.UNSUBSCRIBED_TIMESTAMP, " + + "ARS.AP_APP_RELEASE_ID " + + "FROM AP_ROLE_SUBSCRIPTION ARS " + + "WHERE ARS.AP_APP_RELEASE_ID = ? " + + "AND ARS.UNSUBSCRIBED = ? " + + "AND ARS.TENANT_ID = ? " + + "ORDER BY " + subscriptionStatusTime + " DESC " + + "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setBoolean(2, unsubscribe); + ps.setInt(3, tenantId); + ps.setInt(4, offset); + ps.setInt(5, limit); + try (ResultSet rs = ps.executeQuery()) { + SubscriptionEntity subscriptionEntity; + while (rs.next()) { + subscriptionEntity = new SubscriptionEntity(); + subscriptionEntity.setIdentity(rs.getString("ROLE_NAME")); + subscriptionEntity.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + subscriptionEntity.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); + subscriptionEntity.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + subscriptionEntity.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setApplicationReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + + subscriptionEntities.add(subscriptionEntity); + } + } + return subscriptionEntities; + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection to get role subscriptions for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "SQL Error occurred while getting role subscriptions for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public List getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, + int offset, int limit) throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to get user subscriptions related to the given UUID."); + } + try { + Connection conn = this.getDBConnection(); + List subscriptionEntities = new ArrayList<>(); + + String subscriptionStatusTime = unsubscribe ? "US.UNSUBSCRIBED_TIMESTAMP" : "US.SUBSCRIBED_TIMESTAMP"; + String sql = "SELECT US.USER_NAME, " + + "US.SUBSCRIBED_BY, " + + "US.SUBSCRIBED_TIMESTAMP, " + + "US.UNSUBSCRIBED, " + + "US.UNSUBSCRIBED_BY, " + + "US.UNSUBSCRIBED_TIMESTAMP, " + + "US.AP_APP_RELEASE_ID " + + "FROM AP_USER_SUBSCRIPTION US " + + "WHERE US.AP_APP_RELEASE_ID = ? " + + "AND US.UNSUBSCRIBED = ? " + + "AND US.TENANT_ID = ? " + + "ORDER BY " + subscriptionStatusTime + " DESC " + + "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setBoolean(2, unsubscribe); + ps.setInt(3, tenantId); + ps.setInt(4, offset); + ps.setInt(5, limit); + try (ResultSet rs = ps.executeQuery()) { + SubscriptionEntity subscriptionEntity; + while (rs.next()) { + subscriptionEntity = new SubscriptionEntity(); + subscriptionEntity.setIdentity(rs.getString("USER_NAME")); + subscriptionEntity.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + subscriptionEntity.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); + subscriptionEntity.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + subscriptionEntity.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setApplicationReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + + subscriptionEntities.add(subscriptionEntity); + } + } + return subscriptionEntities; + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection to get user subscriptions for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "SQL Error occurred while getting user subscriptions for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public List getGroupsSubscriptionDetailsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) + throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Request received in DAO Layer to get groups related to the given AppReleaseID."); + } + try { + Connection conn = this.getDBConnection(); + List subscriptionEntities = new ArrayList<>(); + + String subscriptionStatusTime = unsubscribe ? "GS.UNSUBSCRIBED_TIMESTAMP" : "GS.SUBSCRIBED_TIMESTAMP"; + String sql = "SELECT GS.GROUP_NAME, " + + "GS.SUBSCRIBED_BY, " + + "GS.SUBSCRIBED_TIMESTAMP, " + + "GS.UNSUBSCRIBED, " + + "GS.UNSUBSCRIBED_BY, " + + "GS.UNSUBSCRIBED_TIMESTAMP, " + + "GS.AP_APP_RELEASE_ID " + + "FROM AP_GROUP_SUBSCRIPTION GS " + + "WHERE GS.AP_APP_RELEASE_ID = ? " + + "AND GS.UNSUBSCRIBED = ? AND GS.TENANT_ID = ? " + + "ORDER BY " + subscriptionStatusTime + " DESC " + + "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + ps.setInt(1, appReleaseId); + ps.setBoolean(2, unsubscribe); + ps.setInt(3, tenantId); + ps.setInt(4, offset); + ps.setInt(5, limit); + + try (ResultSet rs = ps.executeQuery()) { + SubscriptionEntity subscriptionEntity; + while (rs.next()) { + subscriptionEntity = new SubscriptionEntity(); + subscriptionEntity.setIdentity(rs.getString("GROUP_NAME")); + subscriptionEntity.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + subscriptionEntity.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); + subscriptionEntity.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + subscriptionEntity.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_TIMESTAMP")); + subscriptionEntity.setApplicationReleaseId(rs.getInt("AP_APP_RELEASE_ID")); + + subscriptionEntities.add(subscriptionEntity); + } + } + return subscriptionEntities; + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection to get groups for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "SQL Error occurred while getting groups for the given UUID."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } + + @Override + public List getAllSubscriptionsDetails(int appReleaseId, boolean unsubscribe, int tenantId, + List actionStatus, String actionType, String actionTriggeredBy, + int offset, int limit) throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Getting device subscriptions for the application release id " + appReleaseId + " from the database"); + } + String subscriptionStatusTime = unsubscribe ? "DS.UNSUBSCRIBED_TIMESTAMP" : "DS.SUBSCRIBED_TIMESTAMP"; + String actionTriggeredColumn = unsubscribe ? "DS.UNSUBSCRIBED_BY" : "DS.SUBSCRIBED_BY"; + StringBuilder sql = new StringBuilder("SELECT " + + "DS.ID AS ID, " + + "DS.SUBSCRIBED_BY AS SUBSCRIBED_BY, " + + "DS.SUBSCRIBED_TIMESTAMP AS SUBSCRIBED_AT, " + + "DS.UNSUBSCRIBED AS IS_UNSUBSCRIBED, " + + "DS.UNSUBSCRIBED_BY AS UNSUBSCRIBED_BY, " + + "DS.UNSUBSCRIBED_TIMESTAMP AS UNSUBSCRIBED_AT, " + + "DS.ACTION_TRIGGERED_FROM AS ACTION_TRIGGERED_FROM, " + + "DS.STATUS AS STATUS, " + + "DS.DM_DEVICE_ID AS DEVICE_ID " + + "FROM AP_DEVICE_SUBSCRIPTION DS " + + "WHERE DS.AP_APP_RELEASE_ID = ? " + + "AND DS.UNSUBSCRIBED = ? " + + "AND DS.TENANT_ID = ? "); + if (actionStatus != null && !actionStatus.isEmpty()) { + sql.append(" AND DS.STATUS IN (") + .append(actionStatus.stream().map(status -> "?").collect(Collectors.joining(","))).append(") "); + } + if (actionType != null && !actionType.isEmpty()) { + sql.append(" AND DS.ACTION_TRIGGERED_FROM = ? "); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + sql.append(" AND ").append(actionTriggeredColumn).append(" LIKE ? "); + } + sql.append("ORDER BY ").append(subscriptionStatusTime).append(" DESC "); + if (limit >= 0 && offset >= 0) { + sql.append("OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"); + } + try { + Connection conn = this.getDBConnection(); + try (PreparedStatement ps = conn.prepareStatement(sql.toString())) { + int paramIdx = 1; + ps.setInt(paramIdx++, appReleaseId); + ps.setBoolean(paramIdx++, unsubscribe); + ps.setInt(paramIdx++, tenantId); + if (actionStatus != null && !actionStatus.isEmpty()) { + for (String status : actionStatus) { + ps.setString(paramIdx++, status); + } + } + if (actionType != null && !actionType.isEmpty()) { + ps.setString(paramIdx++, actionType); + } + if (actionTriggeredBy != null && !actionTriggeredBy.isEmpty()) { + ps.setString(paramIdx++, "%" + actionTriggeredBy + "%"); + } + if (limit >= 0 && offset >= 0) { + ps.setInt(paramIdx++, offset); + ps.setInt(paramIdx, limit); + } + try (ResultSet rs = ps.executeQuery()) { + if (log.isDebugEnabled()) { + log.debug("Successfully retrieved device subscriptions for application release id " + + appReleaseId); + } + List deviceSubscriptions = new ArrayList<>(); + while (rs.next()) { + DeviceSubscriptionDTO subscription = new DeviceSubscriptionDTO(); + subscription.setId(rs.getInt("ID")); + subscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); + subscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_AT")); + subscription.setUnsubscribed(rs.getBoolean("IS_UNSUBSCRIBED")); + subscription.setUnsubscribedBy(rs.getString("UNSUBSCRIBED_BY")); + subscription.setUnsubscribedTimestamp(rs.getTimestamp("UNSUBSCRIBED_AT")); + subscription.setActionTriggeredFrom(rs.getString("ACTION_TRIGGERED_FROM")); + subscription.setStatus(rs.getString("STATUS")); + subscription.setDeviceId(rs.getInt("DEVICE_ID")); + + deviceSubscriptions.add(subscription); + } + return deviceSubscriptions; + } + } + } catch (DBConnectionException e) { + String msg = "Error occurred while obtaining the DB connection for getting device subscription for application Id: " + + appReleaseId + "."; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get device subscription data for application ID: " + appReleaseId; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index b7dc62a0fc..49552ea153 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -24,17 +24,17 @@ import io.entgra.device.mgt.core.application.mgt.common.ApplicationSubscriptionI import io.entgra.device.mgt.core.application.mgt.common.ApplicationType; import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult; import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionResponse; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionStatistics; import io.entgra.device.mgt.core.application.mgt.common.dto.CategorizedSubscriptionCountsDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionResponseDTO; import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; import io.entgra.device.mgt.core.application.mgt.common.SubAction; import io.entgra.device.mgt.core.application.mgt.common.SubscribingDeviceIdHolder; import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; -import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; @@ -45,15 +45,13 @@ import io.entgra.device.mgt.core.application.mgt.common.services.VPPApplicationM import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.VppApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementServiceProvider; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; -import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO; -import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO; import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dto.OperationDTO; -import io.entgra.device.mgt.core.device.mgt.core.dto.OwnerWithDeviceDTO; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.AppInstallLogContext; import io.entgra.device.mgt.core.notification.logger.impl.EntgraAppInstallLoggerImpl; @@ -112,7 +110,6 @@ import io.entgra.device.mgt.core.device.mgt.core.util.MDMIOSOperationUtil; import io.entgra.device.mgt.core.device.mgt.core.util.MDMWindowsOperationUtil; import io.entgra.device.mgt.core.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.api.UserStoreManager; import javax.ws.rs.core.MediaType; import java.io.BufferedReader; @@ -127,7 +124,6 @@ import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -135,7 +131,6 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -1703,1111 +1698,48 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } } + /** + * Get subscription data describes by {@link SubscriptionInfo} entity + * @param subscriptionInfo {@link SubscriptionInfo} + * @param limit Limit value + * @param offset Offset value + * @return {@link SubscriptionResponse} + * @throws ApplicationManagementException Throws when error encountered while getting subscription data + */ @Override - public List getGroupsSubscriptionDetailsByUUID( - String uuid, String subscriptionStatus, PaginationRequest request, int offset, int limit) + public SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException { - - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); - - try { - ConnectionManagerUtil.openDBConnection(); - - ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); - if (applicationReleaseDTO == null) { - String msg = "Couldn't find an application release for application release UUID: " + uuid; - log.error(msg); - throw new NotFoundException(msg); - } - ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); - int appReleaseId = applicationReleaseDTO.getId(); - List groupDetailsWithDevices = new ArrayList<>(); - - List groupDetails = - subscriptionDAO.getGroupsSubscriptionDetailsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, -1); - if (groupDetails == null) { - throw new ApplicationManagementException("Group details not found for appReleaseId: " + appReleaseId); - } - - GroupManagementProviderService groupManagementProviderService = HelperUtil.getGroupManagementProviderService(); - - for (GroupSubscriptionDTO groupDetail : groupDetails) { - - if (StringUtils.isNotBlank(request.getGroupName()) && !request.getGroupName().equals(groupDetail.getGroupName())) { - continue; - } - - String groupName = StringUtils.isNotBlank(request.getGroupName()) ? request.getGroupName() : groupDetail.getGroupName(); - - // Retrieve group details and device IDs for the group using the service layer - GroupDetailsDTO groupDetailWithDevices = - groupManagementProviderService.getGroupDetailsWithDevices( - groupName, applicationDTO.getDeviceTypeId(), request.getOwner(), - request.getDeviceName(), request.getDeviceStatus(), offset, -1); - - SubscriptionsDTO groupDetailDTO = new SubscriptionsDTO(); - groupDetailDTO.setId(groupDetailWithDevices.getGroupId()); - groupDetailDTO.setName(groupDetail.getGroupName()); - groupDetailDTO.setOwner(groupDetailWithDevices.getGroupOwner()); - groupDetailDTO.setSubscribedBy(groupDetail.getSubscribedBy()); - groupDetailDTO.setSubscribedTimestamp(groupDetail.getSubscribedTimestamp()); - groupDetailDTO.setUnsubscribed(groupDetail.isUnsubscribed()); - groupDetailDTO.setUnsubscribedBy(groupDetail.getUnsubscribedBy()); - groupDetailDTO.setUnsubscribedTimestamp(groupDetail.getUnsubscribedTimestamp()); - groupDetailDTO.setAppReleaseId(groupDetail.getAppReleaseId()); - groupDetailDTO.setDeviceCount(groupDetailWithDevices.getDeviceCount()); - - // Fetch device subscriptions for each device ID in the group - List pendingDevices = new ArrayList<>(); - List installedDevices = new ArrayList<>(); - List errorDevices = new ArrayList<>(); - List newDevices = new ArrayList<>(); - List subscribedDevices = new ArrayList<>(); - - List deviceIds = groupDetailWithDevices.getDeviceIds(); - Map statusCounts = new HashMap<>(); - statusCounts.put("COMPLETED", 0); - statusCounts.put("ERROR", 0); - statusCounts.put("PENDING", 0); - statusCounts.put("NEW", 0); - statusCounts.put("SUBSCRIBED", 0); - - for (Integer deviceId : deviceIds) { - // Get subscribed devices if unsubscribed devices are requested - List deviceSubscriptions; - if (unsubscribe) { - deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - appReleaseId, !unsubscribe, tenantId, deviceIds, - request.getActionStatus(), request.getActionType(), request.getActionTriggeredBy(), request.getTabActionStatus()); - } else { - deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - groupDetail.getAppReleaseId(), false, tenantId, deviceIds, - request.getActionStatus(), request.getActionType(), request.getActionTriggeredBy(), request.getTabActionStatus()); - } - List filteredDeviceSubscriptions = deviceSubscriptions.stream() - .filter(subscription -> StringUtils.isBlank(request.getTabActionStatus()) || subscription.getStatus().equals(request.getTabActionStatus())) - .collect(Collectors.toList()); - boolean isNewDevice = true; - for (DeviceSubscriptionDTO subscription : filteredDeviceSubscriptions) { - if (subscription.getDeviceId() == deviceId) { - DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); - deviceDetail.setDeviceId(subscription.getDeviceId()); - deviceDetail.setStatus(subscription.getStatus()); - deviceDetail.setActionType(subscription.getActionTriggeredFrom()); - deviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId)); - deviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId)); - deviceDetail.setDeviceName(groupDetailWithDevices.getDeviceNames().get(deviceId)); - deviceDetail.setSubId(subscription.getId()); - deviceDetail.setActionTriggeredBy(subscription.getSubscribedBy()); - deviceDetail.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); - deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); - deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); - deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); - deviceDetail.setType(groupDetailWithDevices.getDeviceTypes().get(deviceId)); - deviceDetail.setDeviceIdentifier(groupDetailWithDevices.getDeviceIdentifiers().get(deviceId)); - - String status = subscription.getStatus(); - switch (status) { - case "COMPLETED": - installedDevices.add(deviceDetail); - statusCounts.put("COMPLETED", statusCounts.get("COMPLETED") + 1); - break; - case "ERROR": - case "INVALID": - case "UNAUTHORIZED": - errorDevices.add(deviceDetail); - statusCounts.put("ERROR", statusCounts.get("ERROR") + 1); - break; - case "IN_PROGRESS": - case "PENDING": - case "REPEATED": - pendingDevices.add(deviceDetail); - statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); - break; - default: - newDevices.add(deviceDetail); - statusCounts.put("NEW", statusCounts.get("NEW") + 1); - break; - } - isNewDevice = false; - } - } - if (isNewDevice) { - boolean isSubscribedDevice = false; - for (DeviceSubscriptionDTO subscribedDevice : deviceSubscriptions) { - if (subscribedDevice.getDeviceId() == deviceId) { - DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); - subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); - subscribedDeviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId)); - subscribedDeviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId)); - subscribedDeviceDetail.setDeviceName(groupDetailWithDevices.getDeviceNames().get(deviceId)); - subscribedDeviceDetail.setSubId(subscribedDevice.getId()); - subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); - subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); - subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); - subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); - subscribedDeviceDetail.setType(groupDetailWithDevices.getDeviceTypes().get(deviceId)); - subscribedDeviceDetail.setDeviceIdentifier(groupDetailWithDevices.getDeviceIdentifiers().get(deviceId)); - subscribedDevices.add(subscribedDeviceDetail); - statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); - isSubscribedDevice = true; - break; - } - } - if (!isSubscribedDevice) { - DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); - newDeviceDetail.setDeviceId(deviceId); - newDeviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId)); - newDeviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId)); - newDeviceDetail.setDeviceName(groupDetailWithDevices.getDeviceNames().get(deviceId)); - newDeviceDetail.setType(groupDetailWithDevices.getDeviceTypes().get(deviceId)); - newDeviceDetail.setDeviceIdentifier(groupDetailWithDevices.getDeviceIdentifiers().get(deviceId)); - newDevices.add(newDeviceDetail); - statusCounts.put("NEW", statusCounts.get("NEW") + 1); - } - } - } - - int totalDevices = deviceIds.size(); - Map statusPercentages = new HashMap<>(); - for (Map.Entry entry : statusCounts.entrySet()) { - double percentage = ((double) entry.getValue() / totalDevices) * 100; - String formattedPercentage = String.format("%.2f", percentage); - statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); - } - - List requestedDevices = new ArrayList<>(); - int installedCount; - int pendingCount; - int errorCount; - int newCount; - int subscribedCount; - int totalDeviceCount = - groupManagementProviderService.getDeviceCount(groupDetailWithDevices.getGroupId()); - - if (StringUtils.isNotBlank(request.getTabActionStatus())) { - switch (request.getTabActionStatus()) { - case "COMPLETED": - requestedDevices = installedDevices; - installedCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, request.getTabActionStatus(), request.getActionType()); - break; - case "PENDING": - requestedDevices = pendingDevices; - pendingCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, request.getTabActionStatus(), request.getActionType()); - break; - case "ERROR": - requestedDevices = errorDevices; - errorCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, request.getTabActionStatus(), request.getActionType()); - break; - case "NEW": - requestedDevices = newDevices; - break; - case "SUBSCRIBED": - requestedDevices = subscribedDevices; - subscribedCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, request.getTabActionStatus(), request.getActionType()); - break; - } - groupDetailDTO.setDevices(new CategorizedSubscriptionResult(requestedDevices, request.getTabActionStatus())); - } else { - CategorizedSubscriptionResult categorizedSubscriptionResult; - - installedCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, "COMPLETED", request.getActionType()); - pendingCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, "PENDING", request.getActionType()); - errorCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, "ERROR", request.getActionType()); - subscribedCount = subscriptionDAO.countSubscriptionsByStatus(appReleaseId, tenantId, "SUBSCRIBED", request.getActionType()); - newCount = totalDeviceCount - (installedCount + pendingCount + errorCount + subscribedCount); - - List paginatedInstalledDevices = installedDevices.stream() - .skip(offset) - .limit(limit) - .collect(Collectors.toList()); - List paginatedPendingDevices = pendingDevices.stream() - .skip(offset) - .limit(limit) - .collect(Collectors.toList()); - List paginatedErrorDevices = errorDevices.stream() - .skip(offset) - .limit(limit) - .collect(Collectors.toList()); - List paginatedNewDevices = newDevices.stream() - .skip(offset) - .limit(limit) - .collect(Collectors.toList()); - List paginatedSubscribedDevices = subscribedDevices.stream() - .skip(offset) - .limit(limit) - .collect(Collectors.toList()); - - if (subscribedDevices.isEmpty()) { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(paginatedInstalledDevices, paginatedPendingDevices, paginatedErrorDevices, paginatedNewDevices, installedCount, pendingCount, errorCount, newCount); - } else { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(paginatedInstalledDevices, paginatedPendingDevices, paginatedErrorDevices, paginatedNewDevices, paginatedSubscribedDevices, installedCount, pendingCount, errorCount, newCount, subscribedCount); - } - groupDetailDTO.setDevices(categorizedSubscriptionResult); - } - groupDetailDTO.setStatusPercentages(statusPercentages); - groupDetailsWithDevices.add(groupDetailDTO); - } - - return groupDetailsWithDevices; - } catch (ApplicationManagementDAOException e) { - String msg = "Error occurred while fetching groups and devices for UUID: " + uuid; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (DBConnectionException e) { - String msg = "DB Connection error occurred while fetching groups and devices for UUID: " + uuid; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (GroupManagementException e) { - String msg = "Error occurred while fetching group details and device IDs: " + e.getMessage(); - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } finally { - ConnectionManagerUtil.closeDBConnection(); - } + SubscriptionManagementHelperService subscriptionManagementHelperService = + SubscriptionManagementServiceProvider.getInstance().getSubscriptionManagementHelperService(subscriptionInfo); + return subscriptionManagementHelperService.getSubscriptions(subscriptionInfo, limit, offset); } + /** + * Get status based subscription data describes by {@link SubscriptionInfo} entity + * @param subscriptionInfo {@link SubscriptionInfo} + * @param limit Limit value + * @param offset Offset value + * @return {@link SubscriptionResponse} + * @throws ApplicationManagementException Throws when error encountered while getting subscription data + */ @Override - public List getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, - PaginationRequest request, int offset, int limit) + public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); - String status; - - try { - ConnectionManagerUtil.openDBConnection(); - - ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); - if (applicationReleaseDTO == null) { - String msg = "Couldn't find an application release for application release UUID: " + uuid; - log.error(msg); - throw new NotFoundException(msg); - } - ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); - int appReleaseId = applicationReleaseDTO.getId(); - List userSubscriptionsWithDevices = new ArrayList<>(); - - List userSubscriptions = - subscriptionDAO.getUserSubscriptionsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); - if (userSubscriptions == null) { - throw new ApplicationManagementException("User details not found for appReleaseId: " + appReleaseId); - } - - DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); - - for (SubscriptionsDTO userSubscription : userSubscriptions) { - - if (StringUtils.isNotBlank(request.getUserName()) && !request.getUserName().equals(userSubscription.getName())) { - continue; - } - - String userName = StringUtils.isNotBlank(request.getUserName()) ? request.getUserName() : userSubscription.getName(); - - // Retrieve owner details and device IDs for the user using the service layer - OwnerWithDeviceDTO ownerDetailsWithDevices = - deviceManagementProviderService.getOwnersWithDeviceIds(userName, applicationDTO.getDeviceTypeId(), - request.getOwner(), request.getDeviceName(), request.getDeviceStatus()); - - SubscriptionsDTO userSubscriptionDTO = new SubscriptionsDTO(); - userSubscriptionDTO.setName(userSubscription.getName()); - userSubscriptionDTO.setSubscribedBy(userSubscription.getSubscribedBy()); - userSubscriptionDTO.setSubscribedTimestamp(userSubscription.getSubscribedTimestamp()); - userSubscriptionDTO.setUnsubscribed(userSubscription.getUnsubscribed()); - userSubscriptionDTO.setUnsubscribedBy(userSubscription.getUnsubscribedBy()); - userSubscriptionDTO.setUnsubscribedTimestamp(userSubscription.getUnsubscribedTimestamp()); - userSubscriptionDTO.setAppReleaseId(userSubscription.getAppReleaseId()); - - userSubscriptionDTO.setDeviceCount(ownerDetailsWithDevices.getDeviceCount()); - - // Fetch device subscriptions for each device ID associated with the user - List pendingDevices = new ArrayList<>(); - List installedDevices = new ArrayList<>(); - List errorDevices = new ArrayList<>(); - List newDevices = new ArrayList<>(); - List subscribedDevices = new ArrayList<>(); - - List deviceIds = ownerDetailsWithDevices.getDeviceIds(); - Map statusCounts = new HashMap<>(); - statusCounts.put("PENDING", 0); - statusCounts.put("COMPLETED", 0); - statusCounts.put("ERROR", 0); - statusCounts.put("NEW", 0); - statusCounts.put("SUBSCRIBED", 0); - - List subscribedDeviceSubscriptions = new ArrayList<>(); - if (unsubscribe) { - subscribedDeviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - appReleaseId, !unsubscribe, tenantId, deviceIds, request.getActionStatus(), request.getActionType(), - request.getActionTriggeredBy(), request.getTabActionStatus()); - } - - for (Integer deviceId : deviceIds) { - List deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - userSubscription.getAppReleaseId(), unsubscribe, tenantId, deviceIds, request.getActionStatus(), request.getActionType(), - request.getActionTriggeredBy(), request.getTabActionStatus()); - OwnerWithDeviceDTO ownerWithDeviceByDeviceId = - deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId, request.getOwner(), request.getDeviceName(), - request.getDeviceStatus()); - if (ownerWithDeviceByDeviceId == null) { - continue; - } - boolean isNewDevice = true; - for (DeviceSubscriptionDTO subscription : deviceSubscriptions) { - if (subscription.getDeviceId() == deviceId) { - DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); - deviceDetail.setDeviceId(subscription.getDeviceId()); - deviceDetail.setSubId(subscription.getId()); - deviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); - deviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); - deviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); - deviceDetail.setActionType(subscription.getActionTriggeredFrom()); - deviceDetail.setStatus(subscription.getStatus()); - deviceDetail.setActionType(subscription.getActionTriggeredFrom()); - deviceDetail.setActionTriggeredBy(subscription.getSubscribedBy()); - deviceDetail.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); - deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); - deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); - deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); - deviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); - deviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); - - status = subscription.getStatus(); - switch (status) { - case "COMPLETED": - installedDevices.add(deviceDetail); - statusCounts.put("COMPLETED", statusCounts.get("COMPLETED") + 1); - break; - case "ERROR": - case "INVALID": - case "UNAUTHORIZED": - errorDevices.add(deviceDetail); - statusCounts.put("ERROR", statusCounts.get("ERROR") + 1); - break; - case "IN_PROGRESS": - case "PENDING": - case "REPEATED": - pendingDevices.add(deviceDetail); - statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); - break; - } - isNewDevice = false; - } - } - if (isNewDevice) { - boolean isSubscribedDevice = false; - for (DeviceSubscriptionDTO subscribedDevice : subscribedDeviceSubscriptions) { - if (subscribedDevice.getDeviceId() == deviceId) { - DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); - subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); - subscribedDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); - subscribedDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); - subscribedDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); - subscribedDeviceDetail.setSubId(subscribedDevice.getId()); - subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); - subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); - subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); - subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); - subscribedDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); - subscribedDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); - subscribedDevices.add(subscribedDeviceDetail); - statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); - isSubscribedDevice = true; - break; - } - } - if (!isSubscribedDevice) { - DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); - newDeviceDetail.setDeviceId(deviceId); - newDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); - newDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); - newDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); - newDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); - newDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); - newDevices.add(newDeviceDetail); - statusCounts.put("NEW", statusCounts.get("NEW") + 1); - } - } - } - - int totalDevices = deviceIds.size(); - Map statusPercentages = new HashMap<>(); - for (Map.Entry entry : statusCounts.entrySet()) { - double percentage = ((double) entry.getValue() / totalDevices) * 100; - String formattedPercentage = String.format("%.2f", percentage); - statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); - } - - List requestedDevices = new ArrayList<>(); - if (StringUtils.isNotBlank(request.getTabActionStatus())) { - switch (request.getTabActionStatus()) { - case "COMPLETED": - requestedDevices = installedDevices; - break; - case "PENDING": - requestedDevices = pendingDevices; - break; - case "ERROR": - requestedDevices = errorDevices; - break; - case "NEW": - requestedDevices = newDevices; - break; - case "SUBSCRIBED": - requestedDevices = subscribedDevices; - break; - } - userSubscriptionDTO.setDevices(new CategorizedSubscriptionResult(requestedDevices, request.getTabActionStatus())); - } else { - CategorizedSubscriptionResult categorizedSubscriptionResult; - if (subscribedDevices.isEmpty()) { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); - } else { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, - subscribedDevices); - } - userSubscriptionDTO.setDevices(categorizedSubscriptionResult); - userSubscriptionDTO.setStatusPercentages(statusPercentages); - - } - userSubscriptionsWithDevices.add(userSubscriptionDTO); - } - return userSubscriptionsWithDevices; - } catch (ApplicationManagementDAOException e) { - String msg = "Error occurred while getting user subscriptions for the application release UUID: " + uuid; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (DBConnectionException e) { - String msg = "DB Connection error occurred while getting user subscriptions for UUID: " + uuid; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (DeviceManagementDAOException e) { - throw new RuntimeException(e); - } finally { - ConnectionManagerUtil.closeDBConnection(); - } + SubscriptionManagementHelperService subscriptionManagementHelperService = + SubscriptionManagementServiceProvider.getInstance().getSubscriptionManagementHelperService(subscriptionInfo); + return subscriptionManagementHelperService.getStatusBaseSubscriptions(subscriptionInfo, limit, offset); } + /** + * Get subscription statistics related data describes by the {@link SubscriptionInfo} + * @param subscriptionInfo {@link SubscriptionInfo} + * @return {@link SubscriptionStatistics} + * @throws ApplicationManagementException Throws when error encountered while getting statistics + */ @Override - public List getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, - PaginationRequest request, int offset, int limit) - throws ApplicationManagementException { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); - String roleName; - String status; - - try { - ConnectionManagerUtil.openDBConnection(); - - ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); - if (applicationReleaseDTO == null) { - String msg = "Couldn't find an application release for application release UUID: " + uuid; - log.error(msg); - throw new NotFoundException(msg); - } - ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); - int appReleaseId = applicationReleaseDTO.getId(); - List roleSubscriptionsWithDevices = new ArrayList<>(); - - List roleSubscriptions = - subscriptionDAO.getRoleSubscriptionsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); - if (roleSubscriptions == null) { - throw new ApplicationManagementException("Role details not found for appReleaseId: " + appReleaseId); - } - - DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); - - for (SubscriptionsDTO roleSubscription : roleSubscriptions) { - - roleName = StringUtils.isNotBlank(request.getRoleName()) ? request.getRoleName() : roleSubscription.getName(); - - SubscriptionsDTO roleSubscriptionDTO = new SubscriptionsDTO(); - roleSubscriptionDTO.setName(roleSubscription.getName()); - roleSubscriptionDTO.setSubscribedBy(roleSubscription.getSubscribedBy()); - roleSubscriptionDTO.setSubscribedTimestamp(roleSubscription.getSubscribedTimestamp()); - roleSubscriptionDTO.setUnsubscribed(roleSubscription.getUnsubscribed()); - roleSubscriptionDTO.setUnsubscribedBy(roleSubscription.getUnsubscribedBy()); - roleSubscriptionDTO.setUnsubscribedTimestamp(roleSubscription.getUnsubscribedTimestamp()); - roleSubscriptionDTO.setAppReleaseId(roleSubscription.getAppReleaseId()); - - List pendingDevices = new ArrayList<>(); - List installedDevices = new ArrayList<>(); - List errorDevices = new ArrayList<>(); - List newDevices = new ArrayList<>(); - List subscribedDevices = new ArrayList<>(); - - Map statusCounts = new HashMap<>(); - statusCounts.put("PENDING", 0); - statusCounts.put("COMPLETED", 0); - statusCounts.put("ERROR", 0); - statusCounts.put("NEW", 0); - statusCounts.put("SUBSCRIBED", 0); - - List users = this.getUsersForRole(roleName); - - for (String user : users) { - OwnerWithDeviceDTO ownerDetailsWithDevices; - try { - ownerDetailsWithDevices = deviceManagementProviderService.getOwnersWithDeviceIds(user, applicationDTO.getDeviceTypeId(), - request.getOwner(), request.getDeviceName(), request.getDeviceStatus()); - } catch (DeviceManagementDAOException e) { - throw new ApplicationManagementException("Error retrieving owner details with devices for user: " + user, e); - } - - List deviceIds = ownerDetailsWithDevices.getDeviceIds(); - for (Integer deviceId : deviceIds) { - - List subscribedDeviceSubscriptions = new ArrayList<>(); - if (unsubscribe) { - subscribedDeviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - appReleaseId, !unsubscribe, tenantId, deviceIds, request.getActionStatus(), request.getActionType(), - request.getActionTriggeredBy(), request.getTabActionStatus()); - } - OwnerWithDeviceDTO ownerWithDeviceByDeviceId = - deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId, request.getOwner(), request.getDeviceName(), - request.getDeviceStatus()); - if (ownerWithDeviceByDeviceId == null) { - continue; - } - List deviceSubscriptions; - try { - deviceSubscriptions = subscriptionDAO.getSubscriptionDetailsByDeviceIds( - roleSubscription.getAppReleaseId(), unsubscribe, tenantId, deviceIds, request.getActionStatus(), - request.getActionType(), request.getActionTriggeredBy(), request.getTabActionStatus()); - } catch (ApplicationManagementDAOException e) { - throw new ApplicationManagementException("Error retrieving device subscriptions", e); - } - - boolean isNewDevice = true; - for (DeviceSubscriptionDTO deviceSubscription : deviceSubscriptions) { - if (deviceSubscription.getDeviceId() == deviceId) { - DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); - deviceDetail.setDeviceId(deviceSubscription.getDeviceId()); - deviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); - deviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); - deviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); - deviceDetail.setActionType(deviceSubscription.getActionTriggeredFrom()); - deviceDetail.setStatus(deviceSubscription.getStatus()); - deviceDetail.setActionType(deviceSubscription.getActionTriggeredFrom()); - deviceDetail.setActionTriggeredBy(deviceSubscription.getSubscribedBy()); - deviceDetail.setSubId(deviceSubscription.getId()); - deviceDetail.setActionTriggeredTimestamp(deviceSubscription.getSubscribedTimestamp()); - deviceDetail.setUnsubscribed(deviceSubscription.isUnsubscribed()); - deviceDetail.setUnsubscribedBy(deviceSubscription.getUnsubscribedBy()); - deviceDetail.setUnsubscribedTimestamp(deviceSubscription.getUnsubscribedTimestamp()); - deviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); - deviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); - - status = deviceSubscription.getStatus(); - switch (status) { - case "COMPLETED": - installedDevices.add(deviceDetail); - statusCounts.put("COMPLETED", statusCounts.get("COMPLETED") + 1); - break; - case "ERROR": - case "INVALID": - case "UNAUTHORIZED": - errorDevices.add(deviceDetail); - statusCounts.put("ERROR", statusCounts.get("ERROR") + 1); - break; - case "IN_PROGRESS": - case "PENDING": - case "REPEATED": - pendingDevices.add(deviceDetail); - statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); - break; - } - isNewDevice = false; - } - } - if (isNewDevice) { - boolean isSubscribedDevice = false; - for (DeviceSubscriptionDTO subscribedDevice : subscribedDeviceSubscriptions) { - if (subscribedDevice.getDeviceId() == deviceId) { - DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); - subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); - subscribedDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); - subscribedDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); - subscribedDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); - subscribedDeviceDetail.setSubId(subscribedDevice.getId()); - subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); - subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); - subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom()); - subscribedDeviceDetail.setStatus(subscribedDevice.getStatus()); - subscribedDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); - subscribedDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); - subscribedDevices.add(subscribedDeviceDetail); - statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); - isSubscribedDevice = true; - break; - } - } - if (!isSubscribedDevice) { - DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); - newDeviceDetail.setDeviceId(deviceId); - newDeviceDetail.setDeviceName(ownerWithDeviceByDeviceId.getDeviceNames()); - newDeviceDetail.setDeviceOwner(ownerWithDeviceByDeviceId.getUserName()); - newDeviceDetail.setDeviceStatus(ownerWithDeviceByDeviceId.getDeviceStatus()); - newDeviceDetail.setType(ownerWithDeviceByDeviceId.getDeviceTypes()); - newDeviceDetail.setDeviceIdentifier(ownerWithDeviceByDeviceId.getDeviceIdentifiers()); - newDevices.add(newDeviceDetail); - statusCounts.put("NEW", statusCounts.get("NEW") + 1); - } - } - } - } - - int totalDevices = - pendingDevices.size() + installedDevices.size() + errorDevices.size() + newDevices.size() + subscribedDevices.size(); - Map statusPercentages = new HashMap<>(); - for (Map.Entry entry : statusCounts.entrySet()) { - double percentage = totalDevices == 0 ? 0.0 : ((double) entry.getValue() / totalDevices) * 100; - String formattedPercentage = String.format("%.2f", percentage); - statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); - } - - List requestedDevices = new ArrayList<>(); - if (StringUtils.isNotBlank(request.getTabActionStatus())) { - switch (request.getTabActionStatus()) { - case "COMPLETED": - requestedDevices = installedDevices; - break; - case "PENDING": - requestedDevices = pendingDevices; - break; - case "ERROR": - requestedDevices = errorDevices; - break; - case "NEW": - requestedDevices = newDevices; - break; - case "SUBSCRIBED": - requestedDevices = subscribedDevices; - break; - } - roleSubscriptionDTO.setDevices(new CategorizedSubscriptionResult(requestedDevices, request.getTabActionStatus())); - - } else { - CategorizedSubscriptionResult categorizedSubscriptionResult; - if (subscribedDevices.isEmpty()) { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); - } else { - categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, - subscribedDevices); - } - roleSubscriptionDTO.setDevices(categorizedSubscriptionResult); - roleSubscriptionDTO.setStatusPercentages(statusPercentages); - roleSubscriptionDTO.setDeviceCount(totalDevices); - } - roleSubscriptionsWithDevices.add(roleSubscriptionDTO); - } - - return roleSubscriptionsWithDevices; - } catch (ApplicationManagementDAOException | DeviceManagementDAOException e) { - String msg = "Error occurred in retrieving role subscriptions with devices"; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (DBConnectionException e) { - String msg = "Error occurred while retrieving the database connection"; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (UserStoreException e) { - String msg = "Error occurred while retrieving users for role"; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } finally { - ConnectionManagerUtil.closeDBConnection(); - } - } - - // Get user list for each role - public List getUsersForRole(String roleName) throws UserStoreException { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - int tenantId = ctx.getTenantId(); - UserStoreManager userStoreManager = DataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId).getUserStoreManager(); - String[] users = userStoreManager.getUserListOfRole(roleName); - return Arrays.asList(users); - } - - @Override - public DeviceSubscriptionResponseDTO getDeviceSubscriptionsDetailsByUUID(String uuid, String subscriptionStatus, PaginationRequest request, int offset, - int limit) throws ApplicationManagementException { - - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); - - try { - ConnectionManagerUtil.openDBConnection(); - - ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); - if (applicationReleaseDTO == null) { - String msg = "Couldn't find an application release for application release UUID: " + uuid; - log.error(msg); - throw new NotFoundException(msg); - } - ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); - int appReleaseId = applicationReleaseDTO.getId(); - - DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); - List deviceSubscriptions = - subscriptionDAO.getDeviceSubscriptionsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); - - // empty response for no device subscriptions - if (deviceSubscriptions.isEmpty()) { - return new DeviceSubscriptionResponseDTO(0, Collections.emptyMap(), - new CategorizedSubscriptionResult(Collections.emptyList(), - Collections.emptyList(), Collections.emptyList(), Collections.emptyList())); - } - - List allDevices = - deviceManagementProviderService.getDevicesByTenantId(tenantId, applicationDTO.getDeviceTypeId(), - request.getOwner(), request.getDeviceStatus()); - - List deviceIds = allDevices.stream() - .map(DeviceDetailsDTO::getDeviceId) - .collect(Collectors.toList()); - - Map statusCounts = new HashMap<>(); - statusCounts.put("PENDING", 0); - statusCounts.put("COMPLETED", 0); - statusCounts.put("ERROR", 0); - statusCounts.put("NEW", 0); - statusCounts.put("SUBSCRIBED", 0); - - List installedDevices = new ArrayList<>(); - List pendingDevices = new ArrayList<>(); - List errorDevices = new ArrayList<>(); - List newDevices = new ArrayList<>(); - List subscribedDevices = new ArrayList<>(); - - Map deviceSubscriptionMap = deviceSubscriptions.stream() - .collect(Collectors.toMap(DeviceSubscriptionDTO::getDeviceId, Function.identity())); - Map allDevicesMap = allDevices.stream() - .collect(Collectors.toMap(DeviceDetailsDTO::getDeviceId, Function.identity())); - - List allSubscriptionsForUnSubscribed = - subscriptionDAO.getSubscriptionDetailsByDeviceIds(appReleaseId, !unsubscribe, tenantId, deviceIds, request.getActionStatus(), - request.getActionType(), request.getActionTriggeredBy(), request.getTabActionStatus()); - List allSubscriptionsForSubscribed = - subscriptionDAO.getSubscriptionDetailsByDeviceIds(appReleaseId, unsubscribe, tenantId, deviceIds, request.getActionStatus(), - request.getActionType(), request.getActionTriggeredBy(), request.getTabActionStatus()); - Map allSubscriptionForUnSubscribedMap = allSubscriptionsForUnSubscribed.stream() - .collect(Collectors.toMap(DeviceSubscriptionDTO::getDeviceId, Function.identity())); - Map allSubscriptionForSubscribedMap = allSubscriptionsForSubscribed.stream() - .collect(Collectors.toMap(DeviceSubscriptionDTO::getDeviceId, Function.identity())); - - for (DeviceDetailsDTO device : allDevices) { - Integer deviceId = device.getDeviceId(); - OwnerWithDeviceDTO ownerWithDevice = - deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId, request.getOwner(), request.getDeviceName(), - request.getDeviceStatus()); - if (ownerWithDevice == null || (request.getDeviceName() != null && !request.getDeviceName().isEmpty() && - (ownerWithDevice.getDeviceNames() == null || !ownerWithDevice.getDeviceNames().contains(request.getDeviceName())))) { - continue; - } - if (deviceSubscriptionMap.containsKey(deviceId)) { - DeviceSubscriptionDTO subscription = deviceSubscriptionMap.get(deviceId); - DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); - deviceDetail.setDeviceId(subscription.getDeviceId()); - deviceDetail.setSubId(subscription.getId()); - deviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); - deviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); - deviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); - deviceDetail.setActionType(subscription.getActionTriggeredFrom()); - deviceDetail.setStatus(subscription.getStatus()); - deviceDetail.setActionTriggeredBy(subscription.getSubscribedBy()); - deviceDetail.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); - deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); - deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); - deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); - deviceDetail.setType(ownerWithDevice.getDeviceTypes()); - deviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); - - String status = subscription.getStatus(); - switch (status) { - case "COMPLETED": - installedDevices.add(deviceDetail); - statusCounts.put("COMPLETED", statusCounts.get("COMPLETED") + 1); - break; - case "ERROR": - case "INVALID": - case "UNAUTHORIZED": - errorDevices.add(deviceDetail); - statusCounts.put("ERROR", statusCounts.get("ERROR") + 1); - break; - case "IN_PROGRESS": - case "PENDING": - case "REPEATED": - pendingDevices.add(deviceDetail); - statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); - break; - } - } else if (unsubscribe && allSubscriptionForUnSubscribedMap.containsKey(deviceId) && !deviceSubscriptionMap.containsKey(deviceId)) { - // Check if the device subscription has unsubscribed status set to false - DeviceSubscriptionDTO allSubscription = allSubscriptionForUnSubscribedMap.get(deviceId); - if (!allSubscription.isUnsubscribed()) { - DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); - subscribedDeviceDetail.setDeviceId(allSubscription.getDeviceId()); - subscribedDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); - subscribedDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); - subscribedDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); - subscribedDeviceDetail.setSubId(allSubscription.getId()); - subscribedDeviceDetail.setActionTriggeredBy(allSubscription.getSubscribedBy()); - subscribedDeviceDetail.setActionTriggeredTimestamp(allSubscription.getSubscribedTimestamp()); - subscribedDeviceDetail.setActionType(allSubscription.getActionTriggeredFrom()); - subscribedDeviceDetail.setStatus(allSubscription.getStatus()); - subscribedDeviceDetail.setType(ownerWithDevice.getDeviceTypes()); - subscribedDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); - subscribedDevices.add(subscribedDeviceDetail); - statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1); - } - } else if (unsubscribe && !allSubscriptionForUnSubscribedMap.containsKey(deviceId) && !deviceSubscriptionMap.containsKey(deviceId) - && (allDevicesMap.containsKey(deviceId))) { - DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); - newDeviceDetail.setDeviceId(deviceId); - newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); - newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); - newDeviceDetail.setType(ownerWithDevice.getDeviceTypes()); - newDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); - newDevices.add(newDeviceDetail); - statusCounts.put("NEW", statusCounts.get("NEW") + 1); - } else if (!unsubscribe && !allSubscriptionForSubscribedMap.containsKey(deviceId) && !deviceSubscriptionMap.containsKey(deviceId) - && (allDevicesMap.containsKey(deviceId))) { - DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); - newDeviceDetail.setDeviceId(deviceId); - newDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); - newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); - newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); - newDeviceDetail.setType(ownerWithDevice.getDeviceTypes()); - newDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); - newDevices.add(newDeviceDetail); - statusCounts.put("NEW", statusCounts.get("NEW") + 1); - } - } - - int totalDevices = allDevices.size(); - Map statusPercentages = new HashMap<>(); - for (Map.Entry entry : statusCounts.entrySet()) { - double percentage = ((double) entry.getValue() / totalDevices) * 100; - String formattedPercentage = String.format("%.2f", percentage); - statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); - } - - List requestedDevices = new ArrayList<>(); - if (StringUtils.isNotBlank(request.getTabActionStatus())) { - switch (request.getTabActionStatus()) { - case "COMPLETED": - requestedDevices = installedDevices; - break; - case "PENDING": - requestedDevices = pendingDevices; - break; - case "ERROR": - requestedDevices = errorDevices; - break; - case "NEW": - requestedDevices = newDevices; - break; - case "SUBSCRIBED": - requestedDevices = subscribedDevices; - break; - } - } else { - requestedDevices.addAll(installedDevices); - requestedDevices.addAll(pendingDevices); - requestedDevices.addAll(errorDevices); - requestedDevices.addAll(newDevices); - requestedDevices.addAll(subscribedDevices); - } - - CategorizedSubscriptionResult categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices, subscribedDevices); - DeviceSubscriptionResponseDTO deviceSubscriptionResponse = - new DeviceSubscriptionResponseDTO(totalDevices, statusPercentages, categorizedSubscriptionResult); - - return deviceSubscriptionResponse; - - } catch (ApplicationManagementDAOException e) { - String msg = "Error occurred while getting device subscriptions for the application release UUID: " + uuid; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (DBConnectionException e) { - String msg = "DB Connection error occurred while getting device subscriptions for UUID: " + uuid; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (DeviceManagementDAOException e) { - throw new RuntimeException(e); - } finally { - ConnectionManagerUtil.closeDBConnection(); - } - } - - @Override - public DeviceSubscriptionResponseDTO getAllSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, PaginationRequest request, - int offset, int limit) throws ApplicationManagementException { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); - - try { - ConnectionManagerUtil.openDBConnection(); - - ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO.getReleaseByUUID(uuid, tenantId); - if (applicationReleaseDTO == null) { - String msg = "Couldn't find an application release for application release UUID: " + uuid; - log.error(msg); - throw new NotFoundException(msg); - } - ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId); - int appReleaseId = applicationReleaseDTO.getId(); - - List allSubscriptions = - subscriptionDAO.getAllSubscriptionsDetails(appReleaseId, unsubscribe, tenantId, request.getActionStatus(), - request.getActionType(), request.getActionTriggeredBy(), offset, limit); - - // empty response for no subscriptions - if (allSubscriptions.isEmpty()) { - return new DeviceSubscriptionResponseDTO(0, Collections.emptyMap(), - new CategorizedSubscriptionResult(Collections.emptyList(), - Collections.emptyList(), Collections.emptyList(), Collections.emptyList())); - } - - DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); - - Map allSubscriptionMap = allSubscriptions.stream() - .collect(Collectors.toMap(DeviceSubscriptionDTO::getDeviceId, Function.identity())); - - List pendingDevices = new ArrayList<>(); - List installedDevices = new ArrayList<>(); - List errorDevices = new ArrayList<>(); - List newDevices = new ArrayList<>(); - - Map statusCounts = new HashMap<>(); - statusCounts.put("PENDING", 0); - statusCounts.put("COMPLETED", 0); - statusCounts.put("ERROR", 0); - statusCounts.put("NEW", 0); - - List allDevices = - deviceManagementProviderService.getDevicesByTenantId(tenantId, applicationDTO.getDeviceTypeId(), request.getOwner(), - request.getDeviceStatus()); - - for (DeviceDetailsDTO device : allDevices) { - Integer deviceId = device.getDeviceId(); - OwnerWithDeviceDTO ownerWithDevice = - deviceManagementProviderService.getOwnerWithDeviceByDeviceId(deviceId, request.getOwner(), request.getDeviceName(), - request.getDeviceStatus()); - if (ownerWithDevice == null || (request.getDeviceName() != null && !request.getDeviceName().isEmpty() && - (ownerWithDevice.getDeviceNames() == null || !ownerWithDevice.getDeviceNames().contains(request.getDeviceName())))) { - continue; - } - if (allSubscriptionMap.containsKey(deviceId)) { - DeviceSubscriptionDTO subscription = allSubscriptionMap.get(deviceId); - DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); - deviceDetail.setDeviceId(subscription.getDeviceId()); - deviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); - deviceDetail.setSubId(subscription.getId()); - deviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); - deviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); - deviceDetail.setActionType(subscription.getActionTriggeredFrom()); - deviceDetail.setStatus(subscription.getStatus()); - deviceDetail.setActionTriggeredBy(subscription.getSubscribedBy()); - deviceDetail.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); - deviceDetail.setUnsubscribed(subscription.isUnsubscribed()); - deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy()); - deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp()); - deviceDetail.setType(ownerWithDevice.getDeviceTypes()); - deviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); - - String status = subscription.getStatus(); - switch (status) { - case "COMPLETED": - installedDevices.add(deviceDetail); - statusCounts.put("COMPLETED", statusCounts.get("COMPLETED") + 1); - break; - case "ERROR": - case "INVALID": - case "UNAUTHORIZED": - errorDevices.add(deviceDetail); - statusCounts.put("ERROR", statusCounts.get("ERROR") + 1); - break; - case "IN_PROGRESS": - case "PENDING": - case "REPEATED": - pendingDevices.add(deviceDetail); - statusCounts.put("PENDING", statusCounts.get("PENDING") + 1); - break; - } - } else { - DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); - newDeviceDetail.setDeviceId(deviceId); - newDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames()); - newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); - newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); - newDeviceDetail.setType(ownerWithDevice.getDeviceTypes()); - newDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers()); - newDevices.add(newDeviceDetail); - statusCounts.put("NEW", statusCounts.get("NEW") + 1); - } - } - - int totalDevices = allDevices.size(); - Map statusPercentages = new HashMap<>(); - for (Map.Entry entry : statusCounts.entrySet()) { - double percentage = ((double) entry.getValue() / totalDevices) * 100; - String formattedPercentage = String.format("%.2f", percentage); - statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); - } - - List requestedDevices = new ArrayList<>(); - if (StringUtils.isNotBlank(request.getTabActionStatus())) { - switch (request.getTabActionStatus()) { - case "COMPLETED": - requestedDevices = installedDevices; - break; - case "PENDING": - requestedDevices = pendingDevices; - break; - case "ERROR": - requestedDevices = errorDevices; - break; - case "NEW": - requestedDevices = newDevices; - break; - } - } else { - requestedDevices.addAll(installedDevices); - requestedDevices.addAll(pendingDevices); - requestedDevices.addAll(errorDevices); - requestedDevices.addAll(newDevices); - } - - CategorizedSubscriptionResult categorizedSubscriptionResult = - new CategorizedSubscriptionResult(installedDevices, pendingDevices, errorDevices, newDevices); - DeviceSubscriptionResponseDTO result = - new DeviceSubscriptionResponseDTO(totalDevices, statusPercentages, categorizedSubscriptionResult); - - return result; - } catch (ApplicationManagementDAOException e) { - String msg = "Error occurred while getting user subscriptions for the application release UUID: " + uuid; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (DBConnectionException e) { - String msg = "DB Connection error occurred while getting user subscriptions for UUID: " + uuid; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (DeviceManagementDAOException e) { - throw new RuntimeException(e); - } finally { - ConnectionManagerUtil.closeDBConnection(); - } + public SubscriptionStatistics getStatistics(SubscriptionInfo subscriptionInfo) throws ApplicationManagementException { + return SubscriptionManagementServiceProvider.getInstance().getSubscriptionManagementHelperService(subscriptionInfo). + getSubscriptionStatistics(subscriptionInfo); } @Override @@ -2881,13 +1813,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager { List subscriptionCounts = new ArrayList<>(); subscriptionCounts.add(new CategorizedSubscriptionCountsDTO( - "All", + "Device", subscriptionDAO.getAllSubscriptionCount(appReleaseId, tenantId), subscriptionDAO.getAllUnsubscriptionCount(appReleaseId, tenantId))); - subscriptionCounts.add(new CategorizedSubscriptionCountsDTO( - "Device", - subscriptionDAO.getDeviceSubscriptionCount(appReleaseId, tenantId), - subscriptionDAO.getDeviceUnsubscriptionCount(appReleaseId, tenantId))); subscriptionCounts.add(new CategorizedSubscriptionCountsDTO( "Group", subscriptionDAO.getGroupSubscriptionCount(appReleaseId, tenantId), diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/SubscriptionManagementUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/SubscriptionManagementUtil.java new file mode 100644 index 0000000000..9c45f57be4 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/SubscriptionManagementUtil.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.core.util; + +public class SubscriptionManagementUtil { + public static final class DeviceSubscriptionStatus { + public static final String COMPLETED = "COMPLETED"; + public static final String ERROR ="ERROR"; + public static final String NEW = "NEW"; + public static final String SUBSCRIBED = "SUBSCRIBED"; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementHelperUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementHelperUtil.java new file mode 100644 index 0000000000..0fbc32b986 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementHelperUtil.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.core.util.subscription.mgt; + +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscription; +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionFilterCriteria; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionData; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionMetadata; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionStatistics; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionStatisticDTO; +import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class SubscriptionManagementHelperUtil { + + /** + * Retrieves device subscription data based on the provided filters. + * + * @param deviceSubscriptionDTOS List of DeviceSubscriptionDTO objects. + * @param deviceSubscriptionFilterCriteria Filter criteria for device subscription. + * @param isUnsubscribed Boolean indicating whether to filter unsubscribed devices. + * @param deviceTypeId Device type ID. + * @param limit Limit for pagination. + * @param offset Offset for pagination. + * @return List of DeviceSubscription objects. + * @throws DeviceManagementException If an error occurs during device management. + */ + public static List getDeviceSubscriptionData(List deviceSubscriptionDTOS, + DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria, + boolean isUnsubscribed, int deviceTypeId, int limit, int offset) + throws DeviceManagementException { + List deviceIds = deviceSubscriptionDTOS.stream().map(DeviceSubscriptionDTO::getDeviceId).collect(Collectors.toList()); + PaginationRequest paginationRequest = new PaginationRequest(offset, limit); + paginationRequest.setDeviceName(deviceSubscriptionFilterCriteria.getName()); + paginationRequest.setDeviceStatus(deviceSubscriptionFilterCriteria.getDeviceStatus()); + paginationRequest.setOwner(deviceSubscriptionFilterCriteria.getOwner()); + paginationRequest.setDeviceTypeId(deviceTypeId); + List devices = HelperUtil.getDeviceManagementProviderService().getDevicesByDeviceIds(paginationRequest, deviceIds); + return populateDeviceData(deviceSubscriptionDTOS, devices, isUnsubscribed); + } + + /** + * Retrieves the total count of device subscriptions based on the provided filters. + * + * @param deviceSubscriptionDTOS List of DeviceSubscriptionDTO objects. + * @param deviceSubscriptionFilterCriteria Filter criteria for device subscription. + * @param deviceTypeId Device type ID. + * @return int Total count of device subscriptions. + * @throws DeviceManagementException If an error occurs during device management. + */ + public static int getTotalDeviceSubscriptionCount(List deviceSubscriptionDTOS, + DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria, int deviceTypeId) + throws DeviceManagementException { + List deviceIds = deviceSubscriptionDTOS.stream().map(DeviceSubscriptionDTO::getDeviceId).collect(Collectors.toList()); + PaginationRequest paginationRequest = new PaginationRequest(-1, -1); + paginationRequest.setDeviceName(deviceSubscriptionFilterCriteria.getName()); + paginationRequest.setDeviceStatus(deviceSubscriptionFilterCriteria.getDeviceStatus()); + paginationRequest.setOwner(deviceSubscriptionFilterCriteria.getOwner()); + paginationRequest.setDeviceTypeId(deviceTypeId); + return HelperUtil.getDeviceManagementProviderService().getDeviceCountByDeviceIds(paginationRequest, deviceIds); + } + + /** + * Populates device subscription data based on the provided devices and subscription DTOs. + * + * @param deviceSubscriptionDTOS List of DeviceSubscriptionDTO objects. + * @param devices List of Device objects. + * @param isUnsubscribed Boolean indicating whether to filter unsubscribed devices. + * @return List of DeviceSubscription objects. + */ + private static List populateDeviceData(List deviceSubscriptionDTOS, + List devices, boolean isUnsubscribed) { + List deviceSubscriptions = new ArrayList<>(); + for (Device device : devices) { + int idx = deviceSubscriptionDTOS.indexOf(new DeviceSubscriptionDTO(device.getId())); + if (idx >= 0) { + DeviceSubscriptionDTO deviceSubscriptionDTO = deviceSubscriptionDTOS.get(idx); + DeviceSubscription deviceSubscription = new DeviceSubscription(); + deviceSubscription.setDeviceId(device.getId()); + deviceSubscription.setDeviceIdentifier(device.getDeviceIdentifier()); + deviceSubscription.setDeviceOwner(device.getEnrolmentInfo().getOwner()); + deviceSubscription.setDeviceType(device.getType()); + deviceSubscription.setDeviceName(device.getName()); + deviceSubscription.setDeviceStatus(device.getEnrolmentInfo().getStatus().name()); + deviceSubscription.setOwnershipType(device.getEnrolmentInfo().getOwnership().name()); + deviceSubscription.setDateOfLastUpdate(new Timestamp(device.getEnrolmentInfo().getDateOfLastUpdate())); + SubscriptionData subscriptionData = getSubscriptionData(isUnsubscribed, deviceSubscriptionDTO); + deviceSubscription.setSubscriptionData(subscriptionData); + deviceSubscriptions.add(deviceSubscription); + } + } + return deviceSubscriptions; + } + + /** + * Creates a SubscriptionData object based on the provided subscription DTO. + * + * @param isUnsubscribed Boolean indicating whether to filter unsubscribed devices. + * @param deviceSubscriptionDTO DeviceSubscriptionDTO object. + * @return SubscriptionData object. + */ + private static SubscriptionData getSubscriptionData(boolean isUnsubscribed, DeviceSubscriptionDTO deviceSubscriptionDTO) { + SubscriptionData subscriptionData = new SubscriptionData(); + subscriptionData.setTriggeredBy(isUnsubscribed ? deviceSubscriptionDTO.getUnsubscribedBy() : + deviceSubscriptionDTO.getSubscribedBy()); + subscriptionData.setTriggeredAt(deviceSubscriptionDTO.getSubscribedTimestamp()); + subscriptionData.setDeviceSubscriptionStatus(deviceSubscriptionDTO.getStatus()); + subscriptionData.setSubscriptionType(deviceSubscriptionDTO.getActionTriggeredFrom()); + subscriptionData.setSubscriptionId(deviceSubscriptionDTO.getId()); + return subscriptionData; + } + + /** + * Retrieves the device subscription status based on the provided subscription info. + * + * @param subscriptionInfo SubscriptionInfo object. + * @return Device subscription status. + */ + public static String getDeviceSubscriptionStatus(SubscriptionInfo subscriptionInfo) { + return getDeviceSubscriptionStatus(subscriptionInfo.getDeviceSubscriptionFilterCriteria(). + getFilteringDeviceSubscriptionStatus(), subscriptionInfo.getDeviceSubscriptionStatus()); + } + + /** + * Retrieves the device subscription status based on the provided filter and status. + * + * @param deviceSubscriptionStatusFilter Filtered device subscription status. + * @param deviceSubscriptionStatus Device subscription status. + * @return Device subscription status. + */ + public static String getDeviceSubscriptionStatus(String deviceSubscriptionStatusFilter, String deviceSubscriptionStatus) { + return (deviceSubscriptionStatusFilter != null && !deviceSubscriptionStatusFilter.isEmpty()) ? + deviceSubscriptionStatusFilter : deviceSubscriptionStatus; + } + + /** + * Retrieves subscription statistics based on the provided subscription statistics DTO and device count. + * + * @param subscriptionStatisticDTO SubscriptionStatisticDTO object. + * @param allDeviceCount Total count of all devices. + * @return SubscriptionStatistics object. + */ + public static SubscriptionStatistics getSubscriptionStatistics(SubscriptionStatisticDTO subscriptionStatisticDTO, int allDeviceCount) { + SubscriptionStatistics subscriptionStatistics = new SubscriptionStatistics(); + subscriptionStatistics.setCompletedPercentage( + getPercentage(subscriptionStatisticDTO.getCompletedDeviceCount(), allDeviceCount)); + subscriptionStatistics.setPendingPercentage( + getPercentage(subscriptionStatisticDTO.getPendingDevicesCount(), allDeviceCount)); + subscriptionStatistics.setFailedPercentage( + getPercentage(subscriptionStatisticDTO.getFailedDevicesCount(), allDeviceCount)); + subscriptionStatistics.setNewDevicesPercentage(getPercentage((allDeviceCount - + subscriptionStatisticDTO.getCompletedDeviceCount() - + subscriptionStatisticDTO.getPendingDevicesCount() - + subscriptionStatisticDTO.getFailedDevicesCount()), allDeviceCount)); + return subscriptionStatistics; + } + + /** + * Calculates the percentages. + * + * @param numerator Numerator value. + * @param denominator Denominator value. + * @return Calculated percentage. + */ + public static float getPercentage(int numerator, int denominator) { + if (denominator <= 0) { + return 0.0f; + } + return ((float) numerator / (float) denominator) * 100; + } + + /** + * Retrieves database subscription statuses based on the provided device subscription status. + * + * @param deviceSubscriptionStatus Device subscription status. + * @return List of database subscription statuses. + */ + public static List getDBSubscriptionStatus(String deviceSubscriptionStatus) { + return SubscriptionMetadata.deviceSubscriptionStatusToDBSubscriptionStatusMap.get(deviceSubscriptionStatus); + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementServiceProvider.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementServiceProvider.java new file mode 100644 index 0000000000..c2fd88b25e --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementServiceProvider.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.core.util.subscription.mgt; + +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionMetadata; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.impl.DeviceBasedSubscriptionManagementHelperServiceImpl; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.impl.GroupBasedSubscriptionManagementHelperServiceImpl; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.impl.RoleBasedSubscriptionManagementHelperServiceImpl; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.impl.UserBasedSubscriptionManagementHelperServiceImpl; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; + +import java.util.Objects; + +public class SubscriptionManagementServiceProvider { + private SubscriptionManagementServiceProvider() { + } + + /** + * Retrieves the appropriate SubscriptionManagementHelperService based on the provided SubscriptionInfo. + * + * @param subscriptionInfo SubscriptionInfo object containing the subscription type. + * @return SubscriptionManagementHelperService implementation based on the subscription type. + */ + public SubscriptionManagementHelperService getSubscriptionManagementHelperService(SubscriptionInfo subscriptionInfo) { + return getSubscriptionManagementHelperService(subscriptionInfo.getSubscriptionType()); + } + + /** + * Retrieves the appropriate SubscriptionManagementHelperService based on the subscription type. + * + * @param subscriptionType Type of the subscription. + * @return SubscriptionManagementHelperService implementation based on the subscription type. + */ + private SubscriptionManagementHelperService getSubscriptionManagementHelperService(String subscriptionType) { + if (Objects.equals(subscriptionType, SubscriptionMetadata.SubscriptionTypes.ROLE)) + return RoleBasedSubscriptionManagementHelperServiceImpl.getInstance(); + if (Objects.equals(subscriptionType, SubscriptionMetadata.SubscriptionTypes.GROUP)) + return GroupBasedSubscriptionManagementHelperServiceImpl.getInstance(); + if (Objects.equals(subscriptionType, SubscriptionMetadata.SubscriptionTypes.USER)) + return UserBasedSubscriptionManagementHelperServiceImpl.getInstance(); + if (Objects.equals(subscriptionType, SubscriptionMetadata.SubscriptionTypes.DEVICE)) + return DeviceBasedSubscriptionManagementHelperServiceImpl.getInstance(); + throw new UnsupportedOperationException("Subscription type: " + subscriptionType + " not supports"); + } + + private static class SubscriptionManagementProviderServiceHolder { + private static final SubscriptionManagementServiceProvider INSTANCE = new SubscriptionManagementServiceProvider(); + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java new file mode 100644 index 0000000000..b0fc7c97bd --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.core.util.subscription.mgt.impl; + +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscription; +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionFilterCriteria; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionMetadata; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionResponse; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionStatistics; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; +import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; +import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; +import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementHelperUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class DeviceBasedSubscriptionManagementHelperServiceImpl implements SubscriptionManagementHelperService { + private static final Log log = LogFactory.getLog(DeviceBasedSubscriptionManagementHelperServiceImpl.class); + + private DeviceBasedSubscriptionManagementHelperServiceImpl() { + } + + public static DeviceBasedSubscriptionManagementHelperServiceImpl getInstance() { + return DeviceBasedSubscriptionManagementHelperServiceImpl.DeviceBasedSubscriptionManagementHelperServiceImplHolder.INSTANCE; + } + + @Override + public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException { + final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + List deviceSubscriptionDTOS; + int deviceCount = 0; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + + try { + ConnectionManagerUtil.openDBConnection(); + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO. + getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationDTO == null) { + String msg = "Application not found for the release UUID: " + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + + String deviceSubscriptionStatus = SubscriptionManagementHelperUtil.getDeviceSubscriptionStatus(subscriptionInfo); + DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria = subscriptionInfo.getDeviceSubscriptionFilterCriteria(); + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); + List dbSubscriptionStatus = SubscriptionManagementHelperUtil.getDBSubscriptionStatus(subscriptionInfo.getDeviceSubscriptionStatus()); + + if (Objects.equals(SubscriptionMetadata.DeviceSubscriptionStatus.NEW, deviceSubscriptionStatus)) { + deviceSubscriptionDTOS = subscriptionDAO.getAllSubscriptionsDetails(applicationReleaseDTO. + getId(), isUnsubscribe, tenantId, null, null, + deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); + + List deviceIdsOfSubscription = deviceSubscriptionDTOS.stream(). + map(DeviceSubscriptionDTO::getDeviceId).collect(Collectors.toList()); + + List newDeviceIds = deviceManagementProviderService.getDevicesNotInGivenIdList(deviceIdsOfSubscription, + new PaginationRequest(offset, limit)); + + deviceSubscriptionDTOS = newDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); + + deviceCount = deviceManagementProviderService.getDeviceCountNotInGivenIdList(deviceIdsOfSubscription); + } else { + deviceSubscriptionDTOS = subscriptionDAO.getAllSubscriptionsDetails(applicationReleaseDTO. + getId(), isUnsubscribe, tenantId, dbSubscriptionStatus, null, + deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); + + deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); + } + List deviceSubscriptions = SubscriptionManagementHelperUtil.getDeviceSubscriptionData(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset); + return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions); + } catch (DeviceManagementException e) { + String msg = "Error encountered while getting device details"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (ApplicationManagementDAOException | DBConnectionException e) { + String msg = "Error encountered while connecting to the database"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException { + return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), Collections.emptyList()); + } + + @Override + public SubscriptionStatistics getSubscriptionStatistics(SubscriptionInfo subscriptionInfo) + throws ApplicationManagementException { + return null; + } + + private static class DeviceBasedSubscriptionManagementHelperServiceImplHolder { + private static final DeviceBasedSubscriptionManagementHelperServiceImpl INSTANCE + = new DeviceBasedSubscriptionManagementHelperServiceImpl(); + } + +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java new file mode 100644 index 0000000000..1a78df119c --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.core.util.subscription.mgt.impl; + +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscription; +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionFilterCriteria; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionMetadata; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionResponse; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionStatistics; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionStatisticDTO; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; +import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; +import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; +import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementHelperUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; +import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class GroupBasedSubscriptionManagementHelperServiceImpl implements SubscriptionManagementHelperService { + private static final Log log = LogFactory.getLog(GroupBasedSubscriptionManagementHelperServiceImpl.class); + + private GroupBasedSubscriptionManagementHelperServiceImpl() { + } + + public static GroupBasedSubscriptionManagementHelperServiceImpl getInstance() { + return GroupBasedSubscriptionManagementHelperServiceImplHolder.INSTANCE; + } + + @Override + public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException { + + final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + List deviceSubscriptionDTOS; + int deviceCount = 0; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + + try { + ConnectionManagerUtil.openDBConnection(); + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO. + getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId); + + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationDTO == null) { + String msg = "Application not found for the release UUID: " + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + + String deviceSubscriptionStatus = SubscriptionManagementHelperUtil.getDeviceSubscriptionStatus(subscriptionInfo); + DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria = subscriptionInfo.getDeviceSubscriptionFilterCriteria(); + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); + + GroupManagementProviderService groupManagementProviderService = HelperUtil.getGroupManagementProviderService(); + GroupDetailsDTO groupDetailsDTO; + List dbSubscriptionStatus = SubscriptionManagementHelperUtil.getDBSubscriptionStatus(subscriptionInfo.getDeviceSubscriptionStatus()); + + if (Objects.equals(SubscriptionMetadata.DeviceSubscriptionStatus.NEW, deviceSubscriptionStatus)) { + List allDeviceIdsOwnByGroup = groupManagementProviderService.getGroupDetailsWithDevices(subscriptionInfo.getIdentifier(), + applicationDTO.getDeviceTypeId(), deviceSubscriptionFilterCriteria.getOwner(), deviceSubscriptionFilterCriteria.getName(), + deviceSubscriptionFilterCriteria.getDeviceStatus(), -1, -1).getDeviceIds(); + + deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(), + isUnsubscribe, tenantId, allDeviceIdsOwnByGroup, null, + null, deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); + + List deviceIdsOfSubscription = deviceSubscriptionDTOS.stream(). + map(DeviceSubscriptionDTO::getDeviceId).collect(Collectors.toList()); + + for (Integer deviceId : deviceIdsOfSubscription) { + allDeviceIdsOwnByGroup.remove(deviceId); + } + + List paginatedNewDeviceIds = deviceManagementProviderService.getDevicesInGivenIdList(allDeviceIdsOwnByGroup, + new PaginationRequest(offset, limit)); + deviceSubscriptionDTOS = paginatedNewDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); + + deviceCount = allDeviceIdsOwnByGroup.size(); + } else { + groupDetailsDTO = groupManagementProviderService.getGroupDetailsWithDevices(subscriptionInfo.getIdentifier(), + applicationDTO.getDeviceTypeId(), deviceSubscriptionFilterCriteria.getOwner(), deviceSubscriptionFilterCriteria.getName(), + deviceSubscriptionFilterCriteria.getDeviceStatus(), offset, limit); + List paginatedDeviceIdsOwnByGroup = groupDetailsDTO.getDeviceIds(); + + deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(), + isUnsubscribe, tenantId, paginatedDeviceIdsOwnByGroup, dbSubscriptionStatus, + null, deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); + + deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); + } + List deviceSubscriptions = SubscriptionManagementHelperUtil.getDeviceSubscriptionData(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset); + return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions); + } catch (GroupManagementException e) { + String msg = "Error encountered while retrieving group details for group: " + subscriptionInfo.getIdentifier(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (ApplicationManagementDAOException | DBConnectionException e) { + String msg = "Error encountered while connecting to the database"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DeviceManagementException e) { + throw new RuntimeException(e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + + } + + @Override + public SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException { + final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + ConnectionManagerUtil.openDBConnection(); + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO. + getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + List subscriptionEntities = subscriptionDAO. + getGroupsSubscriptionDetailsByAppReleaseID(applicationReleaseDTO.getId(), isUnsubscribe, tenantId, offset, limit); + int subscriptionCount = isUnsubscribe ? subscriptionDAO.getGroupUnsubscriptionCount(applicationReleaseDTO.getId(), tenantId) : + subscriptionDAO.getGroupSubscriptionCount(applicationReleaseDTO.getId(), tenantId); + return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), subscriptionCount, subscriptionEntities); + } catch (DBConnectionException | ApplicationManagementDAOException e) { + String msg = "Error encountered while connecting to the database"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public SubscriptionStatistics getSubscriptionStatistics(SubscriptionInfo subscriptionInfo) + throws ApplicationManagementException { + final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + ConnectionManagerUtil.openDBConnection(); + List devices = HelperUtil.getGroupManagementProviderService(). + getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), false); + List deviceIdsOwnByGroup = devices.stream().map(Device::getId).collect(Collectors.toList()); + SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. + getSubscriptionStatistic(deviceIdsOwnByGroup, null, isUnsubscribe, tenantId); + int allDeviceCount = HelperUtil.getGroupManagementProviderService().getDeviceCount(subscriptionInfo.getIdentifier()); + return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); + } catch (ApplicationManagementDAOException e) { + String msg = "Error encountered while getting subscription statistics for group: " + subscriptionInfo.getIdentifier(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (GroupManagementException e) { + String msg = "Error encountered while getting device subscription for group: " + subscriptionInfo.getIdentifier(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + private static class GroupBasedSubscriptionManagementHelperServiceImplHolder { + private static final GroupBasedSubscriptionManagementHelperServiceImpl INSTANCE + = new GroupBasedSubscriptionManagementHelperServiceImpl(); + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java new file mode 100644 index 0000000000..b3498db662 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.core.util.subscription.mgt.impl; + +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscription; +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionFilterCriteria; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionMetadata; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionResponse; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionStatistics; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionStatisticDTO; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; +import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; +import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; +import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder; +import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementHelperUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.api.UserStoreManager; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class RoleBasedSubscriptionManagementHelperServiceImpl implements SubscriptionManagementHelperService { + private static final Log log = LogFactory.getLog(RoleBasedSubscriptionManagementHelperServiceImpl.class); + + private RoleBasedSubscriptionManagementHelperServiceImpl() { + } + + public static RoleBasedSubscriptionManagementHelperServiceImpl getInstance() { + return RoleBasedSubscriptionManagementHelperServiceImplHolder.INSTANCE; + } + + @Override + public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException { + final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + List deviceSubscriptionDTOS; + int deviceCount = 0; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + + try { + ConnectionManagerUtil.openDBConnection(); + List deviceIdsOwnByRole = getDeviceIdsOwnByRole(subscriptionInfo.getIdentifier(), tenantId); + + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO. + getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationDTO == null) { + String msg = "Application not found for the release UUID: " + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + + String deviceSubscriptionStatus = SubscriptionManagementHelperUtil.getDeviceSubscriptionStatus(subscriptionInfo); + DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria = subscriptionInfo.getDeviceSubscriptionFilterCriteria(); + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); + List dbSubscriptionStatus = SubscriptionManagementHelperUtil.getDBSubscriptionStatus(subscriptionInfo.getDeviceSubscriptionStatus()); + + if (Objects.equals(SubscriptionMetadata.DeviceSubscriptionStatus.NEW, deviceSubscriptionStatus)) { + deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(), + isUnsubscribe, tenantId, deviceIdsOwnByRole, null, + null, deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); + + List deviceIdsOfSubscription = deviceSubscriptionDTOS.stream(). + map(DeviceSubscriptionDTO::getDeviceId).collect(Collectors.toList()); + + for (Integer deviceId : deviceIdsOfSubscription) { + deviceIdsOwnByRole.remove(deviceId); + } + + List paginatedNewDeviceIds = deviceManagementProviderService.getDevicesInGivenIdList(deviceIdsOwnByRole, + new PaginationRequest(offset, limit)); + deviceSubscriptionDTOS = paginatedNewDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); + deviceCount = deviceIdsOwnByRole.size(); + } else { + deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(), + isUnsubscribe, tenantId, deviceIdsOwnByRole, dbSubscriptionStatus, + subscriptionInfo.getSubscriptionType(), deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); + + deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); + } + List deviceSubscriptions = SubscriptionManagementHelperUtil. + getDeviceSubscriptionData(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset); + return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions); + + } catch (UserStoreException e) { + String msg = "Error encountered while getting the user management store for tenant id " + tenantId; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (DeviceManagementException e) { + String msg = "Error encountered while getting device details"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (ApplicationManagementDAOException | DBConnectionException e) { + String msg = "Error encountered while connecting to the database"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException { + final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + ConnectionManagerUtil.openDBConnection(); + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO. + getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + List subscriptionEntities = subscriptionDAO. + getRoleSubscriptionsByAppReleaseID(applicationReleaseDTO.getId(), isUnsubscribe, tenantId, offset, limit); + int subscriptionCount = isUnsubscribe ? subscriptionDAO.getRoleUnsubscriptionCount(applicationReleaseDTO.getId(), tenantId) : + subscriptionDAO.getRoleSubscriptionCount(applicationReleaseDTO.getId(), tenantId); + return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), subscriptionCount, subscriptionEntities); + } catch (DBConnectionException | ApplicationManagementDAOException e) { + String msg = "Error encountered while connecting to the database"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public SubscriptionStatistics getSubscriptionStatistics(SubscriptionInfo subscriptionInfo) throws ApplicationManagementException { + final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + ConnectionManagerUtil.openDBConnection(); + List deviceIdsOwnByRole = getDeviceIdsOwnByRole(subscriptionInfo.getIdentifier(), tenantId); + SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. + getSubscriptionStatistic(deviceIdsOwnByRole, null, isUnsubscribe, tenantId); + int allDeviceCount = deviceIdsOwnByRole.size(); + return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); + } catch (DeviceManagementException | ApplicationManagementDAOException | UserStoreException e) { + String msg = "Error encountered while getting subscription statistics for role: " + subscriptionInfo.getIdentifier(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @SuppressWarnings("unchecked") + private List getDeviceIdsOwnByRole(String roleName, int tenantId) throws UserStoreException, DeviceManagementException { + UserStoreManager userStoreManager = DataHolder.getInstance().getRealmService(). + getTenantUserRealm(tenantId).getUserStoreManager(); + String[] usersWithRole = + userStoreManager.getUserListOfRole(roleName); + List deviceListOwnByRole = new ArrayList<>(); + for (String user : usersWithRole) { + PaginationRequest paginationRequest = new PaginationRequest(-1, -1); + paginationRequest.setOwner(user); + paginationRequest.setStatusList(Arrays.asList("ACTIVE", "INACTIVE", "UNREACHABLE")); + PaginationResult ownDeviceIds = HelperUtil.getDeviceManagementProviderService(). + getAllDevicesIdList(paginationRequest); + if (ownDeviceIds.getData() != null) { + deviceListOwnByRole.addAll((List) ownDeviceIds.getData()); + } + } + return deviceListOwnByRole.stream().map(Device::getId).collect(Collectors.toList()); + } + + private static class RoleBasedSubscriptionManagementHelperServiceImplHolder { + private static final RoleBasedSubscriptionManagementHelperServiceImpl INSTANCE + = new RoleBasedSubscriptionManagementHelperServiceImpl(); + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java new file mode 100644 index 0000000000..83bc8c08e2 --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.core.util.subscription.mgt.impl; + +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscription; +import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionFilterCriteria; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionMetadata; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionResponse; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionStatistics; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; +import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionStatisticDTO; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; +import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; +import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; +import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException; +import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementHelperUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; +import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; +import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class UserBasedSubscriptionManagementHelperServiceImpl implements SubscriptionManagementHelperService { + private static final Log log = LogFactory.getLog(UserBasedSubscriptionManagementHelperServiceImpl.class); + + private UserBasedSubscriptionManagementHelperServiceImpl() { + } + + public static UserBasedSubscriptionManagementHelperServiceImpl getInstance() { + return UserBasedSubscriptionManagementHelperServiceImpl.UserBasedSubscriptionManagementHelperServiceImplHolder.INSTANCE; + } + + @Override + public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException { + final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + List deviceSubscriptionDTOS; + int deviceCount = 0; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + + try { + ConnectionManagerUtil.openDBConnection(); + List deviceIdsOwnByUser = getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier()); + + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO. + getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + + ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationDTO == null) { + String msg = "Application not found for the release UUID: " + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + + String deviceSubscriptionStatus = SubscriptionManagementHelperUtil.getDeviceSubscriptionStatus(subscriptionInfo); + DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria = subscriptionInfo.getDeviceSubscriptionFilterCriteria(); + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); + List dbSubscriptionStatus = SubscriptionManagementHelperUtil.getDBSubscriptionStatus(subscriptionInfo.getDeviceSubscriptionStatus()); + + if (Objects.equals(SubscriptionMetadata.DeviceSubscriptionStatus.NEW, deviceSubscriptionStatus)) { + deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(), + isUnsubscribe, tenantId, deviceIdsOwnByUser, null, + null, deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); + + List deviceIdsOfSubscription = deviceSubscriptionDTOS.stream(). + map(DeviceSubscriptionDTO::getDeviceId).collect(Collectors.toList()); + + for (Integer deviceId : deviceIdsOfSubscription) { + deviceIdsOwnByUser.remove(deviceId); + } + List paginatedNewDeviceIds = deviceManagementProviderService.getDevicesInGivenIdList(deviceIdsOwnByUser, + new PaginationRequest(offset, limit)); + deviceSubscriptionDTOS = paginatedNewDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); + + deviceCount = deviceIdsOwnByUser.size(); + } else { + deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(), + isUnsubscribe, tenantId, deviceIdsOwnByUser, dbSubscriptionStatus, + null, deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); + + deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); + } + List deviceSubscriptions = SubscriptionManagementHelperUtil.getDeviceSubscriptionData(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset); + return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions); + } catch (DeviceManagementException e) { + String msg = "Error encountered while getting device details"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } catch (ApplicationManagementDAOException | DBConnectionException e) { + String msg = "Error encountered while connecting to the database"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException { + final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + ConnectionManagerUtil.openDBConnection(); + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO. + getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } + List subscriptionEntities = subscriptionDAO. + getUserSubscriptionsByAppReleaseID(applicationReleaseDTO.getId(), isUnsubscribe, tenantId, offset, limit); + int subscriptionCount = isUnsubscribe ? subscriptionDAO.getUserUnsubscriptionCount(applicationReleaseDTO.getId(), tenantId) : + subscriptionDAO.getUserSubscriptionCount(applicationReleaseDTO.getId(), tenantId); + return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), subscriptionCount, subscriptionEntities); + } catch (DBConnectionException | ApplicationManagementDAOException e) { + String msg = "Error encountered while connecting to the database"; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @Override + public SubscriptionStatistics getSubscriptionStatistics(SubscriptionInfo subscriptionInfo) throws ApplicationManagementException { + final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + ConnectionManagerUtil.openDBConnection(); + List deviceIdsOwnByUser = getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier()); + SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. + getSubscriptionStatistic(deviceIdsOwnByUser, null, isUnsubscribe, tenantId); + int allDeviceCount = deviceIdsOwnByUser.size(); + return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); + } catch (DeviceManagementException | ApplicationManagementDAOException e) { + String msg = "Error encountered while getting subscription statistics for user: " + subscriptionInfo.getIdentifier(); + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } + + @SuppressWarnings("unchecked") + private List getDeviceIdsOwnByUser(String username) throws DeviceManagementException { + List deviceListOwnByUser = new ArrayList<>(); + PaginationRequest paginationRequest = new PaginationRequest(-1, -1); + paginationRequest.setOwner(username); + paginationRequest.setStatusList(Arrays.asList("ACTIVE", "INACTIVE", "UNREACHABLE")); + PaginationResult ownDeviceIds = HelperUtil.getDeviceManagementProviderService(). + getAllDevicesIdList(paginationRequest); + if (ownDeviceIds.getData() != null) { + deviceListOwnByUser.addAll((List) ownDeviceIds.getData()); + } + return deviceListOwnByUser.stream().map(Device::getId).collect(Collectors.toList()); + } + + private static class UserBasedSubscriptionManagementHelperServiceImplHolder { + private static final UserBasedSubscriptionManagementHelperServiceImpl INSTANCE + = new UserBasedSubscriptionManagementHelperServiceImpl(); + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/service/SubscriptionManagementHelperService.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/service/SubscriptionManagementHelperService.java new file mode 100644 index 0000000000..f869e282dd --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/service/SubscriptionManagementHelperService.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.core.util.subscription.mgt.service; + +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionResponse; +import io.entgra.device.mgt.core.application.mgt.common.SubscriptionStatistics; +import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; +import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationDAO; +import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO; +import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; +import io.entgra.device.mgt.core.application.mgt.core.dao.common.ApplicationManagementDAOFactory; + +public interface SubscriptionManagementHelperService { + SubscriptionDAO subscriptionDAO = ApplicationManagementDAOFactory.getSubscriptionDAO(); + ApplicationDAO applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO(); + ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO(); + + SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException; + + SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) + throws ApplicationManagementException; + + SubscriptionStatistics getSubscriptionStatistics(SubscriptionInfo subscriptionInfo) + throws ApplicationManagementException; +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java index b75f557077..2819364327 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Device.java @@ -97,6 +97,10 @@ public class Device implements Serializable { public Device() { } + public Device(int id) { + this.id = id; + } + public Device(String name, String type, String description, String deviceId, EnrolmentInfo enrolmentInfo, List features, List properties) { this.name = name; @@ -268,7 +272,9 @@ public class Device implements Serializable { Device device = (Device) o; - return getDeviceIdentifier().equals(device.getDeviceIdentifier()); + if (getDeviceIdentifier().equals(device.getDeviceIdentifier())) return true; + + return getId() == device.getId(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java index 95b8a92c6c..c4e01eb282 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java @@ -54,6 +54,7 @@ public class PaginationRequest { private List statusList = new ArrayList<>(); private OperationLogFilters operationLogFilters = new OperationLogFilters(); private List sortColumn = new ArrayList<>(); + private int deviceTypeId; public OperationLogFilters getOperationLogFilters() { return operationLogFilters; } @@ -292,4 +293,12 @@ public class PaginationRequest { public void setTabActionStatus(String tabActionStatus) { this.tabActionStatus = tabActionStatus; } + + public int getDeviceTypeId() { + return deviceTypeId; + } + + public void setDeviceTypeId(int deviceTypeId) { + this.deviceTypeId = deviceTypeId; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java index b71b6cd640..3d646768fb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java @@ -864,4 +864,19 @@ public interface DeviceDAO { * @throws DeviceManagementDAOException */ int getCountOfDevicesNotInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException; + + List getDevicesNotInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + throws DeviceManagementDAOException; + + List getDevicesInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + throws DeviceManagementDAOException; + + int getDeviceCountNotInGivenIdList(List deviceIds, int tenantId) + throws DeviceManagementDAOException; + + List getDevicesByDeviceIds(PaginationRequest paginationRequest, List deviceIds, int tenantId) + throws DeviceManagementDAOException; + + int getDeviceCountByDeviceIds(PaginationRequest paginationRequest, List deviceIds, int tenantId) + throws DeviceManagementDAOException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index c5d2d700cd..5da24ad91d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -488,4 +488,5 @@ public interface GroupDAO { int tenantId, String deviceOwner, String deviceName, String deviceStatus, int offset, int limit) throws GroupManagementDAOException; + int getDeviceCount(String groupName, int tenantId) throws GroupManagementDAOException; } \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index a04da1dd27..b195acfc1f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -54,6 +54,7 @@ import java.util.List; import java.util.Map; import java.util.StringJoiner; import java.util.Random; +import java.util.stream.Collectors; public abstract class AbstractDeviceDAOImpl implements DeviceDAO { @@ -3298,4 +3299,278 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throw new DeviceManagementDAOException(msg, e); } } + + @Override + public List getDevicesNotInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + throws DeviceManagementDAOException { + List filteredDeviceIds = new ArrayList<>(); + try { + Connection connection = getConnection(); + String sql = "SELECT ID AS DEVICE_ID FROM DM_DEVICE WHERE TENANT_ID = ?"; + + if (deviceIds != null && !deviceIds.isEmpty()) { + sql += " AND ID NOT IN ( " + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ")"; + } + + sql += " LIMIT ? OFFSET ?"; + + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int paraIdx = 1; + preparedStatement.setInt(paraIdx++, tenantId); + + if (deviceIds != null && !deviceIds.isEmpty()) { + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(paraIdx++, deviceId); + } + } + + preparedStatement.setInt(paraIdx++, request.getRowCount()); + preparedStatement.setInt(paraIdx, request.getStartIndex()); + try (ResultSet resultSet = preparedStatement.executeQuery()) { + while (resultSet.next()) { + filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); + } + } + return filteredDeviceIds; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving device ids not in: " + filteredDeviceIds; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + + @Override + public List getDevicesInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + throws DeviceManagementDAOException { + List filteredDeviceIds = new ArrayList<>(); + if (deviceIds == null || deviceIds.isEmpty()) return filteredDeviceIds; + + String deviceIdStringList = deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")); + try { + Connection connection = getConnection(); + String sql = "SELECT ID AS DEVICE_ID " + + "FROM DM_DEVICE " + + "WHERE ID IN (" + deviceIdStringList + ")" + + " AND TENANT_ID = ? " + + "LIMIT ? " + + "OFFSET ?"; + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int paraIdx = 1; + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(paraIdx++, deviceId); + } + + preparedStatement.setInt(paraIdx++, tenantId); + preparedStatement.setInt(paraIdx++, request.getRowCount()); + preparedStatement.setInt(paraIdx, request.getStartIndex()); + try (ResultSet resultSet = preparedStatement.executeQuery()) { + while (resultSet.next()) { + filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); + } + } + return filteredDeviceIds; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving device ids in: " + filteredDeviceIds; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + + @Override + public int getDeviceCountNotInGivenIdList(List deviceIds, int tenantId) + throws DeviceManagementDAOException { + int deviceCount = 0; + try { + Connection connection = getConnection(); + String sql = "SELECT COUNT(ID) AS COUNT " + + "FROM DM_DEVICE " + + "WHERE TENANT_ID = ?"; + + if (deviceIds != null && !deviceIds.isEmpty()) { + sql += " AND ID NOT IN ( " + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ")"; + } + + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int paraIdx = 1; + preparedStatement.setInt(paraIdx++, tenantId); + + if (deviceIds != null && !deviceIds.isEmpty()) { + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(paraIdx++, deviceId); + } + } + + try (ResultSet resultSet = preparedStatement.executeQuery()) { + if (resultSet.next()) { + deviceCount = resultSet.getInt("COUNT"); + } + } + return deviceCount; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving device count"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + + @Override + public List getDevicesByDeviceIds(PaginationRequest paginationRequest, List deviceIds, int tenantId) + throws DeviceManagementDAOException { + List devices = new ArrayList<>(); + if (deviceIds == null || deviceIds.isEmpty()) return devices; + + String deviceIdStringList = deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")); + boolean isOwnerProvided = false; + boolean isDeviceStatusProvided = false; + boolean isDeviceNameProvided = false; + try { + Connection connection = getConnection(); + String sql = "SELECT e.DEVICE_ID, " + + "d.DEVICE_IDENTIFICATION, " + + "e.STATUS, " + + "e.OWNER, " + + "d.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE, " + + "e.OWNERSHIP, " + + "e.DATE_OF_LAST_UPDATE " + + "FROM DM_DEVICE d " + + "INNER JOIN DM_ENROLMENT e " + + "ON d.ID = e.DEVICE_ID " + + "WHERE d.DEVICE_TYPE_ID = ? " + + "AND d.TENANT_ID = ? " + + "AND e.DEVICE_ID IN (" + deviceIdStringList+ ") " + + "AND e.STATUS NOT IN ('DELETED', 'REMOVED')"; + + if (paginationRequest.getOwner() != null) { + sql = sql + " AND e.OWNER LIKE ?"; + isOwnerProvided = true; + } + + if (paginationRequest.getDeviceStatus() != null) { + sql = sql + " AND e.STATUS = ?"; + isDeviceStatusProvided = true; + } + + if (paginationRequest.getDeviceName() != null) { + sql = sql + " AND d.NAME LIKE ?"; + isDeviceNameProvided = true; + } + + sql = sql + " LIMIT ? OFFSET ?"; + + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int parameterIdx = 1; + preparedStatement.setInt(parameterIdx++, paginationRequest.getDeviceTypeId()); + preparedStatement.setInt(parameterIdx++, tenantId); + + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(parameterIdx++, deviceId); + } + + if (isOwnerProvided) + preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getOwner() + "%"); + if (isDeviceStatusProvided) + preparedStatement.setString(parameterIdx++, paginationRequest.getDeviceStatus()); + if (isDeviceNameProvided) + preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getDeviceName() + "%"); + + preparedStatement.setInt(parameterIdx++, paginationRequest.getRowCount()); + preparedStatement.setInt(parameterIdx, paginationRequest.getStartIndex()); + + try(ResultSet resultSet = preparedStatement.executeQuery()) { + Device device; + while(resultSet.next()) { + device = new Device(); + device.setId(resultSet.getInt("DEVICE_ID")); + device.setDeviceIdentifier(resultSet.getString("DEVICE_IDENTIFICATION")); + device.setName(resultSet.getString("DEVICE_NAME")); + device.setType(resultSet.getString("DEVICE_TYPE")); + EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); + enrolmentInfo.setStatus(EnrolmentInfo.Status.valueOf(resultSet.getString("STATUS"))); + enrolmentInfo.setOwner(resultSet.getString("OWNER")); + enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.valueOf(resultSet.getString("OWNERSHIP"))); + enrolmentInfo.setDateOfLastUpdate(resultSet.getTimestamp("DATE_OF_LAST_UPDATE").getTime()); + device.setEnrolmentInfo(enrolmentInfo); + devices.add(device); + } + } + } + return devices; + } catch (SQLException e) { + String msg = "Error occurred while retrieving devices for device ids in: " + deviceIds; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + + // todo: fix the join query + @Override + public int getDeviceCountByDeviceIds(PaginationRequest paginationRequest, List deviceIds, int tenantId) + throws DeviceManagementDAOException { + int deviceCount = 0; + if (deviceIds == null || deviceIds.isEmpty()) return deviceCount; + + String deviceIdStringList = deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")); + boolean isOwnerProvided = false; + boolean isDeviceStatusProvided = false; + boolean isDeviceNameProvided = false; + try { + Connection connection = getConnection(); + String sql = "SELECT COUNT(DISTINCT e.DEVICE_ID) AS COUNT " + + "FROM DM_DEVICE d " + + "INNER JOIN DM_ENROLMENT e " + + "ON d.ID = e.DEVICE_ID " + + "WHERE e.TENANT_ID = ? " + + "AND e.DEVICE_ID IN (" + deviceIdStringList+ ") " + + "AND d.DEVICE_TYPE_ID = ? " + + "AND e.STATUS NOT IN ('DELETED', 'REMOVED')"; + + if (paginationRequest.getOwner() != null) { + sql = sql + " AND e.OWNER LIKE ?"; + isOwnerProvided = true; + } + + if (paginationRequest.getDeviceStatus() != null) { + sql = sql + " AND e.STATUS = ?"; + isDeviceStatusProvided = true; + } + + if (paginationRequest.getDeviceName() != null) { + sql = sql + " AND d.NAME LIKE ?"; + isDeviceNameProvided = true; + } + + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int parameterIdx = 1; + preparedStatement.setInt(parameterIdx++, tenantId); + + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(parameterIdx++, deviceId); + } + + preparedStatement.setInt(parameterIdx++, paginationRequest.getDeviceTypeId()); + if (isOwnerProvided) + preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getOwner() + "%"); + if (isDeviceStatusProvided) + preparedStatement.setString(parameterIdx++, paginationRequest.getDeviceStatus()); + if (isDeviceNameProvided) + preparedStatement.setString(parameterIdx, "%" + paginationRequest.getDeviceName() + "%"); + + try(ResultSet resultSet = preparedStatement.executeQuery()) { + if (resultSet.next()) { + deviceCount = resultSet.getInt("COUNT"); + } + } + } + return deviceCount; + } catch (SQLException e) { + String msg = "Error occurred while retrieving device count for device ids in: " + deviceIds; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java index bca05c6b18..091716bfe7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractEnrollmentDAOImpl.java @@ -587,9 +587,9 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { "d.NAME AS DEVICE_NAME, " + "e.DEVICE_TYPE AS DEVICE_TYPE, " + "e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION " + - "FROM DM_ENROLMENT e " + - "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + - "WHERE e.OWNER = ? AND e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters + ")"); + "FROM DM_ENROLMENT e " + + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + + "WHERE e.OWNER = ? AND e.TENANT_ID = ? AND e.STATUS IN (" + deviceFilters + ")"); if (deviceTypeId != 0) { sql.append(" AND d.DEVICE_TYPE_ID = ?"); @@ -629,13 +629,6 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { - if (ownerDetails.getUserName() == null) { - ownerDetails.setUserName(rs.getString("OWNER")); - } - ownerDetails.setDeviceStatus(rs.getString("DEVICE_STATUS")); - ownerDetails.setDeviceNames(rs.getString("DEVICE_NAME")); - ownerDetails.setDeviceTypes(rs.getString("DEVICE_TYPE")); - ownerDetails.setDeviceIdentifiers(rs.getString("DEVICE_IDENTIFICATION")); deviceIds.add(rs.getInt("DEVICE_ID")); deviceCount++; } @@ -646,11 +639,95 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO { log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } + ownerDetails.setUserName(deviceOwner); ownerDetails.setDeviceIds(deviceIds); ownerDetails.setDeviceCount(deviceCount); return ownerDetails; } +// @Override +// public OwnerWithDeviceDTO getOwnersWithDevices(String owner, List allowingDeviceStatuses, int tenantId, +// int deviceTypeId, String deviceOwner, String deviceName, +// String deviceStatus) throws DeviceManagementDAOException { +// Connection conn = null; +// OwnerWithDeviceDTO ownerDetails = new OwnerWithDeviceDTO(); +// List deviceIds = new ArrayList<>(); +// int deviceCount = 0; +// +// StringBuilder deviceFilters = new StringBuilder(); +// for (int i = 0; i < allowingDeviceStatuses.size(); i++) { +// deviceFilters.append("?"); +// if (i < allowingDeviceStatuses.size() - 1) { +// deviceFilters.append(","); +// } +// } +// +// StringBuilder sql = new StringBuilder( +// "SELECT e.DEVICE_ID, " + +// "e.OWNER, " + +// "e.STATUS AS DEVICE_STATUS, " + +// "d.NAME AS DEVICE_NAME, " + +// "e.DEVICE_TYPE AS DEVICE_TYPE, " + +// "e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION " + +// "FROM DM_ENROLMENT e " + +// "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + +// "WHERE e.OWNER = ? AND e.TENANT_ID = ? AND d.DEVICE_TYPE_ID = ? AND e.STATUS IN (" + deviceFilters + ")"); +// +// if (deviceOwner != null && !deviceOwner.isEmpty()) { +// sql.append(" AND e.OWNER LIKE ?"); +// } +// if (deviceName != null && !deviceName.isEmpty()) { +// sql.append(" AND d.NAME LIKE ?"); +// } +// if (deviceStatus != null && !deviceStatus.isEmpty()) { +// sql.append(" AND e.STATUS = ?"); +// } +// +// try { +// conn = this.getConnection(); +// try (PreparedStatement stmt = conn.prepareStatement(sql.toString())) { +// int index = 1; +// stmt.setString(index++, owner); +// stmt.setInt(index++, tenantId); +// stmt.setInt(index++, deviceTypeId); +// for (String status : allowingDeviceStatuses) { +// stmt.setString(index++, status); +// } +// +// if (deviceOwner != null && !deviceOwner.isEmpty()) { +// stmt.setString(index++, "%" + deviceOwner + "%"); +// } +// if (deviceName != null && !deviceName.isEmpty()) { +// stmt.setString(index++, "%" + deviceName + "%"); +// } +// if (deviceStatus != null && !deviceStatus.isEmpty()) { +// stmt.setString(index++, deviceStatus); +// } +// +// try (ResultSet rs = stmt.executeQuery()) { +// while (rs.next()) { +// if (ownerDetails.getUserName() == null) { +// ownerDetails.setUserName(rs.getString("OWNER")); +// } +// ownerDetails.setDeviceStatus(rs.getString("DEVICE_STATUS")); +// ownerDetails.setDeviceNames(rs.getString("DEVICE_NAME")); +// ownerDetails.setDeviceTypes(rs.getString("DEVICE_TYPE")); +// ownerDetails.setDeviceIdentifiers(rs.getString("DEVICE_IDENTIFICATION")); +// deviceIds.add(rs.getInt("DEVICE_ID")); +// deviceCount++; +// } +// } +// } +// } catch (SQLException e) { +// String msg = "Error occurred while retrieving owners and device IDs for owner: " + owner; +// log.error(msg, e); +// throw new DeviceManagementDAOException(msg, e); +// } +// ownerDetails.setDeviceIds(deviceIds); +// ownerDetails.setDeviceCount(deviceCount); +// return ownerDetails; +// } + @Override public OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, int tenantId, String deviceOwner, String deviceName, String deviceStatus) throws DeviceManagementDAOException { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index f747321fc4..518919add1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1496,9 +1496,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { if (deviceStatus != null && !deviceStatus.isEmpty()) { sql.append(" AND e.STATUS = ?"); } - - // Append limit and offset only if limit is not -1 - if (limit != -1) { + if (limit >= 0 && offset >=0 ) { sql.append(" LIMIT ? OFFSET ?"); } @@ -1525,8 +1523,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { stmt.setString(index++, deviceStatus); } - // Set limit and offset parameters only if limit is not -1 - if (limit != -1) { + if (limit >= 0 && offset >=0 ) { stmt.setInt(index++, limit); stmt.setInt(index++, offset); } @@ -1562,4 +1559,29 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throw new GroupManagementDAOException(msg, e); } } + + @Override + public int getDeviceCount(String groupName, int tenantId) throws GroupManagementDAOException { + int deviceCount = 0; + try { + Connection connection = GroupManagementDAOFactory.getConnection(); + String sql = "SELECT COUNT(d.ID) AS COUNT FROM DM_GROUP d INNER JOIN " + + "DM_DEVICE_GROUP_MAP m ON " + + "d.ID = m.GROUP_ID WHERE d.TENANT_ID = ? AND d.GROUP_NAME = ?"; + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + preparedStatement.setInt(1, tenantId); + preparedStatement.setString(2, groupName); + try (ResultSet resultSet = preparedStatement.executeQuery()) { + if (resultSet.next()) { + deviceCount = resultSet.getInt("COUNT"); + } + } + } + return deviceCount; + } catch (SQLException e) { + String msg = "Error occurred while retrieving device count for the group: " + groupName; + log.error(msg, e); + throw new GroupManagementDAOException(msg, e); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index e2063761db..e116df7490 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -42,6 +42,7 @@ import java.util.Date; import java.util.List; import java.util.StringJoiner; import java.util.Map; +import java.util.stream.Collectors; /** * This class holds the generic implementation of DeviceDAO which can be used to support ANSI db syntax. @@ -457,6 +458,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "e.ID AS ENROLMENT_ID " + "FROM DM_ENROLMENT e, " + "(SELECT d.ID, " + + "d.LAST_UPDATED_TIMESTAMP, " + "d.DEVICE_IDENTIFICATION " + "FROM DM_DEVICE d WHERE d.TENANT_ID = ?) d1 " + "WHERE d1.ID = e.DEVICE_ID AND e.TENANT_ID = ? "; @@ -1857,4 +1859,156 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } } + @Override + public List getDevicesByDeviceIds(PaginationRequest paginationRequest, List deviceIds, int tenantId) + throws DeviceManagementDAOException { + List devices = new ArrayList<>(); + if (deviceIds == null || deviceIds.isEmpty()) return devices; + + String deviceIdStringList = deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")); + boolean isOwnerProvided = false; + boolean isDeviceStatusProvided = false; + boolean isDeviceNameProvided = false; + try { + Connection connection = getConnection(); + String sql = "SELECT e.DEVICE_ID, " + + "d.DEVICE_IDENTIFICATION, " + + "e.STATUS, " + + "e.OWNER, " + + "d.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE, " + + "e.OWNERSHIP, " + + "e.DATE_OF_LAST_UPDATE " + + "FROM DM_DEVICE d " + + "INNER JOIN DM_ENROLMENT e " + + "WHERE d.ID = e.DEVICE_ID " + + "AND d.TENANT_ID = ? " + + "AND e.DEVICE_ID IN (" + deviceIdStringList+ ") " + + "AND e.STATUS NOT IN ('DELETED', 'REMOVED')"; + if (paginationRequest.getOwner() != null) { + sql = sql + " AND e.OWNER LIKE ?"; + isOwnerProvided = true; + } + if (paginationRequest.getDeviceStatus() != null) { + sql = sql + " AND e.STATUS = ?"; + isDeviceStatusProvided = true; + } + if (paginationRequest.getDeviceName() != null) { + sql = sql + " AND d.NAME LIKE ?"; + isDeviceNameProvided = true; + } + sql = sql + " LIMIT ? OFFSET ?"; + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int parameterIdx = 1; + preparedStatement.setInt(parameterIdx++, tenantId); + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(parameterIdx++, deviceId); + } + if (isOwnerProvided) + preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getOwner() + "%"); + if (isDeviceStatusProvided) + preparedStatement.setString(parameterIdx++, paginationRequest.getDeviceStatus()); + if (isDeviceNameProvided) + preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getDeviceName() + "%"); + preparedStatement.setInt(parameterIdx++, paginationRequest.getRowCount()); + preparedStatement.setInt(parameterIdx, paginationRequest.getStartIndex()); + try(ResultSet resultSet = preparedStatement.executeQuery()) { + Device device; + while(resultSet.next()) { + device = new Device(); + device.setId(resultSet.getInt("DEVICE_ID")); + device.setDeviceIdentifier(resultSet.getString("DEVICE_IDENTIFICATION")); + device.setName(resultSet.getString("DEVICE_NAME")); + device.setType(resultSet.getString("DEVICE_TYPE")); + EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); + enrolmentInfo.setStatus(EnrolmentInfo.Status.valueOf(resultSet.getString("STATUS"))); + enrolmentInfo.setOwner(resultSet.getString("OWNER")); + enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.valueOf(resultSet.getString("OWNERSHIP"))); + enrolmentInfo.setDateOfLastUpdate(resultSet.getTimestamp("DATE_OF_LAST_UPDATE").getTime()); + device.setEnrolmentInfo(enrolmentInfo); + devices.add(device); + } + } + } + return devices; + } catch (SQLException e) { + String msg = "Error occurred while retrieving devices for device ids in: " + deviceIds; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + + @Override + public List getDevicesInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + throws DeviceManagementDAOException { + List filteredDeviceIds = new ArrayList<>(); + if (deviceIds == null || deviceIds.isEmpty()) return filteredDeviceIds; + String deviceIdStringList = deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")); + try { + Connection connection = getConnection(); + String sql = "SELECT ID AS DEVICE_ID " + + "FROM DM_DEVICE WHERE ID IN " + + "(" + deviceIdStringList + ") " + + "AND TENANT_ID = ? " + + "LIMIT ? " + + "OFFSET ?"; + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int paraIdx = 1; + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(paraIdx++, deviceId); + } + preparedStatement.setInt(paraIdx++, tenantId); + preparedStatement.setInt(paraIdx++, request.getRowCount()); + preparedStatement.setInt(paraIdx, request.getStartIndex()); + try (ResultSet resultSet = preparedStatement.executeQuery()) { + while (resultSet.next()) { + filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); + } + } + return filteredDeviceIds; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving device ids in: " + filteredDeviceIds; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + + @Override + public List getDevicesNotInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + throws DeviceManagementDAOException { + List filteredDeviceIds = new ArrayList<>(); + try { + Connection connection = getConnection(); + String sql = "SELECT ID AS DEVICE_ID " + + "FROM DM_DEVICE" + + " WHERE TENANT_ID = ?"; + + if (deviceIds != null && !deviceIds.isEmpty()) { + sql += " AND ID NOT IN ( " + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ")"; + } + sql += " LIMIT ? OFFSET ?"; + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int paraIdx = 1; + preparedStatement.setInt(paraIdx++, tenantId); + if (deviceIds != null && !deviceIds.isEmpty()) { + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(paraIdx++, deviceId); + } + } + preparedStatement.setInt(paraIdx++, request.getRowCount()); + preparedStatement.setInt(paraIdx, request.getStartIndex()); + try (ResultSet resultSet = preparedStatement.executeQuery()) { + while (resultSet.next()) { + filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); + } + } + return filteredDeviceIds; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving device ids not in: " + filteredDeviceIds; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index 3effd783c1..d1649f8528 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl.device; import io.entgra.device.mgt.core.device.mgt.common.Device; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -28,7 +29,9 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * This class holds the generic implementation of DeviceDAO which can be used to support ANSI db syntax. @@ -69,4 +72,162 @@ public class OracleDeviceDAOImpl extends SQLServerDeviceDAOImpl { } } + @Override + public List getDevicesByDeviceIds(PaginationRequest paginationRequest, List deviceIds, int tenantId) + throws DeviceManagementDAOException { + List devices = new ArrayList<>(); + if (deviceIds == null || deviceIds.isEmpty()) return devices; + + String deviceIdStringList = deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")); + boolean isOwnerProvided = false; + boolean isDeviceStatusProvided = false; + boolean isDeviceNameProvided = false; + try { + Connection connection = getConnection(); + String sql = "SELECT e.DEVICE_ID, " + + "d.DEVICE_IDENTIFICATION, " + + "e.STATUS, " + + "e.OWNER, " + + "d.NAME AS DEVICE_NAME, " + + "e.DEVICE_TYPE, " + + "e.OWNERSHIP, " + + "e.DATE_OF_LAST_UPDATE " + + "FROM DM_DEVICE d " + + "INNER JOIN DM_ENROLMENT e " + + "ON d.ID = e.DEVICE_ID " + + "WHERE d.TENANT_ID = ? " + + "AND e.DEVICE_ID IN (" + deviceIdStringList + ") " + + "AND e.STATUS NOT IN ('DELETED', 'REMOVED')"; + if (paginationRequest.getOwner() != null) { + sql += " AND e.OWNER LIKE ?"; + isOwnerProvided = true; + } + if (paginationRequest.getDeviceStatus() != null) { + sql += " AND e.STATUS = ?"; + isDeviceStatusProvided = true; + } + if (paginationRequest.getDeviceName() != null) { + sql += " AND d.NAME LIKE ?"; + isDeviceNameProvided = true; + } + sql += " OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int parameterIdx = 1; + preparedStatement.setInt(parameterIdx++, tenantId); + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(parameterIdx++, deviceId); + } + if (isOwnerProvided) { + preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getOwner() + "%"); + } + if (isDeviceStatusProvided) { + preparedStatement.setString(parameterIdx++, paginationRequest.getDeviceStatus()); + } + if (isDeviceNameProvided) { + preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getDeviceName() + "%"); + } + preparedStatement.setInt(parameterIdx++, paginationRequest.getStartIndex()); + preparedStatement.setInt(parameterIdx, paginationRequest.getRowCount()); + try (ResultSet resultSet = preparedStatement.executeQuery()) { + while (resultSet.next()) { + Device device = new Device(); + device.setId(resultSet.getInt("DEVICE_ID")); + device.setDeviceIdentifier(resultSet.getString("DEVICE_IDENTIFICATION")); + device.setName(resultSet.getString("DEVICE_NAME")); + device.setType(resultSet.getString("DEVICE_TYPE")); + EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); + enrolmentInfo.setStatus(EnrolmentInfo.Status.valueOf(resultSet.getString("STATUS"))); + enrolmentInfo.setOwner(resultSet.getString("OWNER")); + enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.valueOf(resultSet.getString("OWNERSHIP"))); + enrolmentInfo.setDateOfLastUpdate(resultSet.getTimestamp("DATE_OF_LAST_UPDATE").getTime()); + device.setEnrolmentInfo(enrolmentInfo); + devices.add(device); + } + } + } + return devices; + } catch (SQLException e) { + String msg = "Error occurred while retrieving devices for device ids in: " + deviceIds; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + + @Override + public List getDevicesInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + throws DeviceManagementDAOException { + List filteredDeviceIds = new ArrayList<>(); + if (deviceIds == null || deviceIds.isEmpty()) return filteredDeviceIds; + + String deviceIdStringList = deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")); + try { + Connection connection = getConnection(); + String sql = "SELECT ID AS DEVICE_ID " + + "FROM DM_DEVICE WHERE ID IN " + + "(" + deviceIdStringList + ") " + + "AND TENANT_ID = ? " + + "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int paraIdx = 1; + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(paraIdx++, deviceId); + } + preparedStatement.setInt(paraIdx++, tenantId); + preparedStatement.setInt(paraIdx++, request.getStartIndex()); + preparedStatement.setInt(paraIdx, request.getRowCount()); + + try (ResultSet resultSet = preparedStatement.executeQuery()) { + while (resultSet.next()) { + filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); + } + } + return filteredDeviceIds; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving device ids in: " + deviceIds; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } + + @Override + public List getDevicesNotInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + throws DeviceManagementDAOException { + List filteredDeviceIds = new ArrayList<>(); + try { + Connection connection = getConnection(); + String sql = "SELECT ID AS DEVICE_ID " + + "FROM DM_DEVICE " + + "WHERE TENANT_ID = ?"; + + if (deviceIds != null && !deviceIds.isEmpty()) { + sql += " AND ID NOT IN (" + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ")"; + } + + sql += "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + int paraIdx = 1; + preparedStatement.setInt(paraIdx++, tenantId); + if (deviceIds != null && !deviceIds.isEmpty()) { + for (Integer deviceId : deviceIds) { + preparedStatement.setInt(paraIdx++, deviceId); + } + } + preparedStatement.setInt(paraIdx++, request.getStartIndex()); + preparedStatement.setInt(paraIdx, request.getRowCount()); + + try (ResultSet resultSet = preparedStatement.executeQuery()) { + while (resultSet.next()) { + filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); + } + } + return filteredDeviceIds; + } + } catch (SQLException e) { + String msg = "Error occurred while retrieving device ids not in: " + deviceIds; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index 10d3598ff5..f95bbd3294 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -1152,4 +1152,16 @@ public interface DeviceManagementProviderService { */ Device updateDeviceName(Device device, String deviceType, String deviceId) throws DeviceManagementException, DeviceNotFoundException, ConflictException; + + List getDevicesNotInGivenIdList(List deviceIds, PaginationRequest paginationRequest) + throws DeviceManagementException; + + List getDevicesInGivenIdList(List deviceIds, PaginationRequest paginationRequest) + throws DeviceManagementException; + int getDeviceCountNotInGivenIdList(List deviceIds) throws DeviceManagementException; + + List getDevicesByDeviceIds(PaginationRequest paginationRequest, List deviceIds) + throws DeviceManagementException; + public int getDeviceCountByDeviceIds(PaginationRequest paginationRequest, List deviceIds) + throws DeviceManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index b07f915e43..3fdeb263ea 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -161,6 +161,7 @@ import javax.xml.bind.Marshaller; import java.io.IOException; import java.io.StringWriter; import java.lang.reflect.Type; +import java.sql.Array; import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; @@ -5359,25 +5360,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); OwnerWithDeviceDTO ownerWithDeviceDTO; - List allowingDeviceStatuses = new ArrayList<>(); - allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); - allowingDeviceStatuses.add(EnrolmentInfo.Status.INACTIVE.toString()); - allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); + List allowingDeviceStatuses = Arrays.asList(EnrolmentInfo.Status.ACTIVE.toString(), + EnrolmentInfo.Status.INACTIVE.toString(), EnrolmentInfo.Status.UNREACHABLE.toString()); try { DeviceManagementDAOFactory.openConnection(); - ownerWithDeviceDTO = this.enrollmentDAO.getOwnersWithDevices(owner, allowingDeviceStatuses, tenantId, deviceTypeId, deviceOwner, deviceName, deviceStatus); - if (ownerWithDeviceDTO == null) { - String msg = "No data found for owner: " + owner; - log.error(msg); - throw new DeviceManagementDAOException(msg); - } - List deviceIds = ownerWithDeviceDTO.getDeviceIds(); - if (deviceIds != null) { - ownerWithDeviceDTO.setDeviceCount(deviceIds.size()); - } else { - ownerWithDeviceDTO.setDeviceCount(0); - } + ownerWithDeviceDTO = this.enrollmentDAO.getOwnersWithDevices(owner, allowingDeviceStatuses, + tenantId, deviceTypeId, deviceOwner, deviceName, deviceStatus); } catch (DeviceManagementDAOException | SQLException e) { String msg = "Error occurred while retrieving device IDs for owner: " + owner; log.error(msg, e); @@ -5388,6 +5377,41 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return ownerWithDeviceDTO; } +// @Override +// public OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner, int deviceTypeId, String deviceOwner, String deviceName, String deviceStatus) +// throws DeviceManagementDAOException { +// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); +// OwnerWithDeviceDTO ownerWithDeviceDTO; +// +// List allowingDeviceStatuses = new ArrayList<>(); +// allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); +// allowingDeviceStatuses.add(EnrolmentInfo.Status.INACTIVE.toString()); +// allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); +// +// try { +// DeviceManagementDAOFactory.openConnection(); +// ownerWithDeviceDTO = this.enrollmentDAO.getOwnersWithDevices(owner, allowingDeviceStatuses, tenantId, deviceTypeId, deviceOwner, deviceName, deviceStatus); +// if (ownerWithDeviceDTO == null) { +// String msg = "No data found for owner: " + owner; +// log.error(msg); +// throw new DeviceManagementDAOException(msg); +// } +// List deviceIds = ownerWithDeviceDTO.getDeviceIds(); +// if (deviceIds != null) { +// ownerWithDeviceDTO.setDeviceCount(deviceIds.size()); +// } else { +// ownerWithDeviceDTO.setDeviceCount(0); +// } +// } catch (DeviceManagementDAOException | SQLException e) { +// String msg = "Error occurred while retrieving device IDs for owner: " + owner; +// log.error(msg, e); +// throw new DeviceManagementDAOException(msg, e); +// } finally { +// DeviceManagementDAOFactory.closeConnection(); +// } +// return ownerWithDeviceDTO; +// } + @Override public OwnerWithDeviceDTO getOwnerWithDeviceByDeviceId(int deviceId, String deviceOwner, String deviceName, String deviceStatus) @@ -5568,4 +5592,130 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.closeConnection(); } } + + @Override + public List getDevicesNotInGivenIdList(List deviceIds, PaginationRequest paginationRequest) + throws DeviceManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + if (paginationRequest == null) { + String msg = "Received null for pagination request"; + log.error(msg); + throw new DeviceManagementException(msg); + } + + try { + DeviceManagementDAOFactory.openConnection(); + return deviceDAO.getDevicesNotInGivenIdList(paginationRequest, deviceIds, tenantId); + } catch (DeviceManagementDAOException e) { + String msg = "Error encountered while getting device ids"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error encountered while getting the database connection"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Override + public List getDevicesInGivenIdList(List deviceIds, PaginationRequest paginationRequest) + throws DeviceManagementException { + + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + if (paginationRequest == null) { + String msg = "Received null for pagination request"; + log.error(msg); + throw new DeviceManagementException(msg); + } + + try { + DeviceManagementDAOFactory.openConnection(); + return deviceDAO.getDevicesInGivenIdList(paginationRequest, deviceIds, tenantId); + } catch (DeviceManagementDAOException e) { + String msg = "Error encountered while getting device ids"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error encountered while getting the database connection"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Override + public int getDeviceCountNotInGivenIdList(List deviceIds) + throws DeviceManagementException { + + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + DeviceManagementDAOFactory.openConnection(); + return deviceDAO.getDeviceCountNotInGivenIdList(deviceIds, tenantId); + } catch (DeviceManagementDAOException e) { + String msg = "Error encountered while getting device ids"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error encountered while getting the database connection"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Override + public List getDevicesByDeviceIds(PaginationRequest paginationRequest, List deviceIds) + throws DeviceManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + if (paginationRequest == null) { + String msg = "Received null for pagination request"; + log.error(msg); + throw new DeviceManagementException(msg); + } + + try { + DeviceManagementDAOFactory.openConnection(); + return deviceDAO.getDevicesByDeviceIds(paginationRequest, deviceIds, tenantId); + } catch (DeviceManagementDAOException e) { + String msg = "Error encountered while getting devices for device ids in " + deviceIds; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error encountered while getting the database connection"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Override + public int getDeviceCountByDeviceIds(PaginationRequest paginationRequest, List deviceIds) + throws DeviceManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + if (paginationRequest == null) { + String msg = "Received null for pagination request"; + log.error(msg); + throw new DeviceManagementException(msg); + } + + try { + DeviceManagementDAOFactory.openConnection(); + return deviceDAO.getDeviceCountByDeviceIds(paginationRequest, deviceIds, tenantId); + } catch (DeviceManagementDAOException e) { + String msg = "Error encountered while getting devices for device ids in " + deviceIds; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error encountered while getting the database connection"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index 3104cff169..89af7b66b8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -30,6 +30,7 @@ import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupAlreadyExistEx import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupNotExistException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.RoleDoesNotExistException; +import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO; import org.wso2.carbon.user.api.AuthorizationManager; import org.wso2.carbon.user.api.UserStoreManager; @@ -389,4 +390,6 @@ public interface GroupManagementProviderService { GroupDetailsDTO getGroupDetailsWithDevices(String groupName, int deviceTypeId, String deviceOwner, String deviceName, String deviceStatus, int offset, int limit) throws GroupManagementException; + int getDeviceCount(String groupName) throws GroupManagementException; + } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index c2c00d55c0..36b79f150f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -1725,4 +1725,18 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid return groupDetailsWithDevices; } + @Override + public int getDeviceCount(String groupName) throws GroupManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + GroupManagementDAOFactory.openConnection(); + return groupDAO.getDeviceCount(groupName, tenantId); + } catch (SQLException | GroupManagementDAOException e) { + String msg = "Error occurred while retrieving device count."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } } From f585e37d61a8e7963c5b7838bf7011bac6204cce Mon Sep 17 00:00:00 2001 From: Nipuni Kavindya Date: Tue, 23 Jul 2024 03:51:33 +0000 Subject: [PATCH 258/343] Fix build failure Co-authored-by: Nipuni Kavindya Co-committed-by: Nipuni Kavindya --- .../mgt/SubscriptionManagementServiceProvider.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementServiceProvider.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementServiceProvider.java index c2fd88b25e..1f13a8a5fa 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementServiceProvider.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/SubscriptionManagementServiceProvider.java @@ -33,6 +33,10 @@ public class SubscriptionManagementServiceProvider { private SubscriptionManagementServiceProvider() { } + public static SubscriptionManagementServiceProvider getInstance() { + return SubscriptionManagementProviderServiceHolder.INSTANCE; + } + /** * Retrieves the appropriate SubscriptionManagementHelperService based on the provided SubscriptionInfo. * From 3112fd92a621dac6a2c6c6aa44139375447b2646 Mon Sep 17 00:00:00 2001 From: "osh.silva" Date: Tue, 23 Jul 2024 11:59:13 +0530 Subject: [PATCH 259/343] Validate billing cost --- .../impl/util/RequestValidationUtil.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java index 71d875a6b9..ab66e75d1c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java @@ -23,6 +23,8 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpStatus; +import org.json.JSONArray; +import org.json.JSONObject; import io.entgra.device.mgt.core.device.mgt.common.Base64File; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.Feature; @@ -821,6 +823,30 @@ public class RequestValidationUtil { new ErrorResponse.ErrorResponseBuilder() .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); } + if (metadata.getMetaKey().equals("PER_DEVICE_COST")) { + String metaValue = metadata.getMetaValue(); + JSONArray jsonArray = new JSONArray(metaValue); + + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + if (jsonObject.has("cost")) { + Object costObj = jsonObject.get("cost"); + if (costObj == JSONObject.NULL || (costObj instanceof Number && ((Number) costObj).doubleValue() < 0)) { + String msg = "Billing cost cannot be a minus value or null."; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } + } else { + String msg = "Billing cost is missing."; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } + } + } if (metadata.getMetaValue() == null) { String msg = "Request parameter metaValue should be non empty."; log.error(msg); From c480512f10c88a9b9b35b4fbd909773a2a26e605 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Tue, 23 Jul 2024 17:48:25 +0530 Subject: [PATCH 260/343] Fix issues related to new devices and stats --- .../mgt/core/dao/SubscriptionDAO.java | 4 +- .../GenericSubscriptionDAOImpl.java | 24 ++--- .../core/util/SubscriptionManagementUtil.java | 29 ------ ...bscriptionManagementHelperServiceImpl.java | 12 +-- ...bscriptionManagementHelperServiceImpl.java | 23 +++-- ...bscriptionManagementHelperServiceImpl.java | 22 +++-- ...bscriptionManagementHelperServiceImpl.java | 22 +++-- .../core/device/mgt/core/dao/DeviceDAO.java | 4 +- .../core/dao/impl/AbstractDeviceDAOImpl.java | 63 +++++++----- .../dao/impl/device/GenericDeviceDAOImpl.java | 95 ++++--------------- .../dao/impl/device/OracleDeviceDAOImpl.java | 88 ++--------------- .../DeviceManagementProviderService.java | 7 +- .../DeviceManagementProviderServiceImpl.java | 20 +--- 13 files changed, 127 insertions(+), 286 deletions(-) delete mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/SubscriptionManagementUtil.java diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java index cadab204ca..c35c4a5251 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java @@ -527,8 +527,8 @@ public interface SubscriptionDAO { */ int getUserUnsubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; - SubscriptionStatisticDTO getSubscriptionStatistic(List deviceIds, String subscriptionType, boolean isUnsubscribed, - int tenantId) throws ApplicationManagementDAOException; + SubscriptionStatisticDTO getSubscriptionStatistic(List deviceIds, boolean isUnsubscribed, + int tenantId, int appReleaseId) throws ApplicationManagementDAOException; /** * This method is used to get the counts of devices related to a UUID. * diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index a793638d2d..c459acd7ad 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -18,11 +18,9 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription; import io.entgra.device.mgt.core.application.mgt.common.SubscriptionMetadata; -import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity; import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionStatisticDTO; -import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO; import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; @@ -2792,43 +2790,33 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } } - // todo: fixed the status @Override - public SubscriptionStatisticDTO getSubscriptionStatistic(List deviceIds, String subscriptionType, - boolean isUnsubscribed, int tenantId) + public SubscriptionStatisticDTO getSubscriptionStatistic(List deviceIds, boolean isUnsubscribed, int tenantId, int appReleaseId) throws ApplicationManagementDAOException { SubscriptionStatisticDTO subscriptionStatisticDTO = new SubscriptionStatisticDTO(); if (deviceIds == null || deviceIds.isEmpty()) return subscriptionStatisticDTO; - boolean doesAllEntriesRequired = true; try { Connection connection = getDBConnection(); String sql = "SELECT COUNT(DISTINCT ID) AS COUNT, " + "STATUS FROM AP_DEVICE_SUBSCRIPTION " + "WHERE TENANT_ID = ? " + - "AND UNSUBSCRIBED = ?" + + "AND AP_APP_RELEASE_ID = ? " + + "AND UNSUBSCRIBED = ? " + "AND DM_DEVICE_ID IN (" + - deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ")"; - - if (!Objects.equals(subscriptionType, SubscriptionMetadata.SubscriptionTypes.DEVICE)) { - sql += " AND ACTION_TRIGGERED_FROM = ?"; - doesAllEntriesRequired = false; - } - - sql += " GROUP BY (STATUS)"; + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ") " + + "GROUP BY (STATUS)"; try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { int idx = 1; preparedStatement.setInt(idx++, tenantId); + preparedStatement.setInt(idx++, appReleaseId); preparedStatement.setBoolean(idx++, isUnsubscribed); for (Integer deviceId : deviceIds) { preparedStatement.setInt(idx++, deviceId); } - if (!doesAllEntriesRequired) { - preparedStatement.setString(idx, subscriptionType); - } try (ResultSet resultSet = preparedStatement.executeQuery()) { while (resultSet.next()) { // add the error and in progress diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/SubscriptionManagementUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/SubscriptionManagementUtil.java deleted file mode 100644 index 9c45f57be4..0000000000 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/SubscriptionManagementUtil.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2018 - 2024, 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.application.mgt.core.util; - -public class SubscriptionManagementUtil { - public static final class DeviceSubscriptionStatus { - public static final String COMPLETED = "COMPLETED"; - public static final String ERROR ="ERROR"; - public static final String NEW = "NEW"; - public static final String SUBSCRIBED = "SUBSCRIBED"; - } -} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java index b0fc7c97bd..e3c7396bb5 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java @@ -36,7 +36,6 @@ import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementHelperUtil; import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.apache.commons.logging.Log; @@ -97,20 +96,17 @@ public class DeviceBasedSubscriptionManagementHelperServiceImpl implements Subsc List deviceIdsOfSubscription = deviceSubscriptionDTOS.stream(). map(DeviceSubscriptionDTO::getDeviceId).collect(Collectors.toList()); - List newDeviceIds = deviceManagementProviderService.getDevicesNotInGivenIdList(deviceIdsOfSubscription, - new PaginationRequest(offset, limit)); + List newDeviceIds = deviceManagementProviderService.getDevicesNotInGivenIdList(deviceIdsOfSubscription); deviceSubscriptionDTOS = newDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); - - deviceCount = deviceManagementProviderService.getDeviceCountNotInGivenIdList(deviceIdsOfSubscription); } else { deviceSubscriptionDTOS = subscriptionDAO.getAllSubscriptionsDetails(applicationReleaseDTO. getId(), isUnsubscribe, tenantId, dbSubscriptionStatus, null, deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); - - deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, - subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); } + deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); + List deviceSubscriptions = SubscriptionManagementHelperUtil.getDeviceSubscriptionData(deviceSubscriptionDTOS, subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset); return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java index 1a78df119c..9f7f9db78f 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java @@ -39,7 +39,6 @@ import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementHelperUtil; import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO; @@ -115,11 +114,8 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr allDeviceIdsOwnByGroup.remove(deviceId); } - List paginatedNewDeviceIds = deviceManagementProviderService.getDevicesInGivenIdList(allDeviceIdsOwnByGroup, - new PaginationRequest(offset, limit)); - deviceSubscriptionDTOS = paginatedNewDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); - - deviceCount = allDeviceIdsOwnByGroup.size(); + List newDeviceIds = deviceManagementProviderService.getDevicesInGivenIdList(allDeviceIdsOwnByGroup); + deviceSubscriptionDTOS = newDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); } else { groupDetailsDTO = groupManagementProviderService.getGroupDetailsWithDevices(subscriptionInfo.getIdentifier(), applicationDTO.getDeviceTypeId(), deviceSubscriptionFilterCriteria.getOwner(), deviceSubscriptionFilterCriteria.getName(), @@ -130,9 +126,10 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr isUnsubscribe, tenantId, paginatedDeviceIdsOwnByGroup, dbSubscriptionStatus, null, deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); - deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, - subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); } + deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); + List deviceSubscriptions = SubscriptionManagementHelperUtil.getDeviceSubscriptionData(deviceSubscriptionDTOS, subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset); return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions); @@ -188,11 +185,19 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { ConnectionManagerUtil.openDBConnection(); + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO. + getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } List devices = HelperUtil.getGroupManagementProviderService(). getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), false); List deviceIdsOwnByGroup = devices.stream().map(Device::getId).collect(Collectors.toList()); SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. - getSubscriptionStatistic(deviceIdsOwnByGroup, null, isUnsubscribe, tenantId); + getSubscriptionStatistic(deviceIdsOwnByGroup, isUnsubscribe, tenantId, applicationReleaseDTO.getId()); int allDeviceCount = HelperUtil.getGroupManagementProviderService().getDeviceCount(subscriptionInfo.getIdentifier()); return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); } catch (ApplicationManagementDAOException e) { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java index b3498db662..93e6ebc46a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java @@ -111,18 +111,16 @@ public class RoleBasedSubscriptionManagementHelperServiceImpl implements Subscri deviceIdsOwnByRole.remove(deviceId); } - List paginatedNewDeviceIds = deviceManagementProviderService.getDevicesInGivenIdList(deviceIdsOwnByRole, - new PaginationRequest(offset, limit)); - deviceSubscriptionDTOS = paginatedNewDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); - deviceCount = deviceIdsOwnByRole.size(); + List newDeviceIds = deviceManagementProviderService.getDevicesInGivenIdList(deviceIdsOwnByRole); + deviceSubscriptionDTOS = newDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); } else { deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(), isUnsubscribe, tenantId, deviceIdsOwnByRole, dbSubscriptionStatus, subscriptionInfo.getSubscriptionType(), deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); - - deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, - subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); } + deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); + List deviceSubscriptions = SubscriptionManagementHelperUtil. getDeviceSubscriptionData(deviceSubscriptionDTOS, subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset); @@ -180,9 +178,17 @@ public class RoleBasedSubscriptionManagementHelperServiceImpl implements Subscri int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { ConnectionManagerUtil.openDBConnection(); + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO. + getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } List deviceIdsOwnByRole = getDeviceIdsOwnByRole(subscriptionInfo.getIdentifier(), tenantId); SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. - getSubscriptionStatistic(deviceIdsOwnByRole, null, isUnsubscribe, tenantId); + getSubscriptionStatistic(deviceIdsOwnByRole, isUnsubscribe, tenantId, applicationReleaseDTO.getId()); int allDeviceCount = deviceIdsOwnByRole.size(); return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); } catch (DeviceManagementException | ApplicationManagementDAOException | UserStoreException e) { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java index 83bc8c08e2..a12560146d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java @@ -107,19 +107,17 @@ public class UserBasedSubscriptionManagementHelperServiceImpl implements Subscri for (Integer deviceId : deviceIdsOfSubscription) { deviceIdsOwnByUser.remove(deviceId); } - List paginatedNewDeviceIds = deviceManagementProviderService.getDevicesInGivenIdList(deviceIdsOwnByUser, - new PaginationRequest(offset, limit)); - deviceSubscriptionDTOS = paginatedNewDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); + List newDeviceIds = deviceManagementProviderService.getDevicesInGivenIdList(deviceIdsOwnByUser); + deviceSubscriptionDTOS = newDeviceIds.stream().map(DeviceSubscriptionDTO::new).collect(Collectors.toList()); - deviceCount = deviceIdsOwnByUser.size(); } else { deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(), isUnsubscribe, tenantId, deviceIdsOwnByUser, dbSubscriptionStatus, null, deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); - - deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, - subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); } + deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, + subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); + List deviceSubscriptions = SubscriptionManagementHelperUtil.getDeviceSubscriptionData(deviceSubscriptionDTOS, subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset); return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions); @@ -171,9 +169,17 @@ public class UserBasedSubscriptionManagementHelperServiceImpl implements Subscri int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { ConnectionManagerUtil.openDBConnection(); + ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO. + getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId); + if (applicationReleaseDTO == null) { + String msg = "Couldn't find an application release for application release UUID: " + + subscriptionInfo.getApplicationUUID(); + log.error(msg); + throw new NotFoundException(msg); + } List deviceIdsOwnByUser = getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier()); SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. - getSubscriptionStatistic(deviceIdsOwnByUser, null, isUnsubscribe, tenantId); + getSubscriptionStatistic(deviceIdsOwnByUser, isUnsubscribe, tenantId, applicationReleaseDTO.getId()); int allDeviceCount = deviceIdsOwnByUser.size(); return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); } catch (DeviceManagementException | ApplicationManagementDAOException e) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java index 3d646768fb..606a1eab5c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java @@ -865,10 +865,10 @@ public interface DeviceDAO { */ int getCountOfDevicesNotInGroup(PaginationRequest request, int tenantId) throws DeviceManagementDAOException; - List getDevicesNotInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + List getDevicesNotInGivenIdList(List deviceIds, int tenantId) throws DeviceManagementDAOException; - List getDevicesInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + List getDevicesInGivenIdList(List deviceIds, int tenantId) throws DeviceManagementDAOException; int getDeviceCountNotInGivenIdList(List deviceIds, int tenantId) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index b195acfc1f..eafa2e0d02 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -3301,7 +3301,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } @Override - public List getDevicesNotInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + public List getDevicesNotInGivenIdList(List deviceIds, int tenantId) throws DeviceManagementDAOException { List filteredDeviceIds = new ArrayList<>(); try { @@ -3312,8 +3312,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { sql += " AND ID NOT IN ( " + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ")"; } - sql += " LIMIT ? OFFSET ?"; - try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { int paraIdx = 1; preparedStatement.setInt(paraIdx++, tenantId); @@ -3324,8 +3322,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } } - preparedStatement.setInt(paraIdx++, request.getRowCount()); - preparedStatement.setInt(paraIdx, request.getStartIndex()); try (ResultSet resultSet = preparedStatement.executeQuery()) { while (resultSet.next()) { filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); @@ -3341,7 +3337,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } @Override - public List getDevicesInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) + public List getDevicesInGivenIdList(List deviceIds, int tenantId) throws DeviceManagementDAOException { List filteredDeviceIds = new ArrayList<>(); if (deviceIds == null || deviceIds.isEmpty()) return filteredDeviceIds; @@ -3351,19 +3347,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { Connection connection = getConnection(); String sql = "SELECT ID AS DEVICE_ID " + "FROM DM_DEVICE " + - "WHERE ID IN (" + deviceIdStringList + ")" + - " AND TENANT_ID = ? " + - "LIMIT ? " + - "OFFSET ?"; + "WHERE ID IN (" + deviceIdStringList + ") " + + "AND TENANT_ID = ? "; try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { int paraIdx = 1; for (Integer deviceId : deviceIds) { preparedStatement.setInt(paraIdx++, deviceId); } - preparedStatement.setInt(paraIdx++, tenantId); - preparedStatement.setInt(paraIdx++, request.getRowCount()); - preparedStatement.setInt(paraIdx, request.getStartIndex()); + preparedStatement.setInt(paraIdx, tenantId); try (ResultSet resultSet = preparedStatement.executeQuery()) { while (resultSet.next()) { filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); @@ -3426,6 +3418,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { boolean isOwnerProvided = false; boolean isDeviceStatusProvided = false; boolean isDeviceNameProvided = false; + boolean isDeviceTypeIdProvided = false; + try { Connection connection = getConnection(); String sql = "SELECT e.DEVICE_ID, " + @@ -3439,8 +3433,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "FROM DM_DEVICE d " + "INNER JOIN DM_ENROLMENT e " + "ON d.ID = e.DEVICE_ID " + - "WHERE d.DEVICE_TYPE_ID = ? " + - "AND d.TENANT_ID = ? " + + "WHERE d.TENANT_ID = ? " + "AND e.DEVICE_ID IN (" + deviceIdStringList+ ") " + "AND e.STATUS NOT IN ('DELETED', 'REMOVED')"; @@ -3459,6 +3452,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { isDeviceNameProvided = true; } + if (paginationRequest.getDeviceTypeId() > 0) { + sql = sql + " AND d.DEVICE_TYPE_ID = ?"; + isDeviceTypeIdProvided = true; + } + sql = sql + " LIMIT ? OFFSET ?"; try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { @@ -3470,12 +3468,18 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { preparedStatement.setInt(parameterIdx++, deviceId); } - if (isOwnerProvided) + if (isOwnerProvided) { preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getOwner() + "%"); - if (isDeviceStatusProvided) + } + if (isDeviceStatusProvided) { preparedStatement.setString(parameterIdx++, paginationRequest.getDeviceStatus()); - if (isDeviceNameProvided) + } + if (isDeviceNameProvided) { preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getDeviceName() + "%"); + } + if (isDeviceTypeIdProvided) { + preparedStatement.setInt(parameterIdx++, paginationRequest.getDeviceTypeId()); + } preparedStatement.setInt(parameterIdx++, paginationRequest.getRowCount()); preparedStatement.setInt(parameterIdx, paginationRequest.getStartIndex()); @@ -3506,7 +3510,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } } - // todo: fix the join query @Override public int getDeviceCountByDeviceIds(PaginationRequest paginationRequest, List deviceIds, int tenantId) throws DeviceManagementDAOException { @@ -3517,6 +3520,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { boolean isOwnerProvided = false; boolean isDeviceStatusProvided = false; boolean isDeviceNameProvided = false; + boolean isDeviceTypeIdProvided = false; try { Connection connection = getConnection(); String sql = "SELECT COUNT(DISTINCT e.DEVICE_ID) AS COUNT " + @@ -3525,7 +3529,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "ON d.ID = e.DEVICE_ID " + "WHERE e.TENANT_ID = ? " + "AND e.DEVICE_ID IN (" + deviceIdStringList+ ") " + - "AND d.DEVICE_TYPE_ID = ? " + "AND e.STATUS NOT IN ('DELETED', 'REMOVED')"; if (paginationRequest.getOwner() != null) { @@ -3543,6 +3546,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { isDeviceNameProvided = true; } + if (paginationRequest.getDeviceTypeId() > 0) { + sql = sql + " AND d.DEVICE_TYPE_ID = ?"; + isDeviceTypeIdProvided = true; + } + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { int parameterIdx = 1; preparedStatement.setInt(parameterIdx++, tenantId); @@ -3551,13 +3559,18 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { preparedStatement.setInt(parameterIdx++, deviceId); } - preparedStatement.setInt(parameterIdx++, paginationRequest.getDeviceTypeId()); - if (isOwnerProvided) + if (isOwnerProvided) { preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getOwner() + "%"); - if (isDeviceStatusProvided) + } + if (isDeviceStatusProvided) { preparedStatement.setString(parameterIdx++, paginationRequest.getDeviceStatus()); - if (isDeviceNameProvided) - preparedStatement.setString(parameterIdx, "%" + paginationRequest.getDeviceName() + "%"); + } + if (isDeviceNameProvided) { + preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getDeviceName() + "%"); + } + if (isDeviceTypeIdProvided) { + preparedStatement.setInt(parameterIdx, paginationRequest.getDeviceTypeId()); + } try(ResultSet resultSet = preparedStatement.executeQuery()) { if (resultSet.next()) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index e116df7490..6467f912ff 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -1869,6 +1869,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isOwnerProvided = false; boolean isDeviceStatusProvided = false; boolean isDeviceNameProvided = false; + boolean isDeviceTypeIdProvided = false; try { Connection connection = getConnection(); String sql = "SELECT e.DEVICE_ID, " + @@ -1881,8 +1882,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "e.DATE_OF_LAST_UPDATE " + "FROM DM_DEVICE d " + "INNER JOIN DM_ENROLMENT e " + - "WHERE d.ID = e.DEVICE_ID " + - "AND d.TENANT_ID = ? " + + "WHERE d.TENANT_ID = ? " + "AND e.DEVICE_ID IN (" + deviceIdStringList+ ") " + "AND e.STATUS NOT IN ('DELETED', 'REMOVED')"; if (paginationRequest.getOwner() != null) { @@ -1897,6 +1897,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { sql = sql + " AND d.NAME LIKE ?"; isDeviceNameProvided = true; } + if (paginationRequest.getDeviceTypeId() > 0) { + sql = sql + " AND d.DEVICE_TYPE_ID = ?"; + isDeviceTypeIdProvided = true; + } sql = sql + " LIMIT ? OFFSET ?"; try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { int parameterIdx = 1; @@ -1904,12 +1908,19 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { for (Integer deviceId : deviceIds) { preparedStatement.setInt(parameterIdx++, deviceId); } - if (isOwnerProvided) + if (isOwnerProvided) { preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getOwner() + "%"); - if (isDeviceStatusProvided) + } + if (isDeviceStatusProvided) { preparedStatement.setString(parameterIdx++, paginationRequest.getDeviceStatus()); - if (isDeviceNameProvided) + } + if (isDeviceNameProvided) { preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getDeviceName() + "%"); + } + if (isDeviceTypeIdProvided) { + preparedStatement.setInt(parameterIdx++, paginationRequest.getDeviceTypeId()); + } + preparedStatement.setInt(parameterIdx++, paginationRequest.getRowCount()); preparedStatement.setInt(parameterIdx, paginationRequest.getStartIndex()); try(ResultSet resultSet = preparedStatement.executeQuery()) { @@ -1937,78 +1948,4 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { throw new DeviceManagementDAOException(msg, e); } } - - @Override - public List getDevicesInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) - throws DeviceManagementDAOException { - List filteredDeviceIds = new ArrayList<>(); - if (deviceIds == null || deviceIds.isEmpty()) return filteredDeviceIds; - String deviceIdStringList = deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")); - try { - Connection connection = getConnection(); - String sql = "SELECT ID AS DEVICE_ID " + - "FROM DM_DEVICE WHERE ID IN " + - "(" + deviceIdStringList + ") " + - "AND TENANT_ID = ? " + - "LIMIT ? " + - "OFFSET ?"; - try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { - int paraIdx = 1; - for (Integer deviceId : deviceIds) { - preparedStatement.setInt(paraIdx++, deviceId); - } - preparedStatement.setInt(paraIdx++, tenantId); - preparedStatement.setInt(paraIdx++, request.getRowCount()); - preparedStatement.setInt(paraIdx, request.getStartIndex()); - try (ResultSet resultSet = preparedStatement.executeQuery()) { - while (resultSet.next()) { - filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); - } - } - return filteredDeviceIds; - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving device ids in: " + filteredDeviceIds; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public List getDevicesNotInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) - throws DeviceManagementDAOException { - List filteredDeviceIds = new ArrayList<>(); - try { - Connection connection = getConnection(); - String sql = "SELECT ID AS DEVICE_ID " + - "FROM DM_DEVICE" + - " WHERE TENANT_ID = ?"; - - if (deviceIds != null && !deviceIds.isEmpty()) { - sql += " AND ID NOT IN ( " + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ")"; - } - sql += " LIMIT ? OFFSET ?"; - try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { - int paraIdx = 1; - preparedStatement.setInt(paraIdx++, tenantId); - if (deviceIds != null && !deviceIds.isEmpty()) { - for (Integer deviceId : deviceIds) { - preparedStatement.setInt(paraIdx++, deviceId); - } - } - preparedStatement.setInt(paraIdx++, request.getRowCount()); - preparedStatement.setInt(paraIdx, request.getStartIndex()); - try (ResultSet resultSet = preparedStatement.executeQuery()) { - while (resultSet.next()) { - filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); - } - } - return filteredDeviceIds; - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving device ids not in: " + filteredDeviceIds; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index d1649f8528..e9143faae3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -82,6 +82,7 @@ public class OracleDeviceDAOImpl extends SQLServerDeviceDAOImpl { boolean isOwnerProvided = false; boolean isDeviceStatusProvided = false; boolean isDeviceNameProvided = false; + boolean isDeviceTypeIdProvided = false; try { Connection connection = getConnection(); String sql = "SELECT e.DEVICE_ID, " + @@ -110,6 +111,11 @@ public class OracleDeviceDAOImpl extends SQLServerDeviceDAOImpl { sql += " AND d.NAME LIKE ?"; isDeviceNameProvided = true; } + if (paginationRequest.getDeviceTypeId() > 0) { + sql += " AND d.DEVICE_TYPE_ID = ?"; + isDeviceTypeIdProvided = true; + } + sql += " OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { int parameterIdx = 1; @@ -126,6 +132,10 @@ public class OracleDeviceDAOImpl extends SQLServerDeviceDAOImpl { if (isDeviceNameProvided) { preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getDeviceName() + "%"); } + if (isDeviceTypeIdProvided) { + preparedStatement.setInt(parameterIdx++, paginationRequest.getDeviceTypeId()); + } + preparedStatement.setInt(parameterIdx++, paginationRequest.getStartIndex()); preparedStatement.setInt(parameterIdx, paginationRequest.getRowCount()); try (ResultSet resultSet = preparedStatement.executeQuery()) { @@ -152,82 +162,4 @@ public class OracleDeviceDAOImpl extends SQLServerDeviceDAOImpl { throw new DeviceManagementDAOException(msg, e); } } - - @Override - public List getDevicesInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) - throws DeviceManagementDAOException { - List filteredDeviceIds = new ArrayList<>(); - if (deviceIds == null || deviceIds.isEmpty()) return filteredDeviceIds; - - String deviceIdStringList = deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")); - try { - Connection connection = getConnection(); - String sql = "SELECT ID AS DEVICE_ID " + - "FROM DM_DEVICE WHERE ID IN " + - "(" + deviceIdStringList + ") " + - "AND TENANT_ID = ? " + - "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { - int paraIdx = 1; - for (Integer deviceId : deviceIds) { - preparedStatement.setInt(paraIdx++, deviceId); - } - preparedStatement.setInt(paraIdx++, tenantId); - preparedStatement.setInt(paraIdx++, request.getStartIndex()); - preparedStatement.setInt(paraIdx, request.getRowCount()); - - try (ResultSet resultSet = preparedStatement.executeQuery()) { - while (resultSet.next()) { - filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); - } - } - return filteredDeviceIds; - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving device ids in: " + deviceIds; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - - @Override - public List getDevicesNotInGivenIdList(PaginationRequest request, List deviceIds, int tenantId) - throws DeviceManagementDAOException { - List filteredDeviceIds = new ArrayList<>(); - try { - Connection connection = getConnection(); - String sql = "SELECT ID AS DEVICE_ID " + - "FROM DM_DEVICE " + - "WHERE TENANT_ID = ?"; - - if (deviceIds != null && !deviceIds.isEmpty()) { - sql += " AND ID NOT IN (" + deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")) + ")"; - } - - sql += "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; - - try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { - int paraIdx = 1; - preparedStatement.setInt(paraIdx++, tenantId); - if (deviceIds != null && !deviceIds.isEmpty()) { - for (Integer deviceId : deviceIds) { - preparedStatement.setInt(paraIdx++, deviceId); - } - } - preparedStatement.setInt(paraIdx++, request.getStartIndex()); - preparedStatement.setInt(paraIdx, request.getRowCount()); - - try (ResultSet resultSet = preparedStatement.executeQuery()) { - while (resultSet.next()) { - filteredDeviceIds.add(resultSet.getInt("DEVICE_ID")); - } - } - return filteredDeviceIds; - } - } catch (SQLException e) { - String msg = "Error occurred while retrieving device ids not in: " + deviceIds; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index f95bbd3294..56f95d3f44 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -58,7 +58,6 @@ import io.entgra.device.mgt.core.device.mgt.common.geo.service.GeoCluster; import java.sql.SQLException; import java.sql.Timestamp; -import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; @@ -1153,15 +1152,15 @@ public interface DeviceManagementProviderService { Device updateDeviceName(Device device, String deviceType, String deviceId) throws DeviceManagementException, DeviceNotFoundException, ConflictException; - List getDevicesNotInGivenIdList(List deviceIds, PaginationRequest paginationRequest) + List getDevicesNotInGivenIdList(List deviceIds) throws DeviceManagementException; - List getDevicesInGivenIdList(List deviceIds, PaginationRequest paginationRequest) + List getDevicesInGivenIdList(List deviceIds) throws DeviceManagementException; int getDeviceCountNotInGivenIdList(List deviceIds) throws DeviceManagementException; List getDevicesByDeviceIds(PaginationRequest paginationRequest, List deviceIds) throws DeviceManagementException; - public int getDeviceCountByDeviceIds(PaginationRequest paginationRequest, List deviceIds) + int getDeviceCountByDeviceIds(PaginationRequest paginationRequest, List deviceIds) throws DeviceManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 3fdeb263ea..341714dd10 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -161,7 +161,6 @@ import javax.xml.bind.Marshaller; import java.io.IOException; import java.io.StringWriter; import java.lang.reflect.Type; -import java.sql.Array; import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; @@ -5594,18 +5593,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public List getDevicesNotInGivenIdList(List deviceIds, PaginationRequest paginationRequest) + public List getDevicesNotInGivenIdList(List deviceIds) throws DeviceManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - if (paginationRequest == null) { - String msg = "Received null for pagination request"; - log.error(msg); - throw new DeviceManagementException(msg); - } try { DeviceManagementDAOFactory.openConnection(); - return deviceDAO.getDevicesNotInGivenIdList(paginationRequest, deviceIds, tenantId); + return deviceDAO.getDevicesNotInGivenIdList(deviceIds, tenantId); } catch (DeviceManagementDAOException e) { String msg = "Error encountered while getting device ids"; log.error(msg, e); @@ -5620,19 +5614,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public List getDevicesInGivenIdList(List deviceIds, PaginationRequest paginationRequest) + public List getDevicesInGivenIdList(List deviceIds) throws DeviceManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - if (paginationRequest == null) { - String msg = "Received null for pagination request"; - log.error(msg); - throw new DeviceManagementException(msg); - } - try { DeviceManagementDAOFactory.openConnection(); - return deviceDAO.getDevicesInGivenIdList(paginationRequest, deviceIds, tenantId); + return deviceDAO.getDevicesInGivenIdList(deviceIds, tenantId); } catch (DeviceManagementDAOException e) { String msg = "Error encountered while getting device ids"; log.error(msg, e); From 8f8e5e67d4e5923a12aeece351601a233dcd4246 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Tue, 23 Jul 2024 19:21:28 +0530 Subject: [PATCH 261/343] Update generic device dao --- .../core/dao/impl/AbstractDeviceDAOImpl.java | 102 ------------------ .../dao/impl/device/GenericDeviceDAOImpl.java | 11 ++ 2 files changed, 11 insertions(+), 102 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index eafa2e0d02..bb0bb97b62 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -3408,108 +3408,6 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } } - @Override - public List getDevicesByDeviceIds(PaginationRequest paginationRequest, List deviceIds, int tenantId) - throws DeviceManagementDAOException { - List devices = new ArrayList<>(); - if (deviceIds == null || deviceIds.isEmpty()) return devices; - - String deviceIdStringList = deviceIds.stream().map(id -> "?").collect(Collectors.joining(",")); - boolean isOwnerProvided = false; - boolean isDeviceStatusProvided = false; - boolean isDeviceNameProvided = false; - boolean isDeviceTypeIdProvided = false; - - try { - Connection connection = getConnection(); - String sql = "SELECT e.DEVICE_ID, " + - "d.DEVICE_IDENTIFICATION, " + - "e.STATUS, " + - "e.OWNER, " + - "d.NAME AS DEVICE_NAME, " + - "e.DEVICE_TYPE, " + - "e.OWNERSHIP, " + - "e.DATE_OF_LAST_UPDATE " + - "FROM DM_DEVICE d " + - "INNER JOIN DM_ENROLMENT e " + - "ON d.ID = e.DEVICE_ID " + - "WHERE d.TENANT_ID = ? " + - "AND e.DEVICE_ID IN (" + deviceIdStringList+ ") " + - "AND e.STATUS NOT IN ('DELETED', 'REMOVED')"; - - if (paginationRequest.getOwner() != null) { - sql = sql + " AND e.OWNER LIKE ?"; - isOwnerProvided = true; - } - - if (paginationRequest.getDeviceStatus() != null) { - sql = sql + " AND e.STATUS = ?"; - isDeviceStatusProvided = true; - } - - if (paginationRequest.getDeviceName() != null) { - sql = sql + " AND d.NAME LIKE ?"; - isDeviceNameProvided = true; - } - - if (paginationRequest.getDeviceTypeId() > 0) { - sql = sql + " AND d.DEVICE_TYPE_ID = ?"; - isDeviceTypeIdProvided = true; - } - - sql = sql + " LIMIT ? OFFSET ?"; - - try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { - int parameterIdx = 1; - preparedStatement.setInt(parameterIdx++, paginationRequest.getDeviceTypeId()); - preparedStatement.setInt(parameterIdx++, tenantId); - - for (Integer deviceId : deviceIds) { - preparedStatement.setInt(parameterIdx++, deviceId); - } - - if (isOwnerProvided) { - preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getOwner() + "%"); - } - if (isDeviceStatusProvided) { - preparedStatement.setString(parameterIdx++, paginationRequest.getDeviceStatus()); - } - if (isDeviceNameProvided) { - preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getDeviceName() + "%"); - } - if (isDeviceTypeIdProvided) { - preparedStatement.setInt(parameterIdx++, paginationRequest.getDeviceTypeId()); - } - - preparedStatement.setInt(parameterIdx++, paginationRequest.getRowCount()); - preparedStatement.setInt(parameterIdx, paginationRequest.getStartIndex()); - - try(ResultSet resultSet = preparedStatement.executeQuery()) { - Device device; - while(resultSet.next()) { - device = new Device(); - device.setId(resultSet.getInt("DEVICE_ID")); - device.setDeviceIdentifier(resultSet.getString("DEVICE_IDENTIFICATION")); - device.setName(resultSet.getString("DEVICE_NAME")); - device.setType(resultSet.getString("DEVICE_TYPE")); - EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); - enrolmentInfo.setStatus(EnrolmentInfo.Status.valueOf(resultSet.getString("STATUS"))); - enrolmentInfo.setOwner(resultSet.getString("OWNER")); - enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.valueOf(resultSet.getString("OWNERSHIP"))); - enrolmentInfo.setDateOfLastUpdate(resultSet.getTimestamp("DATE_OF_LAST_UPDATE").getTime()); - device.setEnrolmentInfo(enrolmentInfo); - devices.add(device); - } - } - } - return devices; - } catch (SQLException e) { - String msg = "Error occurred while retrieving devices for device ids in: " + deviceIds; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } - @Override public int getDeviceCountByDeviceIds(PaginationRequest paginationRequest, List deviceIds, int tenantId) throws DeviceManagementDAOException { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 6467f912ff..5710e0181f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -1870,6 +1870,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isDeviceStatusProvided = false; boolean isDeviceNameProvided = false; boolean isDeviceTypeIdProvided = false; + try { Connection connection = getConnection(); String sql = "SELECT e.DEVICE_ID, " + @@ -1882,32 +1883,41 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "e.DATE_OF_LAST_UPDATE " + "FROM DM_DEVICE d " + "INNER JOIN DM_ENROLMENT e " + + "ON d.ID = e.DEVICE_ID " + "WHERE d.TENANT_ID = ? " + "AND e.DEVICE_ID IN (" + deviceIdStringList+ ") " + "AND e.STATUS NOT IN ('DELETED', 'REMOVED')"; + if (paginationRequest.getOwner() != null) { sql = sql + " AND e.OWNER LIKE ?"; isOwnerProvided = true; } + if (paginationRequest.getDeviceStatus() != null) { sql = sql + " AND e.STATUS = ?"; isDeviceStatusProvided = true; } + if (paginationRequest.getDeviceName() != null) { sql = sql + " AND d.NAME LIKE ?"; isDeviceNameProvided = true; } + if (paginationRequest.getDeviceTypeId() > 0) { sql = sql + " AND d.DEVICE_TYPE_ID = ?"; isDeviceTypeIdProvided = true; } + sql = sql + " LIMIT ? OFFSET ?"; + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { int parameterIdx = 1; preparedStatement.setInt(parameterIdx++, tenantId); + for (Integer deviceId : deviceIds) { preparedStatement.setInt(parameterIdx++, deviceId); } + if (isOwnerProvided) { preparedStatement.setString(parameterIdx++, "%" + paginationRequest.getOwner() + "%"); } @@ -1923,6 +1933,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { preparedStatement.setInt(parameterIdx++, paginationRequest.getRowCount()); preparedStatement.setInt(parameterIdx, paginationRequest.getStartIndex()); + try(ResultSet resultSet = preparedStatement.executeQuery()) { Device device; while(resultSet.next()) { From 78cb44d70895089b7acc7bbccae8d43bae9faec6 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Tue, 23 Jul 2024 21:10:54 +0530 Subject: [PATCH 262/343] Update unsubscribed status check --- .../core/application/mgt/common/SubscriptionMetadata.java | 1 + .../DeviceBasedSubscriptionManagementHelperServiceImpl.java | 2 +- .../GroupBasedSubscriptionManagementHelperServiceImpl.java | 6 +++--- .../RoleBasedSubscriptionManagementHelperServiceImpl.java | 6 +++--- .../UserBasedSubscriptionManagementHelperServiceImpl.java | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java index 9e9a87d9a1..8c149bf872 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; public class SubscriptionMetadata { + public static final String SUBSCRIPTION_STATUS_UNSUBSCRIBED = "unsubscribed"; public static final class DeviceSubscriptionStatus { public static final String NEW = "NEW"; public static final String PENDING = "PENDING"; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java index e3c7396bb5..88e78e82cd 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/DeviceBasedSubscriptionManagementHelperServiceImpl.java @@ -60,7 +60,7 @@ public class DeviceBasedSubscriptionManagementHelperServiceImpl implements Subsc @Override public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException { - final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus()); List deviceSubscriptionDTOS; int deviceCount = 0; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java index 9f7f9db78f..16834bf2a1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java @@ -66,7 +66,7 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException { - final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus()); List deviceSubscriptionDTOS; int deviceCount = 0; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); @@ -152,7 +152,7 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr @Override public SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException { - final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus()); final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { ConnectionManagerUtil.openDBConnection(); @@ -181,7 +181,7 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr @Override public SubscriptionStatistics getSubscriptionStatistics(SubscriptionInfo subscriptionInfo) throws ApplicationManagementException { - final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus()); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { ConnectionManagerUtil.openDBConnection(); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java index 93e6ebc46a..b667198fd5 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java @@ -69,7 +69,7 @@ public class RoleBasedSubscriptionManagementHelperServiceImpl implements Subscri @Override public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException { - final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus()); List deviceSubscriptionDTOS; int deviceCount = 0; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); @@ -146,7 +146,7 @@ public class RoleBasedSubscriptionManagementHelperServiceImpl implements Subscri @Override public SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException { - final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus()); final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { ConnectionManagerUtil.openDBConnection(); @@ -174,7 +174,7 @@ public class RoleBasedSubscriptionManagementHelperServiceImpl implements Subscri @Override public SubscriptionStatistics getSubscriptionStatistics(SubscriptionInfo subscriptionInfo) throws ApplicationManagementException { - final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus()); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { ConnectionManagerUtil.openDBConnection(); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java index a12560146d..b8978b1c7a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java @@ -66,7 +66,7 @@ public class UserBasedSubscriptionManagementHelperServiceImpl implements Subscri @Override public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException { - final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus()); List deviceSubscriptionDTOS; int deviceCount = 0; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); @@ -137,7 +137,7 @@ public class UserBasedSubscriptionManagementHelperServiceImpl implements Subscri @Override public SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException { - final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus()); final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { ConnectionManagerUtil.openDBConnection(); @@ -165,7 +165,7 @@ public class UserBasedSubscriptionManagementHelperServiceImpl implements Subscri @Override public SubscriptionStatistics getSubscriptionStatistics(SubscriptionInfo subscriptionInfo) throws ApplicationManagementException { - final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus()); + final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus()); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { ConnectionManagerUtil.openDBConnection(); From 0deebf09d8040bf553535027229be6b603763811 Mon Sep 17 00:00:00 2001 From: Jenkins Date: Tue, 23 Jul 2024 22:30:27 +0530 Subject: [PATCH 263/343] [maven-release-plugin] prepare release v5.2.1 --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.common/pom.xml | 2 +- .../cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml | 2 +- components/cea-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/cea-mgt-feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 146 files changed, 148 insertions(+), 148 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index bb84f55812..519e6b11ed 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index d2fce540f1..92e920b9ac 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index d2f75adc1c..52eb2fe98e 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index e172ba30c9..30bea52746 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 9d8d7f5128..f40d6bda28 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../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 2076a5b8f9..28359eaca1 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 io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 6b31c913a7..210f36faa5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 1dd558542e..e8f8611f57 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 972ddc0e4e..08348ad3ea 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml 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 a837bcb046..7213fe90e5 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 io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 27c3fa7204..3c2187ee62 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index a4b5545299..21c23f35d8 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index e4bc150299..b3ee016db6 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 522625062c..0db11153ee 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index c2ebb66863..13327e9dd0 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index df9d9fc578..a45c3a7ef1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index fcaf2a292d..2eaec72b12 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index b256793a45..8f6a17f781 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index dea23471d7..1aed387b66 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index bef1902ec3..a58fa0d25a 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index f12e4616d2..2a7b8faae6 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index 136bb3c064..cb4a8dfec3 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 24ecc877ae..62824e57ed 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 22345f280f..4dad0a6a32 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 8e5615c3ca..b4240b2d68 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 6281d5be61..744723920c 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index ff12f5c484..1c825d88e9 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index 949abeae97..0cc15b9760 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index fc3fb174d6..fe83532744 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index e135e39924..a241c020a4 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index a71754725d..cc870c372e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 9ab4fc60a2..31d7aa610d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 001da8a15a..b1ad50cb29 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index ae85054204..2ec0e556fc 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 1ec47c569f..ca525f5d15 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 929bb75db9..48836549a3 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index d5b532b59b..aec0d46c64 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 430f3e1673..d229bddedb 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index c453c91ccd..23231dcf97 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 4c4a9049fa..f9b75d20ad 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index 4fc7f685a4..b79ce91ca6 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 9bc24cefdf..9c178c8e0b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index e9936a2841..ea44fe9d2b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index a2588f584d..c04abe81b1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index fe99f19899..ad9ef5b128 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 1e36bb556e..365de37467 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 32fe9e8614..9603073261 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 4d9c218b14..565d5694a7 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 0cd9dd8f9b..9c2494aba2 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index efd2da7f1d..10746732d8 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index bf14726b0d..7f5be8f373 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index a23770f1c3..599735597b 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.2.1-SNAPSHOT + 5.2.1 io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 8c72f7b67c..43220bb01c 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index f122abe746..4e3914a7e5 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index b5f609af3c..b4f90a57ba 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 488588889b..da958c5cbf 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index e0f87cc5da..ac00b333d8 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 206bc81dfe..d22d483242 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 72ed377be7..93f97d0400 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index a6d83132c0..2f585b50da 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index f4a291430d..0d77a453d0 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 93d932ffd5..620b8a0c6c 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 4dcddb3f4d..57ca032c26 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index c7dea3252d..171607f1a9 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 72994dc58f..dd93995093 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 74669ea7ff..d4c39ff812 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index f1ef0a4c42..8ca77cd1c2 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 80868f4069..d3d9b06d1f 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index bf70de1620..fcfb20316c 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 605b8d0035..ca8eadadc1 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 9809326b59..e0af8fd197 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 96ffca0489..8ff9742a97 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 81dffe2443..3fde3916d9 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index e29e8c3274..97fdaaed6c 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 130552c8cb..3a759f12e5 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index ed1194b077..fd8c1212be 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index ae5d773ff3..dd65412cfd 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 681392afd7..1f08172091 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index ca7faa575c..1ddde138b7 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 802f76f4bc..f1cb3bf91e 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 04f0549344..d8fda2f5d8 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 0a0cd44132..aa31958e80 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 8cea3b9b89..4b2375e96e 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index b368938fcd..6b1187b571 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index c1295a1fc9..bd3fcf9a09 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 99c71ee31d..ec67591b3d 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../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 8e29fa4084..8ffb75c4d9 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index a21c8b970d..b3a25e1346 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index b2b4679369..2d135e3414 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 6ae536013b..70e199cdf7 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 3a9883e5c9..e75847cb83 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index c57281853b..fcbe99cd38 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 66a84acf72..54231bf4c7 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 7cb9b51ab0..df6f7333cf 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index 71711748f1..6edd882ea5 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index c27fc3727a..11b4f3b20d 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index e653594725..c91ab08766 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index ce8533f710..c5022eeeb7 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index a639649a4b..54c29b9799 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 7c937f3db9..f9ecf2bce0 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 0404cc3c5c..d1bc8b00be 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index ec881c0238..2d36e0e817 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index b49fb03251..f0788a755a 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 4.0.0 diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index 6ed98297b5..5a41b6c695 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 78230e248c..ecf0539409 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 2df995c371..d6ba6dea27 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index db9c9257ac..0ead4830c4 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 02ac4c300d..f949be9254 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index b67d29c242..d9cd92381c 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 3fb3849902..225af505f8 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 097653eae6..856891b457 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index bb40a31aa9..d4e6631a3f 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 277aff34f0..744537bb17 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 5b47a25b85..6005475522 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 933da87343..33d4d4018b 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 6d95834e22..c4f3a45b8e 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 800e4f44fe..e869f494de 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index e16f1b723b..65cdcacd8f 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 306c966ccc..ad1e8561bc 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 47a111a987..12c67d4cb4 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 03b81d7a05..04f1098f12 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 5bd102c0e8..144e4f4dfd 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 6aa152b878..ff4b247ce5 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 9eb6f40dee..de057d5ab1 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index 30bc3656a2..379bafb5cd 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index e500a961a0..777bf99003 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index b051642b15..2c84a6dc62 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index fc519d08be..25635d7940 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 6ecb1d6e89..2ab11695d3 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 7cd15c6f29..1034425530 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 3f2761de13..ad85432446 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index ab54daebdd..8427251e82 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 79421326e8..11561a479b 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 5af3ace1d6..5028d10ab5 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 9f31cdf3bb..2265883624 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index b28e4250d3..20c80bd907 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 3f53d62438..122f12b433 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index e214bf2074..080a072628 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index cd18d91382..8d4813b235 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 464e3c8ecb..83fccc5ee1 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 8c6c403359..d5c467cdaf 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 2ac85ad511..8c5ddaa168 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 16fc3fa962..63676a4166 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index e74282a52b..1cf4f3ee79 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.2.1-SNAPSHOT + 5.2.1 ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 1dac00220f..24c3196fa6 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1-SNAPSHOT + 5.2.1 ../../pom.xml diff --git a/pom.xml b/pom.xml index e1e29b20b2..e575f1d7d8 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.2.1-SNAPSHOT + 5.2.1 WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1967,7 +1967,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.2.1 @@ -2172,7 +2172,7 @@ 1.2.11.wso2v10 - 5.2.1-SNAPSHOT + 5.2.1 4.7.35 From b1ff511d4cd740c76b569856169cd75507b9ede6 Mon Sep 17 00:00:00 2001 From: Jenkins Date: Tue, 23 Jul 2024 22:30:33 +0530 Subject: [PATCH 264/343] [maven-release-plugin] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.common/pom.xml | 2 +- .../cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml | 2 +- components/cea-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/cea-mgt-feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 146 files changed, 148 insertions(+), 148 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 519e6b11ed..e265b984aa 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 92e920b9ac..7e15bc9588 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 52eb2fe98e..f27a3e0af7 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 30bea52746..51748537a2 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index f40d6bda28..c9ceb488f5 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-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 28359eaca1..f8f9ad5589 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 io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 210f36faa5..93514d2640 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index e8f8611f57..56b0bf126e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 08348ad3ea..4f1356380b 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml 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 7213fe90e5..c66e6f8273 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 io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 3c2187ee62..14d64c688c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 21c23f35d8..8333a8d26e 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index b3ee016db6..a187e48e61 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 0db11153ee..cc3d962066 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 13327e9dd0..5bf3a90ba7 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index a45c3a7ef1..07583ae5f1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 2eaec72b12..fd733a845c 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index 8f6a17f781..19439ed450 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index 1aed387b66..6fe6a36bb4 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index a58fa0d25a..67474a23bf 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index 2a7b8faae6..9ce63869fc 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index cb4a8dfec3..d18861e766 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 62824e57ed..81c1f85d9a 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 4dad0a6a32..21d9035cc9 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index b4240b2d68..8c3d9e54a6 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 744723920c..c9bc5124a5 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 1c825d88e9..278fedff4c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index 0cc15b9760..0f27364cfb 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index fe83532744..833f71ae69 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index a241c020a4..a61e9ff2a1 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index cc870c372e..8149055675 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 31d7aa610d..ee732d54f9 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index b1ad50cb29..89c8fdad66 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 2ec0e556fc..fa1cfce4ec 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index ca525f5d15..33c6ad8249 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 48836549a3..02b440f97f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index aec0d46c64..f0fdb6d83e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index d229bddedb..1dbabfd9e4 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 23231dcf97..173620adcf 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index f9b75d20ad..9d1b959351 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index b79ce91ca6..6bf84ad89b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 9c178c8e0b..c62c53057b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index ea44fe9d2b..b1a9c25d95 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index c04abe81b1..4df9530fa8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index ad9ef5b128..a3347b4c15 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 365de37467..8e7bc0dffb 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 9603073261..2d2a7d20c7 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 565d5694a7..7b28a4c0db 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 9c2494aba2..d6cb52e2e0 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 10746732d8..670a0e3968 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 7f5be8f373..5d7a3cd603 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 599735597b..f20834bb96 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.2.1 + 5.2.2-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 43220bb01c..5b53cbd756 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 4e3914a7e5..7dff4e5ff7 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index b4f90a57ba..8840da3e8c 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index da958c5cbf..34601ff5eb 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index ac00b333d8..14cc447f79 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index d22d483242..4847ad6817 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 93f97d0400..819b1e20cf 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 2f585b50da..282e6eabc8 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 0d77a453d0..e17d9e966b 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 620b8a0c6c..d55353a083 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 57ca032c26..af53b43282 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 171607f1a9..75b07968ea 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index dd93995093..dbb3dbad7c 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index d4c39ff812..4635ec1713 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 8ca77cd1c2..0043b3f62f 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index d3d9b06d1f..646247afe0 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index fcfb20316c..e99a323f18 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index ca8eadadc1..2dd0066ad6 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index e0af8fd197..524c62aff4 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 8ff9742a97..711a0ca001 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 3fde3916d9..8638000de6 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 97fdaaed6c..bcc8787240 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 3a759f12e5..d5a4652fa9 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index fd8c1212be..540782bd1b 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index dd65412cfd..81da24c01e 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 1f08172091..fb96e6dd9c 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 1ddde138b7..fd1652c0d7 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index f1cb3bf91e..b306aeda7a 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index d8fda2f5d8..db518238da 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index aa31958e80..6b81bbf585 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 4b2375e96e..bf757e2131 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 6b1187b571..c2b449612f 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index bd3fcf9a09..37db2ac4b8 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index ec67591b3d..6974aec4b1 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-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 8ffb75c4d9..0d4735fe95 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index b3a25e1346..d519348a3e 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 2d135e3414..cb8e6f79f4 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 70e199cdf7..22f6dfde06 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index e75847cb83..19ff681993 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index fcbe99cd38..5351205649 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 54231bf4c7..2c78ab5a56 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index df6f7333cf..f8fb0aefde 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index 6edd882ea5..eee0887c97 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index 11b4f3b20d..a7755d3c59 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index c91ab08766..29e0350a12 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index c5022eeeb7..11673e0c00 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 54c29b9799..78ddcb529e 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index f9ecf2bce0..6cfa70c7c8 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index d1bc8b00be..c8d73649fb 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 2d36e0e817..4bbe9ef194 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index f0788a755a..a3fedf6abd 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT 4.0.0 diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index 5a41b6c695..0a5a981cb5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index ecf0539409..31c22107e9 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index d6ba6dea27..3e9aa3c421 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 0ead4830c4..64acba1565 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index f949be9254..e0e2d76b4f 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index d9cd92381c..1c68de5514 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 225af505f8..1b31773bed 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 856891b457..215e95a4ca 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index d4e6631a3f..f1e27a195c 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 744537bb17..a16a087881 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 6005475522..237860bf1c 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 33d4d4018b..148d7ab7b7 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index c4f3a45b8e..10a7c7accc 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index e869f494de..42a67be8c5 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 65cdcacd8f..1ce5c48def 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index ad1e8561bc..0cb7283f56 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 12c67d4cb4..df53241e93 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 04f1098f12..b593bc1d85 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 144e4f4dfd..8d5aa6e8ca 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index ff4b247ce5..521946f740 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index de057d5ab1..1e0eab4a6e 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index 379bafb5cd..9d17aeb8b4 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 777bf99003..6dae6727e1 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 2c84a6dc62..bec217a93c 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 25635d7940..73c59417ea 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 2ab11695d3..c9ee1ebf49 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 1034425530..75fa5247d1 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index ad85432446..65d74a06d3 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 8427251e82..14591df22a 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 11561a479b..1b0c4f6408 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 5028d10ab5..625cab197b 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 2265883624..07e2d1696b 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 20c80bd907..836d152831 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 122f12b433..7d6da25a26 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index 080a072628..5354e5bc1f 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 8d4813b235..eb43851323 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 83fccc5ee1..d603b36050 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index d5c467cdaf..00e240f402 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 8c5ddaa168..eb0c991a53 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 63676a4166..616d2a8b38 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index 1cf4f3ee79..b723ceaca4 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.2.1 + 5.2.2-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 24c3196fa6..f06467351b 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.1 + 5.2.2-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index e575f1d7d8..a837d17c06 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.2.1 + 5.2.2-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1967,7 +1967,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.2.1 + HEAD @@ -2172,7 +2172,7 @@ 1.2.11.wso2v10 - 5.2.1 + 5.2.2-SNAPSHOT 4.7.35 From d2d341963d490541790fe4133b9db65d9c09c866 Mon Sep 17 00:00:00 2001 From: "osh.silva" Date: Wed, 24 Jul 2024 13:05:41 +0530 Subject: [PATCH 265/343] Fix search issues --- .../application/mgt/common/SubscriptionMetadata.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java index 8c149bf872..bd487dfea4 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/SubscriptionMetadata.java @@ -35,7 +35,7 @@ public class SubscriptionMetadata { public static final String INVALID = "INVALID"; public static final String UNAUTHORIZED = "UNAUTHORIZED"; public static final String IN_PROGRESS = "IN_PROGRESS"; - public static final String REPEAT = "REPEAT"; + public static final String REPEATED = "REPEATED"; } public static final class SubscriptionTypes { @@ -51,7 +51,7 @@ public class SubscriptionMetadata { public static final List ERROR_STATUS_LIST = Arrays.asList(DeviceSubscriptionStatus.ERROR, DeviceSubscriptionStatus.INVALID, DeviceSubscriptionStatus.UNAUTHORIZED); public static final List PENDING_STATUS_LIST = - Arrays.asList(DeviceSubscriptionStatus.PENDING, DeviceSubscriptionStatus.IN_PROGRESS, DeviceSubscriptionStatus.REPEAT); + Arrays.asList(DeviceSubscriptionStatus.PENDING, DeviceSubscriptionStatus.IN_PROGRESS, DeviceSubscriptionStatus.REPEATED); } public static Map> deviceSubscriptionStatusToDBSubscriptionStatusMap; @@ -59,11 +59,11 @@ public class SubscriptionMetadata { Map> statusMap = new HashMap<>(); statusMap.put(DeviceSubscriptionStatus.COMPLETED, DBSubscriptionStatus.COMPLETED_STATUS_LIST); statusMap.put(DeviceSubscriptionStatus.PENDING, DBSubscriptionStatus.PENDING_STATUS_LIST); - statusMap.put(DeviceSubscriptionStatus.IN_PROGRESS, DBSubscriptionStatus.PENDING_STATUS_LIST); - statusMap.put(DeviceSubscriptionStatus.REPEAT, DBSubscriptionStatus.PENDING_STATUS_LIST); + statusMap.put(DeviceSubscriptionStatus.IN_PROGRESS, Collections.singletonList(DeviceSubscriptionStatus.IN_PROGRESS)); + statusMap.put(DeviceSubscriptionStatus.REPEATED, Collections.singletonList(DeviceSubscriptionStatus.REPEATED)); statusMap.put(DeviceSubscriptionStatus.ERROR, DBSubscriptionStatus.ERROR_STATUS_LIST); - statusMap.put(DeviceSubscriptionStatus.INVALID, DBSubscriptionStatus.ERROR_STATUS_LIST); - statusMap.put(DeviceSubscriptionStatus.UNAUTHORIZED, DBSubscriptionStatus.ERROR_STATUS_LIST); + statusMap.put(DeviceSubscriptionStatus.INVALID,Collections.singletonList(DeviceSubscriptionStatus.INVALID)); + statusMap.put(DeviceSubscriptionStatus.UNAUTHORIZED,Collections.singletonList(DeviceSubscriptionStatus.UNAUTHORIZED)); deviceSubscriptionStatusToDBSubscriptionStatusMap = Collections.unmodifiableMap(statusMap); } } From 8a2425508976e47eeaf65b7dd19ba2927f302c39 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Wed, 24 Jul 2024 00:53:57 +0530 Subject: [PATCH 266/343] Fix device count issues in subscription view --- .../GenericSubscriptionDAOImpl.java | 68 +++++++++++++++---- .../core/device/mgt/core/dao/DeviceDAO.java | 10 +++ .../core/dao/impl/AbstractDeviceDAOImpl.java | 36 ++++++++++ .../DeviceManagementProviderService.java | 8 +++ .../DeviceManagementProviderServiceImpl.java | 24 +++++++ 5 files changed, 132 insertions(+), 14 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index c459acd7ad..c80e10d064 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -25,7 +25,11 @@ import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; import io.entgra.device.mgt.core.application.mgt.core.util.DAOUtil; +import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity; +import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; @@ -2399,23 +2403,41 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public int getAllSubscriptionCount(int appReleaseId, int tenantId) - throws ApplicationManagementDAOException { + public int getAllSubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Getting all subscriptions count for the application appReleaseId " + appReleaseId - + " from the database"); + log.debug("Getting all subscriptions count for the application appReleaseId " + appReleaseId + " from the database"); } + List allowingDeviceStatuses = new ArrayList<>(); + allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.INACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); + + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); try { Connection conn = this.getDBConnection(); + List deviceIds = deviceManagementProviderService.getDeviceIdsByStatus(allowingDeviceStatuses); + if (deviceIds.isEmpty()) { + return 0; + } + StringBuilder idList = new StringBuilder(); + for (int i = 0; i < deviceIds.size(); i++) { + idList.append("?"); + if (i < deviceIds.size() - 1) { + idList.append(","); + } + } String sql = "SELECT COUNT(*) AS count " + "FROM AP_DEVICE_SUBSCRIPTION " + "WHERE AP_APP_RELEASE_ID = ? " + "AND TENANT_ID = ? " + - "AND UNSUBSCRIBED = FALSE"; - + "AND UNSUBSCRIBED = FALSE " + + "AND DM_DEVICE_ID IN (" + idList.toString() + ")"; try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); + for (int i = 0; i < deviceIds.size(); i++) { + ps.setInt(3 + i, deviceIds.get(i)); + } try (ResultSet rs = ps.executeQuery()) { if (rs.next()) { @@ -2429,7 +2451,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } - } catch (DBConnectionException e) { + } catch (DBConnectionException | DeviceManagementException e) { String msg = "Error occurred while obtaining the DB connection for getting all subscriptions count for appReleaseId: " + appReleaseId + "."; log.error(msg, e); @@ -2438,23 +2460,41 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public int getAllUnsubscriptionCount(int appReleaseId, int tenantId) - throws ApplicationManagementDAOException { + public int getAllUnsubscriptionCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Getting all unsubscription count for the application appReleaseId " + appReleaseId - + " from the database"); + log.debug("Getting all unsubscription count for the application appReleaseId " + appReleaseId + " from the database"); } + List allowingDeviceStatuses = new ArrayList<>(); + allowingDeviceStatuses.add(EnrolmentInfo.Status.ACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.INACTIVE.toString()); + allowingDeviceStatuses.add(EnrolmentInfo.Status.UNREACHABLE.toString()); + + DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); try { Connection conn = this.getDBConnection(); + List deviceIds = deviceManagementProviderService.getDeviceIdsByStatus(allowingDeviceStatuses); + if (deviceIds.isEmpty()) { + return 0; + } + StringBuilder idList = new StringBuilder(); + for (int i = 0; i < deviceIds.size(); i++) { + idList.append("?"); + if (i < deviceIds.size() - 1) { + idList.append(","); + } + } String sql = "SELECT COUNT(*) AS count " + "FROM AP_DEVICE_SUBSCRIPTION " + "WHERE AP_APP_RELEASE_ID = ? " + "AND TENANT_ID = ? " + - "AND UNSUBSCRIBED = TRUE"; - + "AND UNSUBSCRIBED = TRUE " + + "AND DM_DEVICE_ID IN (" + idList.toString() + ")"; try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); + for (int i = 0; i < deviceIds.size(); i++) { + ps.setInt(3 + i, deviceIds.get(i)); + } try (ResultSet rs = ps.executeQuery()) { if (rs.next()) { @@ -2468,7 +2508,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } - } catch (DBConnectionException e) { + } catch (DBConnectionException | DeviceManagementException e) { String msg = "Error occurred while obtaining the DB connection for getting all unsubscription count for appReleaseId: " + appReleaseId + "."; log.error(msg, e); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java index 606a1eab5c..5189068242 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceDAO.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.dao; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import org.apache.commons.collections.map.SingletonMap; import io.entgra.device.mgt.core.device.mgt.common.*; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo.Status; @@ -879,4 +880,13 @@ public interface DeviceDAO { int getDeviceCountByDeviceIds(PaginationRequest paginationRequest, List deviceIds, int tenantId) throws DeviceManagementDAOException; + + /** + * This method is used to get device count that are not within a specific group. + * + * @param statuses Device statuses to be filtered + * @return deviceIds + * @throws DeviceManagementException + */ + List getDeviceIdsByStatus(List statuses) throws DeviceManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index bb0bb97b62..3b8aa18647 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import org.apache.commons.collections.map.SingletonMap; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.LogFactory; @@ -3484,4 +3485,39 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } } + @Override + public List getDeviceIdsByStatus(List statuses) throws DeviceManagementException { + StringBuilder deviceFilters = new StringBuilder(); + for (int i = 0; i < statuses.size(); i++) { + deviceFilters.append("?"); + if (i < statuses.size() - 1) { + deviceFilters.append(","); + } + } + + try { + Connection conn = getConnection(); + String sql = "SELECT DEVICE_ID " + + "FROM DM_ENROLMENT " + + "WHERE STATUS IN (" + deviceFilters.toString() + ")"; + + try (PreparedStatement ps = conn.prepareStatement(sql)) { + for (int i = 0; i < statuses.size(); i++) { + ps.setString(i + 1, statuses.get(i)); + } + + try (ResultSet rs = ps.executeQuery()) { + List deviceIds = new ArrayList<>(); + while (rs.next()) { + deviceIds.add(rs.getInt("DEVICE_ID")); + } + return deviceIds; + } + } + } catch (SQLException e) { + String msg = "Error occurred while running SQL to get device IDs by status."; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index 56f95d3f44..682e4e5aac 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -1163,4 +1163,12 @@ public interface DeviceManagementProviderService { throws DeviceManagementException; int getDeviceCountByDeviceIds(PaginationRequest paginationRequest, List deviceIds) throws DeviceManagementException; + + /** + * This method is to get Device ids by statuses + * @param statuses statuses to be filtered. + * @return deviceIds + * @throws DeviceManagementException if any service level or DAO level error occurs. + */ + List getDeviceIdsByStatus(List statuses) throws DeviceManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 341714dd10..851153de16 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -5706,4 +5706,28 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.closeConnection(); } } + + @Override + public List getDeviceIdsByStatus(List statuses) throws DeviceManagementException { + if (statuses == null || statuses.isEmpty()) { + String msg = "Received null or empty list for statuses"; + log.error(msg); + throw new DeviceManagementException(msg); + } + + try { + DeviceManagementDAOFactory.openConnection(); + return deviceDAO.getDeviceIdsByStatus(statuses); + } catch (DeviceManagementException e) { + String msg = "Error encountered while getting device IDs for statuses: " + statuses; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error encountered while getting the database connection"; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } } From 41985cc3472dda40261c8c3b56adc3f89f40a8b3 Mon Sep 17 00:00:00 2001 From: Jenkins Date: Wed, 24 Jul 2024 21:34:10 +0530 Subject: [PATCH 267/343] [maven-release-plugin] prepare release v5.2.2 --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.common/pom.xml | 2 +- .../cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml | 2 +- components/cea-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/cea-mgt-feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 146 files changed, 148 insertions(+), 148 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index e265b984aa..f7118e9141 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 7e15bc9588..5549e4c443 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index f27a3e0af7..729d4de141 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 51748537a2..ebb44b0475 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index c9ceb488f5..b4a175bc52 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../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 f8f9ad5589..15f0ae16ca 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 io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 93514d2640..a381eba298 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 56b0bf126e..cdd63394ab 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 4f1356380b..745f3252bb 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml 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 c66e6f8273..d85ae35dc8 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 io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 14d64c688c..3d99104db4 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 8333a8d26e..a1f1b4e80f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index a187e48e61..ceeb1f0690 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index cc3d962066..f7863c876d 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 5bf3a90ba7..c446235439 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 07583ae5f1..b9d1ced3aa 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index fd733a845c..bbc77864b0 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index 19439ed450..cf6917682e 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index 6fe6a36bb4..c639b14012 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index 67474a23bf..6521d58763 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index 9ce63869fc..a1683f8332 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index d18861e766..65c2ce4ad1 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 81c1f85d9a..fc640ca62e 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 21d9035cc9..ba86fada46 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 8c3d9e54a6..df43d1f57c 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index c9bc5124a5..16a4a6affa 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 278fedff4c..2d748cf579 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index 0f27364cfb..d097e2567b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index 833f71ae69..9c8f987e81 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index a61e9ff2a1..4a1ded6fc8 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index 8149055675..4a8d0a1388 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index ee732d54f9..a9e7dd1c49 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 89c8fdad66..961b6adf78 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index fa1cfce4ec..c7da0007e4 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 33c6ad8249..5ca8249756 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 02b440f97f..f14e9b624c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index f0fdb6d83e..5f1677cf8f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 1dbabfd9e4..1205e0867b 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 173620adcf..018c67fb8d 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 9d1b959351..93d12b7d12 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index 6bf84ad89b..d46f7eed2b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index c62c53057b..66bdc5d445 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index b1a9c25d95..fe83928d2b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 4df9530fa8..0a27095547 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index a3347b4c15..96ec651e5b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 8e7bc0dffb..77a05f697a 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 2d2a7d20c7..274e16e381 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 7b28a4c0db..edbdcb9905 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index d6cb52e2e0..15328e61e8 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 670a0e3968..1c33dbc51e 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 5d7a3cd603..559462ff93 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index f20834bb96..82821e66fb 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.2.2-SNAPSHOT + 5.2.2 io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 5b53cbd756..7a4025e7b9 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 7dff4e5ff7..2fa65565bb 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 8840da3e8c..31edd644c4 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 34601ff5eb..a0378c06bf 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 14cc447f79..bbc5c2c37b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 4847ad6817..4971acb3fd 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 819b1e20cf..c354d377a5 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 282e6eabc8..278293a853 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index e17d9e966b..db0780b9b2 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index d55353a083..2dcb83d378 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index af53b43282..d8f1f88c5a 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 75b07968ea..62146f5a05 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index dbb3dbad7c..8f6ee96357 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 4635ec1713..4c8e78bf4e 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 0043b3f62f..b4898d9222 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 646247afe0..9a7e8e49f1 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index e99a323f18..1ce0650f8f 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 2dd0066ad6..33fb0c8ecd 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 524c62aff4..ae004b2d99 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 711a0ca001..97203a5803 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 8638000de6..ee167867e9 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index bcc8787240..2b9306b242 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index d5a4652fa9..18f676fae7 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 540782bd1b..a7c18878cc 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 81da24c01e..9cdbc48978 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index fb96e6dd9c..d6c8e8c1a2 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index fd1652c0d7..dead19987f 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index b306aeda7a..94e11188c1 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index db518238da..0be8860082 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 6b81bbf585..d7efa5c3c5 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index bf757e2131..a921d4aabd 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index c2b449612f..7d3f3ebd5c 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 37db2ac4b8..b88dbb8965 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 6974aec4b1..6029c402f3 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../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 0d4735fe95..b6a5121d9c 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index d519348a3e..74748a884a 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index cb8e6f79f4..2e94f65678 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 22f6dfde06..cbaddcecc3 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 19ff681993..d21704ccb6 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 5351205649..5e99821528 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 2c78ab5a56..43752fa3ca 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index f8fb0aefde..5c5ec02a00 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index eee0887c97..9bfc3abade 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index a7755d3c59..fb5e3fed92 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index 29e0350a12..e351dfd3a0 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index 11673e0c00..981ccfc5e1 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 78ddcb529e..3157a8b5b1 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 6cfa70c7c8..58b84091bd 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index c8d73649fb..a47c0c5b2c 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 4bbe9ef194..8fa91147af 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index a3fedf6abd..dab4c6cb6c 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 4.0.0 diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index 0a5a981cb5..690ef4abc9 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 31c22107e9..251f4a1a0c 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 3e9aa3c421..6ccf7af5ee 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 64acba1565..7c57e60390 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index e0e2d76b4f..605bc620d2 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 1c68de5514..f7b786e1d8 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 1b31773bed..c2e2a8e477 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 215e95a4ca..f88d2ae8b4 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index f1e27a195c..51ea87f926 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index a16a087881..89175eaaa6 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 237860bf1c..d285e99f09 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 148d7ab7b7..2c9cd7721c 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 10a7c7accc..f52e1ca59a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 42a67be8c5..985e46b1bd 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index 1ce5c48def..f47697e06a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 0cb7283f56..784b268b29 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index df53241e93..106308c5f7 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index b593bc1d85..abd2f962ce 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 8d5aa6e8ca..99b7c62218 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 521946f740..73c33c14ae 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 1e0eab4a6e..1aace0ee4d 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index 9d17aeb8b4..f272ba214c 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 6dae6727e1..7f96be0b5e 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index bec217a93c..7f2b688829 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 73c59417ea..9447cb44df 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index c9ee1ebf49..4015577a12 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 75fa5247d1..1efe3c113e 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 65d74a06d3..67595d2c5d 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 14591df22a..b9ed4951c4 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 1b0c4f6408..64696bedac 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 625cab197b..4642e30ea2 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 07e2d1696b..74a80c503d 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 836d152831..48ecd50d58 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 7d6da25a26..b7c1073e89 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index 5354e5bc1f..af1a7c10d0 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index eb43851323..362e241e79 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index d603b36050..11dfa5e3f1 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 00e240f402..b27313a3b4 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index eb0c991a53..63ed41da99 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 616d2a8b38..b2bbfac783 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index b723ceaca4..442d5d7eeb 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.2.2-SNAPSHOT + 5.2.2 ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index f06467351b..07f6f5b4ca 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2-SNAPSHOT + 5.2.2 ../../pom.xml diff --git a/pom.xml b/pom.xml index a837d17c06..1b44ca5818 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.2.2-SNAPSHOT + 5.2.2 WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1967,7 +1967,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.2.2 @@ -2172,7 +2172,7 @@ 1.2.11.wso2v10 - 5.2.2-SNAPSHOT + 5.2.2 4.7.35 From 770575999e37139574ffc03029d83eae442791b5 Mon Sep 17 00:00:00 2001 From: Jenkins Date: Wed, 24 Jul 2024 21:34:16 +0530 Subject: [PATCH 268/343] [maven-release-plugin] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.common/pom.xml | 2 +- .../cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml | 2 +- components/cea-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/cea-mgt-feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 146 files changed, 148 insertions(+), 148 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index f7118e9141..c291e68cb0 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 5549e4c443..391473bd91 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 729d4de141..4e4d2f1e96 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index ebb44b0475..ace84b1225 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index b4a175bc52..a896674853 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-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 15f0ae16ca..4c461d8595 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 io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index a381eba298..992888fc78 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index cdd63394ab..a5a870c3ea 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 745f3252bb..fc5c665372 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml 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 d85ae35dc8..62e06956cd 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 io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 3d99104db4..65a7e379f5 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index a1f1b4e80f..e1beb0c18c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index ceeb1f0690..7f15b12c6a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index f7863c876d..dd9340f737 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index c446235439..0ec0661178 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index b9d1ced3aa..d43d4c8cc9 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index bbc77864b0..69a9c58eaf 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index cf6917682e..1b3bc6c3b1 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index c639b14012..9427c4089c 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index 6521d58763..573e2a276b 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index a1683f8332..d2b2af0e45 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index 65c2ce4ad1..7a2c06efde 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index fc640ca62e..6d1bf2ded1 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index ba86fada46..eadf3e7ecf 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index df43d1f57c..b1e28eabf9 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 16a4a6affa..3865e86027 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 2d748cf579..4e8300a2b2 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index d097e2567b..4d4b56e7bb 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index 9c8f987e81..08e356a70e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 4a1ded6fc8..c12b8258b3 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index 4a8d0a1388..8a9935294c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index a9e7dd1c49..8dcb41ae17 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 961b6adf78..9ee9f0f9aa 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index c7da0007e4..1861e3a4a8 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 5ca8249756..8e4cc77571 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index f14e9b624c..023bdbb85c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index 5f1677cf8f..5bc752d1e5 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 1205e0867b..07880a7fa5 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 018c67fb8d..3422145c48 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 93d12b7d12..71d5c6f430 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index d46f7eed2b..a10bb9cc9f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 66bdc5d445..385d500784 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index fe83928d2b..5a25641806 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 0a27095547..9d29c42eaf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 96ec651e5b..a99251274b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 77a05f697a..7cb2ede47f 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 274e16e381..6cdcf2d543 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index edbdcb9905..01a0ee5d65 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 15328e61e8..46f56d0f20 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 1c33dbc51e..a134592b01 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 559462ff93..ecf541919c 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 82821e66fb..88e687cf03 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.2.2 + 5.2.3-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 7a4025e7b9..6f126e4b71 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 2fa65565bb..7a0ae726ff 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 31edd644c4..055d44f341 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index a0378c06bf..c2c51b50d6 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index bbc5c2c37b..f66e33ab0c 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 4971acb3fd..9bb22649ba 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index c354d377a5..dfd34033fd 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 278293a853..ab64d91778 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index db0780b9b2..a8eb6487d9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 2dcb83d378..488b472a4b 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index d8f1f88c5a..6123822aab 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 62146f5a05..a6554b675c 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index 8f6ee96357..a2c0b1345f 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 4c8e78bf4e..1efcd22f91 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index b4898d9222..0c18e804e1 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index 9a7e8e49f1..c6aa1e4282 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 1ce0650f8f..37bad8d14a 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 33fb0c8ecd..0a94955827 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index ae004b2d99..5708dfbf2c 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 97203a5803..8c302c7aef 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index ee167867e9..ad6bf47fcf 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 2b9306b242..a4c253f085 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 18f676fae7..fd6fb1ff73 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index a7c18878cc..aa2ef9bb2e 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 9cdbc48978..4c78bc5aa9 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index d6c8e8c1a2..4102dd606a 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index dead19987f..873441a332 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 94e11188c1..76e034107b 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 0be8860082..300fad6171 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index d7efa5c3c5..3c98920031 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index a921d4aabd..c71dc8cf4e 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 7d3f3ebd5c..71accbcc49 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index b88dbb8965..1887029e19 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 6029c402f3..bedf567bd1 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-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 b6a5121d9c..4afc960e83 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index 74748a884a..df1d3bf662 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 2e94f65678..2cd416ae64 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index cbaddcecc3..3aba6bb602 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index d21704ccb6..191c5ae4f3 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 5e99821528..ac96d72e72 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 43752fa3ca..f502e8f65e 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 5c5ec02a00..d7cb956bd2 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index 9bfc3abade..2ef4b7ae60 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index fb5e3fed92..44c3b397a0 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index e351dfd3a0..47e4eabedc 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index 981ccfc5e1..dd2d8f4000 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 3157a8b5b1..49d2f5ca49 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 58b84091bd..788bb09986 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index a47c0c5b2c..1a2f6ae43a 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 8fa91147af..77b43f4a89 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index dab4c6cb6c..6388412196 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT 4.0.0 diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index 690ef4abc9..fd71111d13 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 251f4a1a0c..4a2db5b8be 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 6ccf7af5ee..2429aa054b 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 7c57e60390..24920377e9 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 605bc620d2..0fe1e9a10c 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index f7b786e1d8..f7c0a6b83f 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index c2e2a8e477..1145da7b57 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index f88d2ae8b4..4a03c8818e 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 51ea87f926..f4c58d310e 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 89175eaaa6..5e2afb66f0 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index d285e99f09..b6c6a1bdf1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 2c9cd7721c..2961642ee6 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index f52e1ca59a..0e4026cee3 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 985e46b1bd..65050c5715 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index f47697e06a..bc820315e3 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 784b268b29..da9e460af8 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 106308c5f7..77955d52be 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index abd2f962ce..5e207874eb 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 99b7c62218..d1dcc21b1e 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 73c33c14ae..689da65854 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 1aace0ee4d..87738d46fd 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index f272ba214c..003e6601d6 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 7f96be0b5e..9680f3acba 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 7f2b688829..cb06306dff 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 9447cb44df..8dddd09761 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 4015577a12..b36d6eac00 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 1efe3c113e..e3f5c05415 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 67595d2c5d..adacd6c89a 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index b9ed4951c4..be27a8cc0c 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 64696bedac..390b783992 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 4642e30ea2..6c640e34d5 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 74a80c503d..2743ed3b12 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 48ecd50d58..05fb087d3a 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index b7c1073e89..725624a49c 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index af1a7c10d0..d150739ba2 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 362e241e79..14d0673a79 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 11dfa5e3f1..315823f793 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index b27313a3b4..10e6536b82 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 63ed41da99..0ff62106a3 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index b2bbfac783..04b8604e63 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index 442d5d7eeb..5d9a01d5e2 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.2.2 + 5.2.3-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 07f6f5b4ca..5a80a54e72 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.2 + 5.2.3-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 1b44ca5818..eb8cf25a33 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.2.2 + 5.2.3-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1967,7 +1967,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.2.2 + HEAD @@ -2172,7 +2172,7 @@ 1.2.11.wso2v10 - 5.2.2 + 5.2.3-SNAPSHOT 4.7.35 From 5f94113adfbe6179c2d05a9279c868a51a1e2d22 Mon Sep 17 00:00:00 2001 From: builder Date: Thu, 25 Jul 2024 16:34:01 +0530 Subject: [PATCH 269/343] [maven-release-plugin] prepare release v5.2.3 --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.common/pom.xml | 2 +- .../cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml | 2 +- components/cea-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/cea-mgt-feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 146 files changed, 148 insertions(+), 148 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index c291e68cb0..3dcde558b6 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index 391473bd91..c02a64c0c1 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 4e4d2f1e96..8969cdb2f7 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index ace84b1225..62b93d1004 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index a896674853..7ca55bc8fc 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../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 4c461d8595..f0ed95d992 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 io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 992888fc78..333c44bc67 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index a5a870c3ea..8dd54b668d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index fc5c665372..b11cd17df0 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml 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 62e06956cd..1777c105f3 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 io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 65a7e379f5..38a6e5f71d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index e1beb0c18c..13ed88f134 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 7f15b12c6a..5127162efc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index dd9340f737..0361b5fd9a 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 0ec0661178..d31f51e59d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index d43d4c8cc9..1ed0f9c066 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 69a9c58eaf..cccab97975 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index 1b3bc6c3b1..a701df42df 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index 9427c4089c..d03d46c592 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index 573e2a276b..6ee97c6d64 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index d2b2af0e45..b8c78dd8de 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index 7a2c06efde..64b74f35ed 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index 6d1bf2ded1..ca5699c6ee 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index eadf3e7ecf..4109177f1f 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index b1e28eabf9..76fb3e1559 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 3865e86027..5bc203aa64 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 4e8300a2b2..dd70b8b14c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index 4d4b56e7bb..398ce02c19 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index 08e356a70e..d6adbe1d74 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index c12b8258b3..43ab92ccb5 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index 8a9935294c..a479dfe121 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 8dcb41ae17..ec9f5803f7 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 9ee9f0f9aa..1b66885832 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 1861e3a4a8..3f4c3cf092 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 8e4cc77571..b8fd017f97 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 023bdbb85c..c9590e1c28 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index 5bc752d1e5..cf04ebb17d 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 07880a7fa5..9802483a45 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 3422145c48..c8ce51635e 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 71d5c6f430..9f4468dae4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index a10bb9cc9f..eaac1f700a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 385d500784..7a38130252 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 5a25641806..78b45a2483 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 9d29c42eaf..1015a06427 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index a99251274b..f26f769b49 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 7cb2ede47f..e015fe067d 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 6cdcf2d543..ccf36d8b8d 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 01a0ee5d65..8b27ce7f82 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index 46f56d0f20..df29b3720f 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index a134592b01..82dd871fc4 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index ecf541919c..fa6afa19d4 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 88e687cf03..d41e1d4747 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.2.3-SNAPSHOT + 5.2.3 io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 6f126e4b71..b3ceff1d47 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 7a0ae726ff..d187d5c07d 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 055d44f341..b6a56f0945 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index c2c51b50d6..7e8a328993 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index f66e33ab0c..e3f59665fd 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 9bb22649ba..2521a86dc4 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index dfd34033fd..6d5d45f22d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index ab64d91778..e85b8c2138 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index a8eb6487d9..878744f0f0 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 488b472a4b..367fe85ada 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index 6123822aab..eb55ca6ae2 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index a6554b675c..0c49e35a5b 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index a2c0b1345f..cfff3bf0be 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 1efcd22f91..c6613402d7 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 0c18e804e1..264a3b681c 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index c6aa1e4282..ecb9532d57 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 37bad8d14a..f1dccf08e7 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 0a94955827..b3c124b952 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 5708dfbf2c..9f6bfb3b26 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 8c302c7aef..fb28b62eac 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index ad6bf47fcf..8d97e2c782 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index a4c253f085..8c9b5fa3ba 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index fd6fb1ff73..d3b8947aae 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index aa2ef9bb2e..8ac982f030 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 4c78bc5aa9..1f2fd6ec07 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 4102dd606a..c89dc66c98 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 873441a332..58e25bc1f7 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 76e034107b..aa4326a363 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index 300fad6171..d59052e50c 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 3c98920031..5ee4e8c415 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index c71dc8cf4e..08d45ed43a 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 71accbcc49..bbe6fe6c21 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 1887029e19..569c60acad 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index bedf567bd1..3e072ff8ca 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../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 4afc960e83..d331215a1d 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index df1d3bf662..e5fe27d4be 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 2cd416ae64..4ac3eb9c31 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 3aba6bb602..85afacc2f5 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 191c5ae4f3..727d2e2782 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index ac96d72e72..2e5ea2bd34 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index f502e8f65e..9fd5da2a11 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index d7cb956bd2..adb196b51d 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index 2ef4b7ae60..4971166f0e 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index 44c3b397a0..2f1baf892f 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index 47e4eabedc..3e8a3afb57 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index dd2d8f4000..afea8c9d88 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 49d2f5ca49..4c6b61f2b0 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 788bb09986..8629ecdeb8 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 1a2f6ae43a..15c630ae28 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 77b43f4a89..76ecfa9fda 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index 6388412196..3b761e9961 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 4.0.0 diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index fd71111d13..d9fcd30d60 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 4a2db5b8be..7bf9bdbe00 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 2429aa054b..03216ebdaf 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 24920377e9..c42a86daf4 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 0fe1e9a10c..a54f1418db 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index f7c0a6b83f..40b2e2c590 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 1145da7b57..26e0a4e8b8 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 4a03c8818e..e5a366bab5 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index f4c58d310e..4891089bda 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 5e2afb66f0..aed0244dec 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index b6c6a1bdf1..cb905652ee 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 2961642ee6..97e853c398 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 0e4026cee3..5a01a4e86a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 65050c5715..306b3f8ba1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index bc820315e3..d3982f09a1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index da9e460af8..dfd41b7f1d 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 77955d52be..53a94cb5a4 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 5e207874eb..805d615022 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index d1dcc21b1e..4f9cb14947 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 689da65854..b55550fc84 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 87738d46fd..6950408557 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index 003e6601d6..8eca6f64bd 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 9680f3acba..955ff69ccd 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index cb06306dff..00721babc7 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 8dddd09761..5ae310a564 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index b36d6eac00..1e8e8bcddc 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index e3f5c05415..7240800e2d 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index adacd6c89a..2c66750770 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index be27a8cc0c..55db379a9a 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 390b783992..18713a3b4b 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 6c640e34d5..21773048e1 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 2743ed3b12..2df611a49d 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 05fb087d3a..d3c711b796 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 725624a49c..6a8118cefe 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index d150739ba2..dac2fb2f7d 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 14d0673a79..69705dcd6a 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 315823f793..94988695c8 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 10e6536b82..00968b768d 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 0ff62106a3..5fd4e4140a 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 04b8604e63..43eef1e614 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index 5d9a01d5e2..1faccc735f 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.2.3-SNAPSHOT + 5.2.3 ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 5a80a54e72..9f750dd658 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3-SNAPSHOT + 5.2.3 ../../pom.xml diff --git a/pom.xml b/pom.xml index eb8cf25a33..ce010e9f53 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.2.3-SNAPSHOT + 5.2.3 WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1967,7 +1967,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.2.3 @@ -2172,7 +2172,7 @@ 1.2.11.wso2v10 - 5.2.3-SNAPSHOT + 5.2.3 4.7.35 From fa24f95a693b3d22e92e87b3e0ec62247de20e68 Mon Sep 17 00:00:00 2001 From: builder Date: Thu, 25 Jul 2024 16:34:08 +0530 Subject: [PATCH 270/343] [maven-release-plugin] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.apimgt.annotations/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.application.mgt.core/pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.common/pom.xml | 2 +- .../cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml | 2 +- components/cea-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.api/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.certificate.mgt.core/pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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.device.mgt.core.device.mgt.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.config.api/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.core/pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.extensions/pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../io.entgra.device.mgt.core.notification.logger/pom.xml | 2 +- components/logger/pom.xml | 2 +- .../io.entgra.device.mgt.core.operation.template/pom.xml | 2 +- components/operation-template-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.decision.point/pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt/pom.xml | 2 +- components/subtype-mgt/pom.xml | 2 +- components/task-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.core/pom.xml | 2 +- components/task-mgt/task-manager/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.watcher/pom.xml | 2 +- components/task-mgt/task-watcher/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.common/pom.xml | 2 +- .../io.entgra.device.mgt.core.tenant.mgt.core/pom.xml | 2 +- components/tenant-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/cea-mgt-feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../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 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../io.entgra.device.mgt.core.device.mgt.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/logger/pom.xml | 2 +- .../pom.xml | 2 +- features/operation-template-mgt-plugin-feature/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml | 2 +- features/subtype-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.task.mgt.feature/pom.xml | 2 +- features/task-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/tenant-mgt/pom.xml | 2 +- .../io.entgra.device.mgt.core.email.sender.feature/pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- features/webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 6 +++--- 146 files changed, 148 insertions(+), 148 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 3dcde558b6..5bbb149f5a 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index c02a64c0c1..fe168409c7 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 8969cdb2f7..e1d23b0dd4 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 62b93d1004..456834371f 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 7ca55bc8fc..7de259bada 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-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 f0ed95d992..0644c29899 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 io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 333c44bc67..5386164088 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 8dd54b668d..0431e96880 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index b11cd17df0..b0af3744db 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml 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 1777c105f3..ef2bb81d86 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 io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 38a6e5f71d..ebc4285259 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 13ed88f134..1b31e53d33 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 5127162efc..1f8b3b7809 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 0361b5fd9a..a95c177917 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index d31f51e59d..81c0147a52 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 1ed0f9c066..e275391342 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index cccab97975..b130f15b05 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index a701df42df..7f89c759df 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index d03d46c592..dc4dd90442 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index 6ee97c6d64..84853ec469 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index b8c78dd8de..4521458fed 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index 64b74f35ed..78b391bd6b 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index ca5699c6ee..f4a992e2af 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 4109177f1f..d2cf1432e2 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index 76fb3e1559..5259d27170 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core certificate-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 5bc203aa64..6716687cc1 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index dd70b8b14c..0c52cb5756 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index 398ce02c19..be028cf924 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index d6adbe1d74..b5101280a2 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 43ab92ccb5..888c00a4d4 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index a479dfe121..700cca153c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,7 +21,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index ec9f5803f7..338198eab8 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 1b66885832..8453f05e9f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 3f4c3cf092..53d4fbab79 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index b8fd017f97..2b9a09a282 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index c9590e1c28..c0de48044f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index cf04ebb17d..27a70b464e 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 9802483a45..8cd558dda0 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index c8ce51635e..5e906f2c8e 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 9f4468dae4..a84a45a8d2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index eaac1f700a..98859c7087 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 7a38130252..05f6beeeba 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 78b45a2483..fdd6b0c25b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 1015a06427..cf44513980 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index f26f769b49..8dbc6d726e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index e015fe067d..baca16bf79 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index ccf36d8b8d..6316fff69a 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heartbeat-management - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 8b27ce7f82..7015a871d1 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index df29b3720f..4b46d40ee6 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 82dd871fc4..47b4616212 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core identity-extensions - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index fa6afa19d4..312b3ca244 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index d41e1d4747..ee50ab3265 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger - 5.2.3 + 5.2.4-SNAPSHOT io.entgra.device.mgt.core.notification.logger diff --git a/components/logger/pom.xml b/components/logger/pom.xml index b3ceff1d47..ce94ed8c7d 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index d187d5c07d..ca39311fdb 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core operation-template-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index b6a56f0945..9672e9df32 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 7e8a328993..8eebe210c7 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index e3f59665fd..1c00d6dc5d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 2521a86dc4..4655687a6a 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 6d5d45f22d..cd41a8e17f 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index e85b8c2138..835a0be06a 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 878744f0f0..f6e0ffab5f 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core subtype-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index 367fe85ada..d67a6ffbd5 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index eb55ca6ae2..a6e832a947 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 0c49e35a5b..0be1640628 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,7 +20,7 @@ task-manager io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index cfff3bf0be..3a31447016 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-manager - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index c6613402d7..4169d327f4 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 264a3b681c..790af68e92 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-watcher - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index ecb9532d57..bf1051bfcc 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core task-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index f1dccf08e7..9757c254af 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index b3c124b952..ea496792f4 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,7 +20,7 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index 9f6bfb3b26..cec5e7f315 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -20,7 +20,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index fb28b62eac..197a91af5e 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 8d97e2c782..61f8223384 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 8c9b5fa3ba..f70c86664a 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index d3b8947aae..c95edb55d2 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 8ac982f030..e9eb7fa723 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 1f2fd6ec07..70246b370e 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index c89dc66c98..063ddaf4c8 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index 58e25bc1f7..4a0ea33801 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index aa4326a363..deafa3edd0 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index d59052e50c..e6de5b033c 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 5ee4e8c415..beddb000d8 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 08d45ed43a..06aa865282 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index bbe6fe6c21..31f79d9390 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 569c60acad..2699aa3c41 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 3e072ff8ca..e70f4c5593 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-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 d331215a1d..7aacadb4f7 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 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index e5fe27d4be..051a90fe56 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 4ac3eb9c31..50f93a4051 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index 85afacc2f5..4012b4f0ff 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 727d2e2782..1000bc6860 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 2e5ea2bd34..9933bee4ea 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 9fd5da2a11..3acec29245 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index adb196b51d..302bdfaab1 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index 4971166f0e..2b79de5c78 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index 2f1baf892f..dceaa6269d 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index 3e8a3afb57..1a34604d22 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index afea8c9d88..d75d0d6a4a 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index 4c6b61f2b0..cd735d49ba 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index 8629ecdeb8..d30ecdc964 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 15c630ae28..2605cb5307 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 76ecfa9fda..4803979259 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index 3b761e9961..c9be43a57e 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT 4.0.0 diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index d9fcd30d60..b07e877518 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index 7bf9bdbe00..a829c2ee38 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 03216ebdaf..74f0b590c6 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index c42a86daf4..1a5739468e 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index a54f1418db..cf0713ce5d 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 40b2e2c590..19c98ade1b 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 26e0a4e8b8..bec51304ac 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index e5a366bab5..05ef9d2518 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 4891089bda..5099df1347 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index aed0244dec..03b3cd5035 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index cb905652ee..9e037c35e4 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 97e853c398..88ddcf2365 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 5a01a4e86a..bc77ca025d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 306b3f8ba1..40624fbc02 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index d3982f09a1..fc36953c14 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index dfd41b7f1d..c640bb7a27 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index 53a94cb5a4..47250468b0 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core heart-beat-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 805d615022..36ced90a63 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 4f9cb14947..f2b38a0e9d 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core jwt-client-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index b55550fc84..d6e936796c 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index 6950408557..1e7e05c7bf 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core logger-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/logger/pom.xml b/features/logger/pom.xml index 8eca6f64bd..93bb6e79ad 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 955ff69ccd..26b6faa900 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index 00721babc7..a15e5ee1ac 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 5ae310a564..924db60119 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 1e8e8bcddc..12ad18c744 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index 7240800e2d..4e5ce66fa1 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../../pom.xml diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 2c66750770..580c256614 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index 55db379a9a..8175d327c9 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../../pom.xml diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index 18713a3b4b..c0ee005cf7 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 21773048e1..09d2641ba0 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,7 +20,7 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 2df611a49d..7e7c235776 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index d3c711b796..0e24480bec 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core email-sender-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index 6a8118cefe..1acff47254 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index dac2fb2f7d..f7907e59bb 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index 69705dcd6a..bf8a594c77 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 94988695c8..1dfeea33d9 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index 00968b768d..ec0afa72b5 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 5fd4e4140a..83c3643fa5 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 43eef1e614..6026538937 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index 1faccc735f..61403205d8 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.2.3 + 5.2.4-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 9f750dd658..e4238b6fd7 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.2.3 + 5.2.4-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index ce010e9f53..01ed367560 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent pom - 5.2.3 + 5.2.4-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -1967,7 +1967,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.2.3 + HEAD @@ -2172,7 +2172,7 @@ 1.2.11.wso2v10 - 5.2.3 + 5.2.4-SNAPSHOT 4.7.35 From 748c28d36898455d9f1e1afea5c8624ab809d041 Mon Sep 17 00:00:00 2001 From: "osh.silva" Date: Mon, 29 Jul 2024 16:21:01 +0530 Subject: [PATCH 271/343] Fix ambigous column error --- .../dao/impl/device/GenericDeviceDAOImpl.java | 20 +++++++++---------- .../DeviceManagementProviderServiceImpl.java | 2 -- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 5710e0181f..85b4b5553d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -225,11 +225,11 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { try { Connection conn = getConnection(); String sql = "SELECT d.ID AS DEVICE_ID, " + - "DEVICE_IDENTIFICATION, " + + "d.DEVICE_IDENTIFICATION, " + "DESCRIPTION, " + "NAME, " + "DATE_OF_ENROLMENT, " + - "LAST_UPDATED_TIMESTAMP, " + + "d.LAST_UPDATED_TIMESTAMP, " + "STATUS, " + "DATE_OF_LAST_UPDATE, " + "TIMESTAMPDIFF(DAY, ?, DATE_OF_ENROLMENT) as DAYS_SINCE_ENROLLED " + @@ -266,12 +266,12 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { try { conn = this.getConnection(); String sql = "select d.ID AS DEVICE_ID, " + - "DEVICE_IDENTIFICATION, " + + "d.DEVICE_IDENTIFICATION, " + "DESCRIPTION, " + "NAME, " + "DATE_OF_ENROLMENT, " + "DATE_OF_LAST_UPDATE, " + - "d1.LAST_UPDATED_TIMESTAMP, " + + "d.LAST_UPDATED_TIMESTAMP, " + "STATUS, " + "TIMESTAMPDIFF(DAY, DATE_OF_LAST_UPDATE, DATE_OF_ENROLMENT) AS DAYS_USED " + "from DM_DEVICE d, DM_ENROLMENT e " + @@ -311,11 +311,11 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { try { conn = this.getConnection(); String sql = "select d.ID AS DEVICE_ID, " + - "DEVICE_IDENTIFICATION, " + + "d.DEVICE_IDENTIFICATION, " + "DESCRIPTION, " + "NAME, " + "DATE_OF_ENROLMENT, " + - "LAST_UPDATED_TIMESTAMP, " + + "d.LAST_UPDATED_TIMESTAMP, " + "STATUS, " + "DATE_OF_LAST_UPDATE, " + "TIMESTAMPDIFF(DAY, ?, ?) as DAYS_SINCE_ENROLLED " + @@ -352,12 +352,12 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { try { conn = this.getConnection(); String sql = "select d.ID AS DEVICE_ID, " + - "DEVICE_IDENTIFICATION, " + + "d.DEVICE_IDENTIFICATION, " + "DESCRIPTION, " + "NAME, " + "DATE_OF_ENROLMENT, " + "DATE_OF_LAST_UPDATE, " + - "LAST_UPDATED_TIMESTAMP, " + + "d.LAST_UPDATED_TIMESTAMP, " + "STATUS, " + "TIMESTAMPDIFF(DAY, DATE_OF_LAST_UPDATE, ?) AS DAYS_USED " + "from DM_DEVICE d, DM_ENROLMENT e " + @@ -400,9 +400,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { conn = this.getConnection(); String sql = "SELECT " + "DM_DEVICE.ID AS DEVICE_ID, " + - "DEVICE_IDENTIFICATION, " + + "d.DEVICE_IDENTIFICATION, " + "DESCRIPTION, " + - "LAST_UPDATED_TIMESTAMP, " + + "d.LAST_UPDATED_TIMESTAMP, " + "DM_DEVICE.NAME AS DEVICE_NAME, " + "DEVICE_TYPE, " + "DM_ENROLMENT.ID AS ENROLMENT_ID, " + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 851153de16..918ffb062c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -2233,8 +2233,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv String msg = "Error occurred while opening a connection to the data source"; log.info(msg, e); throw new DeviceManagementException(msg, e); - } finally { - DeviceManagementDAOFactory.closeConnection(); } } From a472f73adc66ef675365ea38b537d71a73042c8d Mon Sep 17 00:00:00 2001 From: "osh.silva" Date: Mon, 29 Jul 2024 23:44:18 +0530 Subject: [PATCH 272/343] Fix status connection issue --- .../DeviceManagementProviderServiceImpl.java | 117 ++++++++---------- 1 file changed, 52 insertions(+), 65 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 918ffb062c..737a14177b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -1154,50 +1154,62 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv public double generateCost(List allDevices, Timestamp startDate, Timestamp endDate, Cost tenantCost, List deviceStatusNotAvailable, double totalCost) throws DeviceManagementException { List deviceStatus; - for (Device device : allDevices) { - long dateDiff = 0; - deviceStatus = getDeviceStatusHistoryInsideTransaction(device, null, endDate, true); - if (device.getEnrolmentInfo().getDateOfEnrolment() < startDate.getTime()) { - if (!deviceStatus.isEmpty() && (String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED") - || String.valueOf(deviceStatus.get(0).getStatus()).equals("DELETED"))) { - if (deviceStatus.get(0).getUpdateTime().getTime() >= startDate.getTime()) { - dateDiff = deviceStatus.get(0).getUpdateTime().getTime() - startDate.getTime(); + try { + DeviceManagementDAOFactory.getConnection(); + for (Device device : allDevices) { + long dateDiff = 0; + int tenantId = this.getTenantId(); + deviceStatus = deviceStatusDAO.getStatus(device.getId(), tenantId, null, endDate, true); + if (device.getEnrolmentInfo().getDateOfEnrolment() < startDate.getTime()) { + if (!deviceStatus.isEmpty() && (String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED") + || String.valueOf(deviceStatus.get(0).getStatus()).equals("DELETED"))) { + if (deviceStatus.get(0).getUpdateTime().getTime() >= startDate.getTime()) { + dateDiff = deviceStatus.get(0).getUpdateTime().getTime() - startDate.getTime(); + } + } else if (!deviceStatus.isEmpty() && (!String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED") + && !String.valueOf(deviceStatus.get(0).getStatus()).equals("DELETED"))) { + dateDiff = endDate.getTime() - startDate.getTime(); + } + } else { + if (!deviceStatus.isEmpty() && (String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED") + || String.valueOf(deviceStatus.get(0).getStatus()).equals("DELETED"))) { + if (deviceStatus.get(0).getUpdateTime().getTime() >= device.getEnrolmentInfo().getDateOfEnrolment()) { + dateDiff = deviceStatus.get(0).getUpdateTime().getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); + } + } else if (!deviceStatus.isEmpty() && (!String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED") + && !String.valueOf(deviceStatus.get(0).getStatus()).equals("DELETED"))) { + dateDiff = endDate.getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); } - } else if (!deviceStatus.isEmpty() && (!String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED") - && !String.valueOf(deviceStatus.get(0).getStatus()).equals("DELETED"))) { - dateDiff = endDate.getTime() - startDate.getTime(); } - } else { - if (!deviceStatus.isEmpty() && (String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED") - || String.valueOf(deviceStatus.get(0).getStatus()).equals("DELETED"))) { - if (deviceStatus.get(0).getUpdateTime().getTime() >= device.getEnrolmentInfo().getDateOfEnrolment()) { - dateDiff = deviceStatus.get(0).getUpdateTime().getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); - } - } else if (!deviceStatus.isEmpty() && (!String.valueOf(deviceStatus.get(0).getStatus()).equals("REMOVED") - && !String.valueOf(deviceStatus.get(0).getStatus()).equals("DELETED"))) { - dateDiff = endDate.getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); + + // Convert dateDiff to days as a decimal value + double dateDiffInDays = (double) dateDiff / (24 * 60 * 60 * 1000); + + if (dateDiffInDays % 1 >= 0.9) { + dateDiffInDays = Math.ceil(dateDiffInDays); + } + + long dateInDays = (long) dateDiffInDays; + double cost = 0; + if (tenantCost != null) { + cost = (tenantCost.getCost() / 365) * dateInDays; + } + totalCost += cost; + device.setCost(Math.round(cost * 100.0) / 100.0); + long totalDays = dateInDays + device.getDaysUsed(); + device.setDaysUsed((int) totalDays); + if (deviceStatus.isEmpty()) { + deviceStatusNotAvailable.add(device); } } - - // Convert dateDiff to days as a decimal value - double dateDiffInDays = (double) dateDiff / (24 * 60 * 60 * 1000); - - if (dateDiffInDays % 1 >= 0.9) { - dateDiffInDays = Math.ceil(dateDiffInDays); - } - - long dateInDays = (long) dateDiffInDays; - double cost = 0; - if (tenantCost != null) { - cost = (tenantCost.getCost() / 365) * dateInDays; - } - totalCost += cost; - device.setCost(Math.round(cost * 100.0) / 100.0); - long totalDays = dateInDays + device.getDaysUsed(); - device.setDaysUsed((int) totalDays); - if (deviceStatus.isEmpty()) { - deviceStatusNotAvailable.add(device); - } + } catch (DeviceManagementDAOException e) { + String msg = "Error occurred in retrieving status history for a device in billing."; + log.error(msg, e); + throw new DeviceManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while opening a connection to the data source"; + log.info(msg, e); + throw new DeviceManagementException(msg, e); } return totalCost; } @@ -2211,31 +2223,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } } - /* - This is just to avoid breaking the billing functionality as it required to call getDeviceStatusHistory method - without transaction handling. - */ - private List getDeviceStatusHistoryInsideTransaction( - Device device, Date fromDate, Date toDate, boolean billingStatus) - throws DeviceManagementException { - if (log.isDebugEnabled()) { - log.debug("get status history of device: " + device.getDeviceIdentifier()); - } - try { - DeviceManagementDAOFactory.getConnection(); - int tenantId = this.getTenantId(); - return deviceStatusDAO.getStatus(device.getId(), tenantId, fromDate, toDate, billingStatus); - } catch (DeviceManagementDAOException e) { - String msg = "Error occurred in retrieving status history for device :" + device.getDeviceIdentifier(); - log.error(msg, e); - throw new DeviceManagementException(msg, e); - } catch (SQLException e) { - String msg = "Error occurred while opening a connection to the data source"; - log.info(msg, e); - throw new DeviceManagementException(msg, e); - } - } - @Override public List getDeviceStatusHistory(Device device, Date fromDate, Date toDate, boolean billingStatus) throws DeviceManagementException { if (log.isDebugEnabled()) { From 56f864a3f5128f68b29154ed2efd6185fe0f51fd Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 31 Jul 2024 00:35:02 +0530 Subject: [PATCH 273/343] Fix server starting issue --- .../pom.xml | 1 + .../webapp/publisher/APIPublisherServiceImpl.java | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index d5663f5433..b211a15d26 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -180,6 +180,7 @@ io.entgra.device.mgt.core.apimgt.webapp.publisher.dto, io.entgra.device.mgt.core.apimgt.webapp.publisher.exception, io.entgra.device.mgt.core.device.mgt.common.exceptions, + io.entgra.device.mgt.core.device.mgt.common.permission.mgt, io.entgra.device.mgt.core.device.mgt.common.metadata.mgt, io.entgra.device.mgt.core.device.mgt.core.config, io.entgra.device.mgt.core.device.mgt.core.config.permission, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java index aebdde8967..c3e5a6bc54 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -68,8 +68,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 io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils; import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException; import java.io.BufferedReader; @@ -79,7 +77,15 @@ import java.io.IOException; import java.nio.file.DirectoryIteratorException; import java.nio.file.Files; import java.nio.file.Paths; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * This class represents the concrete implementation of the APIPublisherService that corresponds to providing all @@ -599,7 +605,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { // add permission if not exist try { PermissionUtils.putPermission(permission); - } catch(PermissionManagementException e) { + } catch (PermissionManagementException e) { log.error("Error when adding permission ", e); } } From e1594c00f12bbbaf34adb7ee22838f6817931e8f Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 31 Jul 2024 13:58:41 +0530 Subject: [PATCH 274/343] Improve tenant deleting logic --- .../common/services/ApplicationManager.java | 14 ++--- .../pom.xml | 11 ---- .../mgt/core/impl/ApplicationManagerImpl.java | 35 +++--------- ...ApplicationManagementServiceComponent.java | 22 -------- .../mgt/core/internal/DataHolder.java | 10 ---- .../admin/UserManagementAdminServiceImpl.java | 56 ++++++++++++------- .../DeviceManagementProviderService.java | 10 +++- .../DeviceManagementProviderServiceImpl.java | 28 +++++----- .../pom.xml | 5 ++ 9 files changed, 77 insertions(+), 114 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java index 2b30b85cf9..d40855db19 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java @@ -25,11 +25,9 @@ import io.entgra.device.mgt.core.application.mgt.common.response.Application; import io.entgra.device.mgt.core.application.mgt.common.response.ApplicationRelease; import io.entgra.device.mgt.core.application.mgt.common.response.Category; import io.entgra.device.mgt.core.application.mgt.common.response.Tag; -import io.entgra.device.mgt.core.application.mgt.common.wrapper.*; import io.entgra.device.mgt.core.device.mgt.common.Base64File; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact; import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger; @@ -549,18 +547,18 @@ public interface ApplicationManager { void deleteApplicationDataOfTenant(int tenantId) throws ApplicationManagementException; /** - * Delete all application related data of a tenant by tenant Domain + * Delete all application related data of a tenant by tenant Id * - * @param tenantDomain Domain of the Tenant + * @param tenantId Id of the Tenant * @throws ApplicationManagementException thrown if an error occurs when deleting data */ - void deleteApplicationDataByTenantDomain(String tenantDomain) throws ApplicationManagementException; + void deleteApplicationDataByTenantId(int tenantId) throws ApplicationManagementException; /** - * Delete all Application artifacts related to a tenant by Tenant Domain + * Delete all Application artifacts related to a tenant by Tenant Id * - * @param tenantDomain Domain of the Tenant + * @param tenantId Id of the Tenant * @throws ApplicationManagementException thrown if an error occurs when deleting app folders */ - void deleteApplicationArtifactsByTenantDomain(String tenantDomain) throws ApplicationManagementException; + void deleteApplicationArtifactsByTenantId(int tenantId) throws ApplicationManagementException; } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 1944506e53..171fa4557d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -99,7 +99,6 @@ io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)", io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="[5.0,6)", io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="[5.0,6)", - io.entgra.device.mgt.core.tenant.mgt.common.*;version="[5.0,6)", javax.annotation;version="[1.0,2)", javax.naming, javax.sql, @@ -439,16 +438,6 @@ okio ${okio.version} - - org.wso2.carbon.multitenancy - org.wso2.carbon.tenant.mgt - compile - - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.tenant.mgt.common - provided - org.wso2.orbit.javax.xml.bind jaxb-api diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index fc90d59035..29d7d84ae5 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -82,7 +82,6 @@ import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import io.entgra.device.mgt.core.device.mgt.core.common.exception.StorageManagementException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringEscapeUtils; @@ -4439,13 +4438,9 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public void deleteApplicationDataByTenantDomain(String tenantDomain) throws ApplicationManagementException { - int tenantId; + public void deleteApplicationDataByTenantId(int tenantId) throws ApplicationManagementException { try { - tenantId = DataHolder.getInstance().getTenantManagerAdminService().getTenantId(tenantDomain); - ConnectionManagerUtil.beginDBTransaction(); - vppApplicationDAO.deleteAssociationByTenant(tenantId); vppApplicationDAO.deleteVppUserByTenant(tenantId); vppApplicationDAO.deleteAssetsByTenant(tenantId); @@ -4471,48 +4466,36 @@ public class ApplicationManagerImpl implements ApplicationManager { ConnectionManagerUtil.commitDBTransaction(); } catch (DBConnectionException e) { String msg = "Error occurred while observing the database connection to delete applications for tenant with " + - "domain: " + tenantDomain; + "tenant ID: " + tenantId; log.error(msg, e); throw new ApplicationManagementException(msg, e); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - String msg = "Database access error is occurred when getting applications for tenant with domain: " - + tenantDomain; + String msg = "Database access error is occurred when getting applications for tenant with tenant Id: " + + tenantId; log.error(msg, e); throw new ApplicationManagementException(msg, e); } catch (LifeCycleManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); String msg = "Error occurred while deleting life-cycle state data of application releases of the tenant" - + " of domain: " + tenantDomain ; + + " of id: " + tenantId ; log.error(msg, e); throw new ApplicationManagementException(msg, e); } catch (ReviewManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); String msg = "Error occurred while deleting reviews of application releases of the applications" - + " of tenant of domain: " + tenantDomain ; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (Exception e) { - String msg = "Error getting tenant ID from domain: " - + tenantDomain; + + " of tenant of id: " + tenantId ; log.error(msg, e); throw new ApplicationManagementException(msg, e); } } @Override - public void deleteApplicationArtifactsByTenantDomain(String tenantDomain) throws ApplicationManagementException { - int tenantId; + public void deleteApplicationArtifactsByTenantId(int tenantId) throws ApplicationManagementException { try { - tenantId = DataHolder.getInstance().getTenantManagerAdminService().getTenantId(tenantDomain); DataHolder.getInstance().getApplicationStorageManager().deleteAppFolderOfTenant(tenantId); - } catch (ApplicationStorageManagementException e) { - String msg = "Error deleting app artifacts of tenant of domain: " + tenantDomain ; - log.error(msg, e); - throw new ApplicationManagementException(msg, e); - } catch (TenantMgtException e) { - String msg = "Error getting tenant ID from domain: " - + tenantDomain + " when trying to delete application artifacts of tenant"; + } catch (ApplicationStorageManagementException e) { + String msg = "Error deleting app artifacts of tenant of Id: " + tenantId; log.error(msg, e); throw new ApplicationManagementException(msg, e); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java index cc042e6ecb..f3e6b56b50 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/ApplicationManagementServiceComponent.java @@ -34,7 +34,6 @@ import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateMa import io.entgra.device.mgt.core.application.mgt.core.task.ScheduledAppSubscriptionTaskManager; import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -203,25 +202,4 @@ public class ApplicationManagementServiceComponent { } DataHolder.getInstance().setTaskService(null); } - - @Reference( - name = "io.entgra.device.mgt.core.tenant.manager", - service = io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService.class, - cardinality = ReferenceCardinality.MANDATORY, - policy = ReferencePolicy.DYNAMIC, - unbind = "unsetTenantManagementAdminService") - protected void setTenantManagementAdminService(TenantManagerAdminService tenantManagerAdminService) { - if (log.isDebugEnabled()) { - log.debug("Setting Tenant management admin Service"); - } - DataHolder.getInstance().setTenantManagerAdminService(tenantManagerAdminService); - } - - @SuppressWarnings("unused") - protected void unsetTenantManagementAdminService(TenantManagerAdminService tenantManagerAdminService) { - if (log.isDebugEnabled()) { - log.debug("Un setting Tenant management admin service"); - } - DataHolder.getInstance().setTenantManagerAdminService(null); - } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java index df1eb4ee02..80416dcd59 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/internal/DataHolder.java @@ -27,7 +27,6 @@ import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionMan import io.entgra.device.mgt.core.application.mgt.common.services.VPPApplicationManager; import io.entgra.device.mgt.core.application.mgt.core.lifecycle.LifecycleStateManager; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; -import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.user.core.service.RealmService; @@ -58,7 +57,6 @@ public class DataHolder { private TaskService taskService; private FileTransferService fileTransferService; - private TenantManagerAdminService tenantManagerAdminService; private static final DataHolder applicationMgtDataHolder = new DataHolder(); @@ -165,12 +163,4 @@ public class DataHolder { public void setFileTransferService(FileTransferService fileTransferService) { this.fileTransferService = fileTransferService; } - - public TenantManagerAdminService getTenantManagerAdminService() { - return tenantManagerAdminService; - } - - public void setTenantManagerAdminService(TenantManagerAdminService tenantManagerAdminService) { - this.tenantManagerAdminService = tenantManagerAdminService; - } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java index 91ed3f6d42..858f31e66c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException; +import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; @@ -32,7 +33,13 @@ import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.CarbonContext; import javax.validation.constraints.Size; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -89,37 +96,46 @@ public class UserManagementAdminServiceImpl implements UserManagementAdminServic @DELETE @Path("/domain/{tenantDomain}") @Override - public Response deleteTenantByDomain(@PathParam("tenantDomain") String tenantDomain, @QueryParam("deleteAppArtifacts") boolean deleteAppArtifacts) { + public Response deleteTenantByDomain(@PathParam("tenantDomain") String tenantDomain, + @QueryParam("deleteAppArtifacts") boolean deleteAppArtifacts) { try { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - if (tenantId != MultitenantConstants.SUPER_TENANT_ID){ - String msg = "Only super tenants are allowed to delete tenants"; + if (CarbonContext.getThreadLocalCarbonContext().getTenantId() != MultitenantConstants.SUPER_TENANT_ID){ + String msg = "Only super tenants are allowed to delete tenants."; + log.error(msg); + return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build(); + } + if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { + String msg = "You are not allowed to delete the super tenant."; log.error(msg); return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build(); - } else { - if (deleteAppArtifacts) { - DeviceMgtAPIUtils.getApplicationManager().deleteApplicationArtifactsByTenantDomain(tenantDomain); - } - DeviceMgtAPIUtils.getApplicationManager().deleteApplicationDataByTenantDomain(tenantDomain); - DeviceMgtAPIUtils.getDeviceManagementService().deleteDeviceDataByTenantDomain(tenantDomain); - DeviceMgtAPIUtils.getTenantManagerAdminService().deleteTenant(tenantDomain); - String msg = "Tenant Deletion process has been initiated for tenant:" + tenantDomain; - if (log.isDebugEnabled()) { - log.debug(msg); - } - return Response.status(Response.Status.OK).entity(msg).build(); } + if (log.isDebugEnabled()) { + log.debug("Tenant Deletion process has been initiated for tenant:" + tenantDomain); + } + + TenantManagerAdminService tenantManagerAdminService = DeviceMgtAPIUtils.getTenantManagerAdminService(); + int tenantId = tenantManagerAdminService.getTenantId(tenantDomain); + + if (deleteAppArtifacts) { + DeviceMgtAPIUtils.getApplicationManager().deleteApplicationArtifactsByTenantId(tenantId); + } + DeviceMgtAPIUtils.getApplicationManager().deleteApplicationDataByTenantId(tenantId); + DeviceMgtAPIUtils.getDeviceManagementService().deleteDeviceDataByTenantId(tenantId); + DeviceMgtAPIUtils.getTenantManagerAdminService().deleteTenant(tenantDomain); + + return Response.status(Response.Status.OK).entity("Tenant Deletion process has been completed " + + "successfully for tenant: " + tenantDomain).build(); } catch (TenantMgtException e) { - String msg = "Error deleting tenant: " + tenantDomain; + String msg = "Error occurred while deleting tenant: " + tenantDomain; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (ApplicationManagementException e) { - String msg = "Error deleting application data of tenant: " + tenantDomain; + String msg = "Error occurred while deleting application data of tenant: " + tenantDomain; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (DeviceManagementException e) { - String msg = "Error deleting device data of tenant: " + tenantDomain; + String msg = "Error occurred while deleting device data of tenant: " + tenantDomain; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java index 53e8aa5796..ee8c5b5871 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java @@ -46,7 +46,6 @@ import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceStatus; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeVersion; -import org.apache.commons.collections.map.SingletonMap; import java.sql.SQLException; import java.sql.Timestamp; @@ -1067,7 +1066,14 @@ public interface DeviceManagementProviderService { List getInstalledApplicationsOnDevice(Device device) throws DeviceManagementException; List getEnrolledDevicesSince(Date since) throws DeviceManagementException; List getEnrolledDevicesPriorTo(Date before) throws DeviceManagementException; - void deleteDeviceDataByTenantDomain(String tenantDomain) throws DeviceManagementException; + + /** + * Delete all the device related data for a given Tenant by Tenant Id + * + * @param tenantId Id of the Tenant + * @throws DeviceManagementException if error occurs when deleting device data by using tenant Id + */ + void deleteDeviceDataByTenantId(int tenantId) throws DeviceManagementException; /** * Get owner details and device IDs for a given owner and tenant. diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 1ab272b43e..6184382668 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -165,7 +165,18 @@ import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; import java.time.LocalTime; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; import java.util.stream.Collectors; public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService, @@ -5272,20 +5283,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public void deleteDeviceDataByTenantDomain(String tenantDomain) throws DeviceManagementException { - int tenantId; - try{ - TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService(); - TenantInfoBean tenantInfoBean = tenantMgtAdminService.getTenant(tenantDomain); - tenantId = tenantInfoBean.getTenantId(); - - } catch (Exception e) { - String msg = "Error getting tenant ID from domain: " - + tenantDomain; - log.error(msg); - throw new DeviceManagementException(msg, e); - } - + public void deleteDeviceDataByTenantId(int tenantId) throws DeviceManagementException { try { DeviceManagementDAOFactory.beginTransaction(); diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index bef09da463..6347269f93 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -139,5 +139,10 @@ org.wso2.carbon org.wso2.carbon.utils + + org.wso2.carbon.multitenancy + org.wso2.carbon.tenant.mgt + provided + \ No newline at end of file From b284bf127675855e96b458bddee047dc4a305b1f Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 8 Aug 2024 20:44:53 +0530 Subject: [PATCH 275/343] Refactor source --- .../extension/api/KeyManagerServiceImpl.java | 1 - .../extension/service/KeyMgtServiceImpl.java | 57 ++++++++++--------- .../impl/DeviceManagementServiceImpl.java | 1 - 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java index 54cb0e98e1..573316be81 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java @@ -46,7 +46,6 @@ public class KeyManagerServiceImpl implements KeyManagerService { public Response dynamicClientRegistration(DCRRequest dcrRequest) { try { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); - //todo lasantha - can pass password from here - modify DCRRequest object DCRResponse resp = keyMgtService.dynamicClientRegistration(dcrRequest.getApplicationName(), dcrRequest.getUsername(), dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod(), dcrRequest.getPassword(), diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java index b6e1e70ca4..2752bfb4d1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/src/main/java/io/entgra/device/mgt/core/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java @@ -30,7 +30,13 @@ import io.entgra.device.mgt.core.apimgt.keymgt.extension.internal.KeyMgtDataHold import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; import io.entgra.device.mgt.core.device.mgt.core.config.keymanager.KeyManagerConfigurations; -import okhttp3.*; +import okhttp3.Credentials; +import okhttp3.FormBody; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONObject; @@ -51,7 +57,11 @@ import javax.net.ssl.X509TrustManager; import java.io.IOException; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; public class KeyMgtServiceImpl implements KeyMgtService { @@ -99,7 +109,6 @@ public class KeyMgtServiceImpl implements KeyMgtService { return new DCRResponse(dcrApplication.getClientId(), dcrApplication.getClientSecret()); } else { // super-tenant admin dcr and token generation - //todo lasantha null passed in last two params OAuthApplication superTenantOauthApp = createOauthApplication( KeyMgtConstants.RESERVED_OAUTH_APP_NAME_PREFIX + KeyMgtConstants.SUPER_TENANT, kmConfig.getAdminUsername(), null, validityPeriod, kmConfig.getAdminPassword(), null, null); @@ -124,17 +133,11 @@ public class KeyMgtServiceImpl implements KeyMgtService { createUserIfNotExists(subTenantUserUsername, subTenantUserPassword); // DCR for the requesting user - //todo lasantha -> need to pass password of user - //todo lasantha null passed in last two params - OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod, password, null, null); String requestingUserAccessToken = createAccessToken(dcrApplication); // get application id - //todo --> can use requestingUserAccessToken token here to get application data - modify getApplication - // method signature - io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application = getApplication(clientName, requestingUserAccessToken); String applicationUUID = application.getApplicationId(); @@ -237,16 +240,16 @@ public class KeyMgtServiceImpl implements KeyMgtService { } } catch (APIManagementException e) { msg = "Error occurred while retrieving application"; - log.error(msg); - throw new KeyMgtException(msg); + log.error(msg, e); + throw new KeyMgtException(msg, e); } catch (IOException e) { msg = "Error occurred while mapping application keys"; - log.error(msg); - throw new KeyMgtException(msg); + log.error(msg, e); + throw new KeyMgtException(msg, e); } catch (UserStoreException e) { msg = "Error occurred while fetching tenant id"; - log.error(msg); - throw new KeyMgtException(msg); + log.error(msg, e); + throw new KeyMgtException(msg, e); } } @@ -283,7 +286,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { client.newCall(request).execute(); } catch (IOException e) { msg = "Error occurred while mapping application keys"; - throw new KeyMgtException(msg); + log.error(msg, e); + throw new KeyMgtException(msg, e); } } @@ -309,8 +313,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { } } catch (UserStoreException e) { msg = "Error when trying to fetch tenant details"; - log.error(msg); - throw new KeyMgtException(msg); + log.error(msg, e); + throw new KeyMgtException(msg, e); } } @@ -325,7 +329,6 @@ public class KeyMgtServiceImpl implements KeyMgtService { private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags, int validityPeriod, String ownerPassword, List supportedGrantTypes, String callbackUrl) throws KeyMgtException { - //todo modify this to pass the password as well String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod, ownerPassword, supportedGrantTypes, callbackUrl); RequestBody oauthAppCreationPayload = RequestBody.Companion.create(oauthAppCreationPayloadStr, JSON); @@ -333,7 +336,6 @@ public class KeyMgtServiceImpl implements KeyMgtService { String dcrEndpoint = kmConfig.getServerUrl() + KeyMgtConstants.DCR_ENDPOINT; String username, password; - //todo why can't we use owner details here? if (KeyMgtConstants.SUPER_TENANT.equals(MultitenantUtils.getTenantDomain(owner))) { username = kmConfig.getAdminUsername(); password = kmConfig.getAdminPassword(); @@ -342,7 +344,6 @@ public class KeyMgtServiceImpl implements KeyMgtService { password = subTenantUserPassword; } - //todo why can't we use owner details for authentication Request request = new Request.Builder() .url(dcrEndpoint) .addHeader(KeyMgtConstants.AUTHORIZATION_HEADER, Credentials.basic(username, password)) @@ -352,8 +353,9 @@ public class KeyMgtServiceImpl implements KeyMgtService { Response response = client.newCall(request).execute(); return gson.fromJson(response.body().string(), OAuthApplication.class); } catch (IOException e) { - msg = "Error occurred while processing the response" + e; - throw new KeyMgtException(msg); + msg = "Error occurred while processing the response." ; + log.error(msg, e); + throw new KeyMgtException(msg, e); } } @@ -384,7 +386,8 @@ public class KeyMgtServiceImpl implements KeyMgtService { return jsonObject.getString("access_token"); } catch (IOException e) { msg = "Error occurred while reading access token from response"; - throw new KeyMgtException(msg); + log.error(msg, e); + throw new KeyMgtException(msg, e); } } @@ -456,15 +459,15 @@ public class KeyMgtServiceImpl implements KeyMgtService { } catch (io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.BadRequestException e) { msg = "Error while trying to retrieve the application"; log.error(msg, e); - throw new KeyMgtException(msg); + throw new KeyMgtException(msg, e); } catch (UnexpectedResponseException e) { msg = "Received invalid response for the API applications retrieving REST API call."; log.error(msg, e); - throw new KeyMgtException(msg); + throw new KeyMgtException(msg, e); } catch (APIServicesException e) { msg = "Error occurred while processing the API Response."; log.error(msg, e); - throw new KeyMgtException(msg); + throw new KeyMgtException(msg, e); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index bd614f5b1e..1d0b0994c9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -957,7 +957,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { KeyMgtService keyMgtService = new KeyMgtServiceImpl(); try { - //todo - lasantha - can't get password from here ApiApplicationKey apiApplicationKey; try { APIApplicationServices apiApplicationServices = DeviceMgtAPIUtils.getApiApplicationServices(); From 57e05b4ca9b656a2f8bfd48ec37c846b39326cc0 Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Fri, 9 Aug 2024 09:14:33 +0530 Subject: [PATCH 276/343] Add supported operations param to subtype --- .../core/subtype/mgt/dao/util/DAOUtil.java | 2 +- .../core/subtype/mgt/dto/DeviceSubType.java | 29 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java index f4569c6c36..3a1aa6fa67 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java @@ -72,7 +72,7 @@ public class DAOUtil { deviceSubType = loadDeviceSubType(rs); } if (operationCode != null) { - deviceSubType.addOperationCode(operationCode); + deviceSubType.addSupportedOperation(operationCode); } deviceSubTypes.put(key, deviceSubType); } diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java index cc27bb592e..e52ed3dbd0 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import java.util.HashSet; import java.util.Set; - public abstract class DeviceSubType { private String subTypeId; @@ -32,22 +31,22 @@ public abstract class DeviceSubType { private String deviceType; private String subTypeName; private String typeDefinition; - private Set operationCodes = new HashSet<>(); + private final Set supportedOperations = new HashSet<>(); + public DeviceSubType() { } - public DeviceSubType(String subTypeId, int tenantId, String deviceType, String subTypeName, String typeDefinition, - Set operationCodes) { + public DeviceSubType(String subTypeId, int tenantId, String deviceType, + String subTypeName, String typeDefinition, + Set supportedOperations) { this.subTypeId = subTypeId; this.tenantId = tenantId; this.deviceType = deviceType; this.subTypeName = subTypeName; this.typeDefinition = typeDefinition; - if (operationCodes != null || !operationCodes.isEmpty()) { - this.operationCodes.addAll(operationCodes); + if (supportedOperations != null && !supportedOperations.isEmpty()) { + this.supportedOperations.addAll(supportedOperations); } - - } public String getSubTypeId() { @@ -94,10 +93,16 @@ public abstract class DeviceSubType { public abstract String parseSubTypeToJson() throws JsonProcessingException; - public void addOperationCode(String code) { - operationCodes.add(code); + public void setSupportedOperations(Set supportedOperations) { + this.supportedOperations.addAll(supportedOperations); } - public Set getOperationCodes() { - return operationCodes; + + public void addSupportedOperation(String code) { + supportedOperations.add(code); } + + public Set getSupportedOperations() { + return supportedOperations; + } + } From 7f8f6d6f75598a99ab99c7f4a01ae75cbc1b771a Mon Sep 17 00:00:00 2001 From: Pahansith Date: Fri, 9 Aug 2024 09:32:15 +0530 Subject: [PATCH 277/343] Add FCM request improvements --- .../pom.xml | 4 ++ .../provider/fcm/FCMNotificationStrategy.java | 42 +++++++++---------- .../provider/fcm/util/FCMUtil.java | 22 ++++++++++ 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 8453f05e9f..a36ec650b6 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -151,6 +151,10 @@ org.wso2.carbon org.wso2.carbon.utils + + com.squareup.okhttp3 + okhttp + diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java index 39bd1ba7e5..66ee2ebb00 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java @@ -19,6 +19,9 @@ package io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provid import com.google.gson.JsonObject; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.util.FCMUtil; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.Device; @@ -89,8 +92,6 @@ public class FCMNotificationStrategy implements NotificationStrategy { */ private void sendWakeUpCall(String accessToken, String registrationId) throws IOException, PushNotificationExecutionFailedException { - HttpURLConnection conn = null; - String fcmServerEndpoint = FCMUtil.getInstance().getContextMetadataProperties() .getProperty(FCM_ENDPOINT_KEY); if(fcmServerEndpoint == null) { @@ -99,26 +100,21 @@ public class FCMNotificationStrategy implements NotificationStrategy { throw new PushNotificationExecutionFailedException(msg); } - try { - byte[] bytes = getFCMRequest(registrationId).getBytes(); - URL url = new URL(fcmServerEndpoint); - conn = (HttpURLConnection) url.openConnection(); - conn.setRequestProperty("Content-Type", "application/json"); - conn.setRequestProperty("Authorization", "Bearer " + accessToken); - conn.setRequestMethod("POST"); - conn.setDoOutput(true); - - try (OutputStream os = conn.getOutputStream()) { - os.write(bytes); + RequestBody fcmRequest = getFCMRequest(registrationId); + Request request = new Request.Builder() + .url(fcmServerEndpoint) + .post(fcmRequest) + .addHeader("Authorization", "Bearer " + accessToken) + .build(); + try (Response response = FCMUtil.getInstance().getHttpClient().newCall(request).execute()) { + if (log.isDebugEnabled()) { + log.debug("FCM message sent to the FCM server. Response code: " + response.code() + + " Response message : " + response.message()); } - - int status = conn.getResponseCode(); - if (status != 200) { - log.error("Response Status: " + status + ", Response Message: " + conn.getResponseMessage()); - } - } finally { - if (conn != null) { - conn.disconnect(); + if(!response.isSuccessful()) { + String msg = "Response Status: " + response.code() + ", Response Message: " + response.message(); + log.error(msg); + throw new IOException(msg); } } } @@ -128,14 +124,14 @@ public class FCMNotificationStrategy implements NotificationStrategy { * @param registrationId Registration ID of the device * @return FCM request as a JSON string */ - private static String getFCMRequest(String registrationId) { + private static RequestBody getFCMRequest(String registrationId) { JsonObject messageObject = new JsonObject(); messageObject.addProperty("token", registrationId); JsonObject fcmRequest = new JsonObject(); fcmRequest.add("message", messageObject); - return fcmRequest.toString(); + return RequestBody.create(fcmRequest.toString(), okhttp3.MediaType.parse("application/json")); } @Override diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java index 0c6c433cc7..e3d15d8974 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/push/notification/provider/fcm/util/FCMUtil.java @@ -22,6 +22,8 @@ import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManag import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.ContextMetadata; import io.entgra.device.mgt.core.device.mgt.core.config.push.notification.PushNotificationConfiguration; import io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.FCMNotificationStrategy; +import okhttp3.ConnectionPool; +import okhttp3.OkHttpClient; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.utils.CarbonUtils; @@ -33,6 +35,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.Properties; +import java.util.concurrent.TimeUnit; public class FCMUtil { @@ -43,10 +46,29 @@ public class FCMUtil { "repository" + File.separator + "resources" + File.separator + "service-account.json"; private static final String[] FCM_SCOPES = { "https://www.googleapis.com/auth/firebase.messaging" }; private Properties contextMetadataProperties; + private static ConnectionPool connectionPool; + private static OkHttpClient client; private FCMUtil() { initContextConfigs(); initDefaultOAuthApplication(); + initPooledConnection(); + } + + /** + * Initialize the connection pool for the OkHttpClient instance. + */ + private void initPooledConnection() { + connectionPool = new ConnectionPool(25, 1, TimeUnit.MINUTES); + client = new OkHttpClient.Builder().connectionPool(connectionPool).build(); + } + + /** + * Get the Pooled OkHttpClient instance + * @return OkHttpClient instance + */ + public OkHttpClient getHttpClient() { + return client; } private void initDefaultOAuthApplication() { From a4138b47789b02fa5f03ebb95aa91f46e2fe1df9 Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Mon, 12 Aug 2024 16:31:13 +0530 Subject: [PATCH 278/343] Fix inconsistencies with subtypes and operation templates --- .../impl/OperationTemplateServiceImpl.java | 20 +++++++++---------- .../template/ServiceNegativeTest.java | 2 +- ...der.java => DeviceSubTypeCacheLoader.java} | 6 +++--- .../mgt/dao/impl/DeviceSubTypeDAOImpl.java | 13 ++++++------ .../mgt/impl/DeviceSubTypeServiceImpl.java | 12 ++++++++--- 5 files changed, 30 insertions(+), 23 deletions(-) rename components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/{GetDeviceSubTypeCacheLoader.java => DeviceSubTypeCacheLoader.java} (93%) diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/impl/OperationTemplateServiceImpl.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/impl/OperationTemplateServiceImpl.java index 5bc0d1c238..5fdefcfd84 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/impl/OperationTemplateServiceImpl.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/main/java/io/entgra/device/mgt/core/operation/template/impl/OperationTemplateServiceImpl.java @@ -216,8 +216,8 @@ public class OperationTemplateServiceImpl implements OperationTemplateService { throws OperationTemplateMgtPluginException { AssertUtils.hasText(deviceType, "Invalid device type."); try { - ConnectionManagerUtils.openDBConnection(); - return operationTemplateDAO.getAllOperationTemplates(deviceType); + ConnectionManagerUtils.openDBConnection(); + return operationTemplateDAO.getAllOperationTemplates(deviceType); } catch (DBConnectionException | OperationTemplateManagementDAOException e) { log.error(e.getMessage()); throw new OperationTemplateMgtPluginException(e.getMessage(), e); @@ -273,11 +273,12 @@ public class OperationTemplateServiceImpl implements OperationTemplateService { */ @Override public Set getOperationTemplateCodes(String deviceType, String subTypeId) - throws OperationTemplateMgtPluginException { + throws OperationTemplateMgtPluginException { try { - AssertUtils.hasText(subTypeId, "Invalid meter device subtype id: " + subTypeId); - AssertUtils.isTrue(Integer.valueOf(subTypeId)>0, "Invalid meter device subtype id: " + subTypeId); + AssertUtils.hasText(subTypeId, "Invalid device subtype id: " + subTypeId); + AssertUtils.isTrue(Integer.parseInt(subTypeId) > 0, + "Invalid device subtype id: " + subTypeId); AssertUtils.hasText(deviceType, "Invalid device type."); String key = OperationTemplateManagementUtil.setOperationTemplateCacheKey(deviceType, subTypeId); @@ -294,7 +295,6 @@ public class OperationTemplateServiceImpl implements OperationTemplateService { } /** - * * @param subTypeId * @param deviceType * @param operationCode @@ -303,18 +303,18 @@ public class OperationTemplateServiceImpl implements OperationTemplateService { private void validateGetOperationTemplate(String subTypeId, String deviceType, String operationCode) throws OperationTemplateMgtPluginException { - AssertUtils.hasText(subTypeId, "Invalid meter device subtype id: " + subTypeId); - AssertUtils.isTrue(Integer.valueOf(subTypeId)>0, "Invalid meter device subtype id: " + subTypeId); + AssertUtils.hasText(subTypeId, "Invalid device subtype id: " + subTypeId); + AssertUtils.isTrue(Integer.parseInt(subTypeId) > 0, "Invalid device subtype id: " + subTypeId); AssertUtils.hasText(operationCode, "Validation failed due to invalid operation code: " + operationCode); AssertUtils.hasText(deviceType, "Invalid device type."); - AssertUtils.isTrue(deviceType.equals("METER"), "Invalid device type. "); } /** * @param operationTemplate * @throws OperationTemplateMgtPluginException */ - private void validateAddOperationTemplate(OperationTemplate operationTemplate) throws OperationTemplateMgtPluginException { + private void validateAddOperationTemplate(OperationTemplate operationTemplate) + throws OperationTemplateMgtPluginException { AssertUtils.isNull(operationTemplate, "Operation Template can not be null"); AssertUtils.hasText(operationTemplate.getOperationDefinition(), "Operation definition can not be null"); diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/ServiceNegativeTest.java b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/ServiceNegativeTest.java index 2c41d1ffc3..dbb7ecdbad 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/ServiceNegativeTest.java +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/java/io/entgra/device/mgt/core/operation/template/ServiceNegativeTest.java @@ -49,7 +49,7 @@ public class ServiceNegativeTest extends BaseOperationTemplatePluginTest { @Test(description = "This method tests Add Operation template under negative circumstances while missing " + "required fields", expectedExceptions = {OperationTemplateMgtPluginException.class}, - expectedExceptionsMessageRegExp = "Invalid meter device subtype id: 0") + expectedExceptionsMessageRegExp = "Invalid device subtype id: 0") public void testAddOperationTemplates() throws OperationTemplateMgtPluginException { OperationTemplate operationTemplate = new OperationTemplate(); diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/DeviceSubTypeCacheLoader.java similarity index 93% rename from components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java rename to components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/DeviceSubTypeCacheLoader.java index 7bf985e5b9..1ac3cd593f 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/DeviceSubTypeCacheLoader.java @@ -31,13 +31,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -public class GetDeviceSubTypeCacheLoader extends CacheLoader { +public class DeviceSubTypeCacheLoader extends CacheLoader { - private static final Log log = LogFactory.getLog(GetDeviceSubTypeCacheLoader.class); + private static final Log log = LogFactory.getLog(DeviceSubTypeCacheLoader.class); private final DeviceSubTypeDAO deviceSubTypeDAO; - public GetDeviceSubTypeCacheLoader() { + public DeviceSubTypeCacheLoader() { this.deviceSubTypeDAO = DeviceSubTypeDAOFactory.getDeviceSubTypeDAO(); } diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java index 6cc2c7cac7..f3aafa5d28 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java @@ -101,8 +101,9 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { public DeviceSubType getDeviceSubType(String subTypeId, int tenantId, String deviceType) throws SubTypeMgtDAOException { try { - String sql = "SELECT s.*, o.OPERATION_CODE FROM DM_DEVICE_SUB_TYPE s " + - "LEFT JOIN SUB_OPERATION_TEMPLATE o on s.SUB_TYPE_ID = o.SUB_TYPE_ID " + + String sql = "SELECT s.*, o.OPERATION_CODE FROM DM_DEVICE_SUB_TYPE s " + + "LEFT JOIN SUB_OPERATION_TEMPLATE o ON s.SUB_TYPE_ID = o.SUB_TYPE_ID " + + "AND s.DEVICE_TYPE = o.DEVICE_TYPE " + "WHERE s.SUB_TYPE_ID = ? AND s.TENANT_ID = ? AND s.DEVICE_TYPE = ?"; Connection conn = ConnectionManagerUtil.getDBConnection(); @@ -143,8 +144,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { stmt.setInt(1, tenantId); stmt.setString(2, deviceType); try (ResultSet rs = stmt.executeQuery()) { - List deviceSubTypes = DAOUtil.loadDeviceSubTypes(rs); - return deviceSubTypes; + return DAOUtil.loadDeviceSubTypes(rs); } } } catch (DBConnectionException e) { @@ -163,14 +163,14 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { @Override public int getDeviceSubTypeCount(String deviceType) throws SubTypeMgtDAOException { try { - String sql = "SELECT COUNT(*) as DEVICE_COUNT FROM DM_DEVICE_SUB_TYPE WHERE DEVICE_TYPE = ? "; + String sql = "SELECT COUNT(*) as SUB_TYPE_COUNT FROM DM_DEVICE_SUB_TYPE WHERE DEVICE_TYPE = ? "; Connection conn = ConnectionManagerUtil.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, deviceType); try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { - return rs.getInt("DEVICE_COUNT"); + return rs.getInt("SUB_TYPE_COUNT"); } return 0; } @@ -252,4 +252,5 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { throw new SubTypeMgtDAOException(msg, e); } } + } diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java index 4e5d855a23..1227f629fe 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java @@ -21,7 +21,7 @@ package io.entgra.device.mgt.core.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.core.subtype.mgt.cache.GetDeviceSubTypeCacheLoader; +import io.entgra.device.mgt.core.subtype.mgt.cache.DeviceSubTypeCacheLoader; import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubTypeCacheKey; import io.entgra.device.mgt.core.subtype.mgt.exception.BadRequestException; import io.entgra.device.mgt.core.subtype.mgt.exception.DBConnectionException; @@ -48,7 +48,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { private static final LoadingCache deviceSubTypeCache = CacheBuilder.newBuilder() .expireAfterWrite(15, TimeUnit.MINUTES) - .build(new GetDeviceSubTypeCacheLoader()); + .build(new DeviceSubTypeCacheLoader()); private final DeviceSubTypeDAO deviceSubTypeDAO; public DeviceSubTypeServiceImpl() { @@ -166,7 +166,13 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { throws SubTypeMgtPluginException { try { ConnectionManagerUtil.openDBConnection(); - return deviceSubTypeDAO.getAllDeviceSubTypes(tenantId, deviceType); + List subtypes = deviceSubTypeDAO.getAllDeviceSubTypes(tenantId, deviceType); + DeviceSubTypeCacheKey key; + for (DeviceSubType dst: subtypes) { + key = DeviceSubTypeMgtUtil.getDeviceSubTypeCacheKey(tenantId, dst.getSubTypeId(), deviceType); + deviceSubTypeCache.put(key, dst); + } + return subtypes; } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the database connection to retrieve all device subtype for " + deviceType + " subtypes"; From e384adc6570c0d7fae7a41e05879dbbe9ff18122 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Mon, 12 Aug 2024 17:50:45 +0530 Subject: [PATCH 279/343] Fix default scopes not updating issue --- .../publisher/APIPublisherStartupHandler.java | 50 +++++++++++++++++++ .../APIPublisherLifecycleListener.java | 12 +---- .../core/internal/TenantCreateObserver.java | 35 ------------- 3 files changed, 51 insertions(+), 46 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java index e039259b92..d218238dc1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -18,12 +18,24 @@ package io.entgra.device.mgt.core.apimgt.webapp.publisher; +import com.google.gson.Gson; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; +import io.entgra.device.mgt.core.device.mgt.core.config.permission.DefaultPermission; +import io.entgra.device.mgt.core.device.mgt.core.config.permission.DefaultPermissions; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.apimgt.webapp.publisher.exception.APIManagerPublisherException; import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import org.wso2.carbon.core.ServerStartupObserver; +import java.util.HashMap; +import java.util.Map; import java.util.Stack; public class APIPublisherStartupHandler implements ServerStartupObserver { @@ -34,6 +46,7 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { private static final int MAX_RETRY_COUNT = 5; private static Stack failedAPIsStack = new Stack<>(); private static Stack currentAPIsStack; + private static final Gson gson = new Gson(); private APIPublisherService publisher; @@ -91,6 +104,8 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { log.error("failed to update scope role mapping.", e); } + updateScopeMetadataEntryWithDefaultScopes(); + // execute after api publishing for (PostApiPublishingObsever observer : APIPublisherDataHolder.getInstance().getPostApiPublishingObseverList()) { if (log.isDebugEnabled()) { @@ -116,4 +131,39 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { } } + /** + * Update permission scope mapping entry with default scopes if perm-scope-mapping entry exists, otherwise this function + * will create that entry and update the value with default permissions. + */ + private void updateScopeMetadataEntryWithDefaultScopes() { + MetadataManagementService metadataManagementService = APIPublisherDataHolder.getInstance().getMetadataManagementService(); + try { + DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); + DefaultPermissions defaultPermissions = deviceManagementConfig.getDefaultPermissions(); + Metadata permScopeMapping = metadataManagementService.retrieveMetadata(Constants.PERM_SCOPE_MAPPING_META_KEY); + Map permScopeMap = (permScopeMapping != null) ? gson.fromJson(permScopeMapping.getMetaValue(), HashMap.class) : + new HashMap<>(); + for (DefaultPermission defaultPermission : defaultPermissions.getDefaultPermissions()) { + permScopeMap.putIfAbsent(defaultPermission.getName(), + defaultPermission.getScopeMapping().getKey()); + } + + APIPublisherDataHolder.getInstance().setPermScopeMapping(permScopeMap); + if (permScopeMapping != null) { + permScopeMapping.setMetaValue(gson.toJson(permScopeMap)); + metadataManagementService.updateMetadata(permScopeMapping); + return; + } + + permScopeMapping = new Metadata(); + permScopeMapping.setMetaKey(Constants.PERM_SCOPE_MAPPING_META_KEY); + permScopeMapping.setMetaValue(gson.toJson(permScopeMap)); + metadataManagementService.createMetadata(permScopeMapping); + } catch (MetadataManagementException e) { + log.error("Error encountered while updating permission scope mapping metadata with default scopes"); + } catch (MetadataKeyAlreadyExistsException e) { + log.error("Metadata entry already exists for " + Constants.PERM_SCOPE_MAPPING_META_KEY); + } + } + } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java index bbd2fd952e..737f734d07 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java @@ -22,10 +22,6 @@ import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiScope; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; -import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; -import io.entgra.device.mgt.core.device.mgt.core.config.permission.DefaultPermission; -import io.entgra.device.mgt.core.device.mgt.core.config.permission.DefaultPermissions; import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleEvent; import org.apache.catalina.LifecycleListener; @@ -131,19 +127,13 @@ public class APIPublisherLifecycleListener implements LifecycleListener { Metadata existingMetaData = metadataManagementService.retrieveMetadata("perm-scope" + "-mapping"); + if (existingMetaData != null) { existingMetaData.setMetaValue(new Gson().toJson(permScopeMap)); metadataManagementService.updateMetadata(existingMetaData); } else { Metadata newMetaData = new Metadata(); newMetaData.setMetaKey("perm-scope-mapping"); - - DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); - DefaultPermissions defaultPermissions = deviceManagementConfig.getDefaultPermissions(); - - for (DefaultPermission defaultPermission : defaultPermissions.getDefaultPermissions()) { - permScopeMap.put(defaultPermission.getName(), defaultPermission.getScopeMapping().getKey()); - } newMetaData.setMetaValue(new Gson().toJson(permScopeMap)); metadataManagementService.createMetadata(newMetaData); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/TenantCreateObserver.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/TenantCreateObserver.java index eb5fe919d2..da5acc7562 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/TenantCreateObserver.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/TenantCreateObserver.java @@ -46,7 +46,6 @@ import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.utils.AbstractAxis2ConfigurationContextObserver; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.util.ArrayList; import java.util.Arrays; @@ -143,26 +142,6 @@ public class TenantCreateObserver extends AbstractAxis2ConfigurationContextObser */ private void publishScopesToTenant(String tenantDomain) throws TenantManagementException { if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { - - MetadataManagementService metadataManagementService = DeviceManagementDataHolder.getInstance().getMetadataManagementService(); - - Map superTenantPermScopeMapping = getPermScopeMapping(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - Map subTenantPermScopeMapping = getPermScopeMapping(tenantDomain); - - if (superTenantPermScopeMapping == null) { - msg = "Error occurred while retrieving meta key '" + Constants.PERM_SCOPE_MAPPING_META_KEY + "' for tenant '" + - MultitenantConstants.SUPER_TENANT_DOMAIN_NAME + "'. Hence aborting publishing scopes to tenant: '" + - tenantDomain + "'."; - log.error(msg); - throw new TenantManagementException(msg); - } - if (superTenantPermScopeMapping.equals(subTenantPermScopeMapping)) { - if (log.isDebugEnabled()) { - log.debug( "Scopes in '" + tenantDomain + "' are up to date with super tenant scopes."); - } - return; - } - APIApplicationServices apiApplicationServices = DeviceManagementDataHolder.getInstance().getApiApplicationServices(); APIApplicationKey apiApplicationKey; AccessTokenInfo accessTokenInfo; @@ -268,10 +247,6 @@ public class TenantCreateObserver extends AbstractAxis2ConfigurationContextObser } } } - - if (missingScopes.size() > 0 || deletedScopes.size() > 0) { - updatePermScopeMetaData(superTenantPermScopeMapping, metadataManagementService); - } } else { if (log.isDebugEnabled()) { log.debug("Starting to publish shared scopes to newly created tenant: '" + tenantDomain + "'."); @@ -279,7 +254,6 @@ public class TenantCreateObserver extends AbstractAxis2ConfigurationContextObser publishSharedScopes(Arrays.asList(superTenantScopes), publisherRESTAPIServices, apiApplicationKey, accessTokenInfo); - updatePermScopeMetaData(superTenantPermScopeMapping, metadataManagementService); } } else { msg = "Unable to publish scopes to sub tenants due to super tenant scopes list being empty."; @@ -298,15 +272,6 @@ public class TenantCreateObserver extends AbstractAxis2ConfigurationContextObser msg = "Error occurred while publishing scopes to '" + tenantDomain + "' tenant space."; log.error(msg, e); throw new TenantManagementException(msg, e); - } catch (MetadataManagementException e) { - msg = "Error occurred trying to create metadata entry '" + Constants.PERM_SCOPE_MAPPING_META_KEY + "'."; - log.error(msg); - throw new TenantManagementException(msg); - } catch (MetadataKeyAlreadyExistsException e) { - msg = "Error occurred trying to create metadata entry '" + Constants.PERM_SCOPE_MAPPING_META_KEY + "'. The meta key " + - "already exists."; - log.error(msg); - throw new TenantManagementException(msg); } finally { APIPublisherUtils.removeScopePublishUserIfExists(tenantDomain); PrivilegedCarbonContext.endTenantFlow(); From 26d4ffdf8a21fbfb9906d4cc2121cc642a273a35 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Wed, 14 Aug 2024 01:43:43 +0530 Subject: [PATCH 280/343] Add improvements for api publishing procedure --- .../publisher/APIPublisherStartupHandler.java | 166 ++++++++++-------- .../webapp/publisher/APIPublisherUtil.java | 78 +++++++- .../internal/APIPublisherDataHolder.java | 3 +- .../APIPublisherLifecycleListener.java | 131 ++------------ 4 files changed, 186 insertions(+), 192 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java index 473e4067d0..fe2f6ba0bc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.apimgt.webapp.publisher; import com.google.gson.Gson; import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiScope; import io.entgra.device.mgt.core.apimgt.webapp.publisher.exception.APIManagerPublisherException; import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; @@ -34,20 +35,22 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.core.ServerStartupObserver; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Stack; public class APIPublisherStartupHandler implements ServerStartupObserver { private static final Log log = LogFactory.getLog(APIPublisherStartupHandler.class); - private static int retryTime = 2000; private static final int CONNECTION_RETRY_FACTOR = 2; private static final int MAX_RETRY_COUNT = 5; - private static Stack failedAPIsStack = new Stack<>(); - private static Stack currentAPIsStack; private static final Gson gson = new Gson(); - + private static final Stack failedAPIsStack = new Stack<>(); + private static int retryTime = 2000; + private static Stack currentAPIsStack; + private final List publishedAPIs = new ArrayList<>(); private APIPublisherService publisher; @Override @@ -59,64 +62,66 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { public void completedServerStartup() { APIPublisherDataHolder.getInstance().setServerStarted(true); currentAPIsStack = APIPublisherDataHolder.getInstance().getUnpublishedApis(); - Thread t = new Thread(new Runnable() { - @Override - public void run() { - if (log.isDebugEnabled()) { - log.debug("Server has just started, hence started publishing unpublished APIs"); - 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())) { - try { - retryTime = retryTime * CONNECTION_RETRY_FACTOR; - Thread.sleep(retryTime); - } catch (InterruptedException te) { - //do nothing. - } - Stack failedApis; - if (!APIPublisherDataHolder.getInstance().getUnpublishedApis().isEmpty()) { - publishAPIs(currentAPIsStack, failedAPIsStack); - failedApis = failedAPIsStack; - } else { - publishAPIs(failedAPIsStack, currentAPIsStack); - failedApis = currentAPIsStack; - } - retryCount++; - if (retryCount == MAX_RETRY_COUNT && !failedApis.isEmpty()) { - StringBuilder error = new StringBuilder(); - error.append("Error occurred while publishing API ['"); - while (!failedApis.isEmpty()) { - APIConfig api = failedApis.pop(); - error.append(api.getName() + ","); - } - error.append("']"); - log.error(error.toString()); - } - } - - try { - publisher.updateScopeRoleMapping(); - publisher.addDefaultScopesIfNotExist(); - } catch (APIManagerPublisherException e) { - log.error("failed to update scope role mapping.", e); - } - - updateScopeMetadataEntryWithDefaultScopes(); - - // execute after api publishing - for (PostApiPublishingObsever observer : APIPublisherDataHolder.getInstance().getPostApiPublishingObseverList()) { - if (log.isDebugEnabled()) { - log.debug("Executing " + observer.getClass().getName()); - } - observer.execute(); - } - log.info("Finish executing PostApiPublishingObsevers"); + Thread t = new Thread(() -> { + if (log.isDebugEnabled()) { + log.debug("Server has just started, hence started publishing unpublished APIs"); + 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())) { + try { + retryTime = retryTime * CONNECTION_RETRY_FACTOR; + Thread.sleep(retryTime); + } catch (InterruptedException te) { + //do nothing. + } + Stack failedApis; + if (!APIPublisherDataHolder.getInstance().getUnpublishedApis().isEmpty()) { + publishAPIs(currentAPIsStack, failedAPIsStack); + failedApis = failedAPIsStack; + } else { + publishAPIs(failedAPIsStack, currentAPIsStack); + failedApis = currentAPIsStack; + } + retryCount++; + if (retryCount == MAX_RETRY_COUNT && !failedApis.isEmpty()) { + StringBuilder error = new StringBuilder(); + error.append("Error occurred while publishing API ['"); + while (!failedApis.isEmpty()) { + APIConfig api = failedApis.pop(); + error.append(api.getName() + ","); + } + error.append("']"); + log.info(error.toString()); + } + } + + try { + publisher.updateScopeRoleMapping(); + publisher.addDefaultScopesIfNotExist(); + } catch (APIManagerPublisherException e) { + log.error("failed to update scope role mapping.", e); + } + + updateScopeMetadataEntryWithDefaultScopes(); + log.info("Successfully published : [" + publishedAPIs + "]. " + + "and failed : [" + failedAPIsStack + "] " + + "Total successful count : [" + publishedAPIs.size() + "]. " + + "Failed count : [" + failedAPIsStack.size() + "]"); + + // execute after api publishing + for (PostApiPublishingObsever observer : APIPublisherDataHolder.getInstance().getPostApiPublishingObseverList()) { + if (log.isDebugEnabled()) { + log.debug("Executing " + observer.getClass().getName()); + } + observer.execute(); + } + log.info("Finish executing PostApiPublishingObsevers"); }); t.start(); + log.info("Starting API publishing procedure"); } private void publishAPIs(Stack apis, Stack failedStack) { @@ -124,6 +129,11 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { APIConfig api = apis.pop(); try { publisher.publishAPI(api); + for (ApiScope scope : api.getScopes()) { + APIPublisherDataHolder.getInstance().getPermScopeMapping().putIfAbsent(scope.getPermissions(), scope.getKey()); + } + publishedAPIs.add(api.getName()); + log.info("Successfully published API [" + api.getName() + "]"); } catch (APIManagerPublisherException e) { log.error("failed to publish api.", e); failedStack.push(api); @@ -136,34 +146,42 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { * will create that entry and update the value with default permissions. */ private void updateScopeMetadataEntryWithDefaultScopes() { + Map permScopeMap = APIPublisherDataHolder.getInstance().getPermScopeMapping(); + Metadata permScopeMapping; + MetadataManagementService metadataManagementService = APIPublisherDataHolder.getInstance().getMetadataManagementService(); + DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); + DefaultPermissions defaultPermissions = deviceManagementConfig.getDefaultPermissions(); + try { - DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); - DefaultPermissions defaultPermissions = deviceManagementConfig.getDefaultPermissions(); - Metadata permScopeMapping = metadataManagementService.retrieveMetadata(Constants.PERM_SCOPE_MAPPING_META_KEY); - Map permScopeMap = (permScopeMapping != null) ? gson.fromJson(permScopeMapping.getMetaValue(), HashMap.class) : - new HashMap<>(); - for (DefaultPermission defaultPermission : defaultPermissions.getDefaultPermissions()) { - permScopeMap.putIfAbsent(defaultPermission.getName(), - defaultPermission.getScopeMapping().getKey()); + permScopeMapping = metadataManagementService.retrieveMetadata(Constants.PERM_SCOPE_MAPPING_META_KEY); + boolean entryAlreadyExists = permScopeMapping != null; + if (permScopeMap == null || permScopeMap.isEmpty()) { + permScopeMap = entryAlreadyExists ? gson.fromJson(permScopeMapping.getMetaValue(), HashMap.class) : + new HashMap<>(); } - APIPublisherDataHolder.getInstance().setPermScopeMapping(permScopeMap); - if (permScopeMapping != null) { - permScopeMapping.setMetaValue(gson.toJson(permScopeMap)); - metadataManagementService.updateMetadata(permScopeMapping); - return; + for (DefaultPermission defaultPermission : defaultPermissions.getDefaultPermissions()) { + permScopeMap.putIfAbsent(defaultPermission.getName(), defaultPermission.getScopeMapping().getKey()); } + permScopeMapping = new Metadata(); permScopeMapping.setMetaKey(Constants.PERM_SCOPE_MAPPING_META_KEY); permScopeMapping.setMetaValue(gson.toJson(permScopeMap)); - metadataManagementService.createMetadata(permScopeMapping); + + if (entryAlreadyExists) { + metadataManagementService.updateMetadata(permScopeMapping); + } else { + metadataManagementService.createMetadata(permScopeMapping); + } + + APIPublisherDataHolder.getInstance().setPermScopeMapping(permScopeMap); + log.info(Constants.PERM_SCOPE_MAPPING_META_KEY + "entry updated successfully"); } catch (MetadataManagementException e) { log.error("Error encountered while updating permission scope mapping metadata with default scopes"); } catch (MetadataKeyAlreadyExistsException e) { log.error("Metadata entry already exists for " + Constants.PERM_SCOPE_MAPPING_META_KEY); } } - } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java index 26cd3077fd..df9f76b285 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java @@ -24,25 +24,33 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import io.entgra.device.mgt.core.apimgt.annotations.Scope; +import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResource; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResourceConfiguration; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.WebappPublisherConfig; import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiScope; import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiUriTemplate; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import io.entgra.device.mgt.core.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import org.apache.catalina.core.StandardContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.Utils; +import org.wso2.carbon.user.api.TenantManager; import org.wso2.carbon.user.api.UserStoreException; import javax.servlet.ServletContext; +import java.io.IOException; import java.util.*; public class APIPublisherUtil { public static final String API_VERSION_PARAM = "{version}"; + public static final String PROPERTY_PROFILE = "profile"; private static final Log log = LogFactory.getLog(APIPublisherUtil.class); private static final String DEFAULT_API_VERSION = "1.0.0"; private static final String API_CONFIG_DEFAULT_VERSION = "1.0.0"; @@ -53,10 +61,10 @@ public class APIPublisherUtil { private static final String PARAM_MANAGED_API_IS_SECURED = "managed-api-isSecured"; private static final String PARAM_SHARED_WITH_ALL_TENANTS = "isSharedWithAllTenants"; private static final String PARAM_PROVIDER_TENANT_DOMAIN = "providerTenantDomain"; - private static final String NON_SECURED_RESOURCES = "nonSecuredEndPoints"; private static final String AUTH_TYPE_NON_SECURED = "None"; private static final String PARAM_IS_DEFAULT = "isDefault"; + private static final Gson gson = new Gson(); public static String getServerBaseUrl() { WebappPublisherConfig webappPublisherConfig = WebappPublisherConfig.getInstance(); @@ -255,7 +263,7 @@ public class APIPublisherUtil { policy = null; } apiConfig.setPolicy(policy); - + setResourceAuthTypes(servletContext, apiConfig); return apiConfig; } @@ -318,7 +326,7 @@ public class APIPublisherUtil { } } if (log.isDebugEnabled()) { - log.debug("API swagger definition: " + swaggerDefinition.toString()); + log.debug("API swagger definition: " + swaggerDefinition); } return swaggerDefinition.toString(); } @@ -336,8 +344,7 @@ public class APIPublisherUtil { String fullPaath = ""; if (!template.getUriTemplate().equals(AnnotationProcessor.WILD_CARD)) { fullPaath = apiConfig.getContext() + template.getUriTemplate(); - } - else { + } else { fullPaath = apiConfig.getContext(); } for (String context : resourcesList) { @@ -349,4 +356,65 @@ public class APIPublisherUtil { } apiConfig.setUriTemplates(templates); } + + public static List getAPIResourceConfiguration(StandardContext standardContext, ServletContext servletContext) + throws IOException, ClassNotFoundException { + List apiResourceConfigurations = new ArrayList<>(); + String profile = System.getProperty(PROPERTY_PROFILE); + if (WebappPublisherConfig.getInstance().getProfiles().getProfile().contains(profile.toLowerCase())) { + AnnotationProcessor annotationProcessor = new AnnotationProcessor(standardContext); + Set annotatedSwaggerAPIClasses = annotationProcessor. + scanStandardContext(io.swagger.annotations.SwaggerDefinition.class.getName()); + apiResourceConfigurations = annotationProcessor.extractAPIInfo(servletContext, + annotatedSwaggerAPIClasses); + } + return apiResourceConfigurations; + } + + /** + * This method can use to publish the apis after the server startup complete. + * + * @param apiConfig {@link APIConfig} Contains API definition + */ + public static void publishAPIAfterServerStartup(APIConfig apiConfig) { + APIPublisherDataHolder apiPublisherDataHolder = APIPublisherDataHolder.getInstance(); + if (!apiPublisherDataHolder.isServerStarted()) { + if (log.isDebugEnabled()) { + log.debug("Abort publishing the API [" + apiConfig.getName() + "]. Server still starting"); + } + throw new IllegalStateException("Server starting procedure is still not completed"); + } + + TenantManager tenantManager = apiPublisherDataHolder.getTenantManager(); + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager service not initialized properly"); + } + try { + if (tenantManager.isTenantActive(tenantManager.getTenantId(apiConfig.getTenantDomain()))) { + APIPublisherService apiPublisherService = apiPublisherDataHolder.getApiPublisherService(); + if (apiPublisherService == null) { + throw new IllegalStateException("API Publisher service is not initialized properly"); + } + apiPublisherService.publishAPI(apiConfig); + for (ApiScope scope : apiConfig.getScopes()) { + apiPublisherDataHolder.getPermScopeMapping().putIfAbsent(scope.getPermissions(), scope.getKey()); + } + + Metadata permScopeMapping = new Metadata(); + permScopeMapping.setMetaKey(Constants.PERM_SCOPE_MAPPING_META_KEY); + permScopeMapping.setMetaValue(gson.toJson(apiPublisherDataHolder.getPermScopeMapping())); + + try { + apiPublisherDataHolder.getMetadataManagementService().updateMetadata(permScopeMapping); + } catch (MetadataManagementException e) { + log.error("Error encountered while updating the " + Constants.PERM_SCOPE_MAPPING_META_KEY + "entry"); + } + } else { + log.error("Can't find an active tenant under tenant domain " + apiConfig.getTenantDomain()); + } + } catch (Throwable e) { + log.error("Error occurred while publishing API '" + apiConfig.getName() + "' with the context '" + + apiConfig.getContext() + "' and version '" + apiConfig.getVersion() + "'", e); + } + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java index d00f50e35f..8e243ab263 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java @@ -33,6 +33,7 @@ import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.tenant.TenantManager; import org.wso2.carbon.utils.ConfigurationContextService; +import java.util.HashMap; import java.util.Map; import java.util.Stack; import java.util.List; @@ -48,7 +49,7 @@ public class APIPublisherDataHolder { private RegistryService registryService; private boolean isServerStarted; private Stack unpublishedApis = new Stack<>(); - private Map permScopeMapping; + private Map permScopeMapping = new HashMap<>(); private APIApplicationServices apiApplicationServices; private PublisherRESTAPIServices publisherRESTAPIServices; private MetadataManagementService metadataManagementService; diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java index 3bdf706857..90c0fb4d6d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java @@ -17,24 +17,11 @@ */ package io.entgra.device.mgt.core.apimgt.webapp.publisher.lifecycle.listener; -import com.google.gson.Gson; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.dto.ApiScope; -import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; -import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; -import org.apache.catalina.Lifecycle; -import org.apache.catalina.LifecycleEvent; -import org.apache.catalina.LifecycleListener; -import org.apache.catalina.core.StandardContext; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIConfig; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherService; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherUtil; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.APIResourceConfiguration; import io.entgra.device.mgt.core.apimgt.webapp.publisher.config.WebappPublisherConfig; import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; -import io.entgra.device.mgt.core.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor; import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleEvent; import org.apache.catalina.LifecycleListener; @@ -46,104 +33,42 @@ import org.wso2.carbon.user.api.UserStoreException; import javax.servlet.ServletContext; import java.io.IOException; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Set; @SuppressWarnings("unused") public class APIPublisherLifecycleListener implements LifecycleListener { + public static final String PROFILE_DEFAULT = "default"; private static final Log log = LogFactory.getLog(APIPublisherLifecycleListener.class); private static final String PARAM_MANAGED_API_ENABLED = "managed-api-enabled"; - public static final String PROPERTY_PROFILE = "profile"; - public static final String PROFILE_DT_WORKER = "dtWorker"; - public static final String PROFILE_DEFAULT = "default"; @Override public void lifecycleEvent(LifecycleEvent lifecycleEvent) { - if (Lifecycle.AFTER_START_EVENT.equals(lifecycleEvent.getType()) ) { - if (WebappPublisherConfig.getInstance() - .isPublished()) { - StandardContext context = (StandardContext) lifecycleEvent.getLifecycle(); - ServletContext servletContext = context.getServletContext(); - String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED); - boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param); + if (Lifecycle.AFTER_START_EVENT.equals(lifecycleEvent.getType())) { + + APIPublisherDataHolder apiPublisherDataHolder = APIPublisherDataHolder.getInstance(); + StandardContext context = (StandardContext) lifecycleEvent.getLifecycle(); + ServletContext servletContext = context.getServletContext(); + String param = servletContext.getInitParameter(PARAM_MANAGED_API_ENABLED); + boolean isManagedApi = (param != null && !param.isEmpty()) && Boolean.parseBoolean(param); + + if (isManagedApi) { + if (WebappPublisherConfig.getInstance().isPublished() || WebappPublisherConfig.getInstance().isEnabledUpdateApi()) { - String profile = System.getProperty(PROPERTY_PROFILE); - if (WebappPublisherConfig.getInstance().getProfiles().getProfile().contains(profile.toLowerCase()) - && isManagedApi) { try { - AnnotationProcessor annotationProcessor = new AnnotationProcessor(context); - Set annotatedSwaggerAPIClasses = annotationProcessor. - scanStandardContext(io.swagger.annotations.SwaggerDefinition.class.getName()); - List apiDefinitions = annotationProcessor.extractAPIInfo(servletContext, - annotatedSwaggerAPIClasses); + List apiResourceConfigurations = + APIPublisherUtil.getAPIResourceConfiguration(context, servletContext); - APIPublisherDataHolder apiPublisherDataHolder = APIPublisherDataHolder.getInstance(); - MetadataManagementService metadataManagementService = - apiPublisherDataHolder.getMetadataManagementService(); - Metadata metadata = metadataManagementService.retrieveMetadata("perm-scope-mapping"); - if (metadata != null) { - HashMap permScopeMapping = - new Gson().fromJson(metadata.getMetaValue().toString(), HashMap.class); - apiPublisherDataHolder.setPermScopeMapping(permScopeMapping); - } - - Map permScopeMap = apiPublisherDataHolder.getPermScopeMapping(); - for (APIResourceConfiguration apiDefinition : apiDefinitions) { - APIConfig apiConfig = APIPublisherUtil.buildApiConfig(servletContext, apiDefinition); - for (ApiScope scope : apiConfig.getScopes()) { - permScopeMap.put(scope.getPermissions(), scope.getKey()); - } - APIPublisherUtil.setResourceAuthTypes(servletContext,apiConfig); - try { - int tenantId = APIPublisherDataHolder.getInstance().getTenantManager(). - getTenantId(apiConfig.getTenantDomain()); - - boolean isTenantActive = APIPublisherDataHolder.getInstance(). - getTenantManager().isTenantActive(tenantId); - if (isTenantActive) { - boolean isServerStarted = APIPublisherDataHolder.getInstance().isServerStarted(); - if (isServerStarted) { - APIPublisherService apiPublisherService = - APIPublisherDataHolder.getInstance().getApiPublisherService(); - if (apiPublisherService == null) { - throw new IllegalStateException( - "API Publisher service is not initialized properly"); - } - apiPublisherService.publishAPI(apiConfig); - } else { - if (log.isDebugEnabled()) { - log.debug("Server has not started yet. Hence adding API '" + - apiConfig.getName() + "' to the queue"); - } - APIPublisherDataHolder.getInstance().getUnpublishedApis().push(apiConfig); - } + if (WebappPublisherConfig.getInstance().isPublished()) { + for (APIResourceConfiguration apiDefinition : apiResourceConfigurations) { + APIConfig apiConfig = APIPublisherUtil.buildApiConfig(servletContext, apiDefinition); + if (apiPublisherDataHolder.isServerStarted()) { + APIPublisherUtil.publishAPIAfterServerStartup(apiConfig); } else { - log.error("No tenant [" + apiConfig.getTenantDomain() + "] " + - "found when publishing the Web app"); + apiPublisherDataHolder.getUnpublishedApis().push(apiConfig); } - } catch (Throwable e) { - log.error("Error occurred while publishing API '" + apiConfig.getName() + - "' with the context '" + apiConfig.getContext() + - "' and version '" + apiConfig.getVersion() + "'", e); } } - - Metadata existingMetaData = metadataManagementService.retrieveMetadata("perm-scope" + - "-mapping"); - - if (existingMetaData != null) { - existingMetaData.setMetaValue(new Gson().toJson(permScopeMap)); - metadataManagementService.updateMetadata(existingMetaData); - } else { - Metadata newMetaData = new Metadata(); - newMetaData.setMetaKey("perm-scope-mapping"); - newMetaData.setMetaValue(new Gson().toJson(permScopeMap)); - metadataManagementService.createMetadata(newMetaData); - } - apiPublisherDataHolder.setPermScopeMapping(permScopeMap); } catch (IOException e) { log.error("Error encountered while discovering annotated classes", e); } catch (ClassNotFoundException e) { @@ -156,24 +81,6 @@ public class APIPublisherLifecycleListener implements LifecycleListener { log.error("Failed to Publish api from " + servletContext.getContextPath(), e); } } - } else { - APIPublisherDataHolder apiPublisherDataHolder = APIPublisherDataHolder.getInstance(); - MetadataManagementService metadataManagementService = - apiPublisherDataHolder.getMetadataManagementService(); - try { - Metadata existingMetaData = metadataManagementService.retrieveMetadata("perm-scope" + - "-mapping"); - if (existingMetaData != null) { - existingMetaData.setMetaValue(new Gson().toJson(apiPublisherDataHolder.getPermScopeMapping() - )); - metadataManagementService.updateMetadata(existingMetaData); - } else { - log.error("Couldn't find 'perm-scope-mapping' Meta entry while API publishing has been turned" + - " off."); - } - } catch (MetadataManagementException e) { - log.error("Failed to Load Meta-Mgt data.", e); - } } } } From c6f65d96759e3d3ed3d4dd1c3f9e7167077505f6 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Wed, 14 Aug 2024 23:21:55 +0530 Subject: [PATCH 281/343] Refactor the code --- .../core/apimgt/webapp/publisher/APIPublisherUtil.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java index df9f76b285..f8d7638480 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherUtil.java @@ -357,6 +357,14 @@ public class APIPublisherUtil { apiConfig.setUriTemplates(templates); } + /** + * This method will extract and retrieve the API resource configuration by processing the API resources + * @param standardContext {@link StandardContext} + * @param servletContext {@link ServletContext} + * @return Extracted {@link APIResourceConfiguration} list describing from the servlet context + * @throws IOException Throws when error occurred while processing the swagger annotations + * @throws ClassNotFoundException Throws when error occurred while extracting api configurations + */ public static List getAPIResourceConfiguration(StandardContext standardContext, ServletContext servletContext) throws IOException, ClassNotFoundException { List apiResourceConfigurations = new ArrayList<>(); From db1f12ea8882cd84db9cbdd40c8f0012720552db Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Thu, 15 Aug 2024 01:13:20 +0530 Subject: [PATCH 282/343] Improve retrying logic and refactor the code --- .../publisher/APIPublisherStartupHandler.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java index fe2f6ba0bc..796a31d957 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -71,14 +71,16 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { publisher = APIPublisherDataHolder.getInstance().getApiPublisherService(); int retryCount = 0; while (retryCount < MAX_RETRY_COUNT && (!failedAPIsStack.isEmpty() || !currentAPIsStack.isEmpty())) { - try { - retryTime = retryTime * CONNECTION_RETRY_FACTOR; - Thread.sleep(retryTime); - } catch (InterruptedException te) { - //do nothing. + if (retryCount > 0) { + try { + retryTime = retryTime * CONNECTION_RETRY_FACTOR; + Thread.sleep(retryTime); + } catch (InterruptedException te) { + //do nothing. + } } Stack failedApis; - if (!APIPublisherDataHolder.getInstance().getUnpublishedApis().isEmpty()) { + if (!currentAPIsStack.isEmpty()) { publishAPIs(currentAPIsStack, failedAPIsStack); failedApis = failedAPIsStack; } else { @@ -124,6 +126,13 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { log.info("Starting API publishing procedure"); } + /** + * Publish apis provided by the API stack, if failed while publishing, then failed API will be added to + * the failed API stack + * + * @param apis Stack of APIs to publish + * @param failedStack Stack to record failed APIs + */ private void publishAPIs(Stack apis, Stack failedStack) { while (!apis.isEmpty()) { APIConfig api = apis.pop(); From bc81c8923c53ff26508d97b5b166157c01e644ed Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Thu, 15 Aug 2024 20:21:31 +0530 Subject: [PATCH 283/343] Change the return type of the app lifecycle's updated time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the API returns Timestamp object it creates from the Unix timestamp (in milliseconds), but its string representation depends on the JVM’s default timezone. Therefore it returns timestamp based on JVM's timezone. Since it is required to return UTC time, changed the data type and returns the long value. With this improvement it is guaranteed that client gets the UTC time of the app lifecycle's updated time. --- .../mgt/core/application/mgt/common/LifecycleState.java | 8 ++++---- .../impl/lifecyclestate/GenericLifecycleStateDAOImpl.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java index b72d169253..53c839c6d8 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/LifecycleState.java @@ -45,8 +45,8 @@ public class LifecycleState { private String updatedBy; @ApiModelProperty(name = "updatedAt", - value = "Timestamp of the lifecycle has been updated") - private Timestamp updatedAt; + value = "The seconds from the epoch of 1970-01-01T00:00:00Z that the lifecycle has been updated") + private Long updatedAt; @ApiModelProperty(name = "reasonForChange", value = "Reason for the application release lifecycle change from previous state to current state.") @@ -76,11 +76,11 @@ public class LifecycleState { this.updatedBy = updatedBy; } - public Timestamp getUpdatedAt() { + public Long getUpdatedAt() { return updatedAt; } - public void setUpdatedAt(Timestamp updatedAt) { + public void setUpdatedAt(Long updatedAt) { this.updatedAt = updatedAt; } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java index ac16c04084..f491a5a657 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java @@ -274,7 +274,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif lifecycleState = new LifecycleState(); lifecycleState.setCurrentState(rs.getString("CURRENT_STATE")); lifecycleState.setPreviousState(rs.getString("PREVIOUS_STATE")); - lifecycleState.setUpdatedAt(new Timestamp(rs.getLong("UPDATED_AT"))); + lifecycleState.setUpdatedAt(rs.getLong("UPDATED_AT")); lifecycleState.setUpdatedBy(rs.getString("UPDATED_BY")); } } catch (SQLException e) { @@ -300,7 +300,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif LifecycleState lifecycleState = new LifecycleState(); lifecycleState.setCurrentState(rs.getString("CURRENT_STATE")); lifecycleState.setPreviousState(rs.getString("PREVIOUS_STATE")); - lifecycleState.setUpdatedAt(new Timestamp(rs.getLong("UPDATED_AT") * 1000L)); + lifecycleState.setUpdatedAt(rs.getLong("UPDATED_AT")); lifecycleState.setUpdatedBy(rs.getString("UPDATED_BY")); lifecycleStates.add(lifecycleState); } From 07794f97d964a2a473777cd1ce6c462c9590ed94 Mon Sep 17 00:00:00 2001 From: Gimhan-minion Date: Fri, 16 Aug 2024 03:27:05 +0530 Subject: [PATCH 284/343] Initialize device tag feature --- .../device/mgt/api/jaxrs/beans/TagInfo.java | 50 +++ .../mgt/api/jaxrs/beans/TagInfoList.java | 53 +++ .../mgt/api/jaxrs/beans/TagMappingInfo.java | 62 +++ .../api/jaxrs/beans/TagMappingInfoList.java | 53 +++ .../service/api/DeviceManagementService.java | 8 +- .../service/api/TagManagementService.java | 401 ++++++++++++++++++ .../impl/DeviceManagementServiceImpl.java | 14 + .../impl/TagManagementServiceImpl.java | 193 +++++++++ .../impl/util/RequestValidationUtil.java | 36 ++ .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 15 + .../src/main/webapp/WEB-INF/cxf-servlet.xml | 2 + .../impl/DeviceManagementServiceImplTest.java | 36 +- .../core/device/mgt/common/EnrolmentInfo.java | 13 +- .../device/mgt/common/PaginationRequest.java | 9 + .../device/mgt/common/tag/mgt/DeviceTag.java | 52 +++ .../core/device/mgt/common/tag/mgt/Tag.java | 86 ++++ .../tag/mgt/TagManagementException.java | 60 +++ .../mgt/common/tag/mgt/TagMappingDTO.java | 73 ++++ .../common/tag/mgt/TagNotFoundException.java | 60 +++ .../core/dao/DeviceManagementDAOFactory.java | 16 + .../mgt/core/device/mgt/core/dao/TagDAO.java | 130 ++++++ .../core/dao/TagManagementDAOException.java | 70 +++ .../core/dao/impl/AbstractDeviceDAOImpl.java | 46 ++ .../device/mgt/core/dao/impl/TagDAOImpl.java | 349 +++++++++++++++ .../dao/impl/device/GenericDeviceDAOImpl.java | 74 +++- .../impl/device/PostgreSQLDeviceDAOImpl.java | 59 ++- .../impl/device/SQLServerDeviceDAOImpl.java | 61 ++- .../dao/util/DeviceManagementDAOUtil.java | 23 +- .../core/dao/util/TagManagementDAOUtil.java | 98 +++++ .../DeviceManagementServiceComponent.java | 5 + .../DeviceManagementProviderServiceImpl.java | 11 +- .../service/TagManagementProviderService.java | 97 +++++ .../TagManagementProviderServiceImpl.java | 275 ++++++++++++ .../mgt/core/device/mgt/core/TestUtils.java | 24 ++ .../mgt/core/common/TestDataHolder.java | 23 +- .../mgt/core/dao/DevicePersistTests.java | 225 ++++++++++ .../TagManagementProviderServiceTest.java | 216 ++++++++++ .../src/test/resources/sql/h2.sql | 22 + .../src/test/resources/testng.xml | 1 + 39 files changed, 3051 insertions(+), 50 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfo.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfoList.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagMappingInfo.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagMappingInfoList.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/TagManagementService.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/DeviceTag.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/Tag.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagManagementException.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagMappingDTO.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagNotFoundException.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagDAO.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagManagementDAOException.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TagDAOImpl.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/TagManagementDAOUtil.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderService.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfo.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfo.java new file mode 100644 index 0000000000..33075f39d2 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfo.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.api.jaxrs.beans; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel(value = "TagInfo", description = "Tag details including parameters associated with tags " + + "wrapped here.") +public class TagInfo { + + @ApiModelProperty(name = "name", value = "The name of the tag.", required = true) + private String name; + + @ApiModelProperty(name = "description", value = "Describes the behavior of the tag.", + required = false) + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfoList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfoList.java new file mode 100644 index 0000000000..4960c35f82 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfoList.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.api.jaxrs.beans; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +@ApiModel(value = "TagInfoList") +public class TagInfoList extends BasePaginatedResult { + + private List tags; + + @ApiModelProperty(value = "Returns the list of tags that match the offset and limit parameter values " + + "that were specified.") + @JsonProperty("tags") + public List getList() { + return tags; + } + + public void setList(List tags) { + this.tags = tags; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{\n"); + sb.append(" count: ").append(getCount()).append(",\n"); + sb.append(" tags: [").append(tags).append("\n"); + sb.append("]}\n"); + return sb.toString(); + } + + +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagMappingInfo.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagMappingInfo.java new file mode 100644 index 0000000000..ae5debb2e4 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagMappingInfo.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.api.jaxrs.beans; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +@ApiModel(value = "TagMappingInfo", description = "Tag mapping details including parameters associated with " + + "device mapping wrapped here.") +public class TagMappingInfo { + + @ApiModelProperty(name = "deviceIdentifiers", value = "Defines the device identifiers.", required = true) + private List deviceIdentifiers; + + @ApiModelProperty(name = "deviceType", value = "Defines the device type.", required = true) + private String deviceType; + + @ApiModelProperty(name = "tags", value = "Defines the tags.", required = true) + private List tags; + + public List getDeviceIdentifiers() { + return deviceIdentifiers; + } + + public void setDeviceIdentifiers(List deviceIdentifiers) { + this.deviceIdentifiers = deviceIdentifiers; + } + + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagMappingInfoList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagMappingInfoList.java new file mode 100644 index 0000000000..8ae856748e --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagMappingInfoList.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.api.jaxrs.beans; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +@ApiModel(value = "TagMappingInfoList") +public class TagMappingInfoList extends BasePaginatedResult { + + private List tagMappings; + + @ApiModelProperty(value = "Returns the list of tag mappings that match the offset and " + + "limit parameter values that were specified.") + @JsonProperty("tagMappings") + public List getList() { + return tagMappings; + } + + public void setList(List tagMappings) { + this.tagMappings = tagMappings; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("{\n"); + sb.append(" count: ").append(getCount()).append(",\n"); + sb.append(" tagMappings: [").append(tagMappings).append("\n"); + sb.append("]}\n"); + return sb.toString(); + } + + +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index 5c41168bcb..e201133681 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -64,9 +64,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.sql.Timestamp; import java.util.List; -import java.util.Map; /** * Device related REST-API. This can be used to manipulated device related details. @@ -339,6 +337,12 @@ public interface DeviceManagementService { required = false) @QueryParam("requireDeviceInfo") boolean requireDeviceInfo, + @ApiParam( + name = "tags", + value = "Describes the tags associated with the enrolment", + required = false) + @QueryParam("tags") + List tags, @ApiParam( name = "offset", value = "The starting pagination index for the complete list of qualified items.", diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/TagManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/TagManagementService.java new file mode 100644 index 0000000000..a9e90d87fe --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/TagManagementService.java @@ -0,0 +1,401 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.api.jaxrs.service.api; + +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; +import io.swagger.annotations.*; +import io.entgra.device.mgt.core.apimgt.annotations.Scope; +import io.entgra.device.mgt.core.apimgt.annotations.Scopes; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.List; + +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "TagManagement"), + @ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/tags"), + }) + } + ), + tags = { + @Tag(name = "device_management") + } +) +@Scopes( + scopes = { + @Scope( + name = "Getting the List of Tags", + description = "Getting the List of Tags", + key = "tm:tags:view", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/tags/view"} + ), + @Scope( + name = "Adding a new tag", + description = "Adding a new tag", + key = "tm:tags:create", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/tags/create"} + ), + @Scope( + name = "Updating a tag", + description = "Updating a tag", + key = "tm:tags:update", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/tags/update"} + ), + @Scope( + name = "Delete a tag", + description = "Delete a tag", + key = "tm:tags:delete", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/tags/delete"} + ), + @Scope( + name = "Adding a device tag mapping", + description = "Adding a device-tag mapping", + key = "tm:tags:mapping:create", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/tags/mapping/create"} + ), + @Scope( + name = "Deleting a device tag mapping", + description = "Deleting a device-tag mapping", + key = "tm:tags:mapping:delete", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/tags/mapping/delete"} + ), + @Scope( + name = "Getting the list of device tag mappings", + description = "Getting the list of device-tag mappings", + key = "tm:tags:mapping:view", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/tags/mapping/view"} + ) + } +) +@Path("/tags") +@Api(value = "Tag Management", description = "Tag management related operations can be found here.") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public interface TagManagementService { + + @GET + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Getting the List of Tags", + notes = "", + tags = "Tag Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "tm:tags:view") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully fetched the list of tags.", + response = TagInfoList.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 304, + message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."), + @ApiResponse( + code = 406, + message = "Not Acceptable.\n The requested media type is not supported"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while fetching list of roles.", + response = ErrorResponse.class) + }) + Response getTags(); + + @POST + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Adding a Tag", + notes = "", + tags = "Tag Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "tm:tags:create") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully created the tag.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The URL to the newly added tag."), + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while adding a new tag.", + response = ErrorResponse.class) + }) + Response addTag( + @ApiParam( + name = "tag", + value = "The properties required to add a new tag.", + required = true) List tags); + + @PUT + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "PUT", + value = "Updating a Tag", + notes = "", + tags = "Tag Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "tm:tags:update") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully updated the tag.", + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 404, + message = "Not Found. \n The specified tag does not exist.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while updating the tag.", + response = ErrorResponse.class) + }) + Response updateTag( + @ApiParam( + name = "tagId", + value = "The ID of the tag to be updated.", + required = false) @QueryParam("tagId") Integer tagId, + @ApiParam( + name = "tagName", + value = "The name of the tag to be updated.", + required = false) @QueryParam("tagName") String tagName, + @ApiParam( + name = "tagInfo", + value = "The properties required to update the tag.", + required = true) TagInfo tagInfo); + + @DELETE + @Path("/{tagId}") + @ApiOperation( + httpMethod = "DELETE", + value = "Deleting a Tag", + notes = "", + tags = "Tag Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "tm:tags:delete") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 204, + message = "No Content. \n Successfully deleted the tag."), + @ApiResponse( + code = 404, + message = "Not Found. \n The specified tag does not exist.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while deleting the tag.", + response = ErrorResponse.class) + }) + Response deleteTag( + @ApiParam( + name = "tagId", + value = "The ID of the tag to be deleted.", + required = true) @PathParam("tagId") int tagId); + + @GET + @Path("/{tagId}") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Getting a Tag by ID", + notes = "", + tags = "Tag Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "tm:tags:view") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully fetched the tag.", + response = Tag.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body")}), + @ApiResponse( + code = 404, + message = "Not Found. \n The specified tag does not exist.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while fetching the tag.", + response = ErrorResponse.class) + }) + Response getTagById( + @ApiParam( + name = "tagId", + value = "The ID of the tag to be fetched.", + required = true) @PathParam("tagId") int tagId); + + @POST + @Path("/mapping") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Adding a Device-Tag Mapping", + notes = "", + tags = "Device-Tag Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "tm:tags:mapping:create") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully created the device-tag mapping.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The URL to the newly added device-tag mapping."), + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while adding the device-tag mapping.", + response = ErrorResponse.class) + }) + Response addDeviceTagMapping( + @ApiParam( + name = "deviceTagInfo", + value = "The properties required to add a new device-tag mapping.", + required = true) TagMappingInfo tagMappingInfo); + + @DELETE + @Path("/mapping") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "DELETE", + value = "Deleting a Device-Tag Mapping", + notes = "", + tags = "Device-Tag Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "tm:tags:mapping:delete") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 204, + message = "No Content. \n Successfully deleted the device-tag mapping."), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while deleting the device-tag mapping.", + response = ErrorResponse.class) + }) + Response deleteDeviceTagMapping( + @ApiParam( + name = "deviceTagInfo", + value = "The properties required to add a new device-tag mapping.", + required = true) TagMappingInfo tagMappingInfo); +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 88cfe125ca..5c7d235b88 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -151,6 +151,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @QueryParam("since") String since, @HeaderParam("If-Modified-Since") String ifModifiedSince, @QueryParam("requireDeviceInfo") boolean requireDeviceInfo, + @QueryParam("tags") List tags, @QueryParam("offset") int offset, @QueryParam("limit") int limit) { try { @@ -226,6 +227,19 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { return Response.status(Response.Status.OK).entity(devices).build(); } + if (tags != null && !tags.isEmpty()) { + boolean isTagsEmpty = true; + for (String tagString : tags) { + if (StringUtils.isNotBlank(tagString)) { + isTagsEmpty = false; + break; + } + } + if (!isTagsEmpty) { + request.setTags(tags); + } + } + // this is the user who initiates the request String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername(); if (groupId != 0) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java new file mode 100644 index 0000000000..b1643472d8 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.api.jaxrs.service.impl; + +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.TagInfo; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.TagMappingInfo; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.TagManagementService; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.*; +import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; +import io.entgra.device.mgt.core.notification.logger.impl.EntgraRoleMgtLoggerImpl; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.List; + +@Path("/tags") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class TagManagementServiceImpl implements TagManagementService { + + private static final EntgraLogger log = new EntgraRoleMgtLoggerImpl(TagManagementServiceImpl.class); + + @GET + @Override + public Response getTags() { + try { + List tags = DeviceMgtAPIUtils.getTagManagementService().getAllTags(); + return Response.status(Response.Status.OK).entity(tags).build(); + } catch (TagManagementException e) { + String msg = "Error occurred while getting tags."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + @POST + @Override + public Response addTag(List tagInfoList) { + RequestValidationUtil.validateTagListDetails(tagInfoList); + try { + List tags = new ArrayList<>(); + for (TagInfo tagInfo : tagInfoList) { + Tag tag = new Tag(tagInfo.getName(), tagInfo.getDescription()); + tags.add(tag); + } + DeviceMgtAPIUtils.getTagManagementService().addTags(tags); + return Response.status(Response.Status.CREATED).entity(tagInfoList).build(); + } catch (TagManagementException e) { + String msg = "Error occurred while adding tags." ; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (BadRequestException e) { + String msg = "Error occurred while adding tags. Please check the request" ; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + } + } + + @PUT + @Override + public Response updateTag(@QueryParam("tagId") Integer tagId, @QueryParam("tagName") String tagName, TagInfo tagInfo) { + RequestValidationUtil.validateTagDetails(tagId, tagName, tagInfo); + try { + Tag tag; + if (tagId != null) { + tag = DeviceMgtAPIUtils.getTagManagementService().getTagById(tagId); + } else { + tag = DeviceMgtAPIUtils.getTagManagementService().getTagByName(tagName); + } + if (tag == null) { + String msg = "Tag not found."; + log.error(msg); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } + tag.setName(tagInfo.getName()); + tag.setDescription(tagInfo.getDescription()); + DeviceMgtAPIUtils.getTagManagementService().updateTag(tag); + return Response.status(Response.Status.OK).entity(tag).build(); + } catch (TagManagementException e) { + String msg = (tagId != null) ? "Error occurred while updating tag with ID " + tagId + "." + : "Error occurred while updating tag with name " + tagName + "."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (TagNotFoundException e) { + String msg = (tagId != null) ? "Tag with ID " + tagId + " is not found." + : "Tag with name " + tagName + " is not found."; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build(); + } catch (BadRequestException e) { + String msg = (tagId != null) ? "Error occurred while updating tag with ID " + tagId + : "Error occurred while updating tag with name " + tagName; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + } + } + + @DELETE + @Path("/{tagId}") + @Override + public Response deleteTag(@PathParam("tagId") int tagId) { + try { + DeviceMgtAPIUtils.getTagManagementService().deleteTag(tagId); + return Response.status(Response.Status.NO_CONTENT).build(); + } catch (TagManagementException e) { + String msg = "Error occurred while deleting tag with ID " + tagId + "."; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } catch (TagNotFoundException e) { + String msg = "Tag with ID " + tagId + " is not found."; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build(); + } + } + + @GET + @Path("/{tagId}") + @Override + public Response getTagById(@PathParam("tagId") int tagId) { + try { + Tag tag = DeviceMgtAPIUtils.getTagManagementService().getTagById(tagId); + return Response.status(Response.Status.OK).entity(tag).build(); + } catch (TagManagementException e) { + String msg = "Error occurred while getting tag with ID " + tagId + "."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (TagNotFoundException e) { + String msg = "Tag with ID " + tagId + " is not found."; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build(); + } + } + + @POST + @Path("/mapping") + public Response addDeviceTagMapping(TagMappingInfo tagMappingInfo) { + RequestValidationUtil.validateTagMappingDetails(tagMappingInfo); + try { + TagMappingDTO tagMappingDTO = new TagMappingDTO(tagMappingInfo.getDeviceIdentifiers(), + tagMappingInfo.getDeviceType(), tagMappingInfo.getTags()); + DeviceMgtAPIUtils.getTagManagementService().addDeviceTagMapping(tagMappingDTO); + return Response.status(Response.Status.CREATED).entity(tagMappingDTO).build(); + } catch (TagManagementException e) { + String msg = "Error occurred while adding device-tag mapping."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (BadRequestException e) { + String msg = "Error occurred while adding tag mappings."; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + } + } + + @DELETE + @Path("/mapping") + public Response deleteDeviceTagMapping(TagMappingInfo tagMappingInfo) { + RequestValidationUtil.validateTagMappingDetails(tagMappingInfo); + try { + TagMappingDTO tagMappingDTO = new TagMappingDTO(tagMappingInfo.getDeviceIdentifiers(), + tagMappingInfo.getDeviceType(), tagMappingInfo.getTags()); + DeviceMgtAPIUtils.getTagManagementService().deleteDeviceTagMapping(tagMappingDTO); + return Response.status(Response.Status.NO_CONTENT).build(); + } catch (TagManagementException e) { + String msg = "Error occurred while deleting tag mappings."; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (BadRequestException e) { + String msg = "Error occurred while deleting tag mappings."; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + } + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java index ab66e75d1c..e39ebb2366 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java @@ -19,6 +19,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -492,6 +493,41 @@ public class RequestValidationUtil { } } + public static void validateTagDetails(Integer tagId, String tagName, TagInfo tagInfo) { + if (tagId == null && tagName == null) { + String msg = "Either tagId or tagName must be provided."; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(msg).build()); + } + if (tagInfo == null) { + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request body is " + + "empty").build()); + } + } + + public static void validateTagListDetails(List tagInfo) { + if (tagInfo == null) { + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request body is " + + "empty").build()); + } + } + + public static void validateTagMappingDetails(TagMappingInfo tagMappingInfo) { + if (tagMappingInfo == null) { + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage("Request body is empty").build()); + } else if (tagMappingInfo.getDeviceIdentifiers() == null || tagMappingInfo.getDeviceType() == null + || tagMappingInfo.getTags() == null) { + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage("Invalid tag mapping request body").build()); + } + } + + + public static void validateScopes(List scopes) { if (scopes == null || scopes.isEmpty()) { throw new InputValidationException( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index 5451572519..b6f44c042c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -21,10 +21,12 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherService; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.TagManagementService; import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuthorizationService; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; +import io.entgra.device.mgt.core.device.mgt.core.service.TagManagementProviderService; import org.apache.axis2.AxisFault; import org.apache.axis2.client.Options; import org.apache.axis2.java.security.SSLProtocolSocketFactory; @@ -505,6 +507,19 @@ public class DeviceMgtAPIUtils { return policyManagementService; } + public static TagManagementProviderService getTagManagementService() { + TagManagementProviderService tagManagementService; + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + tagManagementService = + (TagManagementProviderService) ctx.getOSGiService(TagManagementProviderService.class, null); + if (tagManagementService == null) { + String msg = "Tag Management service not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return tagManagementService; + } + public static PlatformConfigurationManagementService getPlatformConfigurationManagementService() { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PlatformConfigurationManagementService tenantConfigurationManagementService = diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 7cdb4ffa0e..1b0f7abb32 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -51,6 +51,7 @@ + @@ -103,6 +104,7 @@ + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java index b66773e84d..49e2809c25 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java @@ -158,7 +158,7 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -178,22 +178,22 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null,null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, null, DEFAULT_OWNERSHIP, null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, null, null, null, DEFAULT_OWNERSHIP, null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(TEST_DEVICE_NAME, TEST_DEVICE_TYPE, null, null, null, DEFAULT_OWNERSHIP, null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, true, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -307,7 +307,7 @@ public class DeviceManagementServiceImplTest { Mockito.when(deviceAccessAuthorizationService.isDeviceAdminUser()).thenReturn(true); deviceManagementService.getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null,null, DEFAULT_STATUS_LIST, 1, - 0, null, null, false, 10, 5); + 0, null, null, false, null, 10, 5); } @Test(description = "Testing get devices when user is the device admin") @@ -326,11 +326,11 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP - , null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); + , null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, null, DEFAULT_USERNAME, DEFAULT_ROLE, DEFAULT_OWNERSHIP - , null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, 10, 5); + , null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -353,7 +353,7 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, "newuser", null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, null, DEFAULT_STATUS_LIST, 0, 0, null, null, false, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode()); Mockito.reset(this.deviceAccessAuthorizationService); } @@ -375,17 +375,17 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, null, DEFAULT_STATUS_LIST, 0, 0, null, ifModifiedSince, false, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, null, DEFAULT_STATUS_LIST, 0, 0, null, ifModifiedSince, true, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.NOT_MODIFIED.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, null, DEFAULT_STATUS_LIST, 0, 0, null, "ErrorModifiedSince", - false, 10, 5); + false, null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -406,17 +406,17 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, null,DEFAULT_STATUS_LIST, 0, 0, since, null, false, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, null,DEFAULT_STATUS_LIST, 0, 0, since, null, true, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, null,DEFAULT_STATUS_LIST, 0, 0, "ErrorSince", null, false, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode()); } @@ -439,7 +439,7 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, - 10, 5); + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); Mockito.reset(this.deviceManagementProviderService); } @@ -461,8 +461,8 @@ public class DeviceManagementServiceImplTest { Response response = this.deviceManagementService .getDevices(null, TEST_DEVICE_TYPE, DEFAULT_USERNAME, null, DEFAULT_ROLE, DEFAULT_OWNERSHIP, - null, null, DEFAULT_STATUS_LIST, 1, 0, null, null, false, - 10, 5); + null, null, DEFAULT_STATUS_LIST, 1, 0,null, null, false, + null, 10, 5); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); Mockito.reset(this.deviceAccessAuthorizationService); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/EnrolmentInfo.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/EnrolmentInfo.java index 450fe0c5df..6a80c23703 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/EnrolmentInfo.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/EnrolmentInfo.java @@ -21,7 +21,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; -import java.math.BigInteger; +import java.util.List; @ApiModel(value = "EnrolmentInfo", description = "This class carries all information related to a devices enrollment" + " status.") @@ -61,6 +61,9 @@ public class EnrolmentInfo implements Serializable { @ApiModelProperty(name = "owner", value = "The device owner's name.", required = true ) private String owner; + @ApiModelProperty(name = "tags", value = "Tags associated with enrolment.", required = false ) + private List tags; + public EnrolmentInfo() { } @@ -134,6 +137,14 @@ public class EnrolmentInfo implements Serializable { this.owner = owner; } + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + @Override public boolean equals(Object obj) { if (obj instanceof EnrolmentInfo) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java index c4e01eb282..f6ba8d2fe7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/PaginationRequest.java @@ -52,6 +52,7 @@ public class PaginationRequest { private Map customProperty = new HashMap<>(); private Map property = new HashMap<>(); private List statusList = new ArrayList<>(); + private List tags = new ArrayList<>(); private OperationLogFilters operationLogFilters = new OperationLogFilters(); private List sortColumn = new ArrayList<>(); private int deviceTypeId; @@ -199,6 +200,14 @@ public class PaginationRequest { public List getSortColumn() { return sortColumn; } + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + /** * Convert SortColumns field parameter and splitting string into columnName and sortType * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/DeviceTag.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/DeviceTag.java new file mode 100644 index 0000000000..f60dbe2aed --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/DeviceTag.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.common.tag.mgt; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * DTO of DeviceTag object which is used to manage Device Tags. + */ + +@ApiModel(value = "DeviceTag", description = "This is used to manage device tags.") +public class DeviceTag { + + @ApiModelProperty(name = "enrolmentId", value = "Defines the device id.", required = true) + private int enrolmentId; + + @ApiModelProperty(name = "tagId", value = "Defines the tag id.", required = true) + private int tagId; + + public int getEnrolmentId() { + return enrolmentId; + } + + public void setEnrolmentId(int enrolmentId) { + this.enrolmentId = enrolmentId; + } + + public int getTagId() { + return tagId; + } + + public void setTagId(int tagId) { + this.tagId = tagId; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/Tag.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/Tag.java new file mode 100644 index 0000000000..a0546e5447 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/Tag.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.common.tag.mgt; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * DTO of Tag object which is used to manage Tags in devices. + */ + +@ApiModel(value = "Tag", description = "This is used to manage tags in devices.") +public class Tag { + + @ApiModelProperty(name = "id", value = "Defines the tag ID.", required = false) + private int id; + + @ApiModelProperty(name = "name", value = "Defines the tag name.", required = true) + private String name; + + @ApiModelProperty(name = "description", value = "Defines the tag description.", required = false) + private String description; + + public Tag(String name, String description) { + this.name = name; + this.description = description; + } + + public Tag() {} + + public Tag(int id, String name, String description) { + this.id = id; + this.name = name; + this.description = description; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "tag {" + + " id= " + id + + ", name= '" + name + '\'' + + ", description= '" + description + '\'' + + '}'; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagManagementException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagManagementException.java new file mode 100644 index 0000000000..f8c0755d65 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagManagementException.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.common.tag.mgt; + +/** + * Custom exception class to be used in TagManagement related functionalities. + */ +public class TagManagementException extends Exception { + + private static final long serialVersionUID = -8933146283800122660L; + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public TagManagementException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public TagManagementException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public TagManagementException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public TagManagementException() { + super(); + } + + public TagManagementException(Throwable cause) { + super(cause); + } + +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagMappingDTO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagMappingDTO.java new file mode 100644 index 0000000000..3bfe899cf2 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagMappingDTO.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.common.tag.mgt; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +/** + * DTO of TagMapping object which is used to manage Device Tags. + */ + +@ApiModel(value = "TagMappingDTO", description = "This is used to manage device tags.") +public class TagMappingDTO { + + @ApiModelProperty(name = "deviceIdentifiers", value = "Defines the device identifiers.", required = true) + private List deviceIdentifiers; + + @ApiModelProperty(name = "deviceType", value = "Defines the device type.", required = true) + private String deviceType; + + @ApiModelProperty(name = "tags", value = "Defines the tag.", required = true) + private List tags; + + public TagMappingDTO() {} + + public TagMappingDTO(List deviceIdentifiers, String deviceType, List tags) { + this.deviceIdentifiers = deviceIdentifiers; + this.deviceType = deviceType; + this.tags = tags; + } + + public List getDeviceIdentifiers() { + return deviceIdentifiers; + } + + public void setDeviceIdentifiers(List deviceIdentifiers) { + this.deviceIdentifiers = deviceIdentifiers; + } + + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagNotFoundException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagNotFoundException.java new file mode 100644 index 0000000000..f80e41c096 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/TagNotFoundException.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.common.tag.mgt; + +/** + * Custom exception class to be used in TagManagement related functionalities. + */ +public class TagNotFoundException extends Exception { + + private static final long serialVersionUID = -8933146283800122660L; + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public TagNotFoundException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public TagNotFoundException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public TagNotFoundException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public TagNotFoundException() { + super(); + } + + public TagNotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java index b7768f9c52..b4f5087c62 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java @@ -171,6 +171,22 @@ public class DeviceManagementDAOFactory { throw new IllegalStateException("Database engine has not initialized properly."); } + public static TagDAO getTagDAO() { + if (databaseEngine != null) { + switch (databaseEngine) { + case DeviceManagementConstants.DataBaseTypes.DB_TYPE_POSTGRESQL: + case DeviceManagementConstants.DataBaseTypes.DB_TYPE_ORACLE: + case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MSSQL: + case DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2: + case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MYSQL: + return new TagDAOImpl(); + default: + throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine); + } + } + throw new IllegalStateException("Database engine has not initialized properly."); + } + public static DeviceStatusDAO getDeviceStatusDAO() { return new DeviceStatusDAOImpl(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagDAO.java new file mode 100644 index 0000000000..7db392dec6 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagDAO.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.dao; + +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.DeviceTag; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.Tag; + +import java.util.List; + +/** + * This interface represents the key operations associated with persisting tag related information. + */ +public interface TagDAO { + + /** + * Add a new tag. + * + * @param tags to be added. + * @param tenantId of the tag. + * @throws TagManagementDAOException + */ + void addTags(List tags, int tenantId) throws TagManagementDAOException; + + /** + * Update an existing tag. + * + * @param tag to be updated. + * @param tenantId of the tag. + * @throws TagManagementDAOException + */ + void updateTag(Tag tag, int tenantId) throws TagManagementDAOException; + + /** + * Delete an existing tag. + * + * @param tagId of the tag. + * @param tenantId of the tag. + * @throws TagManagementDAOException + */ + void deleteTag(int tagId, int tenantId) throws TagManagementDAOException; + + /** + * Get a tag by id. + * + * @param tagId of the tag. + * @param tenantId of the tag. + * @return Tag object. + * @throws TagManagementDAOException + */ + Tag getTagById(int tagId, int tenantId) throws TagManagementDAOException; + + /** + * Method to retrieve a tag by its name. + * + * @param tagName - Name of the tag to be retrieved. + * @param tenantId - Tenant ID. + * @return Tag object retrieved from the database. + * @throws TagManagementDAOException if something goes wrong while retrieving the Tag. + */ + Tag getTagByName(String tagName, int tenantId) throws TagManagementDAOException; + + /** + * Get all tags for a tenant. + * + * @param tenantId of the tag. + * @return List of all tags. + * @throws TagManagementDAOException + */ + List getTags(int tenantId) throws TagManagementDAOException; + + /** + * Add a device tag mapping. + * + * @param deviceIdentifiers of the mapping. + * @param deviceType of the mapping. + * @param tagNames of the mapping. + * @param tenantId of the mapping. + * @throws TagManagementDAOException + */ + void addDeviceTagMapping(List deviceIdentifiers, String deviceType, List tagNames, int tenantId) + throws TagManagementDAOException; + + /** + * Delete a device tag mapping. + * + * @param deviceIdentifiers of the mapping. + * @param deviceType of the mapping. + * @param tagNames of the mapping. + * @param tenantId of the mapping. + * @throws TagManagementDAOException + */ + void deleteDeviceTagMapping(List deviceIdentifiers, String deviceType, List tagNames, int tenantId) + throws TagManagementDAOException; + + /** + * Get all device tags for a device. + * + * @param deviceId of the device. + * @param tenantId of the mapping. + * @return List of device tags. + * @throws TagManagementDAOException + */ + List getTagsForDevice(int deviceId, int tenantId) throws TagManagementDAOException; + + /** + * Get all devices for a tag. + * + * @param tagId of the tag. + * @param tenantId of the mapping. + * @return List of device tags. + * @throws TagManagementDAOException + */ + List getDevicesForTag(int tagId, int tenantId) throws TagManagementDAOException; +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagManagementDAOException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagManagementDAOException.java new file mode 100644 index 0000000000..39fa7f696b --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagManagementDAOException.java @@ -0,0 +1,70 @@ +package io.entgra.device.mgt.core.device.mgt.core.dao; + +/** + * Custom exception class for tag management data access related exceptions. + */ +public class TagManagementDAOException extends Exception { + + private static final long serialVersionUID = 2021891706072918864L; + private String message; + private boolean uniqueConstraintViolation; + + /** + * Constructs a new exception with the specified detail message and nested exception. + * + * @param message error message + * @param nestedException exception + */ + public TagManagementDAOException(String message, Exception nestedException) { + super(message, nestedException); + setErrorMessage(message); + } + + /** + * Constructs a new exception with the specified detail message and cause. + * + * @param message the detail message. + * @param cause the cause of this exception. + */ + public TagManagementDAOException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + /** + * Constructs a new exception with the specified detail message. + * + * @param message the detail message. + */ + public TagManagementDAOException(String message) { + super(message); + setErrorMessage(message); + } + + /** + * Constructs a new exception with the specified cause. + * + * @param cause the cause of this exception. + */ + public TagManagementDAOException(Throwable cause) { + super(cause); + } + + public TagManagementDAOException(String message, Throwable cause, boolean uniqueConstraintViolation) { + super(message, cause); + setErrorMessage(message); + this.uniqueConstraintViolation = uniqueConstraintViolation; + } + + public String getMessage() { + return message; + } + + public void setErrorMessage(String errorMessage) { + this.message = errorMessage; + } + + public boolean isUniqueConstraintViolation() { + return uniqueConstraintViolation; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 3b8aa18647..c080980ca9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -1030,6 +1030,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { boolean isStatusProvided = false; Date since = request.getSince(); boolean isSinceProvided = false; + List tagList = request.getTags(); + boolean isTagsProvided = false; try { Connection conn = getConnection(); @@ -1084,6 +1086,21 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { sql += buildStatusQuery(statusList); isStatusProvided = true; } + if (tagList != null && !tagList.isEmpty()) { + sql += " AND e.ID IN ( " + + "SELECT dtm.ENROLMENT_ID " + + "FROM DM_DEVICE_TAG_MAPPING dtm " + + "JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE t.NAME IN ("; + for (int i = 0; i < tagList.size(); i++) { + if (i > 0) { + sql += ", "; + } + sql += "?"; + } + sql += ") GROUP BY dtm.ENROLMENT_ID HAVING COUNT(DISTINCT t.NAME) = ? )"; + isTagsProvided = true; + } try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; @@ -1112,6 +1129,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { stmt.setString(paramIdx++, status); } } + if (isTagsProvided) { + for (String tag : tagList) { + stmt.setString(paramIdx++, tag); + } + stmt.setInt(paramIdx++, tagList.size()); + } try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { @@ -1300,6 +1323,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { boolean isStatusProvided = false; Date since = request.getSince(); boolean isSinceProvided = false; + List tagList = request.getTags(); + boolean isTagsProvided = false; try { Connection conn = getConnection(); @@ -1342,6 +1367,21 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { sql += buildStatusQuery(statusList); isStatusProvided = true; } + if (tagList != null && !tagList.isEmpty()) { + sql += " AND e.ID IN ( " + + "SELECT dtm.ENROLMENT_ID " + + "FROM DM_DEVICE_TAG_MAPPING dtm " + + "JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE t.NAME IN ("; + for (int i = 0; i < tagList.size(); i++) { + if (i > 0) { + sql += ", "; + } + sql += "?"; + } + sql += ") GROUP BY dtm.ENROLMENT_ID HAVING COUNT(DISTINCT t.NAME) = ? )"; + isTagsProvided = true; + } try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; @@ -1368,6 +1408,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { stmt.setString(paramIdx++, status); } } + if (isTagsProvided) { + for (String tag : tagList) { + stmt.setString(paramIdx++, tag); + } + stmt.setInt(paramIdx++, tagList.size()); + } try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TagDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TagDAOImpl.java new file mode 100644 index 0000000000..2a9813131b --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TagDAOImpl.java @@ -0,0 +1,349 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.dao.impl; + +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.DeviceTag; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.Tag; +import io.entgra.device.mgt.core.device.mgt.core.dao.*; + +import java.sql.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static io.entgra.device.mgt.core.device.mgt.core.dao.util.TagManagementDAOUtil.loadDeviceTagMapping; +import static io.entgra.device.mgt.core.device.mgt.core.dao.util.TagManagementDAOUtil.loadTag; +import static io.entgra.device.mgt.core.device.mgt.core.dao.util.TagManagementDAOUtil.cleanupResources; + +public class TagDAOImpl implements TagDAO { + + protected Connection getConnection() throws SQLException { + return DeviceManagementDAOFactory.getConnection(); + } + + @Override + public void addTags(List tags, int tenantId) throws TagManagementDAOException { + String query = "INSERT INTO DM_TAG (NAME, DESCRIPTION, TENANT_ID) " + + "SELECT ?, ?, ? " + + "WHERE NOT EXISTS ( " + + " SELECT 1 FROM DM_TAG " + + " WHERE NAME = ? AND TENANT_ID = ? " + + ")"; + Connection connection; + PreparedStatement preparedStatement = null; + + try { + connection = getConnection(); + preparedStatement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS); + for (Tag tag : tags) { + preparedStatement.setString(1, tag.getName()); + preparedStatement.setString(2, tag.getDescription()); + preparedStatement.setInt(3, tenantId); + preparedStatement.setString(4, tag.getName()); + preparedStatement.setInt(5, tenantId); + preparedStatement.addBatch(); + } + int[] updateCounts = preparedStatement.executeBatch(); + for (int count : updateCounts) { + if (count == PreparedStatement.EXECUTE_FAILED) { + throw new TagManagementDAOException("Error occurred while adding tags, adding some tags failed."); + } + } + } catch (SQLException e) { + throw new TagManagementDAOException("Error occurred while adding tags", e); + } finally { + cleanupResources(preparedStatement, null); + } + } + + @Override + public void updateTag(Tag tag, int tenantId) throws TagManagementDAOException { + String query = "UPDATE DM_TAG SET NAME = ?, DESCRIPTION = ? WHERE ID = ? AND TENANT_ID = ?"; + Connection connection; + PreparedStatement preparedStatement = null; + + try { + connection = getConnection(); + preparedStatement = connection.prepareStatement(query); + preparedStatement.setString(1, tag.getName()); + preparedStatement.setString(2, tag.getDescription()); + preparedStatement.setInt(3, tag.getId()); + preparedStatement.setInt(4, tenantId); + preparedStatement.executeUpdate(); + } catch (SQLException e) { + throw new TagManagementDAOException("Error occurred while updating tag", e); + } finally { + cleanupResources(preparedStatement, null); + } + } + + @Override + public void deleteTag(int tagId, int tenantId) throws TagManagementDAOException { + String query = "DELETE FROM DM_TAG WHERE ID = ? AND TENANT_ID = ?"; + Connection connection; + PreparedStatement preparedStatement = null; + + try { + connection = getConnection(); + preparedStatement = connection.prepareStatement(query); + preparedStatement.setInt(1, tagId); + preparedStatement.setInt(2, tenantId); + preparedStatement.executeUpdate(); + } catch (SQLException e) { + throw new TagManagementDAOException("Error occurred while deleting tag", e); + } finally { + cleanupResources(preparedStatement, null); + } + } + + @Override + public Tag getTagById(int tagId, int tenantId) throws TagManagementDAOException { + String query = "SELECT * FROM DM_TAG WHERE ID = ? AND TENANT_ID = ?"; + Connection connection; + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + Tag tag = null; + + try { + connection = getConnection(); + preparedStatement = connection.prepareStatement(query); + preparedStatement.setInt(1, tagId); + preparedStatement.setInt(2, tenantId); + + resultSet = preparedStatement.executeQuery(); + if (resultSet.next()) { + tag = loadTag(resultSet); + } + } catch (SQLException e) { + throw new TagManagementDAOException("Error occurred while retrieving tag", e); + } finally { + cleanupResources(preparedStatement, resultSet); + } + return tag; + } + + @Override + public Tag getTagByName(String tagName, int tenantId) throws TagManagementDAOException { + String query = "SELECT * FROM DM_TAG WHERE NAME = ? AND TENANT_ID = ?"; + Connection connection; + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + Tag tag = null; + + try { + connection = getConnection(); + preparedStatement = connection.prepareStatement(query); + preparedStatement.setString(1, tagName); + preparedStatement.setInt(2, tenantId); + + resultSet = preparedStatement.executeQuery(); + if (resultSet.next()) { + tag = loadTag(resultSet); + } + } catch (SQLException e) { + throw new TagManagementDAOException("Error occurred while retrieving tag with name: " + tagName, e); + } finally { + cleanupResources(preparedStatement, resultSet); + } + return tag; + } + + + @Override + public List getTags(int tenantId) throws TagManagementDAOException { + String query = "SELECT * FROM DM_TAG WHERE TENANT_ID = ?"; + Connection connection; + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + List tags = new ArrayList<>(); + + try { + connection = getConnection(); + preparedStatement = connection.prepareStatement(query); + preparedStatement.setInt(1, tenantId); + + resultSet = preparedStatement.executeQuery(); + while (resultSet.next()) { + Tag tag = loadTag(resultSet); + tags.add(tag); + } + } catch (SQLException e) { + throw new TagManagementDAOException("Error occurred while retrieving tags", e); + } finally { + cleanupResources(preparedStatement, resultSet); + } + return tags; + } + + @Override + public void addDeviceTagMapping(List deviceIdentifiers, String deviceType, List tagNames, int tenantId) throws TagManagementDAOException { + String deviceIdentifiersPlaceholders = String.join(", ", Collections.nCopies(deviceIdentifiers.size(), "?")); + String tagNamesPlaceholders = String.join(", ", Collections.nCopies(tagNames.size(), "?")); + + String query = String.format( + "INSERT INTO DM_DEVICE_TAG_MAPPING (ENROLMENT_ID, TAG_ID, TENANT_ID) " + + "SELECT e.ID, t.ID, ? " + + "FROM DM_ENROLMENT e " + + "JOIN DM_DEVICE d ON d.ID = e.DEVICE_ID " + + "JOIN DM_TAG t ON t.NAME IN (%s) " + + "WHERE d.DEVICE_IDENTIFICATION IN (%s) " + + "AND e.DEVICE_TYPE = ? " + + "AND e.STATUS != 'REMOVED' " + + "AND e.TENANT_ID = ? " + + "AND t.TENANT_ID = ? " + + "AND NOT EXISTS ( " + + " SELECT 1 " + + " FROM DM_DEVICE_TAG_MAPPING m " + + " WHERE m.ENROLMENT_ID = e.ID " + + " AND m.TAG_ID = t.ID " + + " AND m.TENANT_ID = ? " + + ")", + tagNamesPlaceholders, + deviceIdentifiersPlaceholders + ); + + Connection connection; + PreparedStatement preparedStatement = null; + try { + connection = getConnection(); + preparedStatement = connection.prepareStatement(query); + int paramIndex = 1; + preparedStatement.setInt(paramIndex++, tenantId); + for (String tagName : tagNames) { + preparedStatement.setString(paramIndex++, tagName); + } + for (String deviceIdentifier : deviceIdentifiers) { + preparedStatement.setString(paramIndex++, deviceIdentifier); + } + preparedStatement.setString(paramIndex++, deviceType); + preparedStatement.setInt(paramIndex++, tenantId); + preparedStatement.setInt(paramIndex++, tenantId); + preparedStatement.setInt(paramIndex, tenantId); + preparedStatement.executeUpdate(); + } catch (SQLIntegrityConstraintViolationException e) { + throw new TagManagementDAOException("Tag is already mapped to this device", e, true); + } catch (SQLException e) { + throw new TagManagementDAOException("Error occurred while adding device tag", e); + } finally { + cleanupResources(preparedStatement, null); + } + } + + @Override + public void deleteDeviceTagMapping(List deviceIdentifiers, String deviceType, List tagNames, int tenantId) throws TagManagementDAOException { + String deviceIdentifiersPlaceholders = String.join(", ", Collections.nCopies(deviceIdentifiers.size(), "?")); + String tagNamesPlaceholders = String.join(", ", Collections.nCopies(tagNames.size(), "?")); + + String query = String.format( + "DELETE FROM DM_DEVICE_TAG_MAPPING " + + "WHERE ENROLMENT_ID IN ( " + + " SELECT e.ID " + + " FROM DM_ENROLMENT e " + + " JOIN DM_DEVICE d ON d.ID = e.DEVICE_ID " + + " WHERE d.DEVICE_IDENTIFICATION IN (%s) " + + " AND e.DEVICE_TYPE = ? " + + " AND e.TENANT_ID = ? " + + " AND e.STATUS != 'REMOVED' " + + ") " + + "AND TAG_ID IN ( " + + " SELECT t.ID " + + " FROM DM_TAG t " + + " WHERE t.NAME IN (%s) " + + " AND t.TENANT_ID = ? " + + ")", + deviceIdentifiersPlaceholders, + tagNamesPlaceholders + ); + Connection connection; + PreparedStatement preparedStatement = null; + try { + connection = getConnection(); + preparedStatement = connection.prepareStatement(query); + int paramIndex = 1; + for (String deviceIdentifier : deviceIdentifiers) { + preparedStatement.setString(paramIndex++, deviceIdentifier); + } + preparedStatement.setString(paramIndex++, deviceType); + preparedStatement.setInt(paramIndex++, tenantId); + for (String tagName : tagNames) { + preparedStatement.setString(paramIndex++, tagName); + } + preparedStatement.setInt(paramIndex, tenantId); + preparedStatement.executeUpdate(); + } catch (SQLException e) { + throw new TagManagementDAOException("Error occurred while deleting device tag mapping", e); + } finally { + cleanupResources(preparedStatement, null); + } + } + + @Override + public List getTagsForDevice(int deviceId, int tenantId) throws TagManagementDAOException { + String query = "SELECT * FROM DM_DEVICE_TAG_MAPPING WHERE DEVICE_ID = ? AND TENANT_ID = ?"; + Connection connection; + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + List deviceTags = new ArrayList<>(); + + try { + connection = getConnection(); + preparedStatement = connection.prepareStatement(query); + preparedStatement.setInt(1, deviceId); + preparedStatement.setInt(2, tenantId); + + resultSet = preparedStatement.executeQuery(); + while (resultSet.next()) { + DeviceTag deviceTag = loadDeviceTagMapping(resultSet); + deviceTags.add(deviceTag); + } + } catch (SQLException e) { + throw new TagManagementDAOException("Error occurred while retrieving device tags", e); + } finally { + cleanupResources(preparedStatement, resultSet); + } + return deviceTags; + } + + @Override + public List getDevicesForTag(int tagId, int tenantId) throws TagManagementDAOException { + String query = "SELECT * FROM DM_DEVICE_TAG_MAPPING WHERE TAG_ID = ? AND TENANT_ID = ?"; + Connection connection; + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + List deviceTags = new ArrayList<>(); + + try { + connection = getConnection(); + preparedStatement = connection.prepareStatement(query); + preparedStatement.setInt(1, tagId); + preparedStatement.setInt(2, tenantId); + + resultSet = preparedStatement.executeQuery(); + while (resultSet.next()) { + DeviceTag deviceTag = loadDeviceTagMapping(resultSet); + deviceTags.add(deviceTag); + } + } catch (SQLException e) { + throw new TagManagementDAOException("Error occurred while retrieving devices for tag", e); + } finally { + cleanupResources(preparedStatement, resultSet); + } + return deviceTags; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 5710e0181f..29275128bf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -71,6 +71,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isSinceProvided = false; String serial = request.getSerialNumber(); boolean isSerialProvided = false; + List tagList = request.getTags(); + boolean isTagsProvided = false; try { Connection conn = getConnection(); @@ -86,7 +88,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "e.IS_TRANSFERRED, " + "e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + + "e.ID AS ENROLMENT_ID, " + + "( SELECT GROUP_CONCAT(t.NAME ORDER BY t.NAME SEPARATOR ', ') " + + "FROM DM_DEVICE_TAG_MAPPING dtm JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE dtm.ENROLMENT_ID = e.ID ) AS TAGS " + "FROM DM_ENROLMENT e, " + "(SELECT d.ID, " + "d.DESCRIPTION, " + @@ -162,7 +167,27 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { sql += buildStatusQuery(statusList); isStatusProvided = true; } - sql = sql + " LIMIT ? OFFSET ?"; + sql += " AND e.ID IN (" + + "SELECT e.ID " + + "FROM DM_ENROLMENT e " + + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID "; + + if (tagList != null && !tagList.isEmpty()) { + sql += " WHERE t.NAME IN ("; + for (int i = 0; i < tagList.size(); i++) { + if (i > 0) { + sql += ", "; + } + sql += "?"; + } + sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ? "; + isTagsProvided = true; + } else { + sql += " GROUP BY e.ID "; + } + sql += ") "; + sql += " LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIdx = 1; @@ -198,13 +223,19 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, status); } } + if (isTagsProvided) { + for (String tag : tagList) { + stmt.setString(paramIdx++, tag); + } + stmt.setInt(paramIdx++, tagList.size()); + } stmt.setInt(paramIdx++, request.getRowCount()); stmt.setInt(paramIdx, request.getStartIndex()); try (ResultSet rs = stmt.executeQuery()) { devices = new ArrayList<>(); while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); + Device device = DeviceManagementDAOUtil.loadDevice(rs, true); devices.add(device); } return devices; @@ -667,6 +698,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isSinceProvided = false; String serial = request.getSerialNumber(); boolean isSerialProvided = false; + List tagList = request.getTags(); + boolean isTagsProvided = false; try { Connection conn = getConnection(); @@ -682,7 +715,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "e.IS_TRANSFERRED, " + "e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + + "e.ID AS ENROLMENT_ID, " + + "( SELECT GROUP_CONCAT(t.NAME ORDER BY t.NAME SEPARATOR ', ') " + + "FROM DM_DEVICE_TAG_MAPPING dtm JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE dtm.ENROLMENT_ID = e.ID ) AS TAGS " + "FROM DM_ENROLMENT e, " + "(SELECT gd.DEVICE_ID, " + "gd.DESCRIPTION, " + @@ -739,7 +775,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { //Filter Group with serial number or any Custom Property in DM_DEVICE_INFO if (serial != null || !request.getCustomProperty().isEmpty()) { if (serial != null) { - sql += "AND EXISTS (" + + sql += " AND EXISTS (" + "SELECT VALUE_FIELD " + "FROM DM_DEVICE_INFO di " + "WHERE di.DEVICE_ID = d1.DEVICE_ID " + @@ -749,7 +785,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } if (!request.getCustomProperty().isEmpty()) { for (Map.Entry entry : request.getCustomProperty().entrySet()) { - sql += "AND EXISTS (" + + sql += " AND EXISTS (" + "SELECT VALUE_FIELD " + "FROM DM_DEVICE_INFO di2 " + "WHERE di2.DEVICE_ID = d1.DEVICE_ID " + @@ -758,6 +794,24 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { } } } + if (tagList != null && !tagList.isEmpty()) { + sql += " AND e.ID IN (" + + "SELECT e.ID " + + "FROM DM_ENROLMENT e " + + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE t.NAME IN ("; + for (int i = 0; i < tagList.size(); i++) { + if (i > 0) { + sql += ", "; + } + sql += "?"; + } + sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ? ) "; + isTagsProvided = true; + } else { + sql += " GROUP BY e.ID "; + } sql = sql + " LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -795,13 +849,19 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt.setString(paramIdx++, "%" + entry.getValue() + "%"); } } + if (isTagsProvided) { + for (String tag : tagList) { + stmt.setString(paramIdx++, tag); + } + stmt.setInt(paramIdx++, tagList.size()); + } stmt.setInt(paramIdx++, request.getRowCount()); stmt.setInt(paramIdx, request.getStartIndex()); try (ResultSet rs = stmt.executeQuery()) { devices = new ArrayList<>(); while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); + Device device = DeviceManagementDAOUtil.loadDevice(rs, true); devices.add(device); } return devices; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index 0f502cf874..923189dea3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -68,6 +68,8 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { boolean isSinceProvided = false; String serial = request.getSerialNumber(); boolean isSerialProvided = false; + List tagList = request.getTags(); + boolean isTagsProvided = false; try { conn = getConnection(); @@ -82,7 +84,10 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { "e.IS_TRANSFERRED, " + "e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + + "e.ID AS ENROLMENT_ID, " + + "(SELECT STRING_AGG(t.NAME, ', ') FROM DM_DEVICE_TAG_MAPPING dtm " + + "JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE dtm.ENROLMENT_ID = e.ID) AS TAGS " + "FROM DM_ENROLMENT e, " + "(SELECT d.ID, " + "d.DESCRIPTION, " + @@ -155,6 +160,19 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { sql += buildStatusQuery(statusList); isStatusProvided = true; } + if (tagList != null && !tagList.isEmpty()) { + sql += " AND e.ID IN (SELECT e.ID FROM DM_ENROLMENT e " + + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID WHERE t.NAME IN ("; + for (int i = 0; i < tagList.size(); i++) { + if (i > 0) { + sql += ", "; + } + sql += "?"; + } + sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ? ) "; + isTagsProvided = true; + } sql = sql + " LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -188,6 +206,12 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { stmt.setString(paramIdx++, status); } } + if (isTagsProvided) { + for (String tag : tagList) { + stmt.setString(paramIdx++, tag); + } + stmt.setInt(paramIdx++, tagList.size()); + } stmt.setInt(paramIdx++, request.getRowCount()); stmt.setInt(paramIdx, request.getStartIndex()); @@ -466,6 +490,8 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { boolean isSinceProvided = false; String serial = request.getSerialNumber(); boolean isSerialProvided = false; + List tagList = request.getTags(); + boolean isTagsProvided = false; try { conn = getConnection(); @@ -480,7 +506,10 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { "e.IS_TRANSFERRED, " + "e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + + "e.ID AS ENROLMENT_ID, " + + "(SELECT STRING_AGG(t.NAME, ', ') FROM DM_DEVICE_TAG_MAPPING dtm " + + "JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE dtm.ENROLMENT_ID = e.ID) AS TAGS " + "FROM DM_ENROLMENT e, " + "(SELECT gd.DEVICE_ID, " + "gd.DESCRIPTION, " + @@ -555,6 +584,24 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { } } } + if (tagList != null && !tagList.isEmpty()) { + sql += " AND e.ID IN (" + + "SELECT e.ID " + + "FROM DM_ENROLMENT e " + + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE t.NAME IN ("; + for (int i = 0; i < tagList.size(); i++) { + if (i > 0) { + sql += ", "; + } + sql += "?"; + } + sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ? ) "; + isTagsProvided = true; + } else { + sql += " GROUP BY e.ID "; + } sql = sql + " LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -592,13 +639,19 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { stmt.setString(paramIdx++, "%" + entry.getValue() + "%"); } } + if (isTagsProvided) { + for (String tag : tagList) { + stmt.setString(paramIdx++, tag); + } + stmt.setInt(paramIdx++, tagList.size()); + } stmt.setInt(paramIdx++, request.getRowCount()); stmt.setInt(paramIdx, request.getStartIndex()); try (ResultSet rs = stmt.executeQuery()) { devices = new ArrayList<>(); while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); + Device device = DeviceManagementDAOUtil.loadDevice(rs, true); devices.add(device); } return devices; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 7de242ead9..47823054d8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -69,6 +69,8 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { boolean isSinceProvided = false; String serial = request.getSerialNumber(); boolean isSerialProvided = false; + List tagList = request.getTags(); + boolean isTagsProvided = false; try { conn = getConnection(); @@ -83,7 +85,10 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { "e.IS_TRANSFERRED, " + "e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + + "e.ID AS ENROLMENT_ID, " + + "(SELECT STRING_AGG(t.NAME, ', ') FROM DM_DEVICE_TAG_MAPPING dtm " + + "JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE dtm.ENROLMENT_ID = e.ID) AS TAGS " + "FROM DM_ENROLMENT e, " + "(SELECT d.ID, " + "d.DESCRIPTION, " + @@ -161,6 +166,19 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { sql += buildStatusQuery(statusList); isStatusProvided = true; } + if (tagList!= null && !tagList.isEmpty()) { + sql += " AND e.ID IN (SELECT e.ID FROM DM_ENROLMENT e " + + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID WHERE t.NAME IN ("; + for (int i = 0; i < tagList.size(); i++) { + if (i > 0) { + sql += ", "; + } + sql += "?"; + } + sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ? ) "; + isTagsProvided = true; + } sql = sql + " ORDER BY ENROLMENT_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -197,13 +215,19 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { stmt.setString(paramIdx++, status); } } + if (isTagsProvided) { + for (String tag : tagList) { + stmt.setString(paramIdx++, tag); + } + stmt.setInt(paramIdx++, tagList.size()); + } stmt.setInt(paramIdx++, request.getStartIndex()); stmt.setInt(paramIdx, request.getRowCount()); try (ResultSet rs = stmt.executeQuery()) { devices = new ArrayList<>(); while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); + Device device = DeviceManagementDAOUtil.loadDevice(rs, true); devices.add(device); } return devices; @@ -485,6 +509,8 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { boolean isSinceProvided = false; String serial = request.getSerialNumber(); boolean isSerialProvided = false; + List tagList = request.getTags(); + boolean isTagsProvided = false; try { conn = getConnection(); @@ -499,7 +525,10 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { "e.IS_TRANSFERRED, " + "e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, " + - "e.ID AS ENROLMENT_ID " + + "e.ID AS ENROLMENT_ID, " + + "(SELECT STRING_AGG(t.NAME, ', ') FROM DM_DEVICE_TAG_MAPPING dtm " + + "JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE dtm.ENROLMENT_ID = e.ID) AS TAGS " + "FROM DM_ENROLMENT e, " + "(SELECT gd.DEVICE_ID, " + "gd.DESCRIPTION, " + @@ -574,6 +603,24 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { } } } + + if (tagList != null && !tagList.isEmpty()) { + sql += " AND e.ID IN (" + + "SELECT e.ID FROM DM_ENROLMENT e " + + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + + "WHERE t.NAME IN ("; + for (int i = 0; i < tagList.size(); i++) { + if (i > 0) { + sql += ", "; + } + sql += "?"; + } + sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ?)"; + isTagsProvided = true; + } else { + sql += " GROUP BY e.ID "; + } sql = sql + " ORDER BY ENROLMENT_ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -611,13 +658,19 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { stmt.setString(paramIdx++, "%" + entry.getValue() + "%"); } } + if (isTagsProvided) { + for (String tag : tagList) { + stmt.setString(paramIdx++, tag); + } + stmt.setInt(paramIdx++, tagList.size()); + } stmt.setInt(paramIdx++, request.getStartIndex()); stmt.setInt(paramIdx, request.getRowCount()); try (ResultSet rs = stmt.executeQuery()) { devices = new ArrayList<>(); while (rs.next()) { - Device device = DeviceManagementDAOUtil.loadDevice(rs); + Device device = DeviceManagementDAOUtil.loadDevice(rs, true); devices.add(device); } return devices; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java index a8529398c7..6157f174fc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/DeviceManagementDAOUtil.java @@ -26,16 +26,13 @@ import java.util.Date; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.el.lang.ELSupport; import org.wso2.carbon.context.CarbonContext; import io.entgra.device.mgt.core.device.mgt.common.Device; -import io.entgra.device.mgt.core.device.mgt.common.DeviceBilling; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocationHistorySnapshot; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceMonitoringData; -import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceStatus; import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; @@ -143,6 +140,10 @@ public final class DeviceManagementDAOUtil { }*/ public static EnrolmentInfo loadEnrolment(ResultSet rs) throws SQLException { + return loadEnrolment(rs, false); + } + + public static EnrolmentInfo loadEnrolment(ResultSet rs, boolean isTagsProvided) throws SQLException { EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); enrolmentInfo.setId(rs.getInt("ENROLMENT_ID")); enrolmentInfo.setOwner(rs.getString("OWNER")); @@ -151,6 +152,16 @@ public final class DeviceManagementDAOUtil { enrolmentInfo.setDateOfEnrolment(rs.getTimestamp("DATE_OF_ENROLMENT").getTime()); enrolmentInfo.setDateOfLastUpdate(rs.getTimestamp("DATE_OF_LAST_UPDATE").getTime()); enrolmentInfo.setStatus(EnrolmentInfo.Status.valueOf(rs.getString("STATUS"))); + if (isTagsProvided) { + List tags = new ArrayList<>(); + String tagColumn = rs.getString("TAGS"); + if (tagColumn != null) { + for (String tag : tagColumn.split(",")) { + tags.add(tag.trim()); + } + } + enrolmentInfo.setTags(tags); + } return enrolmentInfo; } @@ -224,6 +235,10 @@ public final class DeviceManagementDAOUtil { } public static Device loadDevice(ResultSet rs) throws SQLException { + return loadDevice(rs, false); + } + + public static Device loadDevice(ResultSet rs, boolean isTagsProvided) throws SQLException { Device device = new Device(); device.setId(rs.getInt("DEVICE_ID")); device.setName(rs.getString("DEVICE_NAME")); @@ -231,7 +246,7 @@ public final class DeviceManagementDAOUtil { device.setType(rs.getString("DEVICE_TYPE")); device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION")); device.setLastUpdatedTimeStamp(rs.getTimestamp("LAST_UPDATED_TIMESTAMP").getTime()); - device.setEnrolmentInfo(loadEnrolment(rs)); + device.setEnrolmentInfo(loadEnrolment(rs, isTagsProvided)); return device; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/TagManagementDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/TagManagementDAOUtil.java new file mode 100644 index 0000000000..71b79e013f --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/util/TagManagementDAOUtil.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.dao.util; + +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.DeviceTag; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.Tag; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.naming.InitialContext; +import javax.sql.DataSource; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Hashtable; + +/** + * This class represents utilities required to work with tag management data + */ +public final class TagManagementDAOUtil { + + private static final Log log = LogFactory.getLog(TagManagementDAOUtil.class); + + /** + * Cleanup resources used to transaction + * + * @param stmt Prepared statement used + * @param rs Obtained results set + */ + public static void cleanupResources(PreparedStatement 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); + } + } + } + + /** + * Lookup datasource using name and jndi properties + * + * @param dataSourceName Name of datasource to lookup + * @param jndiProperties Hash table of JNDI Properties + * @return datasource looked + */ + 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) { + throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e); + } + } + + public static Tag loadTag(ResultSet resultSet) throws SQLException { + Tag tag = new Tag(); + tag.setId(resultSet.getInt("ID")); + tag.setName(resultSet.getString("NAME")); + tag.setDescription(resultSet.getString("DESCRIPTION")); + return tag; + } + + public static DeviceTag loadDeviceTagMapping(ResultSet resultSet) throws SQLException { + DeviceTag deviceTag = new DeviceTag(); + deviceTag.setEnrolmentId(resultSet.getInt("ENROLMENT_ID")); + deviceTag.setTagId(resultSet.getInt("TAG_ID")); + return deviceTag; + } + +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java index b2e1529f40..669e60c593 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -21,6 +21,7 @@ import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuth import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import io.entgra.device.mgt.core.device.mgt.core.authorization.GroupAccessAuthorizationServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.DeviceStatusManagementServiceImpl; +import io.entgra.device.mgt.core.device.mgt.core.service.*; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -349,6 +350,10 @@ public class DeviceManagementServiceComponent { ReportManagementService reportManagementService = new ReportManagementServiceImpl(); bundleContext.registerService(ReportManagementService.class.getName(), reportManagementService, null); + /* Registering Tag Management Service */ + TagManagementProviderService tagManagementProviderService = new TagManagementProviderServiceImpl(); + bundleContext.registerService(TagManagementProviderService.class.getName(), tagManagementProviderService, null); + /* Registering DeviceAccessAuthorization Service */ DeviceAccessAuthorizationService deviceAccessAuthorizationService = new DeviceAccessAuthorizationServiceImpl(); DeviceManagementDataHolder.getInstance().setDeviceAccessAuthorizationService(deviceAccessAuthorizationService); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 851153de16..7e3f835ab0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -22,7 +22,7 @@ import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import io.entgra.device.mgt.core.device.mgt.common.exceptions.ConflictException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; -import io.entgra.device.mgt.core.device.mgt.core.dao.TenantDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.*; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO; import io.entgra.device.mgt.core.device.mgt.core.dto.OwnerWithDeviceDTO; import io.entgra.device.mgt.core.device.mgt.core.dto.OperationDTO; @@ -119,13 +119,6 @@ import io.entgra.device.mgt.core.device.mgt.core.cache.impl.DeviceCacheManagerIm import io.entgra.device.mgt.core.device.mgt.core.common.Constants; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; import io.entgra.device.mgt.core.device.mgt.core.config.DeviceManagementConfig; -import io.entgra.device.mgt.core.device.mgt.core.dao.ApplicationDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceStatusDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceTypeDAO; -import io.entgra.device.mgt.core.device.mgt.core.dao.EnrollmentDAO; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationDAO; import io.entgra.device.mgt.core.device.mgt.core.dao.util.DeviceManagementDAOUtil; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.DeviceDetailsMgtException; @@ -185,6 +178,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv private MetadataDAO metadataDAO; private final DeviceStatusDAO deviceStatusDAO; private final TenantDAO tenantDao; + private final TagDAO tagDAO; int count = 0; public DeviceManagementProviderServiceImpl() { @@ -197,6 +191,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv this.metadataDAO = MetadataManagementDAOFactory.getMetadataDAO(); this.deviceStatusDAO = DeviceManagementDAOFactory.getDeviceStatusDAO(); this.tenantDao = DeviceManagementDAOFactory.getTenantDAO(); + this.tagDAO = DeviceManagementDAOFactory.getTagDAO(); /* Registering a listener to retrieve events when some device management service plugin is installed after * the component is done getting initialized */ diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderService.java new file mode 100644 index 0000000000..6fccdc5701 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderService.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.service; + +import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.*; + +import java.util.List; + +/** + * Defines the contract of TagManagementService. + */ +public interface TagManagementProviderService { + + /** + * Method to add a tag to the database. + * + * @param tag - Tag to be added to the database. + * @throws TagManagementException if something goes wrong while adding the Tag. + */ + void addTags(List tag) throws TagManagementException, BadRequestException; + + /** + * Method to fetch all tags. + * + * @return List of all Tags. + * @throws TagManagementException if something goes wrong while fetching the Tags. + */ + List getAllTags() throws TagManagementException; + + /** + * Method to update a tag in the database. + * + * @param tag - Tag to be updated in the database. + * @throws TagManagementException if something goes wrong while updating the Tag. + */ + void updateTag(Tag tag) throws TagManagementException, TagNotFoundException, BadRequestException; + + /** + * Method to delete a tag from the database. + * + * @param tagId - ID of the tag to be deleted. + * @throws TagManagementException if something goes wrong while deleting the Tag. + */ + void deleteTag(int tagId) throws TagManagementException, TagNotFoundException; + + /** + * Method to retrieve a tag by its ID. + * + * @param tagId - ID of the tag to be retrieved. + * @return Tag object retrieved from the database. + * @throws TagManagementException if something goes wrong while retrieving the Tag. + */ + Tag getTagById(int tagId) throws TagManagementException, TagNotFoundException; + + /** + * Method to retrieve a tag by its name. + * + * @param tagName - Name of the tag to be retrieved. + * @return Tag object retrieved from the database. + * @throws TagManagementException if something goes wrong while retrieving the Tag. + * @throws TagNotFoundException if the Tag with the given name is not found. + */ + Tag getTagByName(String tagName) throws TagManagementException, TagNotFoundException, BadRequestException; + + /** + * Method to add a device-tag mapping. + * + * @param tagMappingDto - TagMappingDTO object containing mapping information. + * @throws TagManagementException if something goes wrong while adding the device-tag mapping. + */ + void addDeviceTagMapping(TagMappingDTO tagMappingDto) throws TagManagementException, BadRequestException; + + /** + * Method to delete a device-tag mapping. + * + * @param tagMappingDTO - TagMappingDTO object containing mapping information. + * @throws TagManagementException if something goes wrong while deleting the device-tag mapping. + */ + void deleteDeviceTagMapping(TagMappingDTO tagMappingDTO) throws TagManagementException, BadRequestException; +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java new file mode 100644 index 0000000000..d7c5b1f112 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.service; + +import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.*; +import io.entgra.device.mgt.core.device.mgt.core.dao.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class TagManagementProviderServiceImpl implements TagManagementProviderService { + private static final Log log = LogFactory.getLog(TagManagementProviderServiceImpl.class); + + private final TagDAO tagDAO; + + public TagManagementProviderServiceImpl() { + this.tagDAO = DeviceManagementDAOFactory.getTagDAO(); + } + + @Override + public void addTags(List tags) throws TagManagementException, BadRequestException { + if (tags == null || tags.isEmpty()) { + String msg = "Received incomplete data for tags"; + log.error(msg); + throw new BadRequestException(msg); + } + try { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceManagementDAOFactory.beginTransaction(); + for (Tag tag : tags) { + if (tag.getName() == null) { + throw new BadRequestException("Tag name cannot be null"); + } + } + if (log.isDebugEnabled()) { + log.debug("Starting creating Tags."); + } + tagDAO.addTags(tags, tenantId); + DeviceManagementDAOFactory.commitTransaction(); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new TagManagementException(msg, e); + } catch (TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while adding tags to database."; + log.error(msg, e); + throw new TagManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in creating tags."; + log.error(msg, e); + throw new TagManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Override + public List getAllTags() throws TagManagementException { + try { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceManagementDAOFactory.beginTransaction(); + return tagDAO.getTags(tenantId); + } catch (TransactionManagementException e) { + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + throw new TagManagementException(msg, e); + } catch (TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while retrieving tags."; + log.error(msg, e); + throw new TagManagementException(msg, e); + } catch (Exception e) { + String msg = "Error occurred in retrieving tags."; + log.error(msg, e); + throw new TagManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Override + public Tag getTagById(int tagId) throws TagManagementException, TagNotFoundException { + try { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceManagementDAOFactory.beginTransaction(); + Tag tag = tagDAO.getTagById(tagId, tenantId); + DeviceManagementDAOFactory.commitTransaction(); + if (tag == null) { + String msg = "Tag with ID " + tagId + " not found."; + throw new TagNotFoundException(msg); + } + return tag; + } catch (TransactionManagementException | TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while retrieving the tag with ID: " + tagId; + log.error(msg, e); + throw new TagManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Override + public Tag getTagByName(String tagName) throws TagManagementException, TagNotFoundException, BadRequestException { + if (tagName == null || tagName.trim().isEmpty()) { + String msg = "Tag name cannot be null or empty."; + log.error(msg); + throw new BadRequestException(msg); + } + + try { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceManagementDAOFactory.beginTransaction(); + Tag tag = tagDAO.getTagByName(tagName, tenantId); + DeviceManagementDAOFactory.commitTransaction(); + + if (tag == null) { + String msg = "Tag with name " + tagName + " not found."; + throw new TagNotFoundException(msg); + } + + return tag; + } catch (TransactionManagementException | TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while retrieving the tag with name: " + tagName; + log.error(msg, e); + throw new TagManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + + @Override + public void updateTag(Tag tag) throws TagManagementException, TagNotFoundException, BadRequestException { + if (tag == null || tag.getName() == null) { + String msg = "Received incomplete data for tag update"; + log.error(msg); + throw new BadRequestException(msg); + } + try { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceManagementDAOFactory.openConnection(); + Tag existingTag = tagDAO.getTagById(tag.getId(), tenantId); + if (existingTag == null) { + String msg = "Tag with ID: " + tag.getId() + " does not exist."; + log.error(msg); + throw new TagNotFoundException(msg); + } + tagDAO.updateTag(tag, tenantId); + } catch (TagManagementDAOException | SQLException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while updating the tag with ID: " + tag.getId(); + log.error(msg, e); + throw new TagManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + + @Override + public void deleteTag(int tagId) throws TagManagementException, TagNotFoundException { + try { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceManagementDAOFactory.openConnection(); + Tag existingTag = tagDAO.getTagById(tagId, tenantId); + if (existingTag == null) { + String msg = "Tag with ID: " + tagId + " does not exist."; + log.error(msg); + throw new TagNotFoundException(msg); + } + tagDAO.deleteTag(tagId, tenantId); + DeviceManagementDAOFactory.commitTransaction(); + } catch (TagManagementDAOException | SQLException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while deleting the tag with ID: " + tagId; + log.error(msg, e); + throw new TagManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Override + public void addDeviceTagMapping(TagMappingDTO tagMappingDto) throws TagManagementException, BadRequestException { + if (tagMappingDto == null || tagMappingDto.getDeviceIdentifiers() == null || tagMappingDto.getTags() == null + || tagMappingDto.getDeviceType() == null) { + String msg = "Received incomplete data for device tag mapping."; + log.error(msg); + throw new BadRequestException(msg); + } + try { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceManagementDAOFactory.openConnection(); + + List tagList = new ArrayList<>(); + for (String tagName : tagMappingDto.getTags()) { + Tag tag = new Tag(); + tag.setName(tagName); + tagList.add(tag); + } + + tagDAO.addTags(tagList, tenantId); + tagDAO.addDeviceTagMapping(tagMappingDto.getDeviceIdentifiers(), tagMappingDto.getDeviceType(), + tagMappingDto.getTags(), tenantId); + + } catch (TagManagementDAOException e) { + if (e.isUniqueConstraintViolation()) { + String msg = "Tag is already mapped to this device."; + log.info(msg, e); + throw new BadRequestException(msg); + } else { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while adding device tag mapping."; + log.error(msg, e); + throw new TagManagementException(msg, e); + } + } catch (SQLException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while adding device tag mapping."; + log.error(msg, e); + throw new TagManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Override + public void deleteDeviceTagMapping(TagMappingDTO tagMappingDto) throws TagManagementException, BadRequestException { + if (tagMappingDto == null || tagMappingDto.getDeviceIdentifiers() == null || tagMappingDto.getTags() == null + || tagMappingDto.getDeviceType() == null) { + String msg = "Received incomplete data for device tag mapping."; + log.error(msg); + throw new BadRequestException(msg); + } + try { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceManagementDAOFactory.openConnection(); + tagDAO.deleteDeviceTagMapping(tagMappingDto.getDeviceIdentifiers(), tagMappingDto.getDeviceType(), + tagMappingDto.getTags(), tenantId); + DeviceManagementDAOFactory.commitTransaction(); + } catch (TagManagementDAOException | SQLException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while deleting device tag mappings."; + log.error(msg, e); + throw new TagManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java index 4d8e11064d..b477cd2a53 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.Tag; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; @@ -100,6 +101,29 @@ public class TestUtils { return group; } + public static Tag getTag1() { + return new Tag(1,"tag1", "This is tag1"); + } + + public static Tag getTag2() { + return new Tag( "tag2", "This is tag2"); + } + public static Tag getTag3() { + return new Tag("tag3", "This is tag3"); + } + + public static List createTagList1() { + List tagList = new ArrayList<>(); + tagList.add(new Tag(null, "This is tag1")); + return tagList; + } + + public static List createTagList2() { + List tagList = new ArrayList<>(); + tagList.add(getTag1()); + tagList.add(getTag2()); + return tagList; + } public static GroupPaginationRequest createPaginationRequest(){ GroupPaginationRequest request = new GroupPaginationRequest(0, 5); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java index 322b2b449d..cffbb3389a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceData; import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup; import io.entgra.device.mgt.core.device.mgt.common.notification.mgt.Notification; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.Tag; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType; import java.util.ArrayList; @@ -34,6 +35,7 @@ import java.util.Date; import java.util.List; import java.util.Properties; import java.util.Calendar; +import java.util.Arrays; public class TestDataHolder { @@ -46,6 +48,7 @@ public class TestDataHolder { public static final String OPERATION_CONFIG = "TEST-OPERATION-"; public static Device initialTestDevice; public static DeviceType initialTestDeviceType; + public static List TAGS = Arrays.asList("tag1", "tag2", "tag3"); public static Date getTimeBefore(int minutes) { Calendar calendar = Calendar.getInstance(); @@ -56,7 +59,7 @@ public class TestDataHolder { public static Device generateDummyDeviceData(String deviceType) { Device device = new Device(); device.setEnrolmentInfo(generateEnrollmentInfo(new Date().getTime(), new Date().getTime(), OWNER, EnrolmentInfo - .OwnerShip.BYOD, EnrolmentInfo.Status.ACTIVE)); + .OwnerShip.BYOD, EnrolmentInfo.Status.ACTIVE, TAGS)); device.setDescription("Test Description"); device.setDeviceIdentifier(initialDeviceIdentifier); device.setType(deviceType); @@ -65,16 +68,26 @@ public class TestDataHolder { public static EnrolmentInfo generateEnrollmentInfo(long dateOfEnrollment, long dateOfLastUpdate, String owner, EnrolmentInfo.OwnerShip ownership, - EnrolmentInfo.Status status) { + EnrolmentInfo.Status status, List tags) { EnrolmentInfo enrolmentInfo = new EnrolmentInfo(); enrolmentInfo.setDateOfEnrolment(dateOfEnrollment); enrolmentInfo.setDateOfLastUpdate(dateOfLastUpdate); enrolmentInfo.setOwner(owner); enrolmentInfo.setOwnership(ownership); enrolmentInfo.setStatus(status); + enrolmentInfo.setTags(tags); return enrolmentInfo; } + public static List getTagList() { + List tagList = new ArrayList<>(); + for (int i = 1; i <= 3; i++) { + Tag tag = new Tag("tag" + i, "This is tag" + i); + tagList.add(tag); + } + return tagList; + } + public static DeviceInfo generateDummyDeviceInfo() { DeviceInfo deviceInfo = new DeviceInfo(); deviceInfo.setDeviceModel("DUMMY_MODEL"); @@ -141,8 +154,12 @@ public class TestDataHolder { public static Device generateDummyDeviceData(DeviceIdentifier deviceIdentifier) { Device device = new Device(); + List tags = new ArrayList<>(); + tags.add("tag1"); + tags.add("tag2"); + tags.add("tag3"); device.setEnrolmentInfo(generateEnrollmentInfo(new Date().getTime(), new Date().getTime(), OWNER, EnrolmentInfo - .OwnerShip.BYOD, EnrolmentInfo.Status.ACTIVE)); + .OwnerShip.BYOD, EnrolmentInfo.Status.ACTIVE, tags)); device.setDescription("Test Description"); device.setDeviceIdentifier(deviceIdentifier.getId()); device.setType(deviceIdentifier.getType()); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java index a8bc1b6924..db51133e2e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/DevicePersistTests.java @@ -47,6 +47,7 @@ import java.util.List; public class DevicePersistTests extends BaseDeviceManagementTest { DeviceDAO deviceDAO; + TagDAO tagDAO; DeviceTypeDAO deviceTypeDAO; private static final Log log = LogFactory.getLog(DevicePersistTests.class); @@ -56,6 +57,7 @@ public class DevicePersistTests extends BaseDeviceManagementTest { public void init() throws Exception { initDataSource(); deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); + tagDAO = DeviceManagementDAOFactory.getTagDAO(); deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); } @@ -103,6 +105,8 @@ public class DevicePersistTests extends BaseDeviceManagementTest { int deviceId = deviceDAO.addDevice(TestDataHolder.initialTestDeviceType.getId(), device, tenantId); device.setId(deviceId); deviceDAO.addEnrollment(device, tenantId); + tagDAO.addTags(TestDataHolder.getTagList(), tenantId); + tagDAO.addDeviceTagMapping(Collections.singletonList(device.getDeviceIdentifier()), TestDataHolder.TEST_DEVICE_TYPE, TestDataHolder.TAGS, tenantId); DeviceManagementDAOFactory.commitTransaction(); TestDataHolder.initialTestDevice = device; } catch (DeviceManagementDAOException e) { @@ -115,6 +119,10 @@ public class DevicePersistTests extends BaseDeviceManagementTest { String msg = "Error occurred while initiating transaction"; log.error(msg, e); Assert.fail(msg, e); + } catch (TagManagementDAOException e) { + String msg = "Error occurred while adding tag mappings"; + log.error(msg, e); + Assert.fail(msg, e); } finally { DeviceManagementDAOFactory.closeConnection(); } @@ -508,6 +516,223 @@ public class DevicePersistTests extends BaseDeviceManagementTest { } } + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesWithTag() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setTags(Collections.singletonList("tag1")); + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevices(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesWithTags() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setTags(TestDataHolder.TAGS); + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevices(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesWithNonExistingTags() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setTags(Collections.singletonList("tag10")); + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevices(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(0, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesWithTagAndStatus() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setStatusList(Collections.singletonList(Status.ACTIVE.name())); + pr.setTags(Collections.singletonList("tag1")); + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevices(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesWithTagsAndStatus() throws DeviceManagementDAOException, TransactionManagementException { + List tags = new ArrayList<>() ; + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setStatusList(Collections.singletonList(Status.ACTIVE.name())); + pr.setTags(tags); + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.getDevices(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountWithTag() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setTags(Collections.singletonList("tag1")); + DeviceManagementDAOFactory.beginTransaction(); + int result = deviceDAO.getDeviceCount(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, result, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountWithTags() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setTags(TestDataHolder.TAGS); + DeviceManagementDAOFactory.beginTransaction(); + int result = deviceDAO.getDeviceCount(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, result, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountWithTagAndStatus() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setStatusList(Collections.singletonList(Status.ACTIVE.name())); + pr.setTags(Collections.singletonList("tag1")); + DeviceManagementDAOFactory.beginTransaction(); + int result = deviceDAO.getDeviceCount(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, result, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountWithTagsAndStatus() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setStatusList(Collections.singletonList(Status.ACTIVE.name())); + pr.setTags(TestDataHolder.TAGS); + DeviceManagementDAOFactory.beginTransaction(); + int result = deviceDAO.getDeviceCount(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(1, result, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesWithTagAndGroupId() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setTags(Collections.singletonList("tag1")); + pr.setGroupId(1); + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.searchDevicesInGroup(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(0, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDevicesWithTagsAndGroupId() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setTags(TestDataHolder.TAGS); + pr.setGroupId(1); + DeviceManagementDAOFactory.beginTransaction(); + List results = deviceDAO.searchDevicesInGroup(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(0, results.size(), "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountWithTagAndGroupId() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setTags(Collections.singletonList("tag1")); + pr.setGroupId(1); + DeviceManagementDAOFactory.beginTransaction(); + int result = deviceDAO.getCountOfDevicesInGroup(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(0, result, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "testAddDeviceTest") + public void getDeviceCountWithTagsAndGroupId() throws DeviceManagementDAOException, TransactionManagementException { + try { + PaginationRequest pr = new PaginationRequest(0, 10); + pr.setTags(TestDataHolder.TAGS); + pr.setGroupId(1); + DeviceManagementDAOFactory.beginTransaction(); + int result = deviceDAO.getCountOfDevicesInGroup(pr, TestDataHolder.SUPER_TENANT_ID); + Assert.assertEquals(0, result, "No device returned"); + DeviceManagementDAOFactory.commitTransaction(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving the device" + e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + @Test(dependsOnMethods = "testAddDeviceTest") public void getCountOfDevicesInGroup() throws DeviceManagementDAOException, TransactionManagementException { PaginationRequest pr = new PaginationRequest(0, 10); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java new file mode 100644 index 0000000000..5a516eb567 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.service; + +import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.Tag; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.TagManagementException; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.TagMappingDTO; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.TagNotFoundException; +import io.entgra.device.mgt.core.device.mgt.core.TestUtils; +import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; +import io.entgra.device.mgt.core.device.mgt.core.config.DeviceConfigurationManager; +import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService; +import org.wso2.carbon.user.core.service.RealmService; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + + +public class TagManagementProviderServiceTest extends BaseDeviceManagementTest { + + private TagManagementProviderService tagManagementProviderService; + + public static final String DEVICE_ID_1 = "100001"; + public static final String DEVICE_ID_2 = "100002"; + private static final String DEVICE_TYPE = "RANDOM_DEVICE_TYPE"; + + @BeforeClass + @Override + public void init() throws Exception { + tagManagementProviderService = new TagManagementProviderServiceImpl(); + RealmService realmService = new InMemoryRealmService(); + DeviceManagementDataHolder.getInstance().setRealmService(realmService); + realmService.getTenantManager().getSuperTenantDomain(); + DeviceConfigurationManager.getInstance().initConfig(); + } + + @Test(expectedExceptions = {TagManagementException.class, BadRequestException.class}) + public void createTagsNull() throws TagManagementException, BadRequestException { + tagManagementProviderService.addTags(null); + } + + @Test(expectedExceptions = {TagManagementException.class, BadRequestException.class}, dependsOnMethods = "createTagsNull") + public void createTagsNameNullError() throws TagManagementException, BadRequestException { + tagManagementProviderService.addTags(TestUtils.createTagList1()); + } + + @Test(dependsOnMethods = "createTagsNameNullError") + public void createTags() throws TagManagementException, BadRequestException { + tagManagementProviderService.addTags(TestUtils.createTagList2()); + } + + @Test(expectedExceptions = {TagNotFoundException.class}, dependsOnMethods = "createTags") + public void updateTagsNotFound() throws TagNotFoundException, TagManagementException, BadRequestException { + String updateDescString = "This tag is updated"; + tagManagementProviderService.updateTag(new Tag(10,"tag10", updateDescString)); + } + + @Test(dependsOnMethods = "updateTagsNotFound") + public void updateTags() throws TagNotFoundException, TagManagementException, BadRequestException { + String updateDescString = "This tag is updated"; + tagManagementProviderService.updateTag(new Tag(1,"tag1", updateDescString)); + Tag tag = tagManagementProviderService.getTagById(1); + Assert.assertEquals(tag.getDescription(), updateDescString); + } + + @Test(dependsOnMethods = "updateTags", expectedExceptions = {TagNotFoundException.class}) + public void getTagNotFoundById() throws TagManagementException, TagNotFoundException { + tagManagementProviderService.getTagById(10); + } + + @Test(dependsOnMethods = "getTagNotFoundById", expectedExceptions = {BadRequestException.class}) + public void getTagNotFoundByNameNull() throws TagManagementException, TagNotFoundException, BadRequestException { + tagManagementProviderService.getTagByName(null); + } + + @Test(dependsOnMethods = "getTagNotFoundByNameNull", expectedExceptions = {TagNotFoundException.class}) + public void getTagNotFoundByName() throws TagManagementException, TagNotFoundException, BadRequestException { + tagManagementProviderService.getTagByName("tag10"); + } + + @Test(dependsOnMethods = "getTagNotFoundByName") + public void getTagById() throws TagManagementException, TagNotFoundException { + Tag tag = tagManagementProviderService.getTagById(2); + Assert.assertEquals(tag.getName(), TestUtils.getTag2().getName()); + } + + @Test(dependsOnMethods = "getTagById") + public void getTagByName() throws TagManagementException, TagNotFoundException, BadRequestException { + Tag tag = tagManagementProviderService.getTagByName("tag2"); + Assert.assertEquals(tag.getName(), TestUtils.getTag2().getName()); + } + + @Test(dependsOnMethods = "getTagByName") + public void getTags() throws TagManagementException { + List tags = tagManagementProviderService.getAllTags(); + Assert.assertEquals(tags.size(), 3); + } + + @Test(expectedExceptions = {TagNotFoundException.class}, dependsOnMethods = "getTags") + public void deleteTagNotExists() throws TagManagementException, TagNotFoundException { + tagManagementProviderService.deleteTag(10); + } + + @Test(dependsOnMethods = "deleteTagNotExists") + public void deleteTag() throws TagManagementException, TagNotFoundException { + tagManagementProviderService.deleteTag(1); + List tags = tagManagementProviderService.getAllTags(); + Assert.assertEquals(tags.size(), 2); + } + + @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "deleteTag") + public void createTagMappingsNull() throws TagManagementException, BadRequestException { + tagManagementProviderService.addDeviceTagMapping(null); + } + + @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "createTagMappingsNull") + public void createTagsMappingsNullDeviceIdentifiers() throws TagManagementException, DeviceManagementException { + TagMappingDTO tagMappingDTO = new TagMappingDTO(); + tagMappingDTO.setDeviceIdentifiers(null); + tagMappingDTO.setDeviceType(DEVICE_TYPE); + tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); + tagManagementProviderService.addDeviceTagMapping(tagMappingDTO); + } + + @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "createTagsMappingsNullDeviceIdentifiers") + public void createTagsMappingsNullDeviceType() throws TagManagementException, DeviceManagementException { + TagMappingDTO tagMappingDTO = new TagMappingDTO(); + tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); + tagMappingDTO.setDeviceType(null); + tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); + tagManagementProviderService.addDeviceTagMapping(tagMappingDTO); + } + + @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "createTagsMappingsNullDeviceType") + public void createTagsMappingsNullTags() throws TagManagementException, DeviceManagementException { + TagMappingDTO tagMappingDTO = new TagMappingDTO(); + tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); + tagMappingDTO.setDeviceType(DEVICE_TYPE); + tagMappingDTO.setTags(null); + tagManagementProviderService.addDeviceTagMapping(tagMappingDTO); + } + + @Test(dependsOnMethods = "createTagsMappingsNullTags") + public void createTagsMappings() throws TagManagementException, DeviceManagementException { + TagMappingDTO tagMappingDTO = new TagMappingDTO(); + tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); + tagMappingDTO.setDeviceType(DEVICE_TYPE); + tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); + tagManagementProviderService.addDeviceTagMapping(tagMappingDTO); + } + + @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "createTagsMappings") + public void deleteTagMappingsNull() throws TagManagementException, BadRequestException { + tagManagementProviderService.deleteDeviceTagMapping(null); + } + + @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "deleteTagMappingsNull") + public void deleteTagsMappingsNullDeviceIdentifiers() throws TagManagementException, DeviceManagementException { + TagMappingDTO tagMappingDTO = new TagMappingDTO(); + tagMappingDTO.setDeviceIdentifiers(null); + tagMappingDTO.setDeviceType(DEVICE_TYPE); + tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); + tagManagementProviderService.deleteDeviceTagMapping(tagMappingDTO); + } + + @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "deleteTagsMappingsNullDeviceIdentifiers") + public void deleteTagsMappingsNullDeviceType() throws TagManagementException, DeviceManagementException { + TagMappingDTO tagMappingDTO = new TagMappingDTO(); + tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); + tagMappingDTO.setDeviceType(null); + tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); + tagManagementProviderService.deleteDeviceTagMapping(tagMappingDTO); + } + + @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "deleteTagsMappingsNullDeviceType") + public void deleteTagsMappingsNullTags() throws TagManagementException, DeviceManagementException { + TagMappingDTO tagMappingDTO = new TagMappingDTO(); + tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); + tagMappingDTO.setDeviceType(DEVICE_TYPE); + tagMappingDTO.setTags(null); + tagManagementProviderService.deleteDeviceTagMapping(tagMappingDTO); + } + + @Test(dependsOnMethods = "deleteTagsMappingsNullTags") + public void deleteTagsMappings() throws TagManagementException, DeviceManagementException { + TagMappingDTO tagMappingDTO = new TagMappingDTO(); + tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); + tagMappingDTO.setDeviceType(DEVICE_TYPE); + tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); + tagManagementProviderService.deleteDeviceTagMapping(tagMappingDTO); + } +} + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index 5f94591885..6ed4f5fddd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -685,3 +685,25 @@ CREATE TABLE IF NOT EXISTS DM_METADATA ( CONSTRAINT METADATA_KEY_TENANT_ID UNIQUE (METADATA_KEY, TENANT_ID) ); -- END OF METADATA TABLE -- + +-- DM_TAG TABLE -- +CREATE TABLE IF NOT EXISTS DM_TAG ( + ID BIGINT AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + DESCRIPTION VARCHAR(255) NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + ); +-- END OF DM_TAG TABLE -- + +-- DM_DEVICE_TAG_MAPPING TABLE -- +CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING ( + ENROLMENT_ID BIGINT NOT NULL, + TAG_ID BIGINT NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), + FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), + FOREIGN KEY (TAG_ID) REFERENCES DM_TAG(ID) ON DELETE CASCADE + ); +-- END OF DM_DEVICE_TAG_MAPPING TABLE -- diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/testng.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/testng.xml index 9e8e787ce0..58789e4fd9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/testng.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/testng.xml @@ -43,6 +43,7 @@ + From 5e1bfd6d9a43dc57237ad678a60eedc9d77d937d Mon Sep 17 00:00:00 2001 From: Gimhan-minion Date: Fri, 16 Aug 2024 04:18:56 +0530 Subject: [PATCH 285/343] Initialize device tag feature --- .../mgt/core/dao/TagManagementDAOException.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagManagementDAOException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagManagementDAOException.java index 39fa7f696b..179d887dc5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagManagementDAOException.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagManagementDAOException.java @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.dao; /** From 295f1831d871bb2cd681f60165132b37456f7336 Mon Sep 17 00:00:00 2001 From: Gimhan-minion Date: Sat, 17 Aug 2024 00:31:47 +0530 Subject: [PATCH 286/343] Initialize device tag feature updated req changes --- .../service/api/TagManagementService.java | 19 +++-- .../impl/DeviceManagementServiceImpl.java | 11 +-- .../impl/TagManagementServiceImpl.java | 79 ++++++++++++------- .../impl/util/RequestValidationUtil.java | 37 ++++++++- .../mgt/api/jaxrs/util/DeviceMgtAPIUtils.java | 28 ++++--- .../core/device/mgt/common/tag/mgt/Tag.java | 1 - .../core/dao/impl/AbstractDeviceDAOImpl.java | 21 ++--- .../device/mgt/core/dao/impl/TagDAOImpl.java | 59 +++++++++++--- .../dao/impl/device/GenericDeviceDAOImpl.java | 16 +--- .../impl/device/PostgreSQLDeviceDAOImpl.java | 16 +--- .../impl/device/SQLServerDeviceDAOImpl.java | 16 +--- .../DeviceManagementServiceComponent.java | 3 +- .../DeviceManagementProviderServiceImpl.java | 10 ++- .../service/TagManagementProviderService.java | 14 +++- .../TagManagementProviderServiceImpl.java | 51 ++++++------ .../TagManagementProviderServiceTest.java | 60 +++++--------- .../src/main/resources/dbscripts/cdm/h2.sql | 21 +++++ .../main/resources/dbscripts/cdm/mssql.sql | 22 ++++++ .../main/resources/dbscripts/cdm/mysql.sql | 22 ++++++ .../main/resources/dbscripts/cdm/oracle.sql | 22 ++++++ .../resources/dbscripts/cdm/postgresql.sql | 22 ++++++ 21 files changed, 349 insertions(+), 201 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/TagManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/TagManagementService.java index a9e90d87fe..23fa92b9f8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/TagManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/TagManagementService.java @@ -17,7 +17,10 @@ */ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.TagInfo; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.TagInfoList; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.TagMappingInfo; import io.swagger.annotations.*; import io.entgra.device.mgt.core.apimgt.annotations.Scope; import io.entgra.device.mgt.core.apimgt.annotations.Scopes; @@ -107,7 +110,7 @@ public interface TagManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "GET", value = "Getting the List of Tags", - notes = "", + notes = "This endpoint is used to retrieve all tags", tags = "Tag Management", extensions = { @Extension(properties = { @@ -153,7 +156,7 @@ public interface TagManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Adding a Tag", - notes = "", + notes = "This endpoint is used to add new tags", tags = "Tag Management", extensions = { @Extension(properties = { @@ -212,7 +215,7 @@ public interface TagManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "PUT", value = "Updating a Tag", - notes = "", + notes = "This endpoint is used to update a specific tag", tags = "Tag Management", extensions = { @Extension(properties = { @@ -260,7 +263,7 @@ public interface TagManagementService { @ApiOperation( httpMethod = "DELETE", value = "Deleting a Tag", - notes = "", + notes = "This endpoint is used to delete a specific tag", tags = "Tag Management", extensions = { @Extension(properties = { @@ -293,7 +296,7 @@ public interface TagManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "GET", value = "Getting a Tag by ID", - notes = "", + notes = "This endpoint is used to retrieve tag by id", tags = "Tag Management", extensions = { @Extension(properties = { @@ -332,7 +335,7 @@ public interface TagManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Adding a Device-Tag Mapping", - notes = "", + notes = "This endpoint is used to map devices with tags", tags = "Device-Tag Management", extensions = { @Extension(properties = { @@ -372,7 +375,7 @@ public interface TagManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "DELETE", value = "Deleting a Device-Tag Mapping", - notes = "", + notes = "This endpoint is used to remove tag mappings from devices", tags = "Device-Tag Management", extensions = { @Extension(properties = { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 5c7d235b88..448d580cc7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -228,16 +228,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } if (tags != null && !tags.isEmpty()) { - boolean isTagsEmpty = true; - for (String tagString : tags) { - if (StringUtils.isNotBlank(tagString)) { - isTagsEmpty = false; - break; - } - } - if (!isTagsEmpty) { - request.setTags(tags); - } + request.setTags(tags); } // this is the user who initiates the request String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java index b1643472d8..26b484538e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java @@ -18,13 +18,16 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.TagInfo; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.TagMappingInfo; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.TagManagementService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException; -import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.*; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.Tag; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.TagManagementException; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.TagNotFoundException; import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger; import io.entgra.device.mgt.core.notification.logger.impl.EntgraRoleMgtLoggerImpl; @@ -50,7 +53,8 @@ public class TagManagementServiceImpl implements TagManagementService { } catch (TagManagementException e) { String msg = "Error occurred while getting tags."; log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } } @@ -69,11 +73,15 @@ public class TagManagementServiceImpl implements TagManagementService { } catch (TagManagementException e) { String msg = "Error occurred while adding tags." ; log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity + (new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } catch (BadRequestException e) { String msg = "Error occurred while adding tags. Please check the request" ; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + if(log.isDebugEnabled()) { + log.debug(msg, e); + } + return Response.status(Response.Status.BAD_REQUEST).entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(e.getMessage()).build()).build(); } } @@ -89,9 +97,11 @@ public class TagManagementServiceImpl implements TagManagementService { tag = DeviceMgtAPIUtils.getTagManagementService().getTagByName(tagName); } if (tag == null) { - String msg = "Tag not found."; + String msg = (tagId != null) ? "Tag with ID " + tagId + " is not found." + : "Tag with name " + tagName + " is not found."; log.error(msg); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + return Response.status(Response.Status.NOT_FOUND).entity(new ErrorResponse.ErrorResponseBuilder(). + setMessage(msg).build()).build(); } tag.setName(tagInfo.getName()); tag.setDescription(tagInfo.getDescription()); @@ -101,17 +111,22 @@ public class TagManagementServiceImpl implements TagManagementService { String msg = (tagId != null) ? "Error occurred while updating tag with ID " + tagId + "." : "Error occurred while updating tag with name " + tagName + "."; log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new ErrorResponse. + ErrorResponseBuilder().setMessage(msg).build()).build(); } catch (TagNotFoundException e) { String msg = (tagId != null) ? "Tag with ID " + tagId + " is not found." : "Tag with name " + tagName + " is not found."; log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build(); + return Response.status(Response.Status.NOT_FOUND).entity(new ErrorResponse.ErrorResponseBuilder(). + setMessage(msg).build()).build(); } catch (BadRequestException e) { String msg = (tagId != null) ? "Error occurred while updating tag with ID " + tagId : "Error occurred while updating tag with name " + tagName; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + if(log.isDebugEnabled()) { + log.debug(msg, e); + } + return Response.status(Response.Status.BAD_REQUEST).entity(new ErrorResponse.ErrorResponseBuilder(). + setMessage(msg).build()).build(); } } @@ -125,11 +140,13 @@ public class TagManagementServiceImpl implements TagManagementService { } catch (TagManagementException e) { String msg = "Error occurred while deleting tag with ID " + tagId + "."; log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + return Response.status(Response.Status.BAD_REQUEST).entity(new ErrorResponse.ErrorResponseBuilder(). + setMessage(msg).build()).build(); } catch (TagNotFoundException e) { String msg = "Tag with ID " + tagId + " is not found."; log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build(); + return Response.status(Response.Status.NOT_FOUND).entity(new ErrorResponse.ErrorResponseBuilder(). + setMessage(e.getMessage()).build()).build(); } } @@ -143,11 +160,13 @@ public class TagManagementServiceImpl implements TagManagementService { } catch (TagManagementException e) { String msg = "Error occurred while getting tag with ID " + tagId + "."; log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new ErrorResponse. + ErrorResponseBuilder().setMessage(msg).build()).build(); } catch (TagNotFoundException e) { String msg = "Tag with ID " + tagId + " is not found."; log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build(); + return Response.status(Response.Status.NOT_FOUND).entity(new ErrorResponse. + ErrorResponseBuilder().setMessage(e.getMessage()).build()).build(); } } @@ -156,18 +175,21 @@ public class TagManagementServiceImpl implements TagManagementService { public Response addDeviceTagMapping(TagMappingInfo tagMappingInfo) { RequestValidationUtil.validateTagMappingDetails(tagMappingInfo); try { - TagMappingDTO tagMappingDTO = new TagMappingDTO(tagMappingInfo.getDeviceIdentifiers(), + DeviceMgtAPIUtils.getTagManagementService().addDeviceTagMapping(tagMappingInfo.getDeviceIdentifiers(), tagMappingInfo.getDeviceType(), tagMappingInfo.getTags()); - DeviceMgtAPIUtils.getTagManagementService().addDeviceTagMapping(tagMappingDTO); - return Response.status(Response.Status.CREATED).entity(tagMappingDTO).build(); + return Response.status(Response.Status.CREATED).entity(tagMappingInfo).build(); } catch (TagManagementException e) { String msg = "Error occurred while adding device-tag mapping."; log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new ErrorResponse. + ErrorResponseBuilder().setMessage(msg).build()).build(); } catch (BadRequestException e) { String msg = "Error occurred while adding tag mappings."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + if(log.isDebugEnabled()) { + log.debug(msg, e); + } + return Response.status(Response.Status.BAD_REQUEST).entity(new ErrorResponse. + ErrorResponseBuilder().setMessage(e.getMessage()).build()).build(); } } @@ -176,18 +198,21 @@ public class TagManagementServiceImpl implements TagManagementService { public Response deleteDeviceTagMapping(TagMappingInfo tagMappingInfo) { RequestValidationUtil.validateTagMappingDetails(tagMappingInfo); try { - TagMappingDTO tagMappingDTO = new TagMappingDTO(tagMappingInfo.getDeviceIdentifiers(), + DeviceMgtAPIUtils.getTagManagementService().deleteDeviceTagMapping(tagMappingInfo.getDeviceIdentifiers(), tagMappingInfo.getDeviceType(), tagMappingInfo.getTags()); - DeviceMgtAPIUtils.getTagManagementService().deleteDeviceTagMapping(tagMappingDTO); - return Response.status(Response.Status.NO_CONTENT).build(); + return Response.status(Response.Status.NO_CONTENT).entity(tagMappingInfo).build(); } catch (TagManagementException e) { String msg = "Error occurred while deleting tag mappings."; log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new ErrorResponse. + ErrorResponseBuilder().setMessage(msg).build()).build(); } catch (BadRequestException e) { String msg = "Error occurred while deleting tag mappings."; - log.error(msg, e); - return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); + if(log.isDebugEnabled()) { + log.debug(msg, e); + } + return Response.status(Response.Status.BAD_REQUEST).entity(new ErrorResponse. + ErrorResponseBuilder().setMessage(e.getMessage()).build()).build(); } } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java index e39ebb2366..00e8723e35 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java @@ -493,41 +493,70 @@ public class RequestValidationUtil { } } + /** + * Validates the provided tag details to ensure that either a valid tagId or a non-empty tagName is provided, + * and that the tagInfo is not null. Throws InputValidationException if any of these conditions are not met. + * + * @param tagId the ID of the tag (must be greater than 0) + * @param tagName the name of the tag (must be non-empty if tagId is not provided) + * @param tagInfo the TagInfo object to validate (must not be null) + * @throws InputValidationException if neither a valid tagId nor a tagName is provided, or if tagInfo is null + */ public static void validateTagDetails(Integer tagId, String tagName, TagInfo tagInfo) { - if (tagId == null && tagName == null) { - String msg = "Either tagId or tagName must be provided."; + if ((tagId == null || tagId <= 0) && StringUtils.isBlank(tagName)) { + String msg = "Either valid tagId or tagName must be provided."; log.error(msg); throw new InputValidationException( new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(msg).build()); } if (tagInfo == null) { + String msg = "Provided request body is empty."; + log.error(msg); throw new InputValidationException( new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request body is " + "empty").build()); } } + /** + * Validates the provided list of TagInfo objects to ensure that it is not null. + * Throws InputValidationException if the list is null. + * + * @param tagInfo the list of TagInfo objects to validate (must not be null) + * @throws InputValidationException if the list is null + */ public static void validateTagListDetails(List tagInfo) { if (tagInfo == null) { + String msg = "Provided request body is empty."; + log.error(msg); throw new InputValidationException( new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request body is " + "empty").build()); } } + /** + * Validates the provided TagMappingInfo object to ensure it is not null and contains valid + * device identifiers, device type, and tags. Throws InputValidationException if validation fails. + * + * @param tagMappingInfo the TagMappingInfo object to validate + * @throws InputValidationException if the tagMappingInfo or its required fields are invalid + */ public static void validateTagMappingDetails(TagMappingInfo tagMappingInfo) { if (tagMappingInfo == null) { + String msg = "Provided request body is empty."; + log.error(msg); throw new InputValidationException( new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage("Request body is empty").build()); } else if (tagMappingInfo.getDeviceIdentifiers() == null || tagMappingInfo.getDeviceType() == null || tagMappingInfo.getTags() == null) { + String msg = "Invalid tag mapping request body."; + log.error(msg); throw new InputValidationException( new ErrorResponse.ErrorResponseBuilder().setCode(400L).setMessage("Invalid tag mapping request body").build()); } } - - public static void validateScopes(List scopes) { if (scopes == null || scopes.isEmpty()) { throw new InputValidationException( diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java index b6f44c042c..74cb42a698 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java @@ -21,12 +21,11 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherService; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; -import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.TagManagementService; import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuthorizationService; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl; -import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; import io.entgra.device.mgt.core.device.mgt.core.service.TagManagementProviderService; +import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; import org.apache.axis2.AxisFault; import org.apache.axis2.client.Options; import org.apache.axis2.java.security.SSLProtocolSocketFactory; @@ -67,7 +66,6 @@ import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation; import io.entgra.device.mgt.core.device.mgt.common.report.mgt.ReportManagementService; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceTypeGeneratorService; import io.entgra.device.mgt.core.device.mgt.common.spi.OTPManagementService; -import io.entgra.device.mgt.core.device.mgt.common.spi.TraccarManagementService; import io.entgra.device.mgt.core.device.mgt.core.app.mgt.ApplicationManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.DeviceInformationManager; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceTypeVersion; @@ -167,6 +165,7 @@ public class DeviceMgtAPIUtils { private static volatile APIPublisherService apiPublisher; private static volatile TenantManagerAdminService tenantManagerAdminService; + private static volatile TagManagementProviderService tagManagementService; static { String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password"); @@ -507,15 +506,24 @@ public class DeviceMgtAPIUtils { return policyManagementService; } + /** + * Initializing and accessing method for TagManagementService. + * + * @return TagManagementService instance + * @throws IllegalStateException if TagManagementService cannot be initialized + */ public static TagManagementProviderService getTagManagementService() { - TagManagementProviderService tagManagementService; - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - tagManagementService = - (TagManagementProviderService) ctx.getOSGiService(TagManagementProviderService.class, null); if (tagManagementService == null) { - String msg = "Tag Management service not initialized."; - log.error(msg); - throw new IllegalStateException(msg); + synchronized (DeviceMgtAPIUtils.class) { + if (tagManagementService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + tagManagementService = (TagManagementProviderService) ctx.getOSGiService( + TagManagementProviderService.class, null); + if (tagManagementService == null) { + throw new IllegalStateException("Tag Management service not initialized."); + } + } + } } return tagManagementService; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/Tag.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/Tag.java index a0546e5447..ba2ffecf16 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/Tag.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/tag/mgt/Tag.java @@ -18,7 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.common.tag.mgt; -import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index c080980ca9..c6c1193f7d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -1091,13 +1091,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "SELECT dtm.ENROLMENT_ID " + "FROM DM_DEVICE_TAG_MAPPING dtm " + "JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + - "WHERE t.NAME IN ("; - for (int i = 0; i < tagList.size(); i++) { - if (i > 0) { - sql += ", "; - } - sql += "?"; - } + "WHERE t.NAME IN (" + buildTagQuery(tagList); sql += ") GROUP BY dtm.ENROLMENT_ID HAVING COUNT(DISTINCT t.NAME) = ? )"; isTagsProvided = true; } @@ -1372,13 +1366,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { "SELECT dtm.ENROLMENT_ID " + "FROM DM_DEVICE_TAG_MAPPING dtm " + "JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + - "WHERE t.NAME IN ("; - for (int i = 0; i < tagList.size(); i++) { - if (i > 0) { - sql += ", "; - } - sql += "?"; - } + "WHERE t.NAME IN (" + buildTagQuery(tagList); sql += ") GROUP BY dtm.ENROLMENT_ID HAVING COUNT(DISTINCT t.NAME) = ? )"; isTagsProvided = true; } @@ -2988,6 +2976,11 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { return joiner.toString(); } + protected String buildTagQuery(List tagList) + throws DeviceManagementDAOException { + return String.join(", ", Collections.nCopies(tagList.size(), "?")); + } + public int getFunctioningDevicesInSystem() throws DeviceManagementDAOException { Connection conn; PreparedStatement stmt = null; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TagDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TagDAOImpl.java index 2a9813131b..bd901e0fed 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TagDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TagDAOImpl.java @@ -21,8 +21,15 @@ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.DeviceTag; import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.Tag; import io.entgra.device.mgt.core.device.mgt.core.dao.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; -import java.sql.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.sql.Statement; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -33,6 +40,8 @@ import static io.entgra.device.mgt.core.device.mgt.core.dao.util.TagManagementDA public class TagDAOImpl implements TagDAO { + private static final Log log = LogFactory.getLog(TagDAOImpl.class); + protected Connection getConnection() throws SQLException { return DeviceManagementDAOFactory.getConnection(); } @@ -62,11 +71,15 @@ public class TagDAOImpl implements TagDAO { int[] updateCounts = preparedStatement.executeBatch(); for (int count : updateCounts) { if (count == PreparedStatement.EXECUTE_FAILED) { - throw new TagManagementDAOException("Error occurred while adding tags, adding some tags failed."); + String msg = "Error occurred while adding tags, adding some tags failed."; + log.error(msg); + throw new TagManagementDAOException(msg); } } } catch (SQLException e) { - throw new TagManagementDAOException("Error occurred while adding tags", e); + String msg = "Error occurred while adding tags."; + log.error(msg, e); + throw new TagManagementDAOException(msg, e); } finally { cleanupResources(preparedStatement, null); } @@ -87,7 +100,9 @@ public class TagDAOImpl implements TagDAO { preparedStatement.setInt(4, tenantId); preparedStatement.executeUpdate(); } catch (SQLException e) { - throw new TagManagementDAOException("Error occurred while updating tag", e); + String msg = "Error occurred while updating tag."; + log.error(msg, e); + throw new TagManagementDAOException(msg, e); } finally { cleanupResources(preparedStatement, null); } @@ -106,7 +121,9 @@ public class TagDAOImpl implements TagDAO { preparedStatement.setInt(2, tenantId); preparedStatement.executeUpdate(); } catch (SQLException e) { - throw new TagManagementDAOException("Error occurred while deleting tag", e); + String msg = "Error occurred while deleting tag."; + log.error(msg, e); + throw new TagManagementDAOException(msg, e); } finally { cleanupResources(preparedStatement, null); } @@ -131,7 +148,9 @@ public class TagDAOImpl implements TagDAO { tag = loadTag(resultSet); } } catch (SQLException e) { - throw new TagManagementDAOException("Error occurred while retrieving tag", e); + String msg = "Error occurred while getting a specific tag." + tagId; + log.error(msg, e); + throw new TagManagementDAOException(msg, e); } finally { cleanupResources(preparedStatement, resultSet); } @@ -157,7 +176,9 @@ public class TagDAOImpl implements TagDAO { tag = loadTag(resultSet); } } catch (SQLException e) { - throw new TagManagementDAOException("Error occurred while retrieving tag with name: " + tagName, e); + String msg = "Error occurred while retrieving tag with name: " + tagName; + log.error(msg, e); + throw new TagManagementDAOException(msg, e); } finally { cleanupResources(preparedStatement, resultSet); } @@ -184,7 +205,9 @@ public class TagDAOImpl implements TagDAO { tags.add(tag); } } catch (SQLException e) { - throw new TagManagementDAOException("Error occurred while retrieving tags", e); + String msg = "Error occurred while retrieving tags"; + log.error(msg, e); + throw new TagManagementDAOException(msg, e); } finally { cleanupResources(preparedStatement, resultSet); } @@ -237,9 +260,13 @@ public class TagDAOImpl implements TagDAO { preparedStatement.setInt(paramIndex, tenantId); preparedStatement.executeUpdate(); } catch (SQLIntegrityConstraintViolationException e) { - throw new TagManagementDAOException("Tag is already mapped to this device", e, true); + String msg = "Tag is already mapped to this device"; + log.error(msg, e); + throw new TagManagementDAOException(msg, e, true); } catch (SQLException e) { - throw new TagManagementDAOException("Error occurred while adding device tag", e); + String msg = "Error occurred while adding device tag mapping"; + log.error(msg, e); + throw new TagManagementDAOException(msg, e); } finally { cleanupResources(preparedStatement, null); } @@ -287,7 +314,9 @@ public class TagDAOImpl implements TagDAO { preparedStatement.setInt(paramIndex, tenantId); preparedStatement.executeUpdate(); } catch (SQLException e) { - throw new TagManagementDAOException("Error occurred while deleting device tag mapping", e); + String msg = "Error occurred while deleting device tag mapping"; + log.error(msg, e); + throw new TagManagementDAOException(msg, e); } finally { cleanupResources(preparedStatement, null); } @@ -313,7 +342,9 @@ public class TagDAOImpl implements TagDAO { deviceTags.add(deviceTag); } } catch (SQLException e) { - throw new TagManagementDAOException("Error occurred while retrieving device tags", e); + String msg = "Error occurred while retrieving device tags"; + log.error(msg, e); + throw new TagManagementDAOException(msg, e); } finally { cleanupResources(preparedStatement, resultSet); } @@ -340,7 +371,9 @@ public class TagDAOImpl implements TagDAO { deviceTags.add(deviceTag); } } catch (SQLException e) { - throw new TagManagementDAOException("Error occurred while retrieving devices for tag", e); + String msg = "Error occurred while retrieving devices for tag"; + log.error(msg, e); + throw new TagManagementDAOException(msg, e); } finally { cleanupResources(preparedStatement, resultSet); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index 29275128bf..4e04a9efbf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -174,13 +174,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID "; if (tagList != null && !tagList.isEmpty()) { - sql += " WHERE t.NAME IN ("; - for (int i = 0; i < tagList.size(); i++) { - if (i > 0) { - sql += ", "; - } - sql += "?"; - } + sql += " WHERE t.NAME IN (" + buildTagQuery(tagList); sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ? "; isTagsProvided = true; } else { @@ -800,13 +794,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { "FROM DM_ENROLMENT e " + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + - "WHERE t.NAME IN ("; - for (int i = 0; i < tagList.size(); i++) { - if (i > 0) { - sql += ", "; - } - sql += "?"; - } + "WHERE t.NAME IN (" + buildTagQuery(tagList); sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ? ) "; isTagsProvided = true; } else { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index 923189dea3..4ad5ce9ab7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -163,13 +163,7 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { if (tagList != null && !tagList.isEmpty()) { sql += " AND e.ID IN (SELECT e.ID FROM DM_ENROLMENT e " + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + - "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID WHERE t.NAME IN ("; - for (int i = 0; i < tagList.size(); i++) { - if (i > 0) { - sql += ", "; - } - sql += "?"; - } + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID WHERE t.NAME IN (" + buildTagQuery(tagList); sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ? ) "; isTagsProvided = true; } @@ -590,13 +584,7 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { "FROM DM_ENROLMENT e " + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + - "WHERE t.NAME IN ("; - for (int i = 0; i < tagList.size(); i++) { - if (i > 0) { - sql += ", "; - } - sql += "?"; - } + "WHERE t.NAME IN (" + buildTagQuery(tagList); sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ? ) "; isTagsProvided = true; } else { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 47823054d8..0624aba5e1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -169,13 +169,7 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { if (tagList!= null && !tagList.isEmpty()) { sql += " AND e.ID IN (SELECT e.ID FROM DM_ENROLMENT e " + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + - "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID WHERE t.NAME IN ("; - for (int i = 0; i < tagList.size(); i++) { - if (i > 0) { - sql += ", "; - } - sql += "?"; - } + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID WHERE t.NAME IN (" + buildTagQuery(tagList); sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ? ) "; isTagsProvided = true; } @@ -609,13 +603,7 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { "SELECT e.ID FROM DM_ENROLMENT e " + "LEFT JOIN DM_DEVICE_TAG_MAPPING dtm ON e.ID = dtm.ENROLMENT_ID " + "LEFT JOIN DM_TAG t ON dtm.TAG_ID = t.ID " + - "WHERE t.NAME IN ("; - for (int i = 0; i < tagList.size(); i++) { - if (i > 0) { - sql += ", "; - } - sql += "?"; - } + "WHERE t.NAME IN (" + buildTagQuery(tagList); sql += ") GROUP BY e.ID HAVING COUNT(DISTINCT t.NAME) = ?)"; isTagsProvided = true; } else { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java index 669e60c593..a57c089c52 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -21,7 +21,8 @@ import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuth import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import io.entgra.device.mgt.core.device.mgt.core.authorization.GroupAccessAuthorizationServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.DeviceStatusManagementServiceImpl; -import io.entgra.device.mgt.core.device.mgt.core.service.*; +import io.entgra.device.mgt.core.device.mgt.core.service.TagManagementProviderService; +import io.entgra.device.mgt.core.device.mgt.core.service.TagManagementProviderServiceImpl; import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 7e3f835ab0..c195969275 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -22,7 +22,15 @@ import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import io.entgra.device.mgt.core.device.mgt.common.exceptions.ConflictException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; -import io.entgra.device.mgt.core.device.mgt.core.dao.*; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceTypeDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.EnrollmentDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.ApplicationDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceStatusDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.dao.TenantDAO; +import io.entgra.device.mgt.core.device.mgt.core.dao.TagDAO; import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceDetailsDTO; import io.entgra.device.mgt.core.device.mgt.core.dto.OwnerWithDeviceDTO; import io.entgra.device.mgt.core.device.mgt.core.dto.OperationDTO; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderService.java index 6fccdc5701..2b31ca8a31 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderService.java @@ -82,16 +82,22 @@ public interface TagManagementProviderService { /** * Method to add a device-tag mapping. * - * @param tagMappingDto - TagMappingDTO object containing mapping information. + * @param deviceIdentifiers - List of device ids to map. + * @param deviceType - Device Type of that specific devices. + * @param tags - List of tags you want to attach. * @throws TagManagementException if something goes wrong while adding the device-tag mapping. */ - void addDeviceTagMapping(TagMappingDTO tagMappingDto) throws TagManagementException, BadRequestException; + void addDeviceTagMapping(List deviceIdentifiers, String deviceType, List tags) + throws TagManagementException, BadRequestException; /** * Method to delete a device-tag mapping. * - * @param tagMappingDTO - TagMappingDTO object containing mapping information. + * @param deviceIdentifiers - List of device ids to map. + * @param deviceType - Device Type of that specific devices. + * @param tags - List of tags you want to attach. * @throws TagManagementException if something goes wrong while deleting the device-tag mapping. */ - void deleteDeviceTagMapping(TagMappingDTO tagMappingDTO) throws TagManagementException, BadRequestException; + void deleteDeviceTagMapping(List deviceIdentifiers, String deviceType, List tags) + throws TagManagementException, BadRequestException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java index d7c5b1f112..ea163eef79 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java @@ -47,11 +47,13 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe throw new BadRequestException(msg); } try { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceManagementDAOFactory.beginTransaction(); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); for (Tag tag : tags) { if (tag.getName() == null) { - throw new BadRequestException("Tag name cannot be null"); + String msg = "Tag name cannot be null"; + log.error(msg); + throw new BadRequestException(msg); } } if (log.isDebugEnabled()) { @@ -80,9 +82,11 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe @Override public List getAllTags() throws TagManagementException { try { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceManagementDAOFactory.beginTransaction(); - return tagDAO.getTags(tenantId); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + List tags = tagDAO.getTags(tenantId); + DeviceManagementDAOFactory.commitTransaction(); + return tags; } catch (TransactionManagementException e) { String msg = "Error occurred while initiating transaction."; log.error(msg, e); @@ -104,8 +108,8 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe @Override public Tag getTagById(int tagId) throws TagManagementException, TagNotFoundException { try { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceManagementDAOFactory.beginTransaction(); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); Tag tag = tagDAO.getTagById(tagId, tenantId); DeviceManagementDAOFactory.commitTransaction(); if (tag == null) { @@ -132,16 +136,14 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe } try { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceManagementDAOFactory.beginTransaction(); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); Tag tag = tagDAO.getTagByName(tagName, tenantId); DeviceManagementDAOFactory.commitTransaction(); - if (tag == null) { String msg = "Tag with name " + tagName + " not found."; throw new TagNotFoundException(msg); } - return tag; } catch (TransactionManagementException | TagManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); @@ -162,8 +164,8 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe throw new BadRequestException(msg); } try { + DeviceManagementDAOFactory.beginTransaction(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - DeviceManagementDAOFactory.openConnection(); Tag existingTag = tagDAO.getTagById(tag.getId(), tenantId); if (existingTag == null) { String msg = "Tag with ID: " + tag.getId() + " does not exist."; @@ -171,7 +173,8 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe throw new TagNotFoundException(msg); } tagDAO.updateTag(tag, tenantId); - } catch (TagManagementDAOException | SQLException e) { + DeviceManagementDAOFactory.commitTransaction(); + } catch (TagManagementDAOException | TransactionManagementException e) { DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while updating the tag with ID: " + tag.getId(); log.error(msg, e); @@ -185,8 +188,8 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe @Override public void deleteTag(int tagId) throws TagManagementException, TagNotFoundException { try { + DeviceManagementDAOFactory.beginTransaction(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - DeviceManagementDAOFactory.openConnection(); Tag existingTag = tagDAO.getTagById(tagId, tenantId); if (existingTag == null) { String msg = "Tag with ID: " + tagId + " does not exist."; @@ -195,7 +198,7 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe } tagDAO.deleteTag(tagId, tenantId); DeviceManagementDAOFactory.commitTransaction(); - } catch (TagManagementDAOException | SQLException e) { + } catch (TagManagementDAOException | TransactionManagementException e) { DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while deleting the tag with ID: " + tagId; log.error(msg, e); @@ -206,17 +209,17 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe } @Override - public void addDeviceTagMapping(TagMappingDTO tagMappingDto) throws TagManagementException, BadRequestException { - if (tagMappingDto == null || tagMappingDto.getDeviceIdentifiers() == null || tagMappingDto.getTags() == null - || tagMappingDto.getDeviceType() == null) { + public void addDeviceTagMapping(List deviceIdentifiers, String deviceType, List tags) + throws TagManagementException, BadRequestException { + if (deviceIdentifiers == null || deviceType == null || tags == null) { String msg = "Received incomplete data for device tag mapping."; log.error(msg); throw new BadRequestException(msg); } try { + DeviceManagementDAOFactory.beginTransaction(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - DeviceManagementDAOFactory.openConnection(); - + TagMappingDTO tagMappingDto = new TagMappingDTO(deviceIdentifiers, deviceType, tags); List tagList = new ArrayList<>(); for (String tagName : tagMappingDto.getTags()) { Tag tag = new Tag(); @@ -227,7 +230,7 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe tagDAO.addTags(tagList, tenantId); tagDAO.addDeviceTagMapping(tagMappingDto.getDeviceIdentifiers(), tagMappingDto.getDeviceType(), tagMappingDto.getTags(), tenantId); - + DeviceManagementDAOFactory.commitTransaction(); } catch (TagManagementDAOException e) { if (e.isUniqueConstraintViolation()) { String msg = "Tag is already mapped to this device."; @@ -239,7 +242,7 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe log.error(msg, e); throw new TagManagementException(msg, e); } - } catch (SQLException e) { + } catch (TransactionManagementException e) { DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while adding device tag mapping."; log.error(msg, e); @@ -250,20 +253,20 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe } @Override - public void deleteDeviceTagMapping(TagMappingDTO tagMappingDto) throws TagManagementException, BadRequestException { - if (tagMappingDto == null || tagMappingDto.getDeviceIdentifiers() == null || tagMappingDto.getTags() == null - || tagMappingDto.getDeviceType() == null) { + public void deleteDeviceTagMapping(List deviceIdentifiers, String deviceType, List tags) throws TagManagementException, BadRequestException { + if (deviceIdentifiers == null || deviceType == null || tags == null) { String msg = "Received incomplete data for device tag mapping."; log.error(msg); throw new BadRequestException(msg); } try { + DeviceManagementDAOFactory.beginTransaction(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); - DeviceManagementDAOFactory.openConnection(); + TagMappingDTO tagMappingDto = new TagMappingDTO(deviceIdentifiers, deviceType, tags); tagDAO.deleteDeviceTagMapping(tagMappingDto.getDeviceIdentifiers(), tagMappingDto.getDeviceType(), tagMappingDto.getTags(), tenantId); DeviceManagementDAOFactory.commitTransaction(); - } catch (TagManagementDAOException | SQLException e) { + } catch (TagManagementDAOException | TransactionManagementException e) { DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while deleting device tag mappings."; log.error(msg, e); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java index 5a516eb567..5039f8f70e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java @@ -133,84 +133,60 @@ public class TagManagementProviderServiceTest extends BaseDeviceManagementTest { @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "deleteTag") public void createTagMappingsNull() throws TagManagementException, BadRequestException { - tagManagementProviderService.addDeviceTagMapping(null); + tagManagementProviderService.addDeviceTagMapping(null, null, null); } @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "createTagMappingsNull") public void createTagsMappingsNullDeviceIdentifiers() throws TagManagementException, DeviceManagementException { - TagMappingDTO tagMappingDTO = new TagMappingDTO(); - tagMappingDTO.setDeviceIdentifiers(null); - tagMappingDTO.setDeviceType(DEVICE_TYPE); - tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); - tagManagementProviderService.addDeviceTagMapping(tagMappingDTO); + tagManagementProviderService.addDeviceTagMapping(null, DEVICE_TYPE, + new ArrayList<>(Arrays.asList("tag1", "tag2"))); } @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "createTagsMappingsNullDeviceIdentifiers") public void createTagsMappingsNullDeviceType() throws TagManagementException, DeviceManagementException { - TagMappingDTO tagMappingDTO = new TagMappingDTO(); - tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); - tagMappingDTO.setDeviceType(null); - tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); - tagManagementProviderService.addDeviceTagMapping(tagMappingDTO); + tagManagementProviderService.addDeviceTagMapping(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2)), + null, new ArrayList<>(Arrays.asList("tag1", "tag2"))); } @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "createTagsMappingsNullDeviceType") public void createTagsMappingsNullTags() throws TagManagementException, DeviceManagementException { - TagMappingDTO tagMappingDTO = new TagMappingDTO(); - tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); - tagMappingDTO.setDeviceType(DEVICE_TYPE); - tagMappingDTO.setTags(null); - tagManagementProviderService.addDeviceTagMapping(tagMappingDTO); + tagManagementProviderService.addDeviceTagMapping(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2)), + DEVICE_TYPE, null); } @Test(dependsOnMethods = "createTagsMappingsNullTags") public void createTagsMappings() throws TagManagementException, DeviceManagementException { - TagMappingDTO tagMappingDTO = new TagMappingDTO(); - tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); - tagMappingDTO.setDeviceType(DEVICE_TYPE); - tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); - tagManagementProviderService.addDeviceTagMapping(tagMappingDTO); + tagManagementProviderService.addDeviceTagMapping(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2)), + DEVICE_TYPE, new ArrayList<>(Arrays.asList("tag1", "tag2"))); } @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "createTagsMappings") public void deleteTagMappingsNull() throws TagManagementException, BadRequestException { - tagManagementProviderService.deleteDeviceTagMapping(null); + tagManagementProviderService.deleteDeviceTagMapping(null, null, null); } @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "deleteTagMappingsNull") public void deleteTagsMappingsNullDeviceIdentifiers() throws TagManagementException, DeviceManagementException { - TagMappingDTO tagMappingDTO = new TagMappingDTO(); - tagMappingDTO.setDeviceIdentifiers(null); - tagMappingDTO.setDeviceType(DEVICE_TYPE); - tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); - tagManagementProviderService.deleteDeviceTagMapping(tagMappingDTO); + tagManagementProviderService.deleteDeviceTagMapping(null, DEVICE_TYPE, + new ArrayList<>(Arrays.asList("tag1", "tag2"))); } @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "deleteTagsMappingsNullDeviceIdentifiers") public void deleteTagsMappingsNullDeviceType() throws TagManagementException, DeviceManagementException { - TagMappingDTO tagMappingDTO = new TagMappingDTO(); - tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); - tagMappingDTO.setDeviceType(null); - tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); - tagManagementProviderService.deleteDeviceTagMapping(tagMappingDTO); + tagManagementProviderService.deleteDeviceTagMapping(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2)), + null, new ArrayList<>(Arrays.asList("tag1", "tag2"))); } @Test(expectedExceptions = {BadRequestException.class}, dependsOnMethods = "deleteTagsMappingsNullDeviceType") public void deleteTagsMappingsNullTags() throws TagManagementException, DeviceManagementException { - TagMappingDTO tagMappingDTO = new TagMappingDTO(); - tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); - tagMappingDTO.setDeviceType(DEVICE_TYPE); - tagMappingDTO.setTags(null); - tagManagementProviderService.deleteDeviceTagMapping(tagMappingDTO); + tagManagementProviderService.deleteDeviceTagMapping(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2)), + DEVICE_TYPE, null); } @Test(dependsOnMethods = "deleteTagsMappingsNullTags") public void deleteTagsMappings() throws TagManagementException, DeviceManagementException { - TagMappingDTO tagMappingDTO = new TagMappingDTO(); - tagMappingDTO.setDeviceIdentifiers(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2))); - tagMappingDTO.setDeviceType(DEVICE_TYPE); - tagMappingDTO.setTags(new ArrayList<>(Arrays.asList("tag1", "tag2"))); - tagManagementProviderService.deleteDeviceTagMapping(tagMappingDTO); + tagManagementProviderService.deleteDeviceTagMapping(new ArrayList<>(Arrays.asList(DEVICE_ID_1, DEVICE_ID_2)), + DEVICE_TYPE, new ArrayList<>(Arrays.asList("tag1", "tag2"))); } } diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 342c330376..02baa647b5 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -875,3 +875,24 @@ CREATE TABLE IF NOT EXISTS DM_CEA_POLICIES ( -- END OF DM_CEA_POLICIES TABLE -- +-- DM_TAG TABLE -- +CREATE TABLE IF NOT EXISTS DM_TAG ( + ID BIGINT AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + DESCRIPTION VARCHAR(255) NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + ); +-- END OF DM_TAG TABLE -- + +-- DM_DEVICE_TAG_MAPPING TABLE -- +CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING ( + ENROLMENT_ID BIGINT NOT NULL, + TAG_ID BIGINT NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), + FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), + FOREIGN KEY (TAG_ID) REFERENCES DM_TAG(ID) ON DELETE CASCADE + ); +-- END OF DM_DEVICE_TAG_MAPPING TABLE -- diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index f6f3232e13..4f5bd193ea 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -951,3 +951,25 @@ BEGIN END; -- END OF DM_CEA_POLICIES TABLE -- + +-- DM_TAG TABLE -- +CREATE TABLE IF NOT EXISTS DM_TAG ( + ID BIGINT IDENTITY(1,1) PRIMARY KEY, + NAME NVARCHAR(255) NOT NULL, + DESCRIPTION NVARCHAR(255) NULL, + TENANT_ID INT NOT NULL, + CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + ); +-- END OF DM_TAG TABLE -- + +-- DM_DEVICE_TAG_MAPPING TABLE -- +CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING ( + ENROLMENT_ID BIGINT NOT NULL, + TAG_ID BIGINT NOT NULL, + TENANT_ID INT NOT NULL, + PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), + FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), + FOREIGN KEY (TAG_ID) REFERENCES DM_TAG(ID) ON DELETE CASCADE + ); +-- END OF DM_DEVICE_TAG_MAPPING TABLE -- + diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 4390f6a40d..89f43bad0d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -950,3 +950,25 @@ CREATE TABLE IF NOT EXISTS DM_CEA_POLICIES ( ); -- END OF DM_CEA_POLICIES TABLE -- + +-- DM_TAG TABLE -- +CREATE TABLE IF NOT EXISTS DM_TAG ( + ID BIGINT AUTO_INCREMENT PRIMARY KEY, + NAME VARCHAR(255) NOT NULL, + DESCRIPTION VARCHAR(255) NULL, + TENANT_ID INT NOT NULL, + CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + ); +-- END OF DM_TAG TABLE -- + +-- DM_DEVICE_TAG_MAPPING TABLE -- +CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING ( + ENROLMENT_ID BIGINT NOT NULL, + TAG_ID BIGINT NOT NULL, + TENANT_ID INT NOT NULL, + PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), + FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), + FOREIGN KEY (TAG_ID) REFERENCES DM_TAG(ID) ON DELETE CASCADE + ); +-- END OF DM_DEVICE_TAG_MAPPING TABLE -- + diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index d5a442c69e..fed865804a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -1255,3 +1255,25 @@ END; / -- END OF DM_CEA_POLICIES TABLE -- + +-- DM_TAG TABLE -- +CREATE TABLE DM_TAG ( + ID NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY PRIMARY KEY, + NAME VARCHAR2(255) NOT NULL, + DESCRIPTION VARCHAR2(255) NULL, + TENANT_ID NUMBER(10) NOT NULL, + CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) +); +-- END OF DM_TAG TABLE -- + +-- DM_DEVICE_TAG_MAPPING TABLE -- +CREATE TABLE DM_DEVICE_TAG_MAPPING ( + ENROLMENT_ID NUMBER(19) NOT NULL, + TAG_ID NUMBER(19) NOT NULL, + TENANT_ID NUMBER(10) NOT NULL, + PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), + FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), + FOREIGN KEY (TAG_ID) REFERENCES DM_TAG(ID) ON DELETE CASCADE +); +-- END OF DM_DEVICE_TAG_MAPPING TABLE -- + diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 354925efe5..baeee662a5 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -881,3 +881,25 @@ CREATE TABLE IF NOT EXISTS DM_CEA_POLICIES ( ); -- END OF DM_CEA_POLICIES TABLE -- + +-- DM_TAG TABLE -- +CREATE TABLE IF NOT EXISTS DM_TAG ( + ID BIGSERIAL PRIMARY KEY, + NAME VARCHAR(255) NOT NULL, + DESCRIPTION VARCHAR(255) NULL, + TENANT_ID INTEGER NOT NULL, + CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + ); +-- END OF DM_TAG TABLE -- + +-- DM_DEVICE_TAG_MAPPING TABLE -- +CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING ( + ENROLMENT_ID BIGINT NOT NULL, + TAG_ID BIGINT NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), + FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), + FOREIGN KEY (TAG_ID) REFERENCES DM_TAG(ID) ON DELETE CASCADE + ); +-- END OF DM_DEVICE_TAG_MAPPING TABLE -- + From 8d2fb5fa76c2cd33dcf2a1f666079c7c664e52a7 Mon Sep 17 00:00:00 2001 From: Gimhan-minion Date: Tue, 20 Aug 2024 11:51:48 +0530 Subject: [PATCH 287/343] Fix tenant id constraint in DM_TAG table --- .../mgt/api/jaxrs/beans/TagInfoList.java | 2 - .../mgt/core/device/mgt/core/TestUtils.java | 16 ++ .../mgt/core/common/TestDataHolder.java | 2 + .../device/mgt/core/dao/TagPersistTests.java | 216 ++++++++++++++++++ .../src/test/resources/mssql-testng.xml | 1 + .../src/test/resources/mysql-testng.xml | 1 + .../src/test/resources/oracle-testng.xml | 1 + .../src/test/resources/postgre-testng.xml | 1 + .../src/test/resources/sql/h2.sql | 2 +- .../src/test/resources/testng.xml | 1 + .../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 +- 15 files changed, 245 insertions(+), 8 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagPersistTests.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfoList.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfoList.java index 4960c35f82..96015c7c6c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfoList.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/TagInfoList.java @@ -48,6 +48,4 @@ public class TagInfoList extends BasePaginatedResult { sb.append("]}\n"); return sb.toString(); } - - } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java index b477cd2a53..a787f0b30e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestUtils.java @@ -106,8 +106,17 @@ public class TestUtils { } public static Tag getTag2() { + return new Tag( 2, "tag2", "This is tag2"); + } + + public static Tag getTag1Dao() { + return new Tag("tag1", "This is tag1"); + } + + public static Tag getTag2Dao() { return new Tag( "tag2", "This is tag2"); } + public static Tag getTag3() { return new Tag("tag3", "This is tag3"); } @@ -125,6 +134,13 @@ public class TestUtils { return tagList; } + public static List createTagList3() { + List tagList = new ArrayList<>(); + tagList.add(getTag1Dao()); + tagList.add(getTag2Dao()); + return tagList; + } + public static GroupPaginationRequest createPaginationRequest(){ GroupPaginationRequest request = new GroupPaginationRequest(0, 5); return request; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java index cffbb3389a..579678ec97 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java @@ -41,6 +41,8 @@ public class TestDataHolder { public final static String TEST_DEVICE_TYPE = "TEST-DEVICE-TYPE"; public final static Integer SUPER_TENANT_ID = -1234; + public final static Integer ALTERNATE_TENANT_ID = -1235; + public final static Integer ALTERNATE_TENANT_ID_1 = -1236; public final static String SUPER_TENANT_DOMAIN = "carbon.super"; public final static String initialDeviceIdentifier = "12345"; public final static String initialDeviceName = "TEST-DEVICE"; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagPersistTests.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagPersistTests.java new file mode 100644 index 0000000000..a18049fa3f --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/dao/TagPersistTests.java @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.dao; + +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; +import io.entgra.device.mgt.core.device.mgt.common.tag.mgt.Tag; +import io.entgra.device.mgt.core.device.mgt.core.TestUtils; +import io.entgra.device.mgt.core.device.mgt.core.common.BaseDeviceManagementTest; +import io.entgra.device.mgt.core.device.mgt.core.common.TestDataHolder; +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 java.util.List; + +public class TagPersistTests extends BaseDeviceManagementTest { + + private TagDAO tagDAO; + private static final Log log = LogFactory.getLog(TagPersistTests.class); + + @BeforeClass + @Override + public void init() throws Exception { + initDataSource(); + tagDAO = DeviceManagementDAOFactory.getTagDAO(); + } + + @Test + public void addTag() { + try { + DeviceManagementDAOFactory.beginTransaction(); + tagDAO.addTags(TestUtils.createTagList3(), TestDataHolder.ALTERNATE_TENANT_ID); + log.debug("Tags added to the database"); + Tag tag = tagDAO.getTagByName("tag1", TestDataHolder.ALTERNATE_TENANT_ID); + DeviceManagementDAOFactory.commitTransaction(); + Assert.assertNotNull(tag, "Tag should be added and retrieved."); + Assert.assertEquals(tag.getName(), "tag1", "Tag name mismatch."); + } catch (TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while adding tag list type."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "addTag") + public void updateTag() { + try { + DeviceManagementDAOFactory.beginTransaction(); + String updatedDescription = "Updated Description"; + Tag tag = tagDAO.getTagByName("tag1", TestDataHolder.ALTERNATE_TENANT_ID); + Tag tagToUpdate = new Tag(tag.getId(), tag.getName(), updatedDescription); + tagDAO.updateTag(tagToUpdate, TestDataHolder.ALTERNATE_TENANT_ID); + log.debug("Tag updated in the database"); + tag = tagDAO.getTagByName("tag1", TestDataHolder.ALTERNATE_TENANT_ID); + DeviceManagementDAOFactory.commitTransaction(); + Assert.assertEquals(tag.getDescription(), updatedDescription, "Tag description mismatch."); + } catch (TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while updating tag."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "updateTag") + public void deleteTag() { + try { + DeviceManagementDAOFactory.beginTransaction(); + tagDAO.deleteTag(1, TestDataHolder.ALTERNATE_TENANT_ID); + log.debug("Tag deleted from the database"); + Tag deletedTag = tagDAO.getTagById(1, TestDataHolder.ALTERNATE_TENANT_ID); + DeviceManagementDAOFactory.commitTransaction(); + Assert.assertNull(deletedTag, "Tag should be deleted."); + } catch (TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while deleting tag."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"deleteTag"}) + public void getTags() { + try { + DeviceManagementDAOFactory.beginTransaction(); + List tags = tagDAO.getTags(TestDataHolder.ALTERNATE_TENANT_ID); + DeviceManagementDAOFactory.commitTransaction(); + log.debug("Tags retrieved successfully."); + Assert.assertEquals(tags.size(), 2); + } catch (TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while retrieving tags."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = {"getTags"}) + public void getTagByName() { + try { + String tagName = "tag2"; + DeviceManagementDAOFactory.beginTransaction(); + Tag tag = tagDAO.getTagByName(tagName, TestDataHolder.ALTERNATE_TENANT_ID); + DeviceManagementDAOFactory.commitTransaction(); + log.debug("Tag " + tagName + " retrieved successfully."); + Assert.assertEquals(tag.getName(), "tag2"); + } catch (TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while retrieving tag by Id."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "getTagByName") + public void addTagsForAlternateTenant() { + try { + DeviceManagementDAOFactory.beginTransaction(); + //Here, adding a same tag name for a separate tenant is tested. + tagDAO.addTags(TestUtils.createTagList3(), TestDataHolder.ALTERNATE_TENANT_ID_1); + log.debug("Tags added for a alternate tenant"); + List tagList = tagDAO.getTags(TestDataHolder.ALTERNATE_TENANT_ID_1); + DeviceManagementDAOFactory.commitTransaction(); + Assert.assertEquals(tagList.size(), 2, "Tag count mismatch."); + } catch (TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while adding tags for a different tenant."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + + @Test(dependsOnMethods = "addTagsForAlternateTenant") + public void getTagsOfAlternateTenant() { + try { + DeviceManagementDAOFactory.beginTransaction(); + List tagList = tagDAO.getTags(TestDataHolder.ALTERNATE_TENANT_ID_1); + log.debug("Tags retrieved for a alternate tenant " + TestDataHolder.ALTERNATE_TENANT_ID_1); + DeviceManagementDAOFactory.commitTransaction(); + Assert.assertEquals(tagList.size(), 2, "Tag count mismatch."); + } catch (TagManagementDAOException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while adding tags for a different tenant."; + log.error(msg, e); + Assert.fail(msg, e); + } catch (TransactionManagementException e) { + DeviceManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while initiating transaction."; + log.error(msg, e); + Assert.fail(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/mssql-testng.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/mssql-testng.xml index 2015c5eb5e..51d60a2aee 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/mssql-testng.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/mssql-testng.xml @@ -33,6 +33,7 @@ + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/mysql-testng.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/mysql-testng.xml index 190802eb51..3959510cbd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/mysql-testng.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/mysql-testng.xml @@ -33,6 +33,7 @@ + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/oracle-testng.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/oracle-testng.xml index e4b774a06f..8650e43b96 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/oracle-testng.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/oracle-testng.xml @@ -33,6 +33,7 @@ + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/postgre-testng.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/postgre-testng.xml index a4839a1a0d..b4bfc29da1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/postgre-testng.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/postgre-testng.xml @@ -33,6 +33,7 @@ + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index 6ed4f5fddd..9fded58e81 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -693,7 +693,7 @@ CREATE TABLE IF NOT EXISTS DM_TAG ( DESCRIPTION VARCHAR(255) NULL, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID), - CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + CONSTRAINT DM_TAG_NAME_TENANT_UNIQUE UNIQUE (NAME, TENANT_ID) ); -- END OF DM_TAG TABLE -- diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/testng.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/testng.xml index 58789e4fd9..a51df0bc38 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/testng.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/testng.xml @@ -33,6 +33,7 @@ + diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 02baa647b5..446eba4794 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -882,7 +882,7 @@ CREATE TABLE IF NOT EXISTS DM_TAG ( DESCRIPTION VARCHAR(255) NULL, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID), - CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + CONSTRAINT DM_TAG_NAME_TENANT_UNIQUE UNIQUE (NAME, TENANT_ID) ); -- END OF DM_TAG TABLE -- diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 4f5bd193ea..dc39bb4d16 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -958,7 +958,7 @@ CREATE TABLE IF NOT EXISTS DM_TAG ( NAME NVARCHAR(255) NOT NULL, DESCRIPTION NVARCHAR(255) NULL, TENANT_ID INT NOT NULL, - CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + CONSTRAINT DM_TAG_NAME_TENANT_UNIQUE UNIQUE (NAME, TENANT_ID) ); -- END OF DM_TAG TABLE -- diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 89f43bad0d..a943265bdb 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -957,7 +957,7 @@ CREATE TABLE IF NOT EXISTS DM_TAG ( NAME VARCHAR(255) NOT NULL, DESCRIPTION VARCHAR(255) NULL, TENANT_ID INT NOT NULL, - CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + CONSTRAINT DM_TAG_NAME_TENANT_UNIQUE UNIQUE (NAME, TENANT_ID) ); -- END OF DM_TAG TABLE -- diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index fed865804a..2fa51b9d49 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -1262,7 +1262,7 @@ CREATE TABLE DM_TAG ( NAME VARCHAR2(255) NOT NULL, DESCRIPTION VARCHAR2(255) NULL, TENANT_ID NUMBER(10) NOT NULL, - CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + CONSTRAINT DM_TAG_NAME_TENANT_UNIQUE UNIQUE (NAME, TENANT_ID) ); -- END OF DM_TAG TABLE -- diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index baeee662a5..d9bce9fd04 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -888,7 +888,7 @@ CREATE TABLE IF NOT EXISTS DM_TAG ( NAME VARCHAR(255) NOT NULL, DESCRIPTION VARCHAR(255) NULL, TENANT_ID INTEGER NOT NULL, - CONSTRAINT DM_TAG_NAME_UNIQUE UNIQUE (NAME) + CONSTRAINT DM_TAG_NAME_TENANT_UNIQUE UNIQUE (NAME, TENANT_ID) ); -- END OF DM_TAG TABLE -- From 5a12dc760152488b3419ff7ba8860775559ecdc7 Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Wed, 21 Aug 2024 03:09:48 +0000 Subject: [PATCH 288/343] Fix logic issue with user authorization validation for groups Co-authored-by: Charitha Goonetilleke Co-committed-by: Charitha Goonetilleke --- .../GroupAccessAuthorizationServiceImpl.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/GroupAccessAuthorizationServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/GroupAccessAuthorizationServiceImpl.java index acceb466c1..2f796f929f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/GroupAccessAuthorizationServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/GroupAccessAuthorizationServiceImpl.java @@ -73,21 +73,24 @@ public class GroupAccessAuthorizationServiceImpl implements GroupAccessAuthoriza UserRealm userRealm = DeviceManagementDataHolder.getInstance().getRealmService() .getTenantUserRealm(getTenantId()); String[] userRoles = userRealm.getUserStoreManager().getRoleListOfUser(username); - boolean isAuthorized = true; + boolean isAuthorized; for (String groupPermission : groupPermissions) { + isAuthorized = false; for (String role : userRoles) { - if (!userRealm.getAuthorizationManager(). + if (userRealm.getAuthorizationManager(). isRoleAuthorized(role, groupPermission, CarbonConstants.UI_PERMISSION_ACTION)) { - isAuthorized = false; + isAuthorized = true; break; } } + if (!isAuthorized) { + return false; + } } - return isAuthorized; + return true; } catch (UserStoreException e) { throw new GroupAccessAuthorizationException("Unable to authorize the access to group : " + - groupId + " for the user : " + - username, e); + groupId + " for the user : " + username, e); } } } From 1e20b3d15c55ada13052eae30d655488dfa7437a Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Wed, 21 Aug 2024 09:40:42 +0530 Subject: [PATCH 289/343] Fix permission updating issue --- .../webapp/publisher/APIPublisherStartupHandler.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java index d218238dc1..e15c38ff13 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -32,6 +32,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.apimgt.webapp.publisher.exception.APIManagerPublisherException; import io.entgra.device.mgt.core.apimgt.webapp.publisher.internal.APIPublisherDataHolder; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.ServerStartupObserver; import java.util.HashMap; @@ -57,6 +58,7 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { @Override public void completedServerStartup() { + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); APIPublisherDataHolder.getInstance().setServerStarted(true); currentAPIsStack = APIPublisherDataHolder.getInstance().getUnpublishedApis(); Thread t = new Thread(new Runnable() { @@ -104,7 +106,13 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { log.error("failed to update scope role mapping.", e); } - updateScopeMetadataEntryWithDefaultScopes(); + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); + updateScopeMetadataEntryWithDefaultScopes(); + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } // execute after api publishing for (PostApiPublishingObsever observer : APIPublisherDataHolder.getInstance().getPostApiPublishingObseverList()) { From cfa40c0d2be0c6b58c94941f42ca2c7a3ebe81bd Mon Sep 17 00:00:00 2001 From: Gimhan-minion Date: Thu, 22 Aug 2024 17:38:24 +0530 Subject: [PATCH 290/343] Fix tag feature modifications after review --- .../mgt/api/jaxrs/service/api/DeviceManagementService.java | 4 ++-- .../api/jaxrs/service/impl/DeviceManagementServiceImpl.java | 2 +- .../api/jaxrs/service/impl/TagManagementServiceImpl.java | 2 +- .../mgt/core/service/TagManagementProviderServiceImpl.java | 6 ++++++ .../mgt/core/device/mgt/core/common/TestDataHolder.java | 4 ++-- .../mgt/core/service/TagManagementProviderServiceTest.java | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index e201133681..889d50e5fd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -338,10 +338,10 @@ public interface DeviceManagementService { @QueryParam("requireDeviceInfo") boolean requireDeviceInfo, @ApiParam( - name = "tags", + name = "tag", value = "Describes the tags associated with the enrolment", required = false) - @QueryParam("tags") + @QueryParam("tag") List tags, @ApiParam( name = "offset", diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 448d580cc7..a137b7ba9b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -151,7 +151,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @QueryParam("since") String since, @HeaderParam("If-Modified-Since") String ifModifiedSince, @QueryParam("requireDeviceInfo") boolean requireDeviceInfo, - @QueryParam("tags") List tags, + @QueryParam("tag") List tags, @QueryParam("offset") int offset, @QueryParam("limit") int limit) { try { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java index 26b484538e..c780c4226b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/TagManagementServiceImpl.java @@ -126,7 +126,7 @@ public class TagManagementServiceImpl implements TagManagementService { log.debug(msg, e); } return Response.status(Response.Status.BAD_REQUEST).entity(new ErrorResponse.ErrorResponseBuilder(). - setMessage(msg).build()).build(); + setMessage(e.getMessage()).build()).build(); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java index ea163eef79..822c3b6497 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceImpl.java @@ -172,6 +172,12 @@ public class TagManagementProviderServiceImpl implements TagManagementProviderSe log.error(msg); throw new TagNotFoundException(msg); } + Tag tagWithName = tagDAO.getTagByName(tag.getName(), tenantId); + if (tagWithName != null && tagWithName.getId() != tag.getId()) { + String msg = "Tag with name: " + tag.getName() + " already exists."; + log.error(msg); + throw new BadRequestException(msg); + } tagDAO.updateTag(tag, tenantId); DeviceManagementDAOFactory.commitTransaction(); } catch (TagManagementDAOException | TransactionManagementException e) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java index 579678ec97..65f45a47d9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/common/TestDataHolder.java @@ -41,8 +41,8 @@ public class TestDataHolder { public final static String TEST_DEVICE_TYPE = "TEST-DEVICE-TYPE"; public final static Integer SUPER_TENANT_ID = -1234; - public final static Integer ALTERNATE_TENANT_ID = -1235; - public final static Integer ALTERNATE_TENANT_ID_1 = -1236; + public final static Integer ALTERNATE_TENANT_ID = 1234; + public final static Integer ALTERNATE_TENANT_ID_1 = 1235; public final static String SUPER_TENANT_DOMAIN = "carbon.super"; public final static String initialDeviceIdentifier = "12345"; public final static String initialDeviceName = "TEST-DEVICE"; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java index 5039f8f70e..16277c99a5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/service/TagManagementProviderServiceTest.java @@ -72,7 +72,7 @@ public class TagManagementProviderServiceTest extends BaseDeviceManagementTest { tagManagementProviderService.addTags(TestUtils.createTagList2()); } - @Test(expectedExceptions = {TagNotFoundException.class}, dependsOnMethods = "createTags") + @Test(expectedExceptions = {TagNotFoundException.class, BadRequestException.class, TagManagementException.class}) public void updateTagsNotFound() throws TagNotFoundException, TagManagementException, BadRequestException { String updateDescString = "This tag is updated"; tagManagementProviderService.updateTag(new Tag(10,"tag10", updateDescString)); From 55f58657262030dd3a71fb9f3b2729453e27d0ee Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Mon, 26 Aug 2024 14:35:08 +0530 Subject: [PATCH 291/343] Fix enroll-web-agent login issue --- .../core/ui/request/interceptor/LoginHandler.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index 633b18eb52..6a97630e99 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -71,6 +71,8 @@ public class LoginHandler extends HttpServlet { httpSession.invalidate(); } httpSession = req.getSession(true); + final String baseContextPath = req.getContextPath(); + final String applicationName = baseContextPath.substring(1, baseContextPath.indexOf("-ui-request-handler")) + "-login"; JsonNode uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp); @@ -83,14 +85,16 @@ public class LoginHandler extends HttpServlet { // Check if OAuth app cache exists. If not create a new application. LoginCache loginCache = HandlerUtil.getLoginCache(httpSession); - OAuthAppCacheKey oAuthAppCacheKey = new OAuthAppCacheKey(HandlerConstants.PUBLISHER_APPLICATION_NAME, username); + OAuthAppCacheKey oAuthAppCacheKey = new OAuthAppCacheKey(applicationName, username); OAuthApp oAuthApp = loginCache.getOAuthAppCache(oAuthAppCacheKey); if (oAuthApp == null) { - + ArrayList supportedGrantTypes = new ArrayList<>(); + supportedGrantTypes.add(HandlerConstants.PASSWORD_GRANT_TYPE); + supportedGrantTypes.add(HandlerConstants.REFRESH_TOKEN_GRANT_TYPE); ClassicHttpRequest apiRegEndpoint = ClassicRequestBuilder.post(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT) - .setEntity(HandlerUtil.constructAppRegPayload(tags, HandlerConstants.PUBLISHER_APPLICATION_NAME, - username, password, null, null)) + .setEntity(HandlerUtil.constructAppRegPayload(tags, applicationName, + username, password, null, supportedGrantTypes)) .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, org.apache.hc.core5.http.ContentType.APPLICATION_JSON.toString()) .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder().encodeToString((username + HandlerConstants.COLON + password).getBytes())) @@ -114,7 +118,7 @@ public class LoginHandler extends HttpServlet { encodedClientApp = Base64.getEncoder() .encodeToString((clientId + HandlerConstants.COLON + clientSecret).getBytes()); oAuthApp = new OAuthApp( - HandlerConstants.PUBLISHER_APPLICATION_NAME, + applicationName, username, clientId, clientSecret, From 31e9a6e45721a5b8ffa95ad03cf4e46e67d90158 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Tue, 20 Aug 2024 14:18:30 +0530 Subject: [PATCH 292/343] Add client certificate authentication for Windows --- .../mgt/core/impl/CertificateGenerator.java | 6 ++ .../certificate/mgt/core/util/CommonUtil.java | 1 - .../authenticator/framework/Constants.java | 11 ++++ .../authenticator/framework/Utils/Utils.java | 60 ++++++++++++++++- .../framework/WebappAuthenticationValve.java | 10 +++ .../CertificateAuthenticator.java | 65 ++++++++++--------- .../authorizer/PermissionAuthorizer.java | 2 - 7 files changed, 120 insertions(+), 35 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index e8a29ebc29..75f4266b1c 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -823,8 +823,14 @@ public class CertificateGenerator { } String subjectDn = joiner.toString(); X500Name issuerName = new X500Name(subjectDn); + String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst() .getValue().toString(); + // CSR sent from a Windows device will have an '!' followed by the device ID in the CN + if (commonName.contains("!")) { + commonName = commonName.split("!")[1]; + } + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); X500Name subjectName = new X500Name("O=" + commonName + " ,CN=" + serialNumber + ", OU=tenant_" + tenantId); diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java index 0aee44954d..0b1d317721 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java @@ -42,5 +42,4 @@ public class CommonUtil { public static synchronized BigInteger generateSerialNumber() { return BigInteger.valueOf(System.currentTimeMillis()); } - } diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Constants.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Constants.java index 3a62f2f3eb..e38bb76412 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Constants.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Constants.java @@ -32,6 +32,9 @@ public final class Constants { public static final String HEADER_HTTP_ACCEPT = "Accept"; public static final String HEADER_HTTP_AUTHORIZATION = "Authorization"; public static final String ONE_TIME_TOKEN_HEADER = "one-time-token"; + public static final String MUTUAL_AUTH_HEADER = "mutual-auth-header"; + public static final String PROXY_MUTUAL_AUTH_HEADER = "proxy-mutual-auth-header"; + public static final String CERTIFICATE_VERIFICATION_HEADER = "Mdm-Signature"; } public static final class ContentTypes { @@ -53,4 +56,12 @@ public final class Constants { public static final String DELETE = "delete"; public static final String ACTION = "action"; } + + public static final class Certificate { + private Certificate() { + throw new AssertionError(); + } + + public static final String ORGANIZATION_ATTRIBUTE = "O="; + } } diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Utils/Utils.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Utils/Utils.java index 014b2fffed..e93c8009c9 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Utils/Utils.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/Utils/Utils.java @@ -18,6 +18,12 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.Utils; +import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPException; +import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager; +import io.entgra.device.mgt.core.certificate.mgt.core.scep.TenantedDeviceWrapper; +import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; +import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.core.util.DeviceManagerUtil; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationException; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; @@ -26,6 +32,7 @@ import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oa import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthValidationResponse; import io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth.OAuthValidatorFactory; import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -34,6 +41,7 @@ import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; +import java.security.cert.X509Certificate; import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -151,10 +159,60 @@ public class Utils { String sysPropertyName = matchPattern.group(1); String sysPropertyValue = System.getProperty(sysPropertyName); if (sysPropertyValue != null && !sysPropertyName.isEmpty()) { - urlWithPlaceholders = urlWithPlaceholders.replaceAll("\\$\\{(" + sysPropertyName + ")\\}", sysPropertyValue); + urlWithPlaceholders = urlWithPlaceholders.replaceAll("\\$\\{(" + sysPropertyName + ")\\}", + sysPropertyValue); } } return urlWithPlaceholders; } + /** + * Returns the value of the given attribute from the subject distinguished name. eg: "entgra.net" + * from "CN=entgra.net" + * @param requestCertificate {@link X509Certificate} that needs to extract an attribute from + * @param attribute the attribute name that needs to be extracted from the cert. eg: "CN=" + * @return the value of the attribute + */ + public static String getSubjectDnAttribute(X509Certificate requestCertificate, String attribute) { + String distinguishedName = requestCertificate.getSubjectDN().getName(); + if (StringUtils.isNotEmpty(distinguishedName)) { + String[] dnSplits = distinguishedName.split(","); + for (String dnSplit : dnSplits) { + if (dnSplit.contains(attribute)) { + String[] cnSplits = dnSplit.split("="); + if (StringUtils.isNotEmpty(cnSplits[1])) { + return cnSplits[1]; + } + } + } + } + return null; + } + + /** + * Check if the device identifier is valid and set the authentication info such as the tenant domain, + * tenant id and username of the enrolled device. + * @param deviceIdentifier {@link DeviceIdentifier} containing device id and type + * @param authenticationInfo {@link AuthenticationInfo} containing tenant and user details + * @throws SCEPException if the device or tenant does not exist + */ + public static void validateScepDevice(DeviceIdentifier deviceIdentifier, AuthenticationInfo authenticationInfo) + throws SCEPException { + SCEPManager scepManager = AuthenticatorFrameworkDataHolder.getInstance().getScepManager(); + TenantedDeviceWrapper tenantedDeviceWrapper = scepManager.getValidatedDevice(deviceIdentifier); + authenticationInfo.setTenantDomain(tenantedDeviceWrapper.getTenantDomain()); + authenticationInfo.setTenantId(tenantedDeviceWrapper.getTenantId()); + + // To make sure the tenant flow is not initiated in the valve as the + // tenant flows are initiated at the API level on iOS + if (deviceIdentifier.getType().equals(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS)) { + authenticationInfo.setTenantId(-1); + } + + if (tenantedDeviceWrapper.getDevice() != null && + tenantedDeviceWrapper.getDevice().getEnrolmentInfo() != null) { + EnrolmentInfo enrolmentInfo = tenantedDeviceWrapper.getDevice().getEnrolmentInfo(); + authenticationInfo.setUsername(enrolmentInfo.getOwner()); + } + } } diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValve.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValve.java index 8b430ba012..3f4ce9f9fc 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValve.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/WebappAuthenticationValve.java @@ -94,6 +94,16 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { return; } AuthenticationInfo authenticationInfo = authenticator.authenticate(request, response); + + // If the request header contains 'Mdm-Signature', then it is a iOS or Windows device trying to sync and + // it is already authenticated from the CertificateAuthenticator. Hence, there is no need to check + // if the user associated with the device has permission. + if (request.getHeader(Constants.HTTPHeaders.CERTIFICATE_VERIFICATION_HEADER) != null && + authenticationInfo.getStatus() == WebappAuthenticator.Status.SUCCESS) { + this.getNext().invoke(request, response, compositeValve); + return; + } + if (isManagedAPI(request) && (authenticationInfo.getStatus() == WebappAuthenticator.Status.CONTINUE || authenticationInfo.getStatus() == WebappAuthenticator.Status.SUCCESS)) { WebappAuthenticator.Status status = WebappTenantAuthorizer.authorize(request, authenticationInfo); diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java index cb9bf50215..1df91c7c30 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authenticator/CertificateAuthenticator.java @@ -21,13 +21,11 @@ package io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator; import io.entgra.device.mgt.core.certificate.mgt.core.dto.CertificateResponse; import io.entgra.device.mgt.core.certificate.mgt.core.exception.KeystoreException; import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPException; -import io.entgra.device.mgt.core.certificate.mgt.core.scep.SCEPManager; -import io.entgra.device.mgt.core.certificate.mgt.core.scep.TenantedDeviceWrapper; import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier; import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; -import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationException; import io.entgra.device.mgt.core.webapp.authenticator.framework.AuthenticationInfo; +import io.entgra.device.mgt.core.webapp.authenticator.framework.Constants; import io.entgra.device.mgt.core.webapp.authenticator.framework.Utils.Utils; import io.entgra.device.mgt.core.webapp.authenticator.framework.internal.AuthenticatorFrameworkDataHolder; import org.apache.catalina.connector.Request; @@ -45,9 +43,6 @@ public class CertificateAuthenticator implements WebappAuthenticator { private static final Log log = LogFactory.getLog(CertificateAuthenticator.class); private static final String CERTIFICATE_AUTHENTICATOR = "CertificateAuth"; - private static final String MUTUAL_AUTH_HEADER = "mutual-auth-header"; - private static final String PROXY_MUTUAL_AUTH_HEADER = "proxy-mutual-auth-header"; - private static final String CERTIFICATE_VERIFICATION_HEADER = "Mdm-Signature"; private static final String CLIENT_CERTIFICATE_ATTRIBUTE = "javax.servlet.request.X509Certificate"; @Override @@ -57,8 +52,9 @@ public class CertificateAuthenticator implements WebappAuthenticator { @Override public boolean canHandle(Request request) { - return request.getHeader(CERTIFICATE_VERIFICATION_HEADER) != null - || request.getHeader(MUTUAL_AUTH_HEADER) != null || request.getHeader(PROXY_MUTUAL_AUTH_HEADER) != null; + return request.getHeader(Constants.HTTPHeaders.CERTIFICATE_VERIFICATION_HEADER) != null + || request.getHeader(Constants.HTTPHeaders.MUTUAL_AUTH_HEADER) != null || + request.getHeader(Constants.HTTPHeaders.PROXY_MUTUAL_AUTH_HEADER) != null; } @Override @@ -73,12 +69,14 @@ public class CertificateAuthenticator implements WebappAuthenticator { try { // When there is a load balancer terminating mutual SSL, it should pass this header along and // as the value of this header, the client certificate subject dn should be passed. - if (request.getHeader(PROXY_MUTUAL_AUTH_HEADER) != null) { + if (request.getHeader(Constants.HTTPHeaders.PROXY_MUTUAL_AUTH_HEADER) != null) { if (log.isDebugEnabled()) { - log.debug("PROXY_MUTUAL_AUTH_HEADER " + request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); + log.debug("PROXY_MUTUAL_AUTH_HEADER " + + request.getHeader(Constants.HTTPHeaders.PROXY_MUTUAL_AUTH_HEADER)); } CertificateResponse certificateResponse = AuthenticatorFrameworkDataHolder.getInstance(). - getCertificateManagementService().verifySubjectDN(request.getHeader(PROXY_MUTUAL_AUTH_HEADER)); + getCertificateManagementService().verifySubjectDN(request.getHeader( + Constants.HTTPHeaders.PROXY_MUTUAL_AUTH_HEADER)); authenticationInfo = checkCertificateResponse(certificateResponse); if (log.isDebugEnabled()) { log.debug("Certificate Serial : " + certificateResponse.getSerialNumber() @@ -86,7 +84,7 @@ public class CertificateAuthenticator implements WebappAuthenticator { + " , username" + authenticationInfo.getUsername()); } } - else if (request.getHeader(MUTUAL_AUTH_HEADER) != null) { + else if (request.getHeader(Constants.HTTPHeaders.MUTUAL_AUTH_HEADER) != null) { Object object = request.getAttribute(CLIENT_CERTIFICATE_ATTRIBUTE); X509Certificate[] clientCertificate = null; if (object instanceof X509Certificate[]) { @@ -101,13 +99,11 @@ public class CertificateAuthenticator implements WebappAuthenticator { authenticationInfo.setStatus(Status.FAILURE); authenticationInfo.setMessage("No client certificate is present"); } - } else if (request.getHeader(CERTIFICATE_VERIFICATION_HEADER) != null) { - String certHeader = request.getHeader(CERTIFICATE_VERIFICATION_HEADER); + } else if (request.getHeader(Constants.HTTPHeaders.CERTIFICATE_VERIFICATION_HEADER) != null) { + String certHeader = request.getHeader(Constants.HTTPHeaders.CERTIFICATE_VERIFICATION_HEADER); if (certHeader != null && AuthenticatorFrameworkDataHolder.getInstance().getCertificateManagementService(). verifySignature(certHeader)) { - AuthenticatorFrameworkDataHolder.getInstance().getCertificateManagementService(). - extractCertificateFromSignature(certHeader); X509Certificate certificate = AuthenticatorFrameworkDataHolder.getInstance().getCertificateManagementService(). extractCertificateFromSignature(certHeader); @@ -116,30 +112,37 @@ public class CertificateAuthenticator implements WebappAuthenticator { if (challengeToken != null) { challengeToken = challengeToken.substring(challengeToken.indexOf("(") + 1).trim(); - SCEPManager scepManager = AuthenticatorFrameworkDataHolder.getInstance().getScepManager(); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setId(challengeToken); deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS); - TenantedDeviceWrapper tenantedDeviceWrapper = scepManager.getValidatedDevice(deviceIdentifier); - authenticationInfo.setTenantDomain(tenantedDeviceWrapper.getTenantDomain()); - // To make sure the tenant flow is not initiated in the valve as the - // tenant flows are initiated at the API level on iOS - authenticationInfo.setTenantId(-1); - - if (tenantedDeviceWrapper.getDevice() != null && - tenantedDeviceWrapper.getDevice().getEnrolmentInfo() != null) { - - EnrolmentInfo enrolmentInfo = tenantedDeviceWrapper.getDevice().getEnrolmentInfo(); - authenticationInfo.setUsername(enrolmentInfo.getOwner()); - } + Utils.validateScepDevice(deviceIdentifier, authenticationInfo); authenticationInfo.setStatus(Status.CONTINUE); + } else { + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + String deviceId = Utils.getSubjectDnAttribute(certificate, + Constants.Certificate.ORGANIZATION_ATTRIBUTE); + if (deviceId == null) { + authenticationInfo.setStatus(Status.FAILURE); + return authenticationInfo; + } + deviceIdentifier.setId(deviceId); + deviceIdentifier.setType( + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS); + Utils.validateScepDevice(deviceIdentifier, authenticationInfo); + authenticationInfo.setStatus(Status.SUCCESS); } } } } catch (KeystoreException e) { - log.error("KeystoreException occurred ", e); + String msg = "Error occurred while validating device client certificate."; + log.error(msg, e); + authenticationInfo.setStatus(Status.FAILURE); + authenticationInfo.setMessage(msg); } catch (SCEPException e) { - log.error("SCEPException occurred ", e); + String msg = "Error occurred while validating device identification."; + log.error(msg, e); + authenticationInfo.setStatus(Status.FAILURE); + authenticationInfo.setMessage(msg); } return authenticationInfo; } diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java index c9bf8974a7..c274184e55 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java @@ -139,9 +139,7 @@ public class PermissionAuthorizer { } else { return WebappAuthenticator.Status.FAILURE; } - } - } From 476fe5f849d0888e6d00d5bce9ee1d9048a231b9 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Wed, 21 Aug 2024 08:21:51 +0530 Subject: [PATCH 293/343] Add release version report supportablility --- .../mgt/common/ReleaseVersionInfo.java | 68 +++++++++++++++++++ .../common/services/ApplicationManager.java | 9 +++ .../mgt/core/dao/ApplicationDAO.java | 3 + .../GenericApplicationDAOImpl.java | 47 +++++++++++++ .../GenericApplicationReleaseDAOImpl.java | 1 + .../mgt/core/impl/ApplicationManagerImpl.java | 22 ++++++ .../src/main/resources/conf/mdm-ui-config.xml | 1 + 7 files changed, 151 insertions(+) create mode 100644 components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ReleaseVersionInfo.java diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ReleaseVersionInfo.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ReleaseVersionInfo.java new file mode 100644 index 0000000000..218f92187b --- /dev/null +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ReleaseVersionInfo.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 - 2024, 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.application.mgt.common; + +public class ReleaseVersionInfo { + private String version; + private String releaseType; + private String rating; + private String state; + private String uuid; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getReleaseType() { + return releaseType; + } + + public String getRating() { + return rating; + } + + public void setRating(String rating) { + this.rating = rating; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public void setReleaseType(String releaseType) { + this.releaseType = releaseType; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } +} diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java index d40855db19..b0356161c6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.application.mgt.common.services; import io.entgra.device.mgt.core.application.mgt.common.ApplicationType; +import io.entgra.device.mgt.core.application.mgt.common.ReleaseVersionInfo; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.RequestValidatingException; import io.entgra.device.mgt.core.application.mgt.common.exception.ResourceManagementException; @@ -561,4 +562,12 @@ public interface ApplicationManager { * @throws ApplicationManagementException thrown if an error occurs when deleting app folders */ void deleteApplicationArtifactsByTenantId(int tenantId) throws ApplicationManagementException; + + /** + * Extract and retrieve application release version data for a given UUID + * @param uuid UUID of the application + * @return List of {@link ReleaseVersionInfo} + * @throws ApplicationManagementException throws when error encountered while retrieving data + */ + List getApplicationReleaseVersions(String uuid) throws ApplicationManagementException; } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java index 9777469cea..b86747c207 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.application.mgt.core.dao; import io.entgra.device.mgt.core.application.mgt.common.Filter; +import io.entgra.device.mgt.core.application.mgt.common.ReleaseVersionInfo; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.CategoryDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.TagDTO; @@ -286,4 +287,6 @@ public interface ApplicationDAO { * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data */ void deleteApplicationsByTenant(int tenantId) throws ApplicationManagementDAOException; + + List getApplicationReleaseVersions(String uuid, int tenantId) throws ApplicationManagementDAOException; } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 0c4e6c12d7..b327d9803d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.CategoryDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.TagDTO; import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException; +import io.entgra.device.mgt.core.application.mgt.common.ReleaseVersionInfo; import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; @@ -2049,4 +2050,50 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } } + @Override + public List getApplicationReleaseVersions(String uuid, int tenantId) throws ApplicationManagementDAOException { + List releaseVersionInfos = new ArrayList<>(); + String sql = "SELECT VERSION, " + + "RELEASE_TYPE, " + + "RATING, " + + "CURRENT_STATE, " + + "UUID FROM " + + "AP_APP_RELEASE WHERE " + + "AP_APP_ID=" + + "(SELECT AP_APP_ID " + + "FROM AP_APP_RELEASE " + + "WHERE UUID = ? " + + "AND TENANT_ID = ?)"; + try { + Connection connection = getDBConnection(); + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + preparedStatement.setString(1, uuid); + preparedStatement.setInt(2, tenantId); + try (ResultSet resultSet = preparedStatement.executeQuery()) { + ReleaseVersionInfo releaseVersionInfo; + while(resultSet.next()) { + releaseVersionInfo = new ReleaseVersionInfo(); + releaseVersionInfo.setVersion(resultSet.getString("VERSION")); + releaseVersionInfo.setReleaseType(resultSet.getString("RELEASE_TYPE")); + releaseVersionInfo.setRating(resultSet.getString("RATING")); + releaseVersionInfo.setState(resultSet.getString("CURRENT_STATE")); + releaseVersionInfo.setUuid(resultSet.getString("UUID")); + releaseVersionInfos.add(releaseVersionInfo); + } + } + } + } catch (DBConnectionException e) { + String msg = "Error encountered while acquiring database connection to get available release versions for " + + "UUID : " + uuid ; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } catch (SQLException e) { + String msg = "SQL error occurred while getting available release versions for : " + uuid + + "Executed query : [" + sql + "]"; + log.error(msg, e); + throw new ApplicationManagementDAOException(msg, e); + } + return releaseVersionInfos; + } + } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java index 8dc97494c0..95b7c8584c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java @@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFactory; import java.sql.*; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.StringJoiner; diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index 29d7d84ae5..e37ec062a3 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.application.mgt.core.impl; +import io.entgra.device.mgt.core.application.mgt.common.ReleaseVersionInfo; import io.entgra.device.mgt.core.application.mgt.common.exception.FileDownloaderServiceException; import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException; import io.entgra.device.mgt.core.application.mgt.core.dao.*; @@ -4500,4 +4501,25 @@ public class ApplicationManagerImpl implements ApplicationManager { throw new ApplicationManagementException(msg, e); } } + + /** + * Retrieve {@link ReleaseVersionInfo} for a given package name + * @param uuid UUID of the application release + * @return List of {@link ReleaseVersionInfo} + * @throws ApplicationManagementException throws when error encountered while retrieving data + */ + @Override + public List getApplicationReleaseVersions(String uuid) throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + ConnectionManagerUtil.openDBConnection(); + return applicationDAO.getApplicationReleaseVersions(uuid, tenantId); + } catch (ApplicationManagementDAOException e) { + String msg = "Error occurred while getting available application releases for uuid : " + uuid; + log.error(msg, e); + throw new ApplicationManagementException(msg, e); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } + } } diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index da4191cff2..43e5c59f98 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -240,6 +240,7 @@ am:admin:store:app:review:update am:admin:store:app:sub:view am:admin:store:app:sub:modify + am:admin:store:app:release-versions:view dm:device-type:view and:enterprise:modify and:enterprise:view From b8542bfffd851adae92fef1c1325c0718b30411c Mon Sep 17 00:00:00 2001 From: Gimhan-minion Date: Fri, 30 Aug 2024 01:44:40 +0530 Subject: [PATCH 294/343] Fix data type inconsistency in tag db scripts --- .../src/test/resources/sql/h2.sql | 6 +++--- .../src/main/resources/dbscripts/cdm/h2.sql | 6 +++--- .../src/main/resources/dbscripts/cdm/mssql.sql | 10 +++++----- .../src/main/resources/dbscripts/cdm/mysql.sql | 10 +++++----- .../src/main/resources/dbscripts/cdm/oracle.sql | 6 +++--- .../src/main/resources/dbscripts/cdm/postgresql.sql | 6 +++--- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index 7ee776da58..323f52762a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -672,7 +672,7 @@ CREATE TABLE IF NOT EXISTS DM_METADATA ( -- DM_TAG TABLE -- CREATE TABLE IF NOT EXISTS DM_TAG ( - ID BIGINT AUTO_INCREMENT, + ID INTEGER AUTO_INCREMENT, NAME VARCHAR(255) NOT NULL, DESCRIPTION VARCHAR(255) NULL, TENANT_ID INTEGER NOT NULL, @@ -683,8 +683,8 @@ CREATE TABLE IF NOT EXISTS DM_TAG ( -- DM_DEVICE_TAG_MAPPING TABLE -- CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING ( - ENROLMENT_ID BIGINT NOT NULL, - TAG_ID BIGINT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + TAG_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 7507ca0d59..6ba0077069 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -878,7 +878,7 @@ CREATE TABLE IF NOT EXISTS DM_CEA_POLICIES ( -- DM_TAG TABLE -- CREATE TABLE IF NOT EXISTS DM_TAG ( - ID BIGINT AUTO_INCREMENT, + ID INTEGER AUTO_INCREMENT, NAME VARCHAR(255) NOT NULL, DESCRIPTION VARCHAR(255) NULL, TENANT_ID INTEGER NOT NULL, @@ -889,8 +889,8 @@ CREATE TABLE IF NOT EXISTS DM_TAG ( -- DM_DEVICE_TAG_MAPPING TABLE -- CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING ( - ENROLMENT_ID BIGINT NOT NULL, - TAG_ID BIGINT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + TAG_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index dc39bb4d16..272066798d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -954,19 +954,19 @@ END; -- DM_TAG TABLE -- CREATE TABLE IF NOT EXISTS DM_TAG ( - ID BIGINT IDENTITY(1,1) PRIMARY KEY, + ID INTEGER IDENTITY(1,1) PRIMARY KEY, NAME NVARCHAR(255) NOT NULL, DESCRIPTION NVARCHAR(255) NULL, - TENANT_ID INT NOT NULL, + TENANT_ID INTEGER NOT NULL, CONSTRAINT DM_TAG_NAME_TENANT_UNIQUE UNIQUE (NAME, TENANT_ID) ); -- END OF DM_TAG TABLE -- -- DM_DEVICE_TAG_MAPPING TABLE -- CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING ( - ENROLMENT_ID BIGINT NOT NULL, - TAG_ID BIGINT NOT NULL, - TENANT_ID INT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + TAG_ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), FOREIGN KEY (TAG_ID) REFERENCES DM_TAG(ID) ON DELETE CASCADE diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index a943265bdb..773fe53b34 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -953,19 +953,19 @@ CREATE TABLE IF NOT EXISTS DM_CEA_POLICIES ( -- DM_TAG TABLE -- CREATE TABLE IF NOT EXISTS DM_TAG ( - ID BIGINT AUTO_INCREMENT PRIMARY KEY, + ID INTEGER AUTO_INCREMENT PRIMARY KEY, NAME VARCHAR(255) NOT NULL, DESCRIPTION VARCHAR(255) NULL, - TENANT_ID INT NOT NULL, + TENANT_ID INTEGER NOT NULL, CONSTRAINT DM_TAG_NAME_TENANT_UNIQUE UNIQUE (NAME, TENANT_ID) ); -- END OF DM_TAG TABLE -- -- DM_DEVICE_TAG_MAPPING TABLE -- CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING ( - ENROLMENT_ID BIGINT NOT NULL, - TAG_ID BIGINT NOT NULL, - TENANT_ID INT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + TAG_ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), FOREIGN KEY (TAG_ID) REFERENCES DM_TAG(ID) ON DELETE CASCADE diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 2fa51b9d49..1b1071c290 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -1258,7 +1258,7 @@ END; -- DM_TAG TABLE -- CREATE TABLE DM_TAG ( - ID NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY PRIMARY KEY, + ID NUMBER(10) GENERATED BY DEFAULT ON NULL AS IDENTITY PRIMARY KEY, NAME VARCHAR2(255) NOT NULL, DESCRIPTION VARCHAR2(255) NULL, TENANT_ID NUMBER(10) NOT NULL, @@ -1268,8 +1268,8 @@ CREATE TABLE DM_TAG ( -- DM_DEVICE_TAG_MAPPING TABLE -- CREATE TABLE DM_DEVICE_TAG_MAPPING ( - ENROLMENT_ID NUMBER(19) NOT NULL, - TAG_ID NUMBER(19) NOT NULL, + ENROLMENT_ID NUMBER(10) NOT NULL, + TAG_ID NUMBER(10) NOT NULL, TENANT_ID NUMBER(10) NOT NULL, PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index d9bce9fd04..31591893e1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -884,7 +884,7 @@ CREATE TABLE IF NOT EXISTS DM_CEA_POLICIES ( -- DM_TAG TABLE -- CREATE TABLE IF NOT EXISTS DM_TAG ( - ID BIGSERIAL PRIMARY KEY, + ID INTEGER PRIMARY KEY, NAME VARCHAR(255) NOT NULL, DESCRIPTION VARCHAR(255) NULL, TENANT_ID INTEGER NOT NULL, @@ -894,8 +894,8 @@ CREATE TABLE IF NOT EXISTS DM_TAG ( -- DM_DEVICE_TAG_MAPPING TABLE -- CREATE TABLE IF NOT EXISTS DM_DEVICE_TAG_MAPPING ( - ENROLMENT_ID BIGINT NOT NULL, - TAG_ID BIGINT NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, + TAG_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ENROLMENT_ID, TAG_ID, TENANT_ID), FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT(ID), From afa329455527cf27dc0093a49dfa5af435c13c54 Mon Sep 17 00:00:00 2001 From: nipuni Date: Thu, 29 Aug 2024 10:15:11 +0530 Subject: [PATCH 295/343] Fix search by middle part of the username is not working in uninstall table in app store. --- .../mgt/core/dao/impl/device/GenericDeviceDAOImpl.java | 6 +++--- .../mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java | 6 +++--- .../mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java index e116df7490..5586be8002 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/GenericDeviceDAOImpl.java @@ -1317,7 +1317,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { query += " AND i.VALUE_FIELD LIKE ?" ; } if (user != null && !user.isEmpty()) { - query += " AND e.OWNER = ?"; + query += " AND e.OWNER LIKE ?"; isOwnerProvided = true; } if (status != null && !status.isEmpty()) { @@ -1347,7 +1347,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); if (isDeviceNameProvided) { - ps.setString(index++, name + "%"); + ps.setString(index++, "%" + name + "%"); } if (isOwnershipProvided) { ps.setString(index++, ownership); @@ -1356,7 +1356,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl { ps.setString(index++, "%" + serial + "%"); } if (isOwnerProvided) { - ps.setString(index++, user); + ps.setString(index++, "%" + user + "%"); } if (isStatusProvided) { for (String deviceStatus : status) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index 0f502cf874..ac63399d38 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -1068,7 +1068,7 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { isOwnershipProvided = true; } if (user != null && !user.isEmpty()) { - query += " AND e.OWNER = ?"; + query += " AND e.OWNER LIKE ?"; isOwnerProvided = true; } if (status != null && !status.isEmpty()) { @@ -1099,13 +1099,13 @@ public class PostgreSQLDeviceDAOImpl extends GenericDeviceDAOImpl { ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); if (isDeviceNameProvided) { - ps.setString(index++, name + "%"); + ps.setString(index++, "%" + name + "%"); } if (isOwnershipProvided) { ps.setString(index++, ownership); } if (isOwnerProvided) { - ps.setString(index++, user); + ps.setString(index++, "%" + user + "%"); } if (isStatusProvided) { for (String deviceStatus : status) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 7de242ead9..9dc29afa72 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -936,7 +936,7 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { isOwnershipProvided = true; } if (user != null && !user.isEmpty()) { - query += " AND e.OWNER = ?"; + query += " AND e.OWNER LIKE ?"; isOwnerProvided = true; } if (status != null && !status.isEmpty()) { @@ -967,13 +967,13 @@ public class SQLServerDeviceDAOImpl extends GenericDeviceDAOImpl { ps.setString(index++, EnrolmentInfo.Status.REMOVED.toString()); ps.setString(index++, EnrolmentInfo.Status.DELETED.toString()); if (isDeviceNameProvided) { - ps.setString(index++, name + "%"); + ps.setString(index++, "%" + name + "%"); } if (isOwnershipProvided) { ps.setString(index++, ownership); } if (isOwnerProvided) { - ps.setString(index++, user); + ps.setString(index++, "%" + user + "%"); } if (isStatusProvided) { for (String deviceStatus : status) { From 9ce605d883fa2dc38c6f7748dfe86e0d1a796b18 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Fri, 30 Aug 2024 17:43:32 +0530 Subject: [PATCH 296/343] Update release rating data type --- .../mgt/core/application/mgt/common/ReleaseVersionInfo.java | 6 +++--- .../dao/impl/application/GenericApplicationDAOImpl.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ReleaseVersionInfo.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ReleaseVersionInfo.java index 218f92187b..e1e7548d68 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ReleaseVersionInfo.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/ReleaseVersionInfo.java @@ -22,7 +22,7 @@ package io.entgra.device.mgt.core.application.mgt.common; public class ReleaseVersionInfo { private String version; private String releaseType; - private String rating; + private double rating; private String state; private String uuid; @@ -38,11 +38,11 @@ public class ReleaseVersionInfo { return releaseType; } - public String getRating() { + public double getRating() { return rating; } - public void setRating(String rating) { + public void setRating(double rating) { this.rating = rating; } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index b327d9803d..c99a06eeb4 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -2075,7 +2075,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic releaseVersionInfo = new ReleaseVersionInfo(); releaseVersionInfo.setVersion(resultSet.getString("VERSION")); releaseVersionInfo.setReleaseType(resultSet.getString("RELEASE_TYPE")); - releaseVersionInfo.setRating(resultSet.getString("RATING")); + releaseVersionInfo.setRating(resultSet.getDouble("RATING")); releaseVersionInfo.setState(resultSet.getString("CURRENT_STATE")); releaseVersionInfo.setUuid(resultSet.getString("UUID")); releaseVersionInfos.add(releaseVersionInfo); From 320d5215de079200ac06475251dad999e38ad152 Mon Sep 17 00:00:00 2001 From: nipuni Date: Fri, 30 Aug 2024 13:39:52 +0530 Subject: [PATCH 297/343] Implement the search API for Subscription details view --- .../common/services/SubscriptionManager.java | 5 +- .../mgt/core/dao/SubscriptionDAO.java | 71 +++++- .../GenericSubscriptionDAOImpl.java | 232 ++++++++++++------ .../OracleSubscriptionDAOImpl.java | 106 +++++--- .../SQLServerSubscriptionDAOImpl.java | 107 +++++--- .../core/impl/SubscriptionManagerImpl.java | 27 +- 6 files changed, 381 insertions(+), 167 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java index 1e70f1b9d6..fd16e70872 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java @@ -187,11 +187,14 @@ public interface SubscriptionManager { * @param subType subscription type of the application. * @param offsetValue offset value for get paginated request. * @param limitValue limit value for get paginated request. + * @param uninstalled a Boolean flag indicating the filter criteria for retrieve subscription data + * @param searchName an optional search term to filter the results by name. If null or empty, no filtering by name is applied. * @return {@link PaginationResult} pagination result of the category details. * @throws {@link ApplicationManagementException} Exception of the application management */ PaginationResult getAppInstalledSubscribers(int offsetValue, int limitValue, String appUUID, - String subType) throws ApplicationManagementException; + String subType, Boolean uninstalled, String searchName) + throws ApplicationManagementException; /** * This method is responsible to provide application subscription data for given application release UUID. diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java index c35c4a5251..cd1755fc21 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java @@ -198,14 +198,33 @@ public interface SubscriptionDAO { * @param offsetValue offset value for get paginated result * @param limitValue limit value for get paginated result * @param appReleaseId id of the application release. + * @param uninstalled a Boolean flag indicating the filter criteria for getting users: + * - `true` to get only unsubscribed users, + * - `false` to get only subscribed users, + * - `null` to get all users regardless of their unsubscription status. + * @param searchName an optional search term to filter the results by username. * @return subscribedUsers - list of app subscribed users. * @throws {@link ApplicationManagementDAOException} if connections establishment fails. */ List getAppSubscribedUsers(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException; - int getSubscribedUserCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + /** + * This method is used to get the count of users who are subscribed or unsubscribed to a specific application release. + * + * @param appReleaseId the ID of the application release for which the user count is to be retrieved. + * @param tenantId the ID of the current tenant. + * @param uninstalled a Boolean flag indicating the filter criteria for counting users: + * - `true` to count only unsubscribed users, + * - `false` to count only subscribed users, + * - `null` to count all users regardless of their unsubscription status. + * @param searchName an optional search term to filter the results by username. + * @return the count of users based on the specified criteria. + * @throws ApplicationManagementDAOException if an error occurs while establishing a database connection or executing the query. + */ + int getSubscribedUserCount(int appReleaseId, int tenantId, Boolean uninstalled, String searchName) + throws ApplicationManagementDAOException; /** * This method is used to get the details of roles @@ -214,14 +233,34 @@ public interface SubscriptionDAO { * @param offsetValue offset value for get paginated request. * @param limitValue limit value for get paginated request. * @param appReleaseId id of the application release. + * @param uninstalled a Boolean flag indicating the filter criteria for getting roles: + * - `true` to get only unsubscribed roles, + * - `false` to get only subscribed roles, + * - `null` to get all roles regardless of their unsubscription status. + * @param searchName an optional search term to filter the results by role name. * @return subscribedRoles - list of app subscribed roles. * @throws {@link ApplicationManagementDAOException} if connections establishment fails. */ List getAppSubscribedRoles(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException; - int getSubscribedRoleCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + /** + * This method retrieves the count of roles subscribed to a given application release. + * The count can be filtered based on the unsubscription status. + * + * @param appReleaseId the ID of the application release for which the subscribed roles are counted. + * @param tenantId the ID of the current tenant. + * @param uninstalled a Boolean flag indicating the filter criteria for counting roles: + * - `true` to count only unsubscribed roles, + * - `false` to count only subscribed roles, + * - `null` to count all roles regardless of their unsubscription status. + * @param searchName an optional search term to filter the results by role name. + * @return the count of roles that match the specified criteria. + * @throws ApplicationManagementDAOException if there is an error while accessing the database or processing the request. + */ + int getSubscribedRoleCount(int appReleaseId, int tenantId, Boolean uninstalled, String searchName) + throws ApplicationManagementDAOException; /** * This method is used to get the details of subscribed groups @@ -230,13 +269,33 @@ public interface SubscriptionDAO { * @param offsetValue offset value for get paginated request. * @param limitValue limit value for get paginated request. * @param appReleaseId id of the application release. + * @param uninstalled a Boolean flag indicating the filter criteria for getting groups: + * - `true` to get only unsubscribed groups, + * - `false` to get only subscribed groups, + * - `null` to get all groups regardless of their unsubscription status. + * @param searchName an optional search term to filter the results by group name. * @return subscribedGroups - list of app subscribed groups. * @throws {@link ApplicationManagementDAOException} if connections establishment fails. */ - List getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId, int tenantId) + List getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId, int tenantId, + Boolean uninstalled, String searchName) throws ApplicationManagementDAOException; - int getSubscribedGroupCount(int appReleaseId, int tenantId) throws ApplicationManagementDAOException; + /** + * This method is used to get the count of subscribed groups + * + * @param tenantId id of the current tenant + * @param appReleaseId id of the application release. + * @param uninstalled a Boolean flag indicating the filter criteria for counting groups: + * - `true` to count only unsubscribed groups, + * - `false` to count only subscribed groups, + * - `null` to count all groups regardless of their unsubscription status. + * @param searchName an optional search term to filter the results by group name. + * @return subscribedGroups - list of app subscribed groups. + * @throws {@link ApplicationManagementDAOException} if connections establishment fails. + */ + int getSubscribedGroupCount(int appReleaseId, int tenantId,Boolean uninstalled, String searchName) + throws ApplicationManagementDAOException; /** * This method is used to get the details of subscribed groups diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 66aec68576..a5701cfdfb 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -967,25 +967,37 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc @Override public List getAppSubscribedUsers(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed users for " + - "given app release id."); + log.debug("Request received in DAO Layer to get subscribed/unsubscribed users for the given app release ID."); } try { Connection conn = this.getDBConnection(); List subscribedUsers = new ArrayList<>(); - String sql = "SELECT " - + "US.USER_NAME AS USER_NAME " - + "FROM AP_USER_SUBSCRIPTION US " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?"; + String sql = "SELECT US.USER_NAME AS USER_NAME " + + "FROM AP_USER_SUBSCRIPTION US " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? "; + if (uninstalled != null) { + sql += "AND UNSUBSCRIBED = ? "; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += "AND US.USER_NAME LIKE ? "; + } + sql += "LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, appReleaseId); - stmt.setInt(2, tenantId); - stmt.setInt(3, limitValue); - stmt.setInt(4, offsetValue); + int index = 1; + stmt.setInt(index++, appReleaseId); + stmt.setInt(index++, tenantId); + if (uninstalled != null) { + stmt.setBoolean(index++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + stmt.setString(index++, "%" + searchName + "%"); + } + stmt.setInt(index++, limitValue); + stmt.setInt(index, offsetValue); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { subscribedUsers.add(rs.getString("USER_NAME")); @@ -994,50 +1006,62 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc return subscribedUsers; } } catch (DBConnectionException e) { - String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed users for given app release id."; + String msg = "Error occurred while obtaining the DB connection to get subscribed/unsubscribed users for the " + + "given app release ID."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed users for given app release id."; + String msg = "SQL Error occurred while getting subscribed/unsubscribed users for the given app release ID."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } } @Override - public int getSubscribedUserCount(int appReleaseId, int tenantId) + public int getSubscribedUserCount(int appReleaseId, int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed users for " + + log.debug("Request received in DAO Layer to get already subscribed/unsubscribed users for " + "given app release id."); } try { Connection conn = this.getDBConnection(); - String sql = "SELECT " - + "COUNT(US.USER_NAME) AS USER_NAME " - + "FROM AP_USER_SUBSCRIPTION US " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ?"; + String sql = "SELECT COUNT(US.USER_NAME) AS USER_COUNT " + + "FROM AP_USER_SUBSCRIPTION US " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ?"; + if (uninstalled != null) { + sql += " AND UNSUBSCRIBED = ?"; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += " AND US.USER_NAME LIKE ?"; + } try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, appReleaseId); - stmt.setInt(2, tenantId); + int index = 1; + stmt.setInt(index++, appReleaseId); + stmt.setInt(index++, tenantId); + if (uninstalled != null) { + stmt.setBoolean(index++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + stmt.setString(index++, "%" + searchName + "%"); + } try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { - return rs.getInt("USER_NAME"); + return rs.getInt("USER_COUNT"); } } return 0; } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed users count for given app release id."; + "subscribed/unsubscribed users count for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed users for given app release id."; + String msg = "SQL Error occurred while getting subscribed/unsubscribed users count for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } @@ -1151,25 +1175,40 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc @Override public List getAppSubscribedRoles(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed roles for " + + log.debug("Request received in DAO Layer to get already subscribed/unsubscribed roles for " + "given app release id."); } try { Connection conn = this.getDBConnection(); List subscribedRoles = new ArrayList<>(); String sql = "SELECT " - + "RS.ROLE_NAME AS ROLE " - + "FROM AP_ROLE_SUBSCRIPTION RS " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?"; + + "RS.ROLE_NAME AS ROLE " + + "FROM AP_ROLE_SUBSCRIPTION RS " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ?"; + if (uninstalled != null) { + sql += " AND UNSUBSCRIBED = ?"; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += " AND RS.ROLE_NAME LIKE ?"; + } + sql += " LIMIT ? OFFSET ?"; try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setInt(1, appReleaseId); - ps.setInt(2, tenantId); - ps.setInt(3, limitValue); - ps.setInt(4, offsetValue); + int paramIndex = 1; + ps.setInt(paramIndex++, appReleaseId); + ps.setInt(paramIndex++, tenantId); + + if (uninstalled != null) { + ps.setBoolean(paramIndex++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + ps.setString(paramIndex++, "%" + searchName + "%"); + } + ps.setInt(paramIndex++, limitValue); + ps.setInt(paramIndex, offsetValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedRoles.add(rs.getString("ROLE")); @@ -1179,49 +1218,61 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed roles for given app release id."; + "subscribed/unsubscribed roles for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed roles for given app release id."; + String msg = "SQL Error occurred while getting subscribed/unsubscribed roles for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } } @Override - public int getSubscribedRoleCount(int appReleaseId, int tenantId) + public int getSubscribedRoleCount(int appReleaseId, int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed roles for " + + log.debug("Request received in DAO Layer to get already subscribed/unsubscribed roles for " + "given app release id."); } try { Connection conn = this.getDBConnection(); String sql = "SELECT " - + "COUNT(RS.ROLE_NAME) AS ROLE_NAME " - + "FROM AP_ROLE_SUBSCRIPTION RS " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ?"; + + "COUNT(RS.ROLE_NAME) AS ROLE_COUNT " + + "FROM AP_ROLE_SUBSCRIPTION RS " + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ?"; + if (uninstalled != null) { + sql += " AND UNSUBSCRIBED = ?"; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += " AND RS.ROLE_NAME LIKE ?"; + } try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, appReleaseId); - stmt.setInt(2, tenantId); - + int paramIndex = 1; + stmt.setInt(paramIndex++, appReleaseId); + stmt.setInt(paramIndex++, tenantId); + if (uninstalled != null) { + stmt.setBoolean(paramIndex++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + stmt.setString(paramIndex++, "%" + searchName + "%"); + } try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { - return rs.getInt("ROLE_NAME"); + return rs.getInt("ROLE_COUNT"); } + return 0; } - return 0; } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed roles count for given app release id."; + "subscribed/unsubscribed roles count for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed roles for given app release id."; + String msg = "SQL Error occurred while getting subscribed/unsubscribed roles count for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } @@ -1269,25 +1320,37 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc @Override public List getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed groups for " + + log.debug("Request received in DAO Layer to get already subscribed/unsubscribed groups for " + "given app release id."); } try { Connection conn = this.getDBConnection(); List subscribedGroups = new ArrayList<>(); - String sql = "SELECT " - + "GS.GROUP_NAME AS APP_GROUPS " - + "FROM AP_GROUP_SUBSCRIPTION GS " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?"; + String sql = "SELECT GS.GROUP_NAME AS APP_GROUPS " + + "FROM AP_GROUP_SUBSCRIPTION GS " + + "WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ?"; + if (uninstalled != null) { + sql += " AND UNSUBSCRIBED = ?"; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += " AND GS.GROUP_NAME LIKE ?"; + } + sql += " LIMIT ? OFFSET ?"; try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setInt(1, appReleaseId); - ps.setInt(2, tenantId); - ps.setInt(3, limitValue); - ps.setInt(4, offsetValue); + int paramIndex = 1; + ps.setInt(paramIndex++, appReleaseId); + ps.setInt(paramIndex++, tenantId); + if (uninstalled != null) { + ps.setBoolean(paramIndex++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + ps.setString(paramIndex++, "%" + searchName + "%"); + } + ps.setInt(paramIndex++, limitValue); + ps.setInt(paramIndex, offsetValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedGroups.add(rs.getString("APP_GROUPS")); @@ -1297,11 +1360,11 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed groups for given app release id."; + "subscribed/unsubscribed groups for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed groups for given " + + String msg = "SQL Error occurred while getting subscribed/unsubscribed groups for given " + "app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); @@ -1309,24 +1372,34 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public int getSubscribedGroupCount(int appReleaseId, int tenantId) + public int getSubscribedGroupCount(int appReleaseId, int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed groups for " + - "given app release id."); + log.debug("Request received in DAO Layer to get the count of subscribed/unsubscribed groups for " + + "given app release id."); } try { Connection conn = this.getDBConnection(); - String sql = "SELECT " - + "COUNT(GS.GROUP_NAME) AS APP_GROUPS_COUNT " - + "FROM AP_GROUP_SUBSCRIPTION GS " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ?"; + String sql = "SELECT COUNT(GS.GROUP_NAME) AS APP_GROUPS_COUNT " + + "FROM AP_GROUP_SUBSCRIPTION GS " + + "WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ?"; + if (uninstalled != null) { + sql += " AND UNSUBSCRIBED = ?"; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += " AND GS.GROUP_NAME LIKE ?"; + } try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, appReleaseId); - stmt.setInt(2, tenantId); - + int paramIndex = 1; + stmt.setInt(paramIndex++, appReleaseId); + stmt.setInt(paramIndex++, tenantId); + if (uninstalled != null) { + stmt.setBoolean(paramIndex++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + stmt.setString(paramIndex++, "%" + searchName + "%"); + } try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { return rs.getInt("APP_GROUPS_COUNT"); @@ -1335,12 +1408,13 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc return 0; } } catch (DBConnectionException e) { - String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed groups count for given app release id."; + String msg = "Error occurred while obtaining the DB connection to get the count of " + + "subscribed/unsubscribed groups for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed groups for given app release id."; + String msg = "SQL Error occurred while getting the count of subscribed/unsubscribed groups for given " + + "app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java index f66051e308..a074672a55 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java @@ -43,10 +43,10 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { @Override public List getAppSubscribedUsers(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed users for " + + log.debug("Request received in DAO Layer to get already subscribed/unsubscribed users for " + "given app release id."); } try { @@ -55,13 +55,28 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { String sql = "SELECT " + "US.USER_NAME AS USER " + "FROM AP_USER_SUBSCRIPTION US " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? "; + if (uninstalled != null) { + sql += "AND UNSUBSCRIBED = ? "; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += "AND US.USER_NAME LIKE ? "; + } + sql += "ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, appReleaseId); - stmt.setInt(2, tenantId); - stmt.setInt(3, offsetValue); - stmt.setInt(4, limitValue); + int index = 1; + stmt.setInt(index++, appReleaseId); + stmt.setInt(index++, tenantId); + if (uninstalled != null) { + stmt.setBoolean(index++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + stmt.setString(index++, "%" + searchName + "%"); + } + stmt.setInt(index++, offsetValue); + stmt.setInt(index, limitValue); + try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { subscribedUsers.add(rs.getString("USER")); @@ -71,11 +86,11 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed users for given app release id."; + "subscribed/unsubscribed users for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed users for given app release id."; + String msg = "SQL Error occurred while getting subscribed/unsubscribed users for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } @@ -83,10 +98,10 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { @Override public List getAppSubscribedRoles(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed roles for " + + log.debug("Request received in DAO Layer to get already subscribed/unsubscribed roles for " + "given app release id."); } try { @@ -95,13 +110,27 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { String sql = "SELECT " + "RS.ROLE_NAME AS ROLE " + "FROM AP_ROLE_SUBSCRIPTION RS " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY RS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? "; + if (uninstalled != null) { + sql += "AND UNSUBSCRIBED = ? "; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += "AND RS.ROLE_NAME LIKE ? "; + } + sql += "ORDER BY RS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setInt(1, appReleaseId); - ps.setInt(2, tenantId); - ps.setInt(3, offsetValue); - ps.setInt(4, limitValue); + int paramIndex = 1; + ps.setInt(paramIndex++, appReleaseId); + ps.setInt(paramIndex++, tenantId); + if (uninstalled != null) { + ps.setBoolean(paramIndex++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + ps.setString(paramIndex++, "%" + searchName + "%"); + } + ps.setInt(paramIndex++, offsetValue); + ps.setInt(paramIndex, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedRoles.add(rs.getString("ROLE")); @@ -111,11 +140,11 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed roles for given app release id."; + "subscribed/unsubscribed roles for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed roles for given app release id."; + String msg = "SQL Error occurred while getting subscribed/unsubscribed roles for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } @@ -123,11 +152,10 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { @Override public List getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed groups for " + - "given app release id."); + log.debug("Request received in DAO Layer to get subscribed/unsubscribed groups for the given app release ID."); } try { Connection conn = this.getDBConnection(); @@ -135,13 +163,26 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { String sql = "SELECT " + "GS.GROUP_NAME AS GROUPS " + "FROM AP_GROUP_SUBSCRIPTION GS " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY GS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + "WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ?"; + if (uninstalled != null) { + sql += " AND UNSUBSCRIBED = ?"; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += " AND GS.GROUP_NAME LIKE ?"; + } + sql += " ORDER BY GS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setInt(1, appReleaseId); - ps.setInt(2, tenantId); - ps.setInt(3, offsetValue); - ps.setInt(4, limitValue); + int paramIndex = 1; + ps.setInt(paramIndex++, appReleaseId); + ps.setInt(paramIndex++, tenantId); + if (uninstalled != null) { + ps.setBoolean(paramIndex++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + ps.setString(paramIndex++, "%" + searchName + "%"); + } + ps.setInt(paramIndex++, offsetValue); + ps.setInt(paramIndex, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedGroups.add(rs.getString("GROUPS")); @@ -150,13 +191,12 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { return subscribedGroups; } } catch (DBConnectionException e) { - String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed groups for given app release id."; + String msg = "Error occurred while obtaining the DB connection to get subscribed/unsubscribed groups" + + " for the given app release ID."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed groups for given " + - "app release id."; + String msg = "SQL Error occurred while getting subscribed/unsubscribed groups for the given app release ID."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java index f715a244c5..622ce0c399 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java @@ -39,10 +39,10 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { @Override public List getAppSubscribedUsers(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed users for " + + log.debug("Request received in DAO Layer to get already subscribed/unsubscribed users for " + "given app release id."); } try { @@ -51,13 +51,28 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { String sql = "SELECT " + "US.USER_NAME AS USER_NAME " + "FROM AP_USER_SUBSCRIPTION US " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? "; + if (uninstalled != null) { + sql += "AND UNSUBSCRIBED = ? "; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += "AND US.USER_NAME LIKE ? "; + } + sql += "ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, appReleaseId); - stmt.setInt(2, tenantId); - stmt.setInt(3, offsetValue); - stmt.setInt(4, limitValue); + int index = 1; + stmt.setInt(index++, appReleaseId); + stmt.setInt(index++, tenantId); + if (uninstalled != null) { + stmt.setBoolean(index++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + stmt.setString(index++, "%" + searchName + "%"); + } + stmt.setInt(index++, offsetValue); + stmt.setInt(index, limitValue); + try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { subscribedUsers.add(rs.getString("USER_NAME")); @@ -67,11 +82,11 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed users for given app release id."; + "subscribed/unsubscribed users for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed users for given app release id."; + String msg = "SQL Error occurred while getting subscribed/unsubscribed users for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } @@ -79,10 +94,10 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { @Override public List getAppSubscribedRoles(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed roles for " + + log.debug("Request received in DAO Layer to get already subscribed/unsubscribed roles for " + "given app release id."); } try { @@ -91,13 +106,29 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { String sql = "SELECT " + "RS.ROLE_NAME AS ROLE " + "FROM AP_ROLE_SUBSCRIPTION RS " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY RS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + "WHERE AP_APP_RELEASE_ID = ? " + + "AND TENANT_ID = ? "; + if (uninstalled != null) { + sql += "AND UNSUBSCRIBED = ? "; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += "AND RS.ROLE_NAME LIKE ? "; + } + sql += "ORDER BY RS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setInt(1, appReleaseId); - ps.setInt(2, tenantId); - ps.setInt(3, offsetValue); - ps.setInt(4, limitValue); + int paramIndex = 1; + ps.setInt(paramIndex++, appReleaseId); + ps.setInt(paramIndex++, tenantId); + if (uninstalled != null) { + ps.setBoolean(paramIndex++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + ps.setString(paramIndex++, "%" + searchName + "%"); + } + ps.setInt(paramIndex++, offsetValue); + ps.setInt(paramIndex, limitValue); + try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedRoles.add(rs.getString("ROLE")); @@ -107,11 +138,11 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed roles for given app release id."; + "subscribed/unsubscribed roles for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed roles for given app release id."; + String msg = "SQL Error occurred while getting subscribed/unsubscribed roles for given app release id."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } @@ -119,11 +150,10 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { @Override public List getAppSubscribedGroups(int offsetValue, int limitValue, int appReleaseId, - int tenantId) + int tenantId, Boolean uninstalled, String searchName) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to get already subscribed groups for " + - "given app release id."); + log.debug("Request received in DAO Layer to get subscribed/unsubscribed groups for the given app release ID."); } try { Connection conn = this.getDBConnection(); @@ -131,13 +161,26 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { String sql = "SELECT " + "GS.GROUP_NAME AS GROUPS " + "FROM AP_GROUP_SUBSCRIPTION GS " - + "WHERE " - + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY GS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + + "WHERE AP_APP_RELEASE_ID = ? AND TENANT_ID = ?"; + if (uninstalled != null) { + sql += " AND UNSUBSCRIBED = ?"; + } + if (searchName != null && !searchName.trim().isEmpty()) { + sql += " AND GS.GROUP_NAME LIKE ?"; + } + sql += " ORDER BY GS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement ps = conn.prepareStatement(sql)) { - ps.setInt(1, appReleaseId); - ps.setInt(2, tenantId); - ps.setInt(3, offsetValue); - ps.setInt(4, limitValue); + int paramIndex = 1; + ps.setInt(paramIndex++, appReleaseId); + ps.setInt(paramIndex++, tenantId); + if (uninstalled != null) { + ps.setBoolean(paramIndex++, uninstalled); + } + if (searchName != null && !searchName.trim().isEmpty()) { + ps.setString(paramIndex++, "%" + searchName + "%"); + } + ps.setInt(paramIndex++, offsetValue); + ps.setInt(paramIndex, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedGroups.add(rs.getString("GROUPS")); @@ -146,13 +189,11 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { return subscribedGroups; } } catch (DBConnectionException e) { - String msg = "Error occurred while obtaining the DB connection to get already " + - "subscribed groups for given app release id."; + String msg = "Error occurred while obtaining the DB connection to get subscribed/unsubscribed groups for the given app release ID."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } catch (SQLException e) { - String msg = "SQL Error occurred while getting subscribed groups for given " + - "app release id."; + String msg = "SQL Error occurred while getting subscribed/unsubscribed groups for the given app release ID."; log.error(msg, e); throw new ApplicationManagementDAOException(msg, e); } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 0c5b4057ff..92f0734c9f 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1498,7 +1498,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public PaginationResult getAppInstalledSubscribers(int offsetValue, int limitValue, String appUUID, String subType) + public PaginationResult getAppInstalledSubscribers(int offsetValue, int limitValue, String appUUID, String subType, + Boolean uninstalled, String searchName) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); @@ -1513,20 +1514,16 @@ public class SubscriptionManagerImpl implements SubscriptionManager { if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) { subscriptionList = subscriptionDAO - .getAppSubscribedUsers(offsetValue, limitValue, applicationReleaseId, tenantId); - count = subscriptionDAO.getSubscribedUserCount(applicationReleaseId, tenantId); - } else { - if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) { - subscriptionList = subscriptionDAO - .getAppSubscribedRoles(offsetValue, limitValue, applicationReleaseId, tenantId); - count = subscriptionDAO.getSubscribedRoleCount(applicationReleaseId, tenantId); - } else { - if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) { - subscriptionList = subscriptionDAO - .getAppSubscribedGroups(offsetValue, limitValue, applicationReleaseId, tenantId); - count = subscriptionDAO.getSubscribedGroupCount(applicationReleaseId, tenantId); - } - } + .getAppSubscribedUsers(offsetValue, limitValue, applicationReleaseId, tenantId, uninstalled, searchName); + count = subscriptionDAO.getSubscribedUserCount(applicationReleaseId, tenantId, uninstalled, searchName); + } else if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) { + subscriptionList = subscriptionDAO + .getAppSubscribedRoles(offsetValue, limitValue, applicationReleaseId, tenantId, uninstalled, searchName); + count = subscriptionDAO.getSubscribedRoleCount(applicationReleaseId, tenantId, uninstalled, searchName); + } else if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) { + subscriptionList = subscriptionDAO + .getAppSubscribedGroups(offsetValue, limitValue, applicationReleaseId, tenantId, uninstalled, searchName); + count = subscriptionDAO.getSubscribedGroupCount(applicationReleaseId, tenantId, uninstalled, searchName); } paginationResult.setData(subscriptionList); From c37cf31ffed35b5167315931e1f405827bf72079 Mon Sep 17 00:00:00 2001 From: pasindu Date: Fri, 30 Aug 2024 12:03:48 +0530 Subject: [PATCH 298/343] Update operations status when serve startup --- .../DeviceManagementConfigService.java | 177 ++++++++++++++++++ .../DeviceManagementConfigServiceImpl.java | 92 +++++++++ .../DeviceManagementServiceComponent.java | 3 + .../internal/OperationStartupHandler.java | 89 +++++++++ .../task/OperationConfigurationService.java | 113 +++++++++++ .../status/task/dto/OperationConfig.java | 55 ++++++ ...OperationConfigAlreadyExistsException.java | 60 ++++++ .../exceptions/OperationConfigException.java | 60 ++++++ .../OperationConfigNotFoundException.java | 60 ++++++ .../core/operation/mgt/dao/OperationDAO.java | 3 + .../mgt/dao/impl/GenericOperationDAOImpl.java | 34 ++++ 11 files changed, 746 insertions(+) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/OperationStartupHandler.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/dto/OperationConfig.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigAlreadyExistsException.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigException.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigNotFoundException.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java index e5d65dd4d3..97627393d5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/DeviceManagementConfigService.java @@ -25,6 +25,7 @@ import io.entgra.device.mgt.core.device.mgt.common.configuration.mgt.DeviceConfi import io.entgra.device.mgt.core.device.mgt.common.general.TenantDetail; import io.entgra.device.mgt.core.device.mgt.config.api.beans.ErrorResponse; import io.swagger.annotations.*; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.dto.OperationConfig; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -77,6 +78,13 @@ import java.util.List; key = "admin:permissions:add", roles = {"Internal/devicemgt-user"}, permissions = {"/permissions/add"} + ), + @Scope( + name = "Manage operation configuration", + description = "Add or update operation configuration", + key = "admin:operation_config:manage", + roles = {"Internal/devicemgt-user"}, + permissions = {"/operation-configuration/manage"} ) } ) @@ -319,4 +327,173 @@ public interface DeviceManagementConfigService { }) @Produces(MediaType.APPLICATION_JSON) Response addPermission(List permissions); + + @GET + @Path("/operation-configuration") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HttpMethod.GET, + value = "Getting operation configuration", + notes = "Retrieve the operation configuration", + tags = "Device Management Configuration", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "scope", value = "admin:operation_config:manage") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully fetched the operation configuration.", + response = OperationConfig.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 400, + message = "Bad Request.", + response = ErrorResponse.class), + @ApiResponse( + code = 401, + message = "Unauthorized. \n Unauthorized operation! Only admin role can perform this operation."), + @ApiResponse( + code = 404, + message = "Not Found. \n No operation found", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while adding operation configuration.", + response = ErrorResponse.class) + }) + Response getOperationConfiguration(); + + @POST + @Path("/operation-configuration") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HttpMethod.POST, + value = "Add operation configuration", + notes = "Add operation configuration.", + tags = "Device Management Configuration", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "scope", value = + "admin:operation_config:manage") + }) + } + ) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK. \n Successfully added the operation configuration.", + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 400, + message = "The incoming request has wrong operation configuration.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while adding operation configuration", + response = ErrorResponse.class) + }) + @Produces(MediaType.APPLICATION_JSON) + Response addOperationConfiguration(OperationConfig config); + + @PUT + @Path("/operation-configuration") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HttpMethod.PUT, + value = "Update operation configuration", + notes = "Update operation configuration.", + tags = "Device Management Configuration", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "scope", value = "admin:operation_config:manage") + }) + } + ) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "OK. \n Successfully Update the operation configuration.", + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 400, + message = "The incoming request has wrong operation configuration.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while adding operation configuration.", + response = ErrorResponse.class) + }) + @Produces(MediaType.APPLICATION_JSON) + Response updateOperationConfiguration(OperationConfig config); + + @DELETE + @Path("/operation-configuration") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HttpMethod.DELETE, + value = "Delete operation configuration", + notes = "Delete operation configuration", + tags = {"Device Management Configuration"}, + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "scope", value = "admin:operation_config:manage") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully deleted the operation configuration", + response = Response.class), + @ApiResponse( + code = 400, + message = "Bad Request.", + response = Response.class), + @ApiResponse( + code = 404, + message = "Not Found. \n Operation configuration not provided", + response = Response.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while deleting the operation configuration.", + response = Response.class) + } + ) + Response deleteOperationConfiguration(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java index a83bd6cc6f..b394f36b78 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/src/main/java/io/entgra/device/mgt/core/device/mgt/config/api/service/impl/DeviceManagementConfigServiceImpl.java @@ -22,6 +22,12 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.logging.Log; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.OTPManagementException; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.OperationConfigurationService; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.dto.OperationConfig; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.exceptions.OperationConfigAlreadyExistsException; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.exceptions.OperationConfigException; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.exceptions.OperationConfigNotFoundException; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -61,6 +67,7 @@ import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; import javax.ws.rs.PUT; +import javax.ws.rs.DELETE; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; @@ -313,4 +320,89 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig return Response.status(Response.Status.OK).build(); } + @GET + @Path("/operation-configuration") + @Produces({MediaType.APPLICATION_JSON}) + public Response getOperationConfiguration() { + OperationConfig config; + try { + config = OperationConfigurationService.getOperationConfig(); + } catch (OperationConfigException e) { + String msg = "Error occurred getting operation configuration"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } + if (config == null) { + String msg = "Operation configuration not provided"; + log.error(msg); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } else { + return Response.status(Response.Status.OK).entity(config).build(); + } + } + + @POST + @Path("/operation-configuration") + @Produces({MediaType.APPLICATION_JSON}) + public Response addOperationConfiguration(OperationConfig config) { + try { + if (config != null) { + OperationConfigurationService.addOperationConfiguration(config); + } else { + String msg = "Operation configuration not provided"; + log.error(msg); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + } catch (OperationConfigException e) { + String msg = "Error occurred adding operation configuration"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (OperationConfigAlreadyExistsException e) { + String msg = "Operation configuration already exists"; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + return Response.status(Response.Status.OK).entity(config).build(); + } + + @PUT + @Path("/operation-configuration") + @Produces({MediaType.APPLICATION_JSON}) + public Response updateOperationConfiguration(OperationConfig config) { + try { + if (config != null) { + OperationConfigurationService.updateOperationConfiguration(config); + } else { + String msg = "Operation configuration body not provided"; + log.error(msg); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + } catch (OperationConfigException e) { + String msg = "Error occurred adding operation configuration"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + return Response.status(Response.Status.OK).entity(config).build(); + } + + @DELETE + @Path("/operation-configuration") + @Produces({MediaType.APPLICATION_JSON}) + public Response deleteOperationConfiguration() { + String msg; + try { + OperationConfigurationService.deleteOperationConfiguration(); + } catch (OperationConfigException e) { + msg = "Error occurred while deleting operation configuration"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (OperationConfigNotFoundException e) { + msg = "Operation configuration not provided"; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } + msg = "Operation configuration deleted successfully"; + log.info(msg); + return Response.status(Response.Status.OK).entity(msg).build(); + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java index 4aae43beb0..b2c9b20ab3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -262,6 +262,9 @@ public class DeviceManagementServiceComponent { UserRoleCreateObserver userRoleCreateObserver = new UserRoleCreateObserver(); bundleContext.registerService(ServerStartupObserver.class.getName(), userRoleCreateObserver, null); + OperationStartupHandler operationStartupHandler = new OperationStartupHandler(); + bundleContext.registerService(ServerStartupObserver.class.getName(), operationStartupHandler, null); + /* Registering Device Management Service */ DeviceManagementProviderService deviceManagementProvider = new DeviceManagementProviderServiceImpl(); DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/OperationStartupHandler.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/OperationStartupHandler.java new file mode 100644 index 0000000000..b29cb012df --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/OperationStartupHandler.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.internal; + +import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationDAO; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; +import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.dto.OperationConfig; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.core.ServerStartupObserver; + +public class OperationStartupHandler implements ServerStartupObserver { + private static final Log log = LogFactory.getLog(OperationStartupHandler.class); + private static final Gson gson = new Gson(); + private final OperationDAO operationDAO = OperationManagementDAOFactory.getOperationDAO(); + private static final String OPERATION_CONFIG = "OPERATION_CONFIG"; + + @Override + public void completingServerStartup() { + + } + + @Override + public void completedServerStartup() { + + MetadataManagementService metadataManagementService = DeviceManagementDataHolder.getInstance().getMetadataManagementService(); + Metadata metadata; + int numOfRecordsUpdated; + + try { + metadata = metadataManagementService.retrieveMetadata(OPERATION_CONFIG); + if (metadata != null) { + OperationConfig operationConfiguration = gson.fromJson(metadata.getMetaValue(), OperationConfig.class); + String[] deviceTypes = operationConfiguration.getDeviceTypes(); + String initialOperationStatus = operationConfiguration.getInitialOperationStatus(); + String requiredStatusChange = operationConfiguration.getRequiredStatusChange(); + + for (String deviceType: deviceTypes) { + try { + OperationManagementDAOFactory.beginTransaction(); + try { + numOfRecordsUpdated = operationDAO.updateOperationByDeviceTypeAndInitialStatus(deviceType, + initialOperationStatus, requiredStatusChange); + log.info(numOfRecordsUpdated + " operations updated successfully for the" + deviceType); + OperationManagementDAOFactory.commitTransaction(); + } catch (OperationManagementDAOException e) { + OperationManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while updating operation status. DeviceType : " + deviceType + ", " + + "Initial operation status: " + initialOperationStatus + ", Required status:" + requiredStatusChange; + log.error(msg, e); + } + } catch (TransactionManagementException e) { + String msg = "Transactional error occurred while updating the operation status"; + log.error(msg, e); + } finally { + OperationManagementDAOFactory.closeConnection(); + } + } + } else { + log.info("Operation configuration not provided"); + } + } catch (MetadataManagementException e) { + String msg = "Error occurred while retrieving the operation configuration"; + log.error(msg, e); + } + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java new file mode 100644 index 0000000000..96c59ad4fc --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.operation.change.status.task; + +import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyNotFoundException; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; +import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; +import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.dto.OperationConfig; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.exceptions.OperationConfigAlreadyExistsException; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.exceptions.OperationConfigException; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.exceptions.OperationConfigNotFoundException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class OperationConfigurationService { + + private static final Log log = LogFactory.getLog(OperationConfigurationService.class); + private static final Gson gson = new Gson(); + private static final String STRING = "STRING"; + private static final String OPERATION_CONFIG = "OPERATION_CONFIG"; + static MetadataManagementService metadataManagementService = DeviceManagementDataHolder.getInstance().getMetadataManagementService(); + + + public static OperationConfig getOperationConfig() throws OperationConfigException { + + Metadata metadata; + try { + metadata = metadataManagementService.retrieveMetadata(OPERATION_CONFIG); + } catch (MetadataManagementException e) { + String msg = "Error occurred while retrieving operation configuration"; + log.error(msg, e); + throw new OperationConfigException(e); + } + if (metadata != null) { + return gson.fromJson(metadata.getMetaValue(), OperationConfig.class); + } else { + return null; + } + } + + public static void addOperationConfiguration(OperationConfig config) throws OperationConfigException, + OperationConfigAlreadyExistsException { + + Metadata metadata = new Metadata(); + metadata.setDataType(STRING); + metadata.setMetaKey(OPERATION_CONFIG); + metadata.setMetaValue(gson.toJson(config)); + + try { + metadataManagementService.createMetadata(metadata); + } catch (MetadataManagementException e) { + String msg = "Error occurred while adding operation configuration"; + log.error(msg, e); + throw new OperationConfigException(e); + } catch (MetadataKeyAlreadyExistsException e) { + String msg = "Operation configuration already exists"; + log.error(msg, e); + throw new OperationConfigAlreadyExistsException(e); + } + } + + public static void updateOperationConfiguration(OperationConfig config) throws OperationConfigException { + + Metadata metadata = new Metadata(); + metadata.setDataType(STRING); + metadata.setMetaKey(OPERATION_CONFIG); + metadata.setMetaValue(gson.toJson(config)); + + try { + metadataManagementService.updateMetadata(metadata); + } catch (MetadataManagementException e) { + String msg = "Error occurred while updating operation configuration"; + log.error(msg, e); + throw new OperationConfigException(e); + } + } + + public static void deleteOperationConfiguration() throws OperationConfigException, OperationConfigNotFoundException { + + try { + metadataManagementService.deleteMetadata(OPERATION_CONFIG); + } catch (MetadataManagementException e) { + String msg = "Error occurred while deleting operation configuration"; + log.error(msg, e); + throw new OperationConfigException(e); + } catch (MetadataKeyNotFoundException e) { + String msg = "Operation configuration already exists"; + log.error(msg, e); + throw new OperationConfigNotFoundException(e); + } + } + +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/dto/OperationConfig.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/dto/OperationConfig.java new file mode 100644 index 0000000000..5e54e5f062 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/dto/OperationConfig.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.operation.change.status.task.dto; + +/** + * DTO for Operation configuration. + */ + +public class OperationConfig { + + private String[] deviceTypes; + private String initialOperationStatus; + private String requiredStatusChange; + + public String[] getDeviceTypes() { + return deviceTypes; + } + + public void setDeviceTypes(String[] deviceTypes) { + this.deviceTypes = deviceTypes; + } + + public String getInitialOperationStatus() { + return initialOperationStatus; + } + + public void setInitialOperationStatus(String initialOperationStatus) { + this.initialOperationStatus = initialOperationStatus; + } + + public String getRequiredStatusChange() { + return requiredStatusChange; + } + + public void setRequiredStatusChange(String requiredStatusChange) { + this.requiredStatusChange = requiredStatusChange; + } + +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigAlreadyExistsException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigAlreadyExistsException.java new file mode 100644 index 0000000000..7bcc3b5f1b --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigAlreadyExistsException.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.operation.change.status.task.exceptions; + +/** + * Custom exception class to be used in operation configuration service related functionalities. + */ +public class OperationConfigAlreadyExistsException extends Exception { + + private static final long serialVersionUID = -1814347544027733436L; + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public OperationConfigAlreadyExistsException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public OperationConfigAlreadyExistsException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public OperationConfigAlreadyExistsException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public OperationConfigAlreadyExistsException() { + super(); + } + + public OperationConfigAlreadyExistsException(Throwable cause) { + super(cause); + } + +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigException.java new file mode 100644 index 0000000000..863de5d48a --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigException.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.core.operation.change.status.task.exceptions; + +/** + * Custom exception class to be used in operation configuration related functionalities. + */ +public class OperationConfigException extends Exception { + + private static final long serialVersionUID = -8933146283800122661L; + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public OperationConfigException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public OperationConfigException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public OperationConfigException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public OperationConfigException() { + super(); + } + + public OperationConfigException(Throwable cause) { + super(cause); + } + +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigNotFoundException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigNotFoundException.java new file mode 100644 index 0000000000..c3e5cd0dc3 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/exceptions/OperationConfigNotFoundException.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018 - 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.device.mgt.core.operation.change.status.task.exceptions; + +/** + * Custom exception class to be used in Operation configuration related functionalities. + */ +public class OperationConfigNotFoundException extends Exception { + + private static final long serialVersionUID = 5260831982626354815L; + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public OperationConfigNotFoundException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public OperationConfigNotFoundException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public OperationConfigNotFoundException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public OperationConfigNotFoundException() { + super(); + } + + public OperationConfigNotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java index c874283a76..60a64a0521 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java @@ -61,6 +61,9 @@ public interface OperationDAO { boolean updateOperationStatus(int enrolmentId, int operationId,Operation.Status status) throws OperationManagementDAOException; + int updateOperationByDeviceTypeAndInitialStatus(String deiceType, String initialStatus, String requiredStatus) + throws OperationManagementDAOException; + void updateEnrollmentOperationsStatus(int enrolmentId, String operationCode, Operation.Status existingStatus, Operation.Status newStatus) throws OperationManagementDAOException; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index 50ec3f1071..fa4b5c4427 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -128,6 +128,40 @@ public class GenericOperationDAOImpl implements OperationDAO { return isUpdated; } + public int updateOperationByDeviceTypeAndInitialStatus(String deiceType, String initialStatus, String requiredStatus) + throws OperationManagementDAOException { + PreparedStatement stmt = null; + int numOfRecordsUpdated; + try { + long time = DeviceManagementDAOUtil.getCurrentUTCTime(); + Connection connection = OperationManagementDAOFactory.getConnection(); + + String sql = "UPDATE DM_ENROLMENT_OP_MAPPING SET STATUS=?, UPDATED_TIMESTAMP=? WHERE DEVICE_TYPE=?"; + + if (initialStatus == null) { + sql += " AND STATUS IS NULL"; + } else { + sql += " AND STATUS=?"; + } + + stmt = connection.prepareStatement(sql); + stmt.setString(1, requiredStatus); + stmt.setLong(2, time); + stmt.setString(3, deiceType); + + if (initialStatus != null) { + stmt.setString(4, initialStatus); + } + numOfRecordsUpdated = stmt.executeUpdate(); + } catch (SQLException e) { + throw new OperationManagementDAOException("Error occurred while update device mapping operation status " + + e.getMessage(), e); + } finally { + OperationManagementDAOUtil.cleanupResources(stmt); + } + return numOfRecordsUpdated; + } + @Override public void updateEnrollmentOperationsStatus(int enrolmentId, String operationCode, Operation.Status existingStatus, Operation.Status newStatus) throws OperationManagementDAOException { From 59056cc8ff06550ca0d5dcd9af69fe9007a0ff14 Mon Sep 17 00:00:00 2001 From: "osh.silva" Date: Tue, 3 Sep 2024 00:40:45 +0530 Subject: [PATCH 299/343] Add tooltip component to features --- .../mgt/core/device/mgt/common/Feature.java | 17 +++++++++++ .../HTTPDeviceTypeManagerService.java | 3 ++ .../device/type/template/config/Feature.java | 29 +++++++++++++++++++ .../ConfigurationBasedFeatureManager.java | 3 ++ 4 files changed, 52 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java index 399389271e..800d142c3e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java @@ -58,6 +58,13 @@ public class Feature implements Serializable { ) private String description; + @ApiModelProperty( + name = "tooltip", + value = "Provides a tooltip for the features.", + required = false + ) + private String tooltip; + @ApiModelProperty( name = "type", value = "Type of the feature.", @@ -139,6 +146,16 @@ public class Feature implements Serializable { this.description = description; } + @XmlElement + public String getTooltip() { + return tooltip; + } + + public void setTooltip(String tooltip) { + this.tooltip = tooltip; + } + + @XmlAttribute public String getType() { return type; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java index 1956962d08..25e3664adc 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java @@ -68,6 +68,9 @@ public class HTTPDeviceTypeManagerService extends DeviceTypeManagerService imple if (feature.getCode() != null && feature.getName() != null) { configFeature.setCode(feature.getCode()); configFeature.setDescription(feature.getDescription()); + if (feature.getTooltip() != null) { + configFeature.setTooltip(feature.getTooltip()); + } configFeature.setName(feature.getName()); if (feature.getMetadataEntries() != null && feature.getMetadataEntries().size() > 0) { List metaValues = new ArrayList<>(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java index 92797621fd..4f20701ef3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java @@ -45,6 +45,7 @@ import java.util.List; @XmlType(name = "Feature", propOrder = { "name", "description", + "tooltip", "operation", "metaData" }) @@ -56,6 +57,9 @@ public class Feature { @XmlElement(name = "Description", required = true) protected String description; + @XmlElement(name = "Tooltip", required = false) + protected String tooltip; + @XmlElement(name = "Operation") protected Operation operation; @@ -117,6 +121,31 @@ public class Feature { this.description = value; } + /** + * Gets the value of the tooltip property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTooltip() { + return tooltip; + } + + /** + * Sets the value of the tooltip property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTooltip(String value) { + this.tooltip = value; + } + + /** * Gets the value of the operation property. * diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java index 4db0d7d108..461eba7776 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java @@ -60,6 +60,9 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { deviceFeature.setCode(feature.getCode()); deviceFeature.setName(feature.getName()); deviceFeature.setDescription(feature.getDescription()); + if (feature.getTooltip() != null) { + deviceFeature.setTooltip(feature.getTooltip()); + } deviceFeature.setType(feature.getType()); Operation operation = feature.getOperation(); List metadataEntries = null; From f59208f6e79f729a06e0349c04c19662c1977045 Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 3 Sep 2024 09:44:11 +0530 Subject: [PATCH 300/343] Save OperationStartupHandler in data holder --- .../mgt/core/internal/DeviceManagementDataHolder.java | 9 +++++++++ .../core/internal/DeviceManagementServiceComponent.java | 2 ++ 2 files changed, 11 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java index f9ea261793..95d3d9b0a4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -100,6 +100,7 @@ public class DeviceManagementDataHolder { private DeviceStatusManagementService deviceStatusManagementService; private APIApplicationServices apiApplicationServices; private PublisherRESTAPIServices publisherRESTAPIServices; + private OperationStartupHandler operationStartupHandler; private final Map deviceStatusTaskPluginConfigs = Collections.synchronizedMap( new HashMap<>()); @@ -457,4 +458,12 @@ public class DeviceManagementDataHolder { public void setGroupAccessAuthorizationService(GroupAccessAuthorizationService groupAccessAuthorizationService) { this.groupAccessAuthorizationService = groupAccessAuthorizationService; } + + public OperationStartupHandler getOperationStartupHandler() { + return operationStartupHandler; + } + + public void setOperationStartupHandler(OperationStartupHandler operationStartupHandler) { + this.operationStartupHandler = operationStartupHandler; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java index b2c9b20ab3..125a2f0524 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -262,7 +262,9 @@ public class DeviceManagementServiceComponent { UserRoleCreateObserver userRoleCreateObserver = new UserRoleCreateObserver(); bundleContext.registerService(ServerStartupObserver.class.getName(), userRoleCreateObserver, null); + /* Registering Device Operation Management Startup Handler */ OperationStartupHandler operationStartupHandler = new OperationStartupHandler(); + DeviceManagementDataHolder.getInstance().setOperationStartupHandler(operationStartupHandler); bundleContext.registerService(ServerStartupObserver.class.getName(), operationStartupHandler, null); /* Registering Device Management Service */ From 6d324c084ae58325f2aac0c804416fbad3f3aefc Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 3 Sep 2024 09:45:07 +0530 Subject: [PATCH 301/343] Throw msg and the exception in relevent places --- .../status/task/OperationConfigurationService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java index 96c59ad4fc..fe7baac9fb 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java @@ -49,7 +49,7 @@ public class OperationConfigurationService { } catch (MetadataManagementException e) { String msg = "Error occurred while retrieving operation configuration"; log.error(msg, e); - throw new OperationConfigException(e); + throw new OperationConfigException(msg, e); } if (metadata != null) { return gson.fromJson(metadata.getMetaValue(), OperationConfig.class); @@ -71,11 +71,11 @@ public class OperationConfigurationService { } catch (MetadataManagementException e) { String msg = "Error occurred while adding operation configuration"; log.error(msg, e); - throw new OperationConfigException(e); + throw new OperationConfigException(msg, e); } catch (MetadataKeyAlreadyExistsException e) { String msg = "Operation configuration already exists"; log.error(msg, e); - throw new OperationConfigAlreadyExistsException(e); + throw new OperationConfigAlreadyExistsException(msg, e); } } @@ -91,7 +91,7 @@ public class OperationConfigurationService { } catch (MetadataManagementException e) { String msg = "Error occurred while updating operation configuration"; log.error(msg, e); - throw new OperationConfigException(e); + throw new OperationConfigException(msg, e); } } @@ -102,11 +102,11 @@ public class OperationConfigurationService { } catch (MetadataManagementException e) { String msg = "Error occurred while deleting operation configuration"; log.error(msg, e); - throw new OperationConfigException(e); + throw new OperationConfigException(msg, e); } catch (MetadataKeyNotFoundException e) { String msg = "Operation configuration already exists"; log.error(msg, e); - throw new OperationConfigNotFoundException(e); + throw new OperationConfigNotFoundException(msg, e); } } From 87b98a6cb55719eb0b7b408243d899e22bccce43 Mon Sep 17 00:00:00 2001 From: pasindu Date: Tue, 3 Sep 2024 09:46:05 +0530 Subject: [PATCH 302/343] Use try with resources for dao layer --- .../mgt/dao/impl/GenericOperationDAOImpl.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index fa4b5c4427..3df2f41aac 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -130,21 +130,21 @@ public class GenericOperationDAOImpl implements OperationDAO { public int updateOperationByDeviceTypeAndInitialStatus(String deiceType, String initialStatus, String requiredStatus) throws OperationManagementDAOException { - PreparedStatement stmt = null; int numOfRecordsUpdated; - try { - long time = DeviceManagementDAOUtil.getCurrentUTCTime(); - Connection connection = OperationManagementDAOFactory.getConnection(); + long time = DeviceManagementDAOUtil.getCurrentUTCTime(); - String sql = "UPDATE DM_ENROLMENT_OP_MAPPING SET STATUS=?, UPDATED_TIMESTAMP=? WHERE DEVICE_TYPE=?"; + String sql = "UPDATE DM_ENROLMENT_OP_MAPPING SET STATUS=?, UPDATED_TIMESTAMP=? WHERE DEVICE_TYPE=?"; - if (initialStatus == null) { - sql += " AND STATUS IS NULL"; - } else { - sql += " AND STATUS=?"; - } + if (initialStatus == null) { + sql += " AND STATUS IS NULL"; + } else { + sql += " AND STATUS=?"; + } - stmt = connection.prepareStatement(sql); + try ( + Connection connection = OperationManagementDAOFactory.getConnection(); + PreparedStatement stmt = connection.prepareStatement(sql) + ) { stmt.setString(1, requiredStatus); stmt.setLong(2, time); stmt.setString(3, deiceType); @@ -156,8 +156,6 @@ public class GenericOperationDAOImpl implements OperationDAO { } catch (SQLException e) { throw new OperationManagementDAOException("Error occurred while update device mapping operation status " + e.getMessage(), e); - } finally { - OperationManagementDAOUtil.cleanupResources(stmt); } return numOfRecordsUpdated; } From 0272bda2ce8c7d41ba8d977dba2c0780542f4e2c Mon Sep 17 00:00:00 2001 From: pasindu Date: Thu, 5 Sep 2024 09:04:17 +0530 Subject: [PATCH 303/343] Get server startup handlers to a single point in device-mgt core --- .../internal/DeviceManagementDataHolder.java | 10 +-- .../DeviceManagementServiceComponent.java | 11 +-- ...va => DeviceManagementStartupHandler.java} | 78 ++++++++++++++-- .../core/internal/UserRoleCreateObserver.java | 89 ------------------- 4 files changed, 78 insertions(+), 110 deletions(-) rename components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/{OperationStartupHandler.java => DeviceManagementStartupHandler.java} (51%) delete mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/UserRoleCreateObserver.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java index 95d3d9b0a4..c9ae912a70 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -100,7 +100,7 @@ public class DeviceManagementDataHolder { private DeviceStatusManagementService deviceStatusManagementService; private APIApplicationServices apiApplicationServices; private PublisherRESTAPIServices publisherRESTAPIServices; - private OperationStartupHandler operationStartupHandler; + private DeviceManagementStartupHandler deviceManagementStartupHandler; private final Map deviceStatusTaskPluginConfigs = Collections.synchronizedMap( new HashMap<>()); @@ -459,11 +459,11 @@ public class DeviceManagementDataHolder { this.groupAccessAuthorizationService = groupAccessAuthorizationService; } - public OperationStartupHandler getOperationStartupHandler() { - return operationStartupHandler; + public DeviceManagementStartupHandler getDeviceManagementStartupHandler() { + return deviceManagementStartupHandler; } - public void setOperationStartupHandler(OperationStartupHandler operationStartupHandler) { - this.operationStartupHandler = operationStartupHandler; + public void setDeviceManagementStartupHandler(DeviceManagementStartupHandler deviceManagementStartupHandler) { + this.deviceManagementStartupHandler = deviceManagementStartupHandler; } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java index 125a2f0524..58e1d34ec8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -259,13 +259,10 @@ public class DeviceManagementServiceComponent { TenantCreateObserver listener = new TenantCreateObserver(); bundleContext.registerService(Axis2ConfigurationContextObserver.class.getName(), listener, null); - UserRoleCreateObserver userRoleCreateObserver = new UserRoleCreateObserver(); - bundleContext.registerService(ServerStartupObserver.class.getName(), userRoleCreateObserver, null); - - /* Registering Device Operation Management Startup Handler */ - OperationStartupHandler operationStartupHandler = new OperationStartupHandler(); - DeviceManagementDataHolder.getInstance().setOperationStartupHandler(operationStartupHandler); - bundleContext.registerService(ServerStartupObserver.class.getName(), operationStartupHandler, null); + /* Registering Device Management Startup Handler */ + DeviceManagementStartupHandler deviceManagementStartupHandler = new DeviceManagementStartupHandler(); + DeviceManagementDataHolder.getInstance().setDeviceManagementStartupHandler(deviceManagementStartupHandler); + bundleContext.registerService(ServerStartupObserver.class.getName(), deviceManagementStartupHandler, null); /* Registering Device Management Service */ DeviceManagementProviderService deviceManagementProvider = new DeviceManagementProviderServiceImpl(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/OperationStartupHandler.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementStartupHandler.java similarity index 51% rename from components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/OperationStartupHandler.java rename to components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementStartupHandler.java index b29cb012df..56fabedf6c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/OperationStartupHandler.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementStartupHandler.java @@ -15,7 +15,6 @@ * specific language governing permissions and limitations * under the License. */ - package io.entgra.device.mgt.core.device.mgt.core.internal; import com.google.gson.Gson; @@ -23,19 +22,25 @@ import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagement import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.Metadata; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; +import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; +import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.dto.OperationConfig; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationDAO; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; import io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; -import io.entgra.device.mgt.core.device.mgt.core.operation.change.status.task.dto.OperationConfig; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.core.ServerStartupObserver; +import org.wso2.carbon.user.api.AuthorizationManager; +import org.wso2.carbon.user.api.Permission; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.api.UserStoreManager; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -public class OperationStartupHandler implements ServerStartupObserver { - private static final Log log = LogFactory.getLog(OperationStartupHandler.class); +public class DeviceManagementStartupHandler implements ServerStartupObserver { + private static final Log log = LogFactory.getLog(DeviceManagementStartupHandler.class); private static final Gson gson = new Gson(); - private final OperationDAO operationDAO = OperationManagementDAOFactory.getOperationDAO(); private static final String OPERATION_CONFIG = "OPERATION_CONFIG"; + private static final String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; @Override public void completingServerStartup() { @@ -44,11 +49,66 @@ public class OperationStartupHandler implements ServerStartupObserver { @Override public void completedServerStartup() { + userRoleCreateObserver(); + operationStatusChangeObserver(); + } - MetadataManagementService metadataManagementService = DeviceManagementDataHolder.getInstance().getMetadataManagementService(); + private void userRoleCreateObserver() { + try { + UserStoreManager userStoreManager = + DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm( + MultitenantConstants.SUPER_TENANT_ID).getUserStoreManager(); + String tenantAdminName = + DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm( + MultitenantConstants.SUPER_TENANT_ID).getRealmConfiguration().getAdminUserName(); + AuthorizationManager authorizationManager = DeviceManagementDataHolder.getInstance().getRealmService() + .getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID).getAuthorizationManager(); + + if (!userStoreManager.isExistingRole(DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN)) { + userStoreManager.addRole( + DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN, + null, + DeviceManagementConstants.User.PERMISSIONS_FOR_DEVICE_ADMIN); + } else { + for (Permission permission : DeviceManagementConstants.User.PERMISSIONS_FOR_DEVICE_ADMIN) { + authorizationManager.authorizeRole(DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN, + permission.getResourceId(), permission.getAction()); + } + } + if (!userStoreManager.isExistingRole(DeviceManagementConstants.User.DEFAULT_DEVICE_USER)) { + userStoreManager.addRole( + DeviceManagementConstants.User.DEFAULT_DEVICE_USER, + null, + DeviceManagementConstants.User.PERMISSIONS_FOR_DEVICE_USER); + } else { + for (Permission permission : DeviceManagementConstants.User.PERMISSIONS_FOR_DEVICE_USER) { + authorizationManager.authorizeRole(DeviceManagementConstants.User.DEFAULT_DEVICE_USER, + permission.getResourceId(), permission.getAction()); + } + } + userStoreManager.updateRoleListOfUser(tenantAdminName, null, + new String[]{DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN, + DeviceManagementConstants.User.DEFAULT_DEVICE_USER}); + + if (log.isDebugEnabled()) { + log.debug("Device management roles: " + DeviceManagementConstants.User.DEFAULT_DEVICE_USER + ", " + + DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN + " created for the tenant:" + tenantDomain + "." + ); + log.debug("Tenant administrator: " + tenantAdminName + "@" + tenantDomain + + " is assigned to the role:" + DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN + "." + ); + } + } catch (UserStoreException e) { + log.error("Error occurred while creating roles for the tenant: " + tenantDomain + "."); + } + } + + private void operationStatusChangeObserver () { + MetadataManagementService metadataManagementService = DeviceManagementDataHolder + .getInstance().getMetadataManagementService(); + OperationDAO operationDAO = OperationManagementDAOFactory.getOperationDAO(); Metadata metadata; int numOfRecordsUpdated; - try { metadata = metadataManagementService.retrieveMetadata(OPERATION_CONFIG); if (metadata != null) { @@ -57,7 +117,7 @@ public class OperationStartupHandler implements ServerStartupObserver { String initialOperationStatus = operationConfiguration.getInitialOperationStatus(); String requiredStatusChange = operationConfiguration.getRequiredStatusChange(); - for (String deviceType: deviceTypes) { + for (String deviceType : deviceTypes) { try { OperationManagementDAOFactory.beginTransaction(); try { @@ -74,7 +134,7 @@ public class OperationStartupHandler implements ServerStartupObserver { } catch (TransactionManagementException e) { String msg = "Transactional error occurred while updating the operation status"; log.error(msg, e); - } finally { + } finally { OperationManagementDAOFactory.closeConnection(); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/UserRoleCreateObserver.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/UserRoleCreateObserver.java deleted file mode 100644 index f7b2a27a4b..0000000000 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/UserRoleCreateObserver.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2018 - 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.device.mgt.core.internal; - -import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.core.ServerStartupObserver; -import org.wso2.carbon.user.api.AuthorizationManager; -import org.wso2.carbon.user.api.Permission; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.api.UserStoreManager; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -public class UserRoleCreateObserver implements ServerStartupObserver { - private static final Log log = LogFactory.getLog(UserRoleCreateObserver.class); - @Override - public void completingServerStartup() { - - } - - @Override - public void completedServerStartup() { - String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; - - try { - UserStoreManager userStoreManager = - DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm( - MultitenantConstants.SUPER_TENANT_ID).getUserStoreManager(); - String tenantAdminName = - DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm( - MultitenantConstants.SUPER_TENANT_ID).getRealmConfiguration().getAdminUserName(); - AuthorizationManager authorizationManager = DeviceManagementDataHolder.getInstance().getRealmService() - .getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID).getAuthorizationManager(); - - if (!userStoreManager.isExistingRole(DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN)) { - userStoreManager.addRole( - DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN, - null, - DeviceManagementConstants.User.PERMISSIONS_FOR_DEVICE_ADMIN); - } else { - for (Permission permission : DeviceManagementConstants.User.PERMISSIONS_FOR_DEVICE_ADMIN) { - authorizationManager.authorizeRole(DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN, - permission.getResourceId(), permission.getAction()); - } - } - if (!userStoreManager.isExistingRole(DeviceManagementConstants.User.DEFAULT_DEVICE_USER)) { - userStoreManager.addRole( - DeviceManagementConstants.User.DEFAULT_DEVICE_USER, - null, - DeviceManagementConstants.User.PERMISSIONS_FOR_DEVICE_USER); - } else { - for (Permission permission : DeviceManagementConstants.User.PERMISSIONS_FOR_DEVICE_USER) { - authorizationManager.authorizeRole(DeviceManagementConstants.User.DEFAULT_DEVICE_USER, - permission.getResourceId(), permission.getAction()); - } - } - userStoreManager.updateRoleListOfUser(tenantAdminName, null, - new String[] {DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN, - DeviceManagementConstants.User.DEFAULT_DEVICE_USER}); - - if (log.isDebugEnabled()) { - log.debug("Device management roles: " + DeviceManagementConstants.User.DEFAULT_DEVICE_USER + ", " + - DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN + " created for the tenant:" + tenantDomain + "." - ); - log.debug("Tenant administrator: " + tenantAdminName + "@" + tenantDomain + - " is assigned to the role:" + DeviceManagementConstants.User.DEFAULT_DEVICE_ADMIN + "." - ); - } - } catch (UserStoreException e) { - log.error("Error occurred while creating roles for the tenant: " + tenantDomain + "."); - } - } -} From 77a521e550653dd1183d5ef83b1a4d0c8710e47b Mon Sep 17 00:00:00 2001 From: nipuni Date: Fri, 6 Sep 2024 22:26:32 +0530 Subject: [PATCH 304/343] Add special warning message for Factory Reset, Enterprise Wipe, disneroll operations. --- .../mgt/core/device/mgt/common/Feature.java | 164 ++++++++++++++++++ .../HTTPDeviceTypeManagerService.java | 23 +++ .../template/config/ConfirmationTexts.java | 127 ++++++++++++++ .../config/DangerZoneTooltipTexts.java | 90 ++++++++++ .../device/type/template/config/Feature.java | 26 ++- .../type/template/config/Operation.java | 28 ++- .../ConfigurationBasedFeatureManager.java | 27 ++- 7 files changed, 481 insertions(+), 4 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/ConfirmationTexts.java create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DangerZoneTooltipTexts.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java index 800d142c3e..a495acc279 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/Feature.java @@ -93,6 +93,20 @@ public class Feature implements Serializable { ) private List metadataEntries; + @ApiModelProperty( + name = "confirmationTexts", + value = "Disenroll delete confirmation modal texts.", + required = false + ) + private ConfirmationTexts confirmationTexts; + + @ApiModelProperty( + name = "dangerZoneTooltipTexts", + value = "Danger zone tooltip texts.", + required = false + ) + private DangerZoneTooltipTexts dangerZoneTooltipTexts; + @XmlElement public int getId() { return id; @@ -173,6 +187,24 @@ public class Feature implements Serializable { this.hidden = hidden; } + @XmlElement + public ConfirmationTexts getConfirmationTexts() { + return confirmationTexts; + } + + public void setConfirmationTexts(ConfirmationTexts confirmationTexts) { + this.confirmationTexts = confirmationTexts; + } + + @XmlElement + public DangerZoneTooltipTexts getDangerZoneTooltipTexts() { + return dangerZoneTooltipTexts; + } + + public void setDangerZoneTooltipTexts(DangerZoneTooltipTexts dangerZoneTooltipTexts) { + this.dangerZoneTooltipTexts = dangerZoneTooltipTexts; + } + public static class MetadataEntry implements Serializable { private int id; @@ -203,4 +235,136 @@ public class Feature implements Serializable { this.value = value; } } + + public static class ConfirmationTexts implements Serializable { + private int id; + private String deleteConfirmModalTitle; + private String deleteConfirmModalText; + private String deleteConfirmationTextDescribe; + private String deleteConfirmationText; + private String cancelText; + private String confirmText; + private String inputLabel; + private String inputRequireMessage; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCancelText() { + return cancelText; + } + + public void setCancelText(String cancelText) { + this.cancelText = cancelText; + } + + public String getConfirmText() { + return confirmText; + } + + public void setConfirmText(String confirmText) { + this.confirmText = confirmText; + } + + public String getInputLabel() { + return inputLabel; + } + + public void setInputLabel(String inputLabel) { + this.inputLabel = inputLabel; + } + + public String getInputRequireMessage() { + return inputRequireMessage; + } + + public void setInputRequireMessage(String inputRequireMessage) { + this.inputRequireMessage = inputRequireMessage; + } + + public String getDeleteConfirmModalTitle() { + return deleteConfirmModalTitle; + } + + public void setDeleteConfirmModalTitle(String deleteConfirmModalTitle) { + this.deleteConfirmModalTitle = deleteConfirmModalTitle; + } + + public String getDeleteConfirmModalText() { + return deleteConfirmModalText; + } + + public void setDeleteConfirmModalText(String deleteConfirmModalText) { + this.deleteConfirmModalText = deleteConfirmModalText; + } + + public String getDeleteConfirmationTextDescribe() { + return deleteConfirmationTextDescribe; + } + + public void setDeleteConfirmationTextDescribe(String deleteConfirmationTextDescribe) { + this.deleteConfirmationTextDescribe = deleteConfirmationTextDescribe; + } + + public String getDeleteConfirmationText() { + return deleteConfirmationText; + } + + public void setDeleteConfirmationText(String deleteConfirmationText) { + this.deleteConfirmationText = deleteConfirmationText; + } + } + + public static class DangerZoneTooltipTexts implements Serializable { + private String toolTipTitle; + private String toolTipPopConfirmText; + private String confirmText; + private String cancelText; + private String toolTipAvailable; + + public String getToolTipAvailable() { + return toolTipAvailable; + } + + public void setToolTipAvailable(String toolTipAvailable) { + this.toolTipAvailable = toolTipAvailable; + } + + public String getToolTipTitle() { + return toolTipTitle; + } + + public void setToolTipTitle(String toolTipTitle) { + this.toolTipTitle = toolTipTitle; + } + + public String getToolTipPopConfirmText() { + return toolTipPopConfirmText; + } + + public void setToolTipPopConfirmText(String toolTipPopConfirmText) { + this.toolTipPopConfirmText = toolTipPopConfirmText; + } + + public String getConfirmText() { + return confirmText; + } + + public void setConfirmText(String confirmText) { + this.confirmText = confirmText; + } + + public String getCancelText() { + return cancelText; + } + + public void setCancelText(String cancelText) { + this.cancelText = cancelText; + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java index 25e3664adc..82ca6b2082 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java @@ -79,6 +79,29 @@ public class HTTPDeviceTypeManagerService extends DeviceTypeManagerService imple } configFeature.setMetaData(metaValues); } + if (feature.getConfirmationTexts() != null) { + List confirmationTextValues = new ArrayList<>(); + Feature.ConfirmationTexts confirmationText = feature.getConfirmationTexts(); + confirmationTextValues.add(confirmationText.getDeleteConfirmModalTitle()); + confirmationTextValues.add(confirmationText.getDeleteConfirmModalText()); + confirmationTextValues.add(confirmationText.getDeleteConfirmationTextDescribe()); + confirmationTextValues.add(confirmationText.getDeleteConfirmationText()); + confirmationTextValues.add(confirmationText.getCancelText()); + confirmationTextValues.add(confirmationText.getConfirmText()); + confirmationTextValues.add(confirmationText.getInputLabel()); + confirmationTextValues.add(confirmationText.getInputRequireMessage()); + configFeature.setConfirmationTexts(confirmationTextValues); + } + if (feature.getDangerZoneTooltipTexts() != null) { + List dangerZoneTextValues = new ArrayList<>(); + Feature.DangerZoneTooltipTexts dangerZoneText = feature.getDangerZoneTooltipTexts(); + dangerZoneTextValues.add(dangerZoneText.getToolTipTitle()); + dangerZoneTextValues.add(dangerZoneText.getToolTipPopConfirmText()); + dangerZoneTextValues.add(dangerZoneText.getConfirmText()); + dangerZoneTextValues.add(dangerZoneText.getCancelText()); + dangerZoneTextValues.add(dangerZoneText.getToolTipAvailable()); + configFeature.setDangerZoneTooltipTexts(dangerZoneTextValues); + } featureList.add(configFeature); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/ConfirmationTexts.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/ConfirmationTexts.java new file mode 100644 index 0000000000..d3bf15f8e6 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/ConfirmationTexts.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.extensions.device.type.template.config; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "confirmationTexts", propOrder = { + "deleteConfirmModalTitle", + "deleteConfirmModalText", + "deleteConfirmationTextDescribe", + "deleteConfirmationText", + "cancelText", + "confirmText", + "inputLabel", + "inputRequireMessage" +}) +public class ConfirmationTexts { + + @XmlElement(name = "deleteConfirmModalTitle") + private String deleteConfirmModalTitle; + + @XmlElement(name = "deleteConfirmModalText") + private String deleteConfirmModalText; + + @XmlElement(name = "deleteConfirmationTextDescribe") + private String deleteConfirmationTextDescribe; + + @XmlElement(name = "deleteConfirmationText") + private String deleteConfirmationText; + + @XmlElement(name = "cancelText") + private String cancelText; + + @XmlElement(name = "confirmText") + private String confirmText; + + @XmlElement(name = "inputLabel") + private String inputLabel; + + @XmlElement(name = "inputRequireMessage") + private String inputRequireMessage; + + public String getCancelText() { + return cancelText; + } + + public void setCancelText(String cancelText) { + this.cancelText = cancelText; + } + + public String getInputRequireMessage() { + return inputRequireMessage; + } + + public void setInputRequireMessage(String inputRequireMessage) { + this.inputRequireMessage = inputRequireMessage; + } + + public String getInputLabel() { + return inputLabel; + } + + public void setInputLabel(String inputLabel) { + this.inputLabel = inputLabel; + } + + public String getConfirmText() { + return confirmText; + } + + public void setConfirmText(String confirmText) { + this.confirmText = confirmText; + } + + public String getDeleteConfirmModalTitle() { + return deleteConfirmModalTitle; + } + + public void setDeleteConfirmModalTitle(String deleteConfirmModalTitle) { + this.deleteConfirmModalTitle = deleteConfirmModalTitle; + } + + public String getDeleteConfirmModalText() { + return deleteConfirmModalText; + } + + public void setDeleteConfirmModalText(String deleteConfirmModalText) { + this.deleteConfirmModalText = deleteConfirmModalText; + } + + public String getDeleteConfirmationTextDescribe() { + return deleteConfirmationTextDescribe; + } + + public void setDeleteConfirmationTextDescribe(String deleteConfirmationTextDescribe) { + this.deleteConfirmationTextDescribe = deleteConfirmationTextDescribe; + } + + public String getDeleteConfirmationText() { + return deleteConfirmationText; + } + + public void setDeleteConfirmationText(String deleteConfirmationText) { + this.deleteConfirmationText = deleteConfirmationText; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DangerZoneTooltipTexts.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DangerZoneTooltipTexts.java new file mode 100644 index 0000000000..2a38729c99 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DangerZoneTooltipTexts.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2018 - 2024, 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.device.mgt.extensions.device.type.template.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "dangerZoneTooltipTexts", propOrder = { + "toolTipTitle", + "toolTipPopConfirmText", + "confirmText", + "cancelText", + "toolTipAvailable" +}) +public class DangerZoneTooltipTexts { + + @XmlElement(name = "toolTipTitle") + private String toolTipTitle; + + @XmlElement(name = "toolTipPopConfirmText") + private String toolTipPopConfirmText; + + @XmlElement(name = "confirmText") + private String confirmText; + + @XmlElement(name = "cancelText") + private String cancelText; + + @XmlElement(name = "toolTipAvailable") + private String toolTipAvailable; + + public String getToolTipAvailable() { + return toolTipAvailable; + } + + public void setToolTipAvailable(String toolTipAvailable) { + this.toolTipAvailable = toolTipAvailable; + } + + public String getToolTipTitle() { + return toolTipTitle; + } + + public void setToolTipTitle(String toolTipTitle) { + this.toolTipTitle = toolTipTitle; + } + + public String getToolTipPopConfirmText() { + return toolTipPopConfirmText; + } + + public void setToolTipPopConfirmText(String toolTipPopConfirmText) { + this.toolTipPopConfirmText = toolTipPopConfirmText; + } + + public String getConfirmText() { + return confirmText; + } + + public void setConfirmText(String confirmText) { + this.confirmText = confirmText; + } + + public String getCancelText() { + return cancelText; + } + + public void setCancelText(String cancelText) { + this.cancelText = cancelText; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java index 4f20701ef3..a8c32e621b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Feature.java @@ -47,7 +47,9 @@ import java.util.List; "description", "tooltip", "operation", - "metaData" + "metaData", + "confirmationTexts", + "dangerZoneTooltipTexts" }) public class Feature { @@ -73,6 +75,12 @@ public class Feature { @XmlElement(name = "Property", required = true) private List metaData; + @XmlElement(name = "ConfirmationTexts", required = false) + private List confirmationTexts; + + @XmlElement(name = "DangerZoneTooltipTexts", required = false) + private List dangerZoneTooltipTexts; + /** * Gets the value of the name property. * @@ -209,4 +217,20 @@ public class Feature { public void setType(String type) { this.type = type; } + + public List getConfirmationTexts() { + return confirmationTexts; + } + + public void setConfirmationTexts(List confirmationTexts) { + this.confirmationTexts = confirmationTexts; + } + + public List getDangerZoneTooltipTexts() { + return dangerZoneTooltipTexts; + } + + public void setDangerZoneTooltipTexts(List dangerZoneTooltipTexts) { + this.dangerZoneTooltipTexts = dangerZoneTooltipTexts; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Operation.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Operation.java index 289b89e8a0..e7c9275cd5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Operation.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/Operation.java @@ -41,8 +41,10 @@ import javax.xml.bind.annotation.*; */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Operation", propOrder = { - "params", - "metadata" + "params", + "metadata", + "confirmationTexts", + "tooltipTexts" }) public class Operation { @@ -58,6 +60,28 @@ public class Operation { @XmlAttribute(name = "icon") private String icon; + @XmlElement(name = "tooltipTexts", required = false) + private DangerZoneTooltipTexts tooltipTexts; + + @XmlElement(name = "confirmationTexts", required = false) + private ConfirmationTexts confirmationTexts; + + public DangerZoneTooltipTexts getTooltipTexts() { + return tooltipTexts; + } + + public void setTooltipTexts(DangerZoneTooltipTexts tooltipTexts) { + this.tooltipTexts = tooltipTexts; + } + + public ConfirmationTexts getConfirmationTexts() { + return confirmationTexts; + } + + public void setConfirmationTexts(ConfirmationTexts confirmationTexts) { + this.confirmationTexts = confirmationTexts; + } + public Params getParams() { return params; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java index 461eba7776..7b6a55e260 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/feature/ConfigurationBasedFeatureManager.java @@ -116,7 +116,32 @@ public class ConfigurationBasedFeatureManager implements FeatureManager { operationMeta.put(UI_PARAMS, uiParams); operationMeta.put(FORM_PARAMS, formParams); } - + if (operation.getConfirmationTexts() != null) { + Feature.ConfirmationTexts confirmationTexts = new Feature.ConfirmationTexts(); + confirmationTexts.setDeleteConfirmModalTitle( + operation.getConfirmationTexts().getDeleteConfirmModalTitle()); + confirmationTexts.setDeleteConfirmModalText( + operation.getConfirmationTexts().getDeleteConfirmModalText()); + confirmationTexts.setDeleteConfirmationTextDescribe( + operation.getConfirmationTexts().getDeleteConfirmationTextDescribe()); + confirmationTexts.setDeleteConfirmationText( + operation.getConfirmationTexts().getDeleteConfirmationText()); + confirmationTexts.setCancelText(operation.getConfirmationTexts().getCancelText()); + confirmationTexts.setConfirmText(operation.getConfirmationTexts().getConfirmText()); + confirmationTexts.setInputLabel(operation.getConfirmationTexts().getInputLabel()); + confirmationTexts.setInputRequireMessage( + operation.getConfirmationTexts().getInputRequireMessage()); + deviceFeature.setConfirmationTexts(confirmationTexts); + } + if (operation.getTooltipTexts() != null) { + Feature.DangerZoneTooltipTexts tooltipTexts = new Feature.DangerZoneTooltipTexts(); + tooltipTexts.setToolTipTitle(operation.getTooltipTexts().getToolTipTitle()); + tooltipTexts.setToolTipPopConfirmText(operation.getTooltipTexts().getToolTipPopConfirmText()); + tooltipTexts.setConfirmText(operation.getTooltipTexts().getConfirmText()); + tooltipTexts.setCancelText(operation.getTooltipTexts().getCancelText()); + tooltipTexts.setToolTipAvailable(operation.getTooltipTexts().getToolTipAvailable()); + deviceFeature.setDangerZoneTooltipTexts(tooltipTexts); + } if (metadataEntries == null) { metadataEntries = new ArrayList<>(); } From 2da8cdd05feedfb2f540342382570288df096e22 Mon Sep 17 00:00:00 2001 From: ruwin Date: Tue, 10 Sep 2024 07:25:08 +0530 Subject: [PATCH 305/343] Fixed the incorrect device statistics issue happening due to REMOVED and DELETED devices. --- ...BasedSubscriptionManagementHelperServiceImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java index 16834bf2a1..e78ab631f2 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java @@ -195,10 +195,18 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr } List devices = HelperUtil.getGroupManagementProviderService(). getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), false); - List deviceIdsOwnByGroup = devices.stream().map(Device::getId).collect(Collectors.toList()); + List removedIds = devices.stream() + .filter(device -> {String status = String.valueOf(device.getEnrolmentInfo().getStatus()); + return "REMOVED".equalsIgnoreCase(status) || "DELETED".equalsIgnoreCase(status);}) + .map(device -> device.getEnrolmentInfo().getId()).collect(Collectors.toList()); + List enrollmentIdsOwnByGroup = devices.stream().map(device -> device.getEnrolmentInfo().getId()).collect(Collectors.toList()); + enrollmentIdsOwnByGroup.removeAll(removedIds); + List deviceIdsOwnByGroup = devices.stream() + .filter(device -> enrollmentIdsOwnByGroup.contains(device.getEnrolmentInfo().getId())) + .map(Device::getId).collect(Collectors.toList()); SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. getSubscriptionStatistic(deviceIdsOwnByGroup, isUnsubscribe, tenantId, applicationReleaseDTO.getId()); - int allDeviceCount = HelperUtil.getGroupManagementProviderService().getDeviceCount(subscriptionInfo.getIdentifier()); + int allDeviceCount= deviceIdsOwnByGroup.size(); return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); } catch (ApplicationManagementDAOException e) { String msg = "Error encountered while getting subscription statistics for group: " + subscriptionInfo.getIdentifier(); From 6934827920cf94ac499c904564fb2df486837c15 Mon Sep 17 00:00:00 2001 From: ruwin Date: Tue, 10 Sep 2024 07:28:29 +0530 Subject: [PATCH 306/343] Fixed the incorrect device statistics issue happening due to REMOVED and DELETED devices. --- ...GroupBasedSubscriptionManagementHelperServiceImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java index e78ab631f2..d67706e575 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java @@ -196,8 +196,10 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr List devices = HelperUtil.getGroupManagementProviderService(). getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), false); List removedIds = devices.stream() - .filter(device -> {String status = String.valueOf(device.getEnrolmentInfo().getStatus()); - return "REMOVED".equalsIgnoreCase(status) || "DELETED".equalsIgnoreCase(status);}) + .filter(device -> { + String status = String.valueOf(device.getEnrolmentInfo().getStatus()); + return "REMOVED".equalsIgnoreCase(status) || "DELETED".equalsIgnoreCase(status); + }) .map(device -> device.getEnrolmentInfo().getId()).collect(Collectors.toList()); List enrollmentIdsOwnByGroup = devices.stream().map(device -> device.getEnrolmentInfo().getId()).collect(Collectors.toList()); enrollmentIdsOwnByGroup.removeAll(removedIds); @@ -206,7 +208,7 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr .map(Device::getId).collect(Collectors.toList()); SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. getSubscriptionStatistic(deviceIdsOwnByGroup, isUnsubscribe, tenantId, applicationReleaseDTO.getId()); - int allDeviceCount= deviceIdsOwnByGroup.size(); + int allDeviceCount = deviceIdsOwnByGroup.size(); return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); } catch (ApplicationManagementDAOException e) { String msg = "Error encountered while getting subscription statistics for group: " + subscriptionInfo.getIdentifier(); From 30837f2f3d075b272d3c5711dc5a50d70f9d0d66 Mon Sep 17 00:00:00 2001 From: Arshana Date: Tue, 10 Sep 2024 10:02:26 +0530 Subject: [PATCH 307/343] Add missing cope --- .../src/main/resources/conf/mdm-ui-config.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 43e5c59f98..e3145564e1 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -362,6 +362,7 @@ and:ops:change-lock-code and:ops:upgrade-firmware and:ops:send-notif + and:ops:secure-folder dm:geo:geo-fence:manage dm:whitelable:view dm:whitelable:update From 0609b3a9c2f6b48975bbccd33bdae77ead491ec9 Mon Sep 17 00:00:00 2001 From: ruwin Date: Wed, 11 Sep 2024 07:21:33 +0530 Subject: [PATCH 308/343] Used constants instead of hardcoding --- .../GroupBasedSubscriptionManagementHelperServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java index d67706e575..9b5dc445de 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java @@ -39,6 +39,7 @@ import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementHelperUtil; import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException; import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO; @@ -197,8 +198,8 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), false); List removedIds = devices.stream() .filter(device -> { - String status = String.valueOf(device.getEnrolmentInfo().getStatus()); - return "REMOVED".equalsIgnoreCase(status) || "DELETED".equalsIgnoreCase(status); + EnrolmentInfo.Status status = device.getEnrolmentInfo().getStatus(); + return status == EnrolmentInfo.Status.REMOVED || status == EnrolmentInfo.Status.DELETED; }) .map(device -> device.getEnrolmentInfo().getId()).collect(Collectors.toList()); List enrollmentIdsOwnByGroup = devices.stream().map(device -> device.getEnrolmentInfo().getId()).collect(Collectors.toList()); From c6905b968e4acceed4d51f03f4be52c9c1561008 Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Wed, 11 Sep 2024 23:18:21 +0530 Subject: [PATCH 309/343] Improve device status management service --- .../APIManagementProviderServiceImpl.java | 10 +- .../publisher/APIPublisherStartupHandler.java | 4 +- .../impl/DeviceStatusFilterServiceImpl.java | 22 ++-- .../service/impl/MetadataServiceImpl.java | 19 --- .../MetadataKeyAlreadyExistsException.java | 2 +- .../MetadataKeyNotFoundException.java | 2 +- .../mgt/DeviceStatusManagementService.java | 2 +- .../DeviceManagementServiceComponent.java | 8 +- .../DeviceStatusManagementServiceImpl.java | 122 ++++++++++++------ .../MetaRepositoryBasedLicenseManager.java | 10 +- 10 files changed, 115 insertions(+), 86 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java index d3f54d1247..3e612e5838 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -257,14 +257,12 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService(); metadataManagementService.createMetadata(metaData); return apiApplicationKey; - } catch (MetadataManagementException e) { - String msg = "Error occurred while creating meta data for meta key: " + applicationName; + } catch (MetadataKeyAlreadyExistsException e) { + String msg = "Since meta key:" + applicationName + " already exists, meta data creating process failed."; log.error(msg, e); throw new APIManagerException(msg, e); - } catch (MetadataKeyAlreadyExistsException e) { - String msg = - "Since meta key:" + applicationName + " already exists, meta data creating process " + - "failed."; + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating meta data for meta key: " + applicationName; log.error(msg, e); throw new APIManagerException(msg, e); } catch (BadRequestException e) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java index dcad2fa846..bd3451c4e3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -196,10 +196,10 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { APIPublisherDataHolder.getInstance().setPermScopeMapping(permScopeMap); log.info(Constants.PERM_SCOPE_MAPPING_META_KEY + "entry updated successfully"); - } catch (MetadataManagementException e) { - log.error("Error encountered while updating permission scope mapping metadata with default scopes"); } catch (MetadataKeyAlreadyExistsException e) { log.error("Metadata entry already exists for " + Constants.PERM_SCOPE_MAPPING_META_KEY); + } catch (MetadataManagementException e) { + log.error("Error encountered while updating permission scope mapping metadata with default scopes"); } } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java index 7e5fd01437..cc2a2c90e9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java @@ -20,13 +20,20 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceStatusFilterService; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; @@ -42,15 +49,14 @@ public class DeviceStatusFilterServiceImpl implements DeviceStatusFilterService @GET @Path("/{deviceType}") public Response getDeviceStatusFilters(@PathParam("deviceType") String deviceType) { - List result; - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { DeviceStatusManagementService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceStatusManagmentService(); - result = deviceManagementProviderService.getDeviceStatusFilters(deviceType, tenantId); - if (result != null) { - return Response.status(Response.Status.OK).entity(result).build(); - } - return Response.status(Response.Status.NO_CONTENT).entity(false).build(); + return Response.status(Response.Status.OK).entity(deviceManagementProviderService + .getDeviceStatusFilters(deviceType, CarbonContext.getThreadLocalCarbonContext().getTenantId())).build(); + } catch (MetadataKeyNotFoundException e) { + String msg = "Couldn't find the device status filter details for device type: " + deviceType; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } catch (MetadataManagementException e) { String msg = "Error occurred while getting device status filter of the tenant."; log.error(msg, e); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/MetadataServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/MetadataServiceImpl.java index 6ed5270334..2e2999bbda 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/MetadataServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/MetadataServiceImpl.java @@ -36,8 +36,6 @@ import org.apache.commons.logging.LogFactory; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.ByteArrayInputStream; -import java.io.IOException; import java.util.List; /** @@ -147,21 +145,4 @@ public class MetadataServiceImpl implements MetadataService { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } - - /** - * Useful to send files as application/octet-stream responses - */ - private Response sendFileStream(byte[] content) throws IOException { - try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { - Response.ResponseBuilder response = Response - .ok(binaryDuplicate, MediaType.APPLICATION_OCTET_STREAM); - response.status(Response.Status.OK); - response.header("Content-Length", content.length); - return response.build(); - } catch (IOException e) { - String msg = "Error occurred while creating input stream from buffer array. "; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/MetadataKeyAlreadyExistsException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/MetadataKeyAlreadyExistsException.java index f138d5c12c..5feabe2708 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/MetadataKeyAlreadyExistsException.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/MetadataKeyAlreadyExistsException.java @@ -21,7 +21,7 @@ package io.entgra.device.mgt.core.device.mgt.common.exceptions; /** * Custom exception class to be used in MetadataMgmt related functionalities. */ -public class MetadataKeyAlreadyExistsException extends Exception { +public class MetadataKeyAlreadyExistsException extends MetadataManagementException { private static final long serialVersionUID = -1814347544027733436L; private String errorMessage; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/MetadataKeyNotFoundException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/MetadataKeyNotFoundException.java index 965c1b757b..0f95bdaf05 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/MetadataKeyNotFoundException.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/exceptions/MetadataKeyNotFoundException.java @@ -21,7 +21,7 @@ package io.entgra.device.mgt.core.device.mgt.common.exceptions; /** * Custom exception class to be used in MetadataMgmt related functionalities. */ -public class MetadataKeyNotFoundException extends Exception { +public class MetadataKeyNotFoundException extends MetadataManagementException { private static final long serialVersionUID = 5260831982626354815L; private String errorMessage; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/DeviceStatusManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/DeviceStatusManagementService.java index 5ee7c8fce0..5abb9c7e88 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/DeviceStatusManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/DeviceStatusManagementService.java @@ -38,7 +38,7 @@ public interface DeviceStatusManagementService { * * @throws MetadataManagementException if error while resetting default device status */ - void resetToDefaultDeviceStausFilter() throws MetadataManagementException; + void resetToDefaultDeviceStatusFilter(int tenantId) throws MetadataManagementException; /** * This method is useful to update existing allowed device status diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java index 58e1d34ec8..c648965773 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -346,15 +346,15 @@ public class DeviceManagementServiceComponent { bundleContext.registerService(WhiteLabelManagementService.class.getName(), whiteLabelManagementService, null); /* Registering DeviceState Filter Service */ - DeviceStatusManagementService deviceStatusManagemntService = new DeviceStatusManagementServiceImpl(); - DeviceManagementDataHolder.getInstance().setDeviceStatusManagementService(deviceStatusManagemntService); + DeviceStatusManagementService deviceStatusManagementService = new DeviceStatusManagementServiceImpl(); + DeviceManagementDataHolder.getInstance().setDeviceStatusManagementService(deviceStatusManagementService); try { - deviceStatusManagemntService.addDefaultDeviceStatusFilterIfNotExist(tenantId); + deviceStatusManagementService.addDefaultDeviceStatusFilterIfNotExist(tenantId); } catch (Throwable e) { log.error("Error occurred while adding default tenant device status", e); } - bundleContext.registerService(DeviceStatusManagementService.class.getName(), deviceStatusManagemntService, null); + bundleContext.registerService(DeviceStatusManagementService.class.getName(), deviceStatusManagementService, null); /* Registering Event Configuration Service */ EventConfigurationProviderService eventConfigurationService = new EventConfigurationProviderServiceImpl(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java index 1daea9fd24..42c0966da5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java @@ -21,6 +21,7 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataKeyNotFoundException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.AllowedDeviceStatus; @@ -42,12 +43,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; - public class DeviceStatusManagementServiceImpl implements DeviceStatusManagementService { private static final Log log = LogFactory.getLog(DeviceStatusManagementServiceImpl.class); private final MetadataDAO metadataDAO; + private static final Gson gson = new Gson(); public DeviceStatusManagementServiceImpl() { this.metadataDAO = MetadataManagementDAOFactory.getMetadataDAO(); @@ -57,12 +58,11 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement public void addDefaultDeviceStatusFilterIfNotExist(int tenantId) throws MetadataManagementException { try { MetadataManagementDAOFactory.beginTransaction(); - if (!metadataDAO.isExist(tenantId, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY) && !metadataDAO.isExist(tenantId, MetadataConstants.IS_DEVICE_STATUS_CHECK_META_KEY)) { - Metadata defaultDeviceStatusMetadata = constructDeviceStatusMetadata(getDefaultDeviceStatus()); - Metadata defaultDeviceStatusCheckMetadata = constructDeviceStatusCheckMetadata(getDefaultDeviceStatusCheck()); - // Add default device status and device status check metadata entries - addMetadataEntry(tenantId, defaultDeviceStatusMetadata, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY); - addMetadataEntry(tenantId, defaultDeviceStatusCheckMetadata, MetadataConstants.IS_DEVICE_STATUS_CHECK_META_KEY); + if (!metadataDAO.isExist(tenantId, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY)) { + metadataDAO.addMetadata(tenantId, constructDeviceStatusMetadata(getDefaultDeviceStatus())); + } + if (!metadataDAO.isExist(tenantId, MetadataConstants.IS_DEVICE_STATUS_CHECK_META_KEY)) { + metadataDAO.addMetadata(tenantId, constructDeviceStatusCheckMetadata(getDefaultDeviceStatusCheck())); } MetadataManagementDAOFactory.commitTransaction(); } catch (MetadataManagementDAOException e) { @@ -80,8 +80,27 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement } @Override - public void resetToDefaultDeviceStausFilter() throws MetadataManagementException { - + public void resetToDefaultDeviceStatusFilter(int tenantId) throws MetadataManagementException { + try { + MetadataManagementDAOFactory.beginTransaction(); + Metadata defaultDeviceStatusMetadata = constructDeviceStatusMetadata(getDefaultDeviceStatus()); + Metadata defaultDeviceStatusCheckMetadata = constructDeviceStatusCheckMetadata(getDefaultDeviceStatusCheck()); + // Add default device status and device status check metadata entries + metadataDAO.addMetadata(tenantId, defaultDeviceStatusMetadata); + metadataDAO.addMetadata(tenantId, defaultDeviceStatusCheckMetadata); + MetadataManagementDAOFactory.commitTransaction(); + } catch (MetadataManagementDAOException e) { + MetadataManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while inserting default device status metadata entries."; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while starting the transaction to reset default device status filters."; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } finally { + MetadataManagementDAOFactory.closeConnection(); + } } @Override @@ -91,7 +110,6 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement // Retrieve the current device status metadata Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY); if (metadata != null) { - Gson gson = new Gson(); Type listType = new TypeToken>() { }.getType(); List currentStatusList = gson.fromJson(metadata.getMetaValue(), listType); @@ -105,7 +123,7 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement } } metadata.setMetaValue(gson.toJson(currentStatusList)); - updateMetadataEntry(tenantId, metadata, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY); + metadataDAO.updateMetadata(tenantId, metadata); } MetadataManagementDAOFactory.commitTransaction(); } catch (MetadataManagementDAOException e) { @@ -124,14 +142,12 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement @Override public boolean updateDefaultDeviceStatusCheck(int tenantId, boolean isChecked) throws MetadataManagementException { - boolean success = false; try { MetadataManagementDAOFactory.beginTransaction(); if (metadataDAO.isExist(tenantId, MetadataConstants.IS_DEVICE_STATUS_CHECK_META_KEY)) { - Metadata isDeviceStatusChecked = constructDeviceStatusCheckMetadata(isChecked); // Add default device status check metadata entries - updateMetadataEntry(tenantId, isDeviceStatusChecked, MetadataConstants.IS_DEVICE_STATUS_CHECK_META_KEY); - success = true; + metadataDAO.updateMetadata(tenantId, constructDeviceStatusCheckMetadata(isChecked)); + return true; } MetadataManagementDAOFactory.commitTransaction(); } catch (MetadataManagementDAOException e) { @@ -146,7 +162,7 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement } finally { MetadataManagementDAOFactory.closeConnection(); } - return success; + return false; } @Override @@ -154,11 +170,15 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement try { MetadataManagementDAOFactory.openConnection(); Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY); - Gson gson = new Gson(); - Type listType = new TypeToken>() {}.getType(); - List statusList = gson.fromJson(metadata.getMetaValue(), listType); - - return statusList; + if (metadata == null) { + String msg = + "Couldn't find the meta data value for meta key: " + MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY; + log.error(msg); + throw new MetadataKeyNotFoundException(msg); + } + Type listType = new TypeToken>() { + }.getType(); + return gson.fromJson(metadata.getMetaValue(), listType); } catch (MetadataManagementDAOException e) { String msg = "Error occurred while retrieving device status meta data for tenant:" + tenantId; log.error(msg, e); @@ -177,8 +197,14 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement try { MetadataManagementDAOFactory.openConnection(); Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY); - Gson gson = new Gson(); - Type listType = new TypeToken>() {}.getType(); + if (metadata == null) { + String msg = "Couldn't find the meta details of meta Key: " + + MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY + " and tenant Id: " + tenantId; + log.error(msg); + throw new MetadataKeyNotFoundException(msg); + } + Type listType = new TypeToken>() { + }.getType(); List statusList = gson.fromJson(metadata.getMetaValue(), listType); for (AllowedDeviceStatus status : statusList) { @@ -207,6 +233,12 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement try { MetadataManagementDAOFactory.openConnection(); Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.IS_DEVICE_STATUS_CHECK_META_KEY); + if (metadata == null) { + String msg = "Couldn't find the meta data value for meta key: " + + MetadataConstants.IS_DEVICE_STATUS_CHECK_META_KEY + " and tenant Id: " + tenantId; + log.error(msg); + throw new MetadataKeyNotFoundException(msg); + } String metaValue = metadata.getMetaValue(); return Boolean.parseBoolean(metaValue); } catch (MetadataManagementDAOException e) { @@ -227,8 +259,13 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement try { MetadataManagementDAOFactory.openConnection(); Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY); + if (metadata == null) { + String msg = "Couldn't find the meta data value for meta key: " + + MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY + " and tenant Id: " + tenantId; + log.error(msg); + throw new MetadataKeyNotFoundException(msg); + } - Gson gson = new Gson(); Type listType = new TypeToken>() { }.getType(); List statusList = gson.fromJson(metadata.getMetaValue(), listType); @@ -254,22 +291,13 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement } } - private void addMetadataEntry(int tenantId, Metadata metadata, String key) throws MetadataManagementDAOException { - metadataDAO.addMetadata(tenantId, metadata); - if (log.isDebugEnabled()) { - log.debug(key + " metadata entry has been inserted successfully"); - } - } - - private void updateMetadataEntry(int tenantId, Metadata metadata, String key) throws MetadataManagementDAOException { - metadataDAO.updateMetadata(tenantId, metadata); - if (log.isDebugEnabled()) { - log.debug(key + " metadata entry has been updated successfully"); - } - } - + /** + * To construct device status Meta data by using received device status items + * + * @param deviceStatusItems {@link List} + * @return {@link Metadata} + */ private Metadata constructDeviceStatusMetadata(List deviceStatusItems) { - Gson gson = new Gson(); String deviceStatusItemsJsonString = gson.toJson(deviceStatusItems); Metadata metadata = new Metadata(); @@ -279,6 +307,12 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement return metadata; } + /** + * To construct device status check Meta data to either enable it or disable it. + * + * @param deviceStatusCheck True or False + * @return {@link Metadata} + */ private Metadata constructDeviceStatusCheckMetadata(boolean deviceStatusCheck) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("deviceStatusCheck", String.valueOf(deviceStatusCheck)); @@ -289,6 +323,11 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement return metadata; } + /** + * Get default list of device status items from the configuration. + * + * @return List of device status items + */ private List getDefaultDeviceStatus() { DeviceStatusConfigurations deviceStatusConfigurations = UIConfigurationManager.getInstance().getUIConfig().getDeviceStatusConfigurations(); List deviceStatusItems = new ArrayList<>(); @@ -305,6 +344,11 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement return deviceStatusItems; } + /** + * Get Default device status check from the configuration. + * + * @return default status check value, it will be either 'True' or 'False' + */ private boolean getDefaultDeviceStatusCheck() { DeviceStatusConfigurations deviceStatusConfigurations = UIConfigurationManager.getInstance().getUIConfig().getDeviceStatusConfigurations(); boolean deviceStatusCheck = false; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/license/mgt/meta/data/MetaRepositoryBasedLicenseManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/license/mgt/meta/data/MetaRepositoryBasedLicenseManager.java index d86c15c118..c38701e111 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/license/mgt/meta/data/MetaRepositoryBasedLicenseManager.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/license/mgt/meta/data/MetaRepositoryBasedLicenseManager.java @@ -107,13 +107,13 @@ public class MetaRepositoryBasedLicenseManager implements LicenseManager { } else { metadataManagementService.createMetadata(metadata); } - } catch (MetadataManagementException e) { - String msg = "Error occurred while saving the licence value in meta data repository"; + } catch (MetadataKeyAlreadyExistsException e) { + String msg = "Error occurred while saving the licence key and licence key exist.Licence Key: " + + licenceKey; log.error(msg, e); throw new LicenseManagementException(msg, e); - } catch (MetadataKeyAlreadyExistsException e) { - String msg = - "Error occurred while saving the licence key and licence key exist. Licence Key: " + licenceKey; + } catch (MetadataManagementException e) { + String msg = "Error occurred while saving the licence value in meta data repository"; log.error(msg, e); throw new LicenseManagementException(msg, e); } From b61af92293584393ddd319f66f7957fcd73d9dc4 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Thu, 12 Sep 2024 00:26:15 +0530 Subject: [PATCH 310/343] Fix compile failure --- .../task/OperationConfigurationService.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java index fe7baac9fb..522f406a7b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/change/status/task/OperationConfigurationService.java @@ -68,14 +68,14 @@ public class OperationConfigurationService { try { metadataManagementService.createMetadata(metadata); - } catch (MetadataManagementException e) { - String msg = "Error occurred while adding operation configuration"; - log.error(msg, e); - throw new OperationConfigException(msg, e); } catch (MetadataKeyAlreadyExistsException e) { String msg = "Operation configuration already exists"; log.error(msg, e); throw new OperationConfigAlreadyExistsException(msg, e); + } catch (MetadataManagementException e) { + String msg = "Error occurred while adding operation configuration"; + log.error(msg, e); + throw new OperationConfigException(msg, e); } } @@ -99,14 +99,14 @@ public class OperationConfigurationService { try { metadataManagementService.deleteMetadata(OPERATION_CONFIG); - } catch (MetadataManagementException e) { - String msg = "Error occurred while deleting operation configuration"; - log.error(msg, e); - throw new OperationConfigException(msg, e); } catch (MetadataKeyNotFoundException e) { String msg = "Operation configuration already exists"; log.error(msg, e); throw new OperationConfigNotFoundException(msg, e); + } catch (MetadataManagementException e) { + String msg = "Error occurred while deleting operation configuration"; + log.error(msg, e); + throw new OperationConfigException(msg, e); } } From 5cba2d6a816b8df28efe3481f4cc41590f17a891 Mon Sep 17 00:00:00 2001 From: nipuni Date: Wed, 18 Sep 2024 06:54:16 +0530 Subject: [PATCH 311/343] Add improvements for the TenantMgtServiceComponent. --- .../internal/TenantMgtServiceComponent.java | 50 +++++++++++++++---- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java index 9bb4f9067c..58d2385868 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/internal/TenantMgtServiceComponent.java @@ -19,9 +19,7 @@ package io.entgra.device.mgt.core.tenant.mgt.core.internal; import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelManagementService; -import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.WhiteLabelManagementServiceImpl; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; -import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.DeviceStatusManagementServiceImpl; import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerAdminService; import io.entgra.device.mgt.core.tenant.mgt.common.spi.TenantManagerService; import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager; @@ -56,14 +54,6 @@ public class TenantMgtServiceComponent { registerService(TenantManagerAdminService.class.getName(), tenantManagerAdminService, null); TenantManager tenantManager = new TenantManagerImpl(); TenantMgtDataHolder.getInstance().setTenantManager(tenantManager); - WhiteLabelManagementService whiteLabelManagementService = new WhiteLabelManagementServiceImpl(); - componentContext.getBundleContext().registerService(WhiteLabelManagementService.class.getName(), - whiteLabelManagementService, null); - TenantMgtDataHolder.getInstance().setWhiteLabelManagementService(whiteLabelManagementService); - DeviceStatusManagementService deviceStatusManagementService = new DeviceStatusManagementServiceImpl(); - componentContext.getBundleContext().registerService(DeviceStatusManagementService.class.getName(), - deviceStatusManagementService, null); - TenantMgtDataHolder.getInstance().setDeviceStatusManagementService(deviceStatusManagementService); DeviceMgtTenantListener deviceMgtTenantListener = new DeviceMgtTenantListener(); if(log.isDebugEnabled()) { log.info("Tenant management listener is registering"); @@ -85,6 +75,46 @@ public class TenantMgtServiceComponent { // nothing to do } + @Reference( + name = "whiteLabelManagement.service", + service = io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.WhiteLabelManagementService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetWhiteLabelManagementService" + ) + protected void setWhiteLabelManagementService(WhiteLabelManagementService whiteLabelManagementService) { + if(log.isDebugEnabled()) { + log.info("WhiteLabelManagementService is binding"); + } + TenantMgtDataHolder.getInstance().setWhiteLabelManagementService(whiteLabelManagementService); + } + protected void unsetWhiteLabelManagementService(WhiteLabelManagementService whiteLabelManagementService) { + if(log.isDebugEnabled()) { + log.info("WhiteLabelManagementService is unbinding"); + } + TenantMgtDataHolder.getInstance().setWhiteLabelManagementService(null); + } + + @Reference( + name = "deviceStatusManagement.service", + service = io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService.class, + cardinality = ReferenceCardinality.MANDATORY, + policy = ReferencePolicy.DYNAMIC, + unbind = "unsetDeviceStatusManagementService" + ) + protected void setDeviceStatusManagementService(DeviceStatusManagementService deviceStatusManagementService) { + if(log.isDebugEnabled()) { + log.info("DeviceStatusManagementService is binding"); + } + TenantMgtDataHolder.getInstance().setDeviceStatusManagementService(deviceStatusManagementService); + } + protected void unsetDeviceStatusManagementService(DeviceStatusManagementService deviceStatusManagementService) { + if(log.isDebugEnabled()) { + log.info("DeviceStatusManagementService is unbinding"); + } + TenantMgtDataHolder.getInstance().setDeviceStatusManagementService(null); + } + @Reference( name = "application.mgr", service = io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager.class, From a161791fc07eb9636dd2b24517a9a2dd1563fe36 Mon Sep 17 00:00:00 2001 From: ruwin Date: Thu, 19 Sep 2024 12:43:39 +0530 Subject: [PATCH 312/343] Added a method to retrieve the device count based on application type --- ...bscriptionManagementHelperServiceImpl.java | 26 +++++---------- ...bscriptionManagementHelperServiceImpl.java | 4 ++- ...bscriptionManagementHelperServiceImpl.java | 4 ++- .../core/device/mgt/core/dao/GroupDAO.java | 2 ++ .../core/dao/impl/AbstractGroupDAOImpl.java | 33 +++++++++++++++++++ .../GroupManagementProviderService.java | 2 ++ .../GroupManagementProviderServiceImpl.java | 16 ++++++++- 7 files changed, 67 insertions(+), 20 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java index 9b5dc445de..02628d3ef6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java @@ -49,6 +49,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; +import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -147,7 +148,6 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr } finally { ConnectionManagerUtil.closeDBConnection(); } - } @Override @@ -194,22 +194,14 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr log.error(msg); throw new NotFoundException(msg); } - List devices = HelperUtil.getGroupManagementProviderService(). - getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), false); - List removedIds = devices.stream() - .filter(device -> { - EnrolmentInfo.Status status = device.getEnrolmentInfo().getStatus(); - return status == EnrolmentInfo.Status.REMOVED || status == EnrolmentInfo.Status.DELETED; - }) - .map(device -> device.getEnrolmentInfo().getId()).collect(Collectors.toList()); - List enrollmentIdsOwnByGroup = devices.stream().map(device -> device.getEnrolmentInfo().getId()).collect(Collectors.toList()); - enrollmentIdsOwnByGroup.removeAll(removedIds); - List deviceIdsOwnByGroup = devices.stream() - .filter(device -> enrollmentIdsOwnByGroup.contains(device.getEnrolmentInfo().getId())) - .map(Device::getId).collect(Collectors.toList()); - SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO. - getSubscriptionStatistic(deviceIdsOwnByGroup, isUnsubscribe, tenantId, applicationReleaseDTO.getId()); - int allDeviceCount = deviceIdsOwnByGroup.size(); + List deviceStatuses = Arrays.asList(EnrolmentInfo.Status.ACTIVE.name(), + EnrolmentInfo.Status.INACTIVE.name(), EnrolmentInfo.Status.UNREACHABLE.name()); + List devices = HelperUtil.getGroupManagementProviderService().getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), deviceStatuses, false); + List deviceIdsOwnByGroup = devices.stream().map(Device::getId).collect(Collectors.toList()); + SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO.getSubscriptionStatistic + (deviceIdsOwnByGroup, isUnsubscribe, tenantId, applicationReleaseDTO.getId()); + int allDeviceCount = HelperUtil.getGroupManagementProviderService().getDeviceCountWithGroup(subscriptionInfo.getIdentifier(), + applicationDAO.getApplication(applicationReleaseDTO.getUuid(), tenantId).getDeviceTypeId()); return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount); } catch (ApplicationManagementDAOException e) { String msg = "Error encountered while getting subscription statistics for group: " + subscriptionInfo.getIdentifier(); diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java index b667198fd5..c78c27d261 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java @@ -40,6 +40,7 @@ import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementHelperUtil; import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; @@ -210,7 +211,8 @@ public class RoleBasedSubscriptionManagementHelperServiceImpl implements Subscri for (String user : usersWithRole) { PaginationRequest paginationRequest = new PaginationRequest(-1, -1); paginationRequest.setOwner(user); - paginationRequest.setStatusList(Arrays.asList("ACTIVE", "INACTIVE", "UNREACHABLE")); + paginationRequest.setStatusList(Arrays.asList(EnrolmentInfo.Status.ACTIVE.name(), + EnrolmentInfo.Status.INACTIVE.name(),EnrolmentInfo.Status.UNREACHABLE.name())); PaginationResult ownDeviceIds = HelperUtil.getDeviceManagementProviderService(). getAllDevicesIdList(paginationRequest); if (ownDeviceIds.getData() != null) { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java index b8978b1c7a..9b51d51ecd 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/UserBasedSubscriptionManagementHelperServiceImpl.java @@ -39,6 +39,7 @@ import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementHelperUtil; import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService; import io.entgra.device.mgt.core.device.mgt.common.Device; +import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; import io.entgra.device.mgt.core.device.mgt.common.PaginationResult; import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException; @@ -196,7 +197,8 @@ public class UserBasedSubscriptionManagementHelperServiceImpl implements Subscri List deviceListOwnByUser = new ArrayList<>(); PaginationRequest paginationRequest = new PaginationRequest(-1, -1); paginationRequest.setOwner(username); - paginationRequest.setStatusList(Arrays.asList("ACTIVE", "INACTIVE", "UNREACHABLE")); + paginationRequest.setStatusList(Arrays.asList(EnrolmentInfo.Status.ACTIVE.name(), + EnrolmentInfo.Status.INACTIVE.name(),EnrolmentInfo.Status.UNREACHABLE.name())); PaginationResult ownDeviceIds = HelperUtil.getDeviceManagementProviderService(). getAllDevicesIdList(paginationRequest); if (ownDeviceIds.getData() != null) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 5da24ad91d..513995fab1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -489,4 +489,6 @@ public interface GroupDAO { throws GroupManagementDAOException; int getDeviceCount(String groupName, int tenantId) throws GroupManagementDAOException; + + int getDeviceCountWithGroup(String groupName, int deviceTypeId, int tenantId) throws GroupManagementDAOException; } \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java index 21f831e712..94b675d723 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/AbstractGroupDAOImpl.java @@ -1584,4 +1584,37 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO { throw new GroupManagementDAOException(msg, e); } } + + @Override + public int getDeviceCountWithGroup(String groupName, int deviceTypeId, int tenantId) throws GroupManagementDAOException { + int deviceCount = 0; + try { + Connection connection = GroupManagementDAOFactory.getConnection(); + String sql = "SELECT COUNT(e.ID) AS COUNT " + + "FROM DM_GROUP d " + + "INNER JOIN DM_DEVICE_GROUP_MAP m ON d.ID = m.GROUP_ID " + + "INNER JOIN DM_ENROLMENT e ON m.DEVICE_ID = e.DEVICE_ID " + + "INNER JOIN DM_DEVICE r ON e.DEVICE_ID = r.ID " + + "WHERE d.TENANT_ID = ? " + + "AND d.GROUP_NAME = ? " + + "AND r.DEVICE_TYPE_ID = ? " + + "AND e.STATUS NOT IN ('REMOVED', 'DELETED')"; + + try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + preparedStatement.setInt(1, tenantId); + preparedStatement.setString(2, groupName); + preparedStatement.setInt(3, deviceTypeId); + try (ResultSet resultSet = preparedStatement.executeQuery()) { + if (resultSet.next()) { + deviceCount = resultSet.getInt("COUNT"); + } + } + } + return deviceCount; + } catch (SQLException e) { + String msg = "Error occurred while retrieving device count for the group: " + groupName; + log.error(msg, e); + throw new GroupManagementDAOException(msg, e); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index 89af7b66b8..90049beef9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -392,4 +392,6 @@ public interface GroupManagementProviderService { int getDeviceCount(String groupName) throws GroupManagementException; + + int getDeviceCountWithGroup(String groupName, int deviceTypeId) throws GroupManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 1549b3c7b7..f8aa6477a1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -77,7 +77,6 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid private final GroupDAO groupDAO; private final DeviceDAO deviceDAO; - /** * Set groupDAO from GroupManagementDAOFactory when class instantiate. */ @@ -1746,4 +1745,19 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid GroupManagementDAOFactory.closeConnection(); } } + + @Override + public int getDeviceCountWithGroup(String groupName,int deviceTypeId) throws GroupManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + GroupManagementDAOFactory.openConnection(); + return groupDAO.getDeviceCountWithGroup(groupName,deviceTypeId, tenantId); + } catch (SQLException | GroupManagementDAOException e) { + String msg = "Error occurred while retrieving device count."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } finally { + GroupManagementDAOFactory.closeConnection(); + } + } } From a2b8b8bda231e1585bd518191c4dfdc49d22d5ae Mon Sep 17 00:00:00 2001 From: "osh.silva" Date: Thu, 19 Sep 2024 14:17:26 +0530 Subject: [PATCH 313/343] Remove unwanted connection --- .../core/service/DeviceManagementProviderServiceImpl.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 9949cc24b1..df57af8444 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -1177,7 +1177,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv public double generateCost(List allDevices, Timestamp startDate, Timestamp endDate, Cost tenantCost, List deviceStatusNotAvailable, double totalCost) throws DeviceManagementException { List deviceStatus; try { - DeviceManagementDAOFactory.getConnection(); for (Device device : allDevices) { long dateDiff = 0; int tenantId = this.getTenantId(); @@ -1228,10 +1227,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv String msg = "Error occurred in retrieving status history for a device in billing."; log.error(msg, e); throw new DeviceManagementException(msg, e); - } catch (SQLException e) { - String msg = "Error occurred while opening a connection to the data source"; - log.info(msg, e); - throw new DeviceManagementException(msg, e); } return totalCost; } From 9107efb3a672e46406fda8fba4851097e999b41a Mon Sep 17 00:00:00 2001 From: ruwin Date: Thu, 19 Sep 2024 19:13:31 +0530 Subject: [PATCH 314/343] Added a method to get the device count based on app os type with group --- .../mgt/core/service/GroupManagementProviderServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index f8aa6477a1..825d89184d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -77,6 +77,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid private final GroupDAO groupDAO; private final DeviceDAO deviceDAO; + /** * Set groupDAO from GroupManagementDAOFactory when class instantiate. */ From 230192f2d9d6b926b1661c863aaf2ac06f1105a9 Mon Sep 17 00:00:00 2001 From: ruwin Date: Thu, 19 Sep 2024 22:51:12 +0530 Subject: [PATCH 315/343] Completed the requested changes --- .../device/mgt/core/device/mgt/core/dao/GroupDAO.java | 9 +++++++++ .../mgt/core/service/GroupManagementProviderService.java | 9 ++++++++- .../core/service/GroupManagementProviderServiceImpl.java | 8 ++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java index 513995fab1..c883e2790e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/GroupDAO.java @@ -490,5 +490,14 @@ public interface GroupDAO { int getDeviceCount(String groupName, int tenantId) throws GroupManagementDAOException; + /** + * Retrieves the count of devices for a specific group, device type, and tenant. + * + * @param groupName the name of the group + * @param deviceTypeId the ID of the device type (e.g., Android, iOS, Windows) + * @param tenantId the ID of the tenant + * @return the count of devices for the given group, device type, and tenant + * @throws GroupManagementDAOException if an error occurs during the retrieval of the device count + */ int getDeviceCountWithGroup(String groupName, int deviceTypeId, int tenantId) throws GroupManagementDAOException; } \ No newline at end of file diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java index 90049beef9..9750b7471e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderService.java @@ -392,6 +392,13 @@ public interface GroupManagementProviderService { int getDeviceCount(String groupName) throws GroupManagementException; - + /** + * Retrieves the count of devices for a specific group and device type. + * + * @param groupName the name of the group + * @param deviceTypeId the ID of the device type (e.g., Android, iOS, Windows) + * @return the count of devices for the given group and device type + * @throws GroupManagementException if an error occurs during the retrieval of the device count + */ int getDeviceCountWithGroup(String groupName, int deviceTypeId) throws GroupManagementException; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java index 825d89184d..575f2b3fa1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java @@ -1753,8 +1753,12 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid try { GroupManagementDAOFactory.openConnection(); return groupDAO.getDeviceCountWithGroup(groupName,deviceTypeId, tenantId); - } catch (SQLException | GroupManagementDAOException e) { - String msg = "Error occurred while retrieving device count."; + } catch (SQLException e) { + String msg = "SQL error occurred while retrieving device count."; + log.error(msg, e); + throw new GroupManagementException(msg, e); + } catch (GroupManagementDAOException e) { + String msg = "DAO error occurred while retrieving device count."; log.error(msg, e); throw new GroupManagementException(msg, e); } finally { From fe8b784cdf4ba457120a9eafc471971e10725701 Mon Sep 17 00:00:00 2001 From: uddhika Date: Fri, 20 Sep 2024 09:04:28 +0530 Subject: [PATCH 316/343] 204 status code and delete method json body handling --- .../ui/request/interceptor/InvokerHandler.java | 18 ++++++++++++++++++ .../request/interceptor/util/HandlerUtil.java | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java index e8ffb2deef..d561ace090 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/InvokerHandler.java @@ -27,8 +27,10 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.io.entity.StringEntity; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import javax.servlet.annotation.MultipartConfig; @@ -37,6 +39,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import java.io.BufferedReader; import java.io.IOException; @MultipartConfig @@ -183,9 +186,24 @@ public class InvokerHandler extends HttpServlet { @Override protected void doDelete(HttpServletRequest req, HttpServletResponse resp) { try { + String jsonPayload = null; + if (req.getContentLength() > 0) { + StringBuilder jsonBuilder = new StringBuilder(); + String line; + try (BufferedReader reader = req.getReader()) { + while ((line = reader.readLine()) != null) { + jsonBuilder.append(line); + } + } + jsonPayload = jsonBuilder.toString(); + } if (validateRequest(req, resp)) { ClassicHttpRequest deleteRequest = ClassicRequestBuilder.delete(HandlerUtil.generateBackendRequestURL(req, apiEndpoint)).build(); + if (jsonPayload != null && !jsonPayload.isEmpty()) { + StringEntity entity = new StringEntity(jsonPayload, ContentType.APPLICATION_JSON); + deleteRequest.setEntity(entity); + } HandlerUtil.copyRequestHeaders(req, deleteRequest, false); deleteRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + authData.getAccessToken()); ProxyResponse proxyResponse = HandlerUtil.execute(deleteRequest); diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 26c4be4201..57ccd146ad 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -105,6 +105,13 @@ public class HandlerUtil { ProxyResponse handlerResponse = new ProxyResponse(); int statusCode = response.getCode(); if (responseEntity == null) { + if (statusCode == 204) { + handlerResponse.setCode(statusCode); + handlerResponse.setStatus(ProxyResponse.Status.SUCCESS); + handlerResponse.setExecutorResponse("SUCCESS"); + handlerResponse.setHeaders(response.getHeaders()); + return handlerResponse; + } log.error("Received null response for http request : " + httpRequest.getMethod() + " " + httpRequest.getRequestUri()); handlerResponse.setCode(HandlerConstants.INTERNAL_ERROR_CODE); handlerResponse.setStatus(ProxyResponse.Status.ERROR); From 258b312a492d18e80f6d8c11782bdef37f402d89 Mon Sep 17 00:00:00 2001 From: ruwin Date: Fri, 20 Sep 2024 16:04:28 +0530 Subject: [PATCH 317/343] Set limit and offset to -1 for retrieving all device details Updated the logic to set limit and offset values to -1 when fetching device details, ensuring that all devices are retrieved. Without this change, only the devices within the paginated range were being fetched. This change removes the pagination constraint, allowing retrieval of all devices in the system. --- .../GroupBasedSubscriptionManagementHelperServiceImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java index 02628d3ef6..9b357a0a69 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/GroupBasedSubscriptionManagementHelperServiceImpl.java @@ -121,13 +121,12 @@ public class GroupBasedSubscriptionManagementHelperServiceImpl implements Subscr } else { groupDetailsDTO = groupManagementProviderService.getGroupDetailsWithDevices(subscriptionInfo.getIdentifier(), applicationDTO.getDeviceTypeId(), deviceSubscriptionFilterCriteria.getOwner(), deviceSubscriptionFilterCriteria.getName(), - deviceSubscriptionFilterCriteria.getDeviceStatus(), offset, limit); - List paginatedDeviceIdsOwnByGroup = groupDetailsDTO.getDeviceIds(); + deviceSubscriptionFilterCriteria.getDeviceStatus(), -1, -1); + List nonPaginatedDeviceIdsOwnByGroup = groupDetailsDTO.getDeviceIds(); deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(), - isUnsubscribe, tenantId, paginatedDeviceIdsOwnByGroup, dbSubscriptionStatus, + isUnsubscribe, tenantId, nonPaginatedDeviceIdsOwnByGroup, dbSubscriptionStatus, null, deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1); - } deviceCount = SubscriptionManagementHelperUtil.getTotalDeviceSubscriptionCount(deviceSubscriptionDTOS, subscriptionInfo.getDeviceSubscriptionFilterCriteria(), applicationDTO.getDeviceTypeId()); From 50a952a1fa4306a77d76627250096cf6b876df3f Mon Sep 17 00:00:00 2001 From: tcdlpds Date: Tue, 24 Sep 2024 06:34:10 +0530 Subject: [PATCH 318/343] Fix warning message showing in login page --- .../src/test/resources/config/operation/mdm-ui-config.xml | 4 ++-- .../src/main/resources/conf/mdm-ui-config.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/operation/mdm-ui-config.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/operation/mdm-ui-config.xml index 0b04668453..fe3674fac1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/operation/mdm-ui-config.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/operation/mdm-ui-config.xml @@ -343,7 +343,7 @@ and:ops:lock-devices and:ops:unlock-devices and:ops:location - and:ops:clear-password + and:ops:clear-pwd and:ops:control-camera and:ops:enterprise-wipe and:ops:wipe @@ -356,7 +356,7 @@ and:ops:send-app-restrictions and:ops:file-transfer and:ops:set-webclip - and:ops:password-policy + and:ops:pwd-policy and:ops:change-lock-code and:ops:upgrade-firmware and:ops:send-notif diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index e3145564e1..45c3ebe581 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -345,7 +345,7 @@ and:ops:lock-devices and:ops:unlock-devices and:ops:location - and:ops:clear-password + and:ops:clear-pwd and:ops:control-camera and:ops:enterprise-wipe and:ops:wipe @@ -358,7 +358,7 @@ and:ops:send-app-restrictions and:ops:file-transfer and:ops:set-webclip - and:ops:password-policy + and:ops:pwd-policy and:ops:change-lock-code and:ops:upgrade-firmware and:ops:send-notif From aa35121a0394ad79d0fe4b3db443b661a3e7222e Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Wed, 25 Sep 2024 16:51:52 +0530 Subject: [PATCH 319/343] Add jenkins file for PR review --- Jenkinsfile | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..1420c9f347 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,162 @@ +pipeline { + agent { + label 'node-agent' + } + environment { + def isPendingUpstreamDependenciesExists = false + def triggeredViaPush = false + SCANNER_HOME = tool 'sonar-scanner' + JAVA_HOME = '/usr/lib/jvm/java-11-openjdk' + PATH = "${JAVA_HOME}/bin:${env.PATH}" + } + stages { + stage('Initialize Variables') { + steps { + script { + // Define swaggerEndPoint as a global variable + swaggerEndPoint = { + def matcher = (env.CHANGE_URL =~ /^(?https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b)(?[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/) + matcher.find() + return matcher.group('host') + '/api/v1/repos' + matcher.group('path') + } + + echo "Swagger Endpoint: ${swaggerEndPoint.call()}" + } + } + } + + stage('Tool Versioning') { + steps { + script { + sh 'java -version' + sh 'node --version' + sh 'npm --version' + sh 'jq --version' + } + } + } + + stage('Check Environment Variables') { + steps { + script { + echo "CHANGE_ID: ${env.CHANGE_ID}" + echo "CHANGE_URL: ${env.CHANGE_URL}" + echo "CHANGE_AUTHOR: ${env.CHANGE_AUTHOR}" + echo "CHANGE_BRANCH: ${env.CHANGE_BRANCH}" + echo "JAVA_HOME: ${JAVA_HOME}" + echo "PATH: ${PATH}" + } + } + } + + stage('Check SonarQube Installation') { + steps { + script { + echo "Initial JAVA_HOME: ${env.JAVA_HOME}" + echo "Initial PATH: ${env.PATH}" + + withEnv(["JAVA_HOME=${env.JAVA_HOME}", "PATH=${env.JAVA_HOME}/bin:${env.PATH}"]) { + sh """ + java -version + ${SCANNER_HOME}/bin/sonar-scanner --version + """ + } + } + } +} + + stage('Fetch Pending Upstream Dependencies') { + steps { + script { + if (env.CHANGE_ID) { + def url = swaggerEndPoint.call() + echo "Fetching from URL: ${url}" + withCredentials([usernamePassword(credentialsId: '4093a0bf-073a-4874-b929-be5b69273f4a', passwordVariable: 'password', usernameVariable: 'username')]) { + def response = sh(script: """curl -X GET "${url}" -H 'accept: application/json' -u \$username:\$password""", returnStdout: true).trim() + echo "API Response: ${response}" + isPendingUpstreamDependenciesExists = sh(script: "echo '${response}' | jq 'contains({\"labels\": [{ \"name\": \"pending upstream\"}]})'", returnStdout: true).trim().toBoolean() + } + } else { + echo '[Jenkinsfile] Triggered via a push request.' + echo '[Jenkinsfile] Skipping dependency checking.' + triggeredViaPush = true + } + } + } + } + + stage('Execute Test Suites') { + steps { + script { + if (!isPendingUpstreamDependenciesExists) { + echo '[Jenkinsfile] Pending upstream dependencies do not exist.' + echo '[Jenkinsfile] Entering testing phase.' + try { + checkout scm + withCredentials([usernamePassword(credentialsId: 'builder2-deployer', passwordVariable: 'password', usernameVariable: 'username')]) { + sh """/opt/scripts/run-test.sh -u \$username -p \$password""" + } + currentBuild.result = 'SUCCESS' + message = 'Tests approved' + } catch (error) { + currentBuild.result = 'FAILURE' + message = 'Tests cannot be approved' + } + } else { + echo '[Jenkinsfile] Pending upstream dependencies exist.' + echo '[Jenkinsfile] Entering waiting phase.' + currentBuild.result = 'NOT_BUILT' + message = 'PR waiting due to pending upstream dependencies' + } + } + } + } + + stage('Code Quality Check') { + steps { + script { + def projectName = "device-mgt-core-${env.CHANGE_ID}" + def projectKey = "device-mgt-core-${env.CHANGE_ID}" + + withSonarQubeEnv('sonar') { + sh """ + $SCANNER_HOME/bin/sonar-scanner \ + -Dsonar.projectName=${projectName} \ + -Dsonar.projectKey=${projectKey} \ + -Dsonar.java.binaries=target + """ + } + } + } +} + + stage('Report Job Status') { + steps { + script { + if (true) { + withCredentials([usernamePassword(credentialsId: '4093a0bf-073a-4874-b929-be5b69273f4a', passwordVariable: 'password', usernameVariable: 'username')]) { + def url = swaggerEndPoint.call() + '/reviews' + echo "[Jenkinsfile] Notifying pull request build status to ${url}" + def response = sh(script: """curl -X POST "${url}" -H 'accept: application/json' -H 'Content-Type: application/json' -u \$username:\$password -d '{ "body": "${message}" }'""", returnStdout: true).trim() + echo "API Response: ${response}" + } + } + + def committerEmail = sh( + script: 'git --no-pager show -s --format=\'%ae\'', + returnStdout: true + ).trim() + + if (currentBuild.result == 'FAILURE') { + emailext( + subject: "${currentBuild.result}: Job ${env.JOB_NAME} [${env.BUILD_NUMBER}]", + body: 'Hi, Please find below.\n
${BUILD_LOG_REGEX, regex="BUILD FAILURE", linesAfter=30, showTruncatedLines=false, escapeHtml=true}
' + "Find more at : ${env.BUILD_URL}", + to: triggeredViaPush ? '$DEFAULT_RECIPIENTS' : committerEmail + ) + } + } + } + } + } +} + From 930f555835d2be227a55c9c4fad1c40e59431459 Mon Sep 17 00:00:00 2001 From: nipuni Date: Fri, 27 Sep 2024 23:09:00 +0530 Subject: [PATCH 320/343] Add docUrl into metadata. --- .../common/metadata/mgt/WhiteLabelTheme.java | 9 ++ .../mgt/WhiteLabelThemeCreateRequest.java | 9 ++ .../metadata/mgt/MetaDataConfiguration.java | 11 -- .../mgt/documentation/DocConfiguration.java | 36 ------ .../whitelabel/WhiteLabelConfiguration.java | 10 ++ .../DeviceManagementServiceComponent.java | 12 +- .../mgt/WhiteLabelManagementServiceImpl.java | 113 ++++++++++++++++-- .../mgt/core/util/DeviceManagerUtil.java | 6 +- .../repository/conf/cdm-config.xml | 4 +- .../src/main/resources/conf/cdm-config.xml | 4 +- .../repository/conf/cdm-config.xml.j2 | 6 +- 11 files changed, 146 insertions(+), 74 deletions(-) delete mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/WhiteLabelTheme.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/WhiteLabelTheme.java index 3bf6cc2e5b..62303e8c73 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/WhiteLabelTheme.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/WhiteLabelTheme.java @@ -24,6 +24,7 @@ public class WhiteLabelTheme { private WhiteLabelImage logoIconImage; private String footerText; private String appTitle; + private String docUrl; public String getFooterText() { return footerText; @@ -64,4 +65,12 @@ public class WhiteLabelTheme { public void setLogoIconImage(WhiteLabelImage logoIconImage) { this.logoIconImage = logoIconImage; } + + public String getDocUrl() { + return docUrl; + } + + public void setDocUrl(String docUrl) { + this.docUrl = docUrl; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java index 0a48bf0144..95eeb6b01a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java @@ -24,6 +24,7 @@ public class WhiteLabelThemeCreateRequest { private WhiteLabelImageRequestPayload logoIcon; private String footerText; private String appTitle; + private String docUrl; public WhiteLabelImageRequestPayload getFavicon() { return favicon; @@ -64,4 +65,12 @@ public class WhiteLabelThemeCreateRequest { public void setLogoIcon(WhiteLabelImageRequestPayload logoIcon) { this.logoIcon = logoIcon; } + + public String getDocUrl() { + return docUrl; + } + + public void setDocUrl(String docUrl) { + this.docUrl = docUrl; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java index 52cf65dbf7..1812862dd5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java @@ -18,7 +18,6 @@ package io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt; -import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.documentation.DocConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.whitelabel.WhiteLabelConfiguration; import javax.xml.bind.annotation.XmlElement; @@ -27,7 +26,6 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "MetaDataConfiguration") public class MetaDataConfiguration { private WhiteLabelConfiguration whiteLabelConfiguration; - private DocConfiguration docConfiguration; @XmlElement(name = "WhiteLabelConfiguration", required = true) public WhiteLabelConfiguration getWhiteLabelConfiguration() { @@ -37,13 +35,4 @@ public class MetaDataConfiguration { public void setWhiteLabelConfiguration(WhiteLabelConfiguration whiteLabelConfiguration) { this.whiteLabelConfiguration = whiteLabelConfiguration; } - - @XmlElement(name = "DocConfiguration", required = true) - public DocConfiguration getDocConfiguration() { - return docConfiguration; - } - - public void setDocConfiguration(DocConfiguration docConfiguration) { - this.docConfiguration = docConfiguration; - } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java deleted file mode 100644 index 63a6981146..0000000000 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2018 - 2024, 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.device.mgt.core.config.metadata.mgt.documentation; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "DocConfiguration") -public class DocConfiguration { - private String docUrl; - - @XmlElement(name = "DocUrl", required = true) - public String getDocUrl() { - return docUrl; - } - - public void setDocUrl(String docUrl) { - this.docUrl = docUrl; - } -} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java index 0ff43eee28..b12c1b0b6d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java @@ -26,6 +26,16 @@ public class WhiteLabelConfiguration { private String footerText; private String appTitle; private WhiteLabelImages whiteLabelImages; + private String docUrl; + + @XmlElement(name = "DocUrl", required = true) + public String getDocUrl() { + return docUrl; + } + + public void setDocUrl(String docUrl) { + this.docUrl = docUrl; + } @XmlElement(name = "FooterText", required = true) public String getFooterText() { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java index c648965773..8d45e1ec91 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.internal; import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuthorizationService; +import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService; import io.entgra.device.mgt.core.device.mgt.core.authorization.GroupAccessAuthorizationServiceImpl; import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.DeviceStatusManagementServiceImpl; @@ -335,15 +336,14 @@ public class DeviceManagementServiceComponent { bundleContext.registerService(MetadataManagementService.class.getName(), metadataManagementService, null); /* Registering Whitelabel Service */ - WhiteLabelManagementService whiteLabelManagementService = new WhiteLabelManagementServiceImpl(); - DeviceManagementDataHolder.getInstance().setWhiteLabelManagementService(whiteLabelManagementService); try { + WhiteLabelManagementService whiteLabelManagementService = new WhiteLabelManagementServiceImpl(); + DeviceManagementDataHolder.getInstance().setWhiteLabelManagementService(whiteLabelManagementService); whiteLabelManagementService.addDefaultWhiteLabelThemeIfNotExist(tenantId); - } catch (Throwable e) { - log.error("Error occurred while adding default tenant white label theme", e); - + bundleContext.registerService(WhiteLabelManagementService.class.getName(), whiteLabelManagementService, null); + } catch (MetadataManagementException e) { + log.error("Error occurred while initializing the white label management service", e); } - bundleContext.registerService(WhiteLabelManagementService.class.getName(), whiteLabelManagementService, null); /* Registering DeviceState Filter Service */ DeviceStatusManagementService deviceStatusManagementService = new DeviceStatusManagementServiceImpl(); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index 4ade3adc82..7ceb88178d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -60,8 +60,53 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ private final MetadataDAO metadataDAO; - public WhiteLabelManagementServiceImpl() { + public WhiteLabelManagementServiceImpl() throws MetadataManagementException { this.metadataDAO = MetadataManagementDAOFactory.getMetadataDAO(); + initializeWhiteLabelThemes(); + } + + /** + * Initializes white label theme for a tenant by retrieving white label metadata and updating it if necessary. + * If the white label metadata is found and the DocUrl is missing,it updates the metadata with the default value + * for DocUrl. + * + * @throws MetadataManagementException if an error occurs while managing metadata or transactions. + */ + private void initializeWhiteLabelThemes() throws MetadataManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + WhiteLabelTheme defaultTheme = getDefaultWhiteLabelTheme(); + Metadata whiteLabelMetadata = getWhiteLabelMetaData(tenantId); + if (whiteLabelMetadata != null) { + WhiteLabelTheme whiteLabelTheme = new Gson().fromJson(whiteLabelMetadata.getMetaValue(), + WhiteLabelTheme.class); + if (whiteLabelTheme.getDocUrl() == null) { + whiteLabelTheme.setDocUrl(defaultTheme.getDocUrl()); + Metadata updatedMetadata = constructWhiteLabelThemeMetadata(whiteLabelTheme); + try { + MetadataManagementDAOFactory.beginTransaction(); + metadataDAO.updateMetadata(tenantId, updatedMetadata); + MetadataManagementDAOFactory.commitTransaction(); + if (log.isDebugEnabled()) { + log.debug("WhiteLabel theme's DocUrl was missing and has been updated to the default value " + + "for tenant: " + tenantId); + } + } catch (MetadataManagementDAOException e) { + MetadataManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while fetching white label metadata for tenant: " + tenantId; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } catch (TransactionManagementException e) { + String msg = "Transaction failed while updating white label theme for tenant: " + + tenantId; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } finally { + MetadataManagementDAOFactory.closeConnection(); + } + } + } else { + addDefaultWhiteLabelThemeIfNotExist(tenantId); + } } @Override @@ -126,9 +171,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ /** * Useful to get white label image file response from provided url */ - private FileResponse getImageFileResponseFromUrl(String url) throws IOException, NotFoundException { + private FileResponse getImageFileResponseFromUrl(String url) throws IOException, NotFoundException { FileResponse fileResponse = new FileResponse(); - try(CloseableHttpClient client = HttpClients.createDefault()) { + try (CloseableHttpClient client = HttpClients.createDefault()) { HttpGet imageGetRequest = new HttpGet(url); HttpResponse response = client.execute(imageGetRequest); InputStream imageStream = response.getEntity().getContent(); @@ -183,6 +228,16 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ WhiteLabelStorageUtil.deleteWhiteLabelImageForTenantIfExists(tenantId); } + /** + * Get default metaDataConfiguration DocUrl from config + */ + private String getDefaultDocUrl() { + MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance(). + getDeviceManagementConfig().getMetaDataConfiguration(); + WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration(); + return whiteLabelConfiguration.getDocUrl(); + } + /** * Construct and return default whitelabel detail bean {@link WhiteLabelImage} */ @@ -193,11 +248,13 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ WhiteLabelImage logo = constructDefaultLogoImage(); WhiteLabelImage logoIcon = constructDefaultLogoIconImage(); WhiteLabelTheme defaultTheme = new WhiteLabelTheme(); + String docUrl = getDefaultDocUrl(); defaultTheme.setFooterText(footerText); defaultTheme.setAppTitle(appTitle); defaultTheme.setLogoImage(logo); defaultTheme.setLogoIconImage(logoIcon); defaultTheme.setFaviconImage(favicon); + defaultTheme.setDocUrl(docUrl); return defaultTheme; } @@ -338,9 +395,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ * those can be passed to this method in order to restore. * * @param existingFavicon existing favicon image file - * @param existingLogo existing logo image file + * @param existingLogo existing logo image file */ - private void restoreWhiteLabelImages(File existingFavicon, File existingLogo, File existingLogoIcon, int tenantId) + private void restoreWhiteLabelImages(File existingFavicon, File existingLogo, File existingLogoIcon, int tenantId) throws MetadataManagementException { WhiteLabelStorageUtil.deleteWhiteLabelImageForTenantIfExists(tenantId); if (existingFavicon != null) { @@ -359,7 +416,7 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ * For example if the provided white label image is of URL type it doesn't need to be stored * * @param whiteLabelImage image to be stored - * @param imageName (i.e: FAVICON) + * @param imageName (i.e: FAVICON) */ private void storeWhiteLabelImageIfRequired(WhiteLabelImageRequestPayload whiteLabelImage, WhiteLabelImage.ImageName imageName, int tenantId) @@ -386,6 +443,7 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ whiteLabelTheme.setLogoIconImage(logoIconImage); whiteLabelTheme.setFooterText(whiteLabelThemeCreateRequest.getFooterText()); whiteLabelTheme.setAppTitle(whiteLabelThemeCreateRequest.getAppTitle()); + whiteLabelTheme.setDocUrl(whiteLabelThemeCreateRequest.getDocUrl()); return whiteLabelTheme; } @@ -418,6 +476,38 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ return metadata; } + /** + * updates the given WhiteLabelTheme with default value for docUrl + * + * @param whiteLabelTheme the WhiteLabelTheme to be updated with defaults if necessary. + * @param tenantId the ID of the tenant whose metadata is being updated. + * @throws MetadataManagementException exception for an error occurs during the update or transaction commit. + */ + private void updateWhiteLabelThemeWithDefaults(WhiteLabelTheme whiteLabelTheme, int tenantId) + throws MetadataManagementException { + WhiteLabelTheme defaultTheme = getDefaultWhiteLabelTheme(); + if (whiteLabelTheme.getDocUrl() == null) { + whiteLabelTheme.setDocUrl(defaultTheme.getDocUrl()); + } + Metadata updatedMetadata = constructWhiteLabelThemeMetadata(whiteLabelTheme); + try { + MetadataManagementDAOFactory.beginTransaction(); + metadataDAO.updateMetadata(tenantId, updatedMetadata); + MetadataManagementDAOFactory.commitTransaction(); + } catch (MetadataManagementDAOException e) { + MetadataManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while updating metadata for tenant: " + tenantId; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while committing the transaction for tenant: " + tenantId; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } finally { + MetadataManagementDAOFactory.closeConnection(); + } + } + @Override public WhiteLabelTheme getWhiteLabelTheme(String tenantDomain) throws MetadataManagementException, DeviceManagementException { int tenantId = DeviceManagerUtil.getTenantId(tenantDomain); @@ -435,17 +525,22 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ throw new MetadataManagementException(msg); } } - return new Gson().fromJson(metadata.getMetaValue(), WhiteLabelTheme.class); + WhiteLabelTheme whiteLabelTheme = new Gson().fromJson(metadata.getMetaValue(), WhiteLabelTheme.class); + if (whiteLabelTheme.getDocUrl() == null) { + updateWhiteLabelThemeWithDefaults(whiteLabelTheme, tenantId); + } + return whiteLabelTheme; } /** * Load White label Meta Data for given tenant Id. + * * @param tenantId Id of the tenant * @return {@link Metadata} * @throws MetadataManagementException if an error occurred while getting Meta-Data info from Database for a - * given tenant ID. + * given tenant ID. */ - private Metadata getWhiteLabelMetaData (int tenantId) throws MetadataManagementException { + private Metadata getWhiteLabelMetaData(int tenantId) throws MetadataManagementException { try { MetadataManagementDAOFactory.openConnection(); return metadataDAO.getMetadata(tenantId, MetadataConstants.WHITELABEL_META_KEY); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java index 5ff2c15b6d..3965b1cc77 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java @@ -20,7 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.core.util; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; -import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.documentation.DocConfiguration; +import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.whitelabel.WhiteLabelConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; @@ -1289,7 +1289,7 @@ public final class DeviceManagerUtil { */ public static String getDocUrl() { DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); - DocConfiguration docConfiguration = deviceManagementConfig.getMetaDataConfiguration().getDocConfiguration(); - return docConfiguration.getDocUrl(); + WhiteLabelConfiguration whiteLabelConfig = deviceManagementConfig.getMetaDataConfiguration().getWhiteLabelConfiguration(); + return whiteLabelConfig.getDocUrl(); } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml index d12d30b401..54c7b59ae3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -160,9 +160,9 @@ BYOD,COPE - + https://docs.entgra.io/uem/6.0.0 - + diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index f4b6d5266b..a8946af8eb 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -200,10 +200,8 @@ icon.png default - - https://docs.entgra.io/uem/6.0.0 - + diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index 2d5f7639f8..e8560353c3 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -348,12 +348,10 @@ icon.png default - - {% if product_conf is defined %} - https://docs.entgra.io/uem/{{product_conf.server_version}} + https://docs.entgra.io/uem/{{product_conf.server_version}} {% endif %} - + From da90ca8973e7cab648592c1aff1a66517d4b7888 Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Tue, 1 Oct 2024 05:07:36 +0530 Subject: [PATCH 321/343] Bump version to 6.0.0-SNAPSHOT --- .gitlab-ci.yml | 28 ------------------- .travis.yml | 8 ------ .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/analytics-mgt/grafana-mgt/pom.xml | 4 +-- components/analytics-mgt/pom.xml | 9 +++--- .../pom.xml | 4 +-- .../pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 6 ++-- components/apimgt-extensions/pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/application-mgt/pom.xml | 8 +++--- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/cea-mgt/pom.xml | 8 +++--- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/certificate-mgt/pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/device-mgt-extensions/pom.xml | 8 +++--- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/device-mgt/pom.xml | 6 ++-- .../pom.xml | 14 ++++++---- components/heartbeat-management/pom.xml | 11 ++++---- .../pom.xml | 4 +-- .../pom.xml | 6 ++-- components/identity-extensions/pom.xml | 6 ++-- .../pom.xml | 4 +-- components/logger/pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/operation-template-mgt/pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/policy-mgt/pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/subtype-mgt/pom.xml | 6 ++-- components/task-mgt/pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/task-mgt/task-manager/pom.xml | 4 +-- .../pom.xml | 6 ++-- components/task-mgt/task-watcher/pom.xml | 4 +-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/tenant-mgt/pom.xml | 8 +++--- components/test-coverage/pom.xml | 4 +-- .../pom.xml | 6 ++-- components/transport-mgt/email-sender/pom.xml | 4 +-- components/transport-mgt/pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- components/transport-mgt/sms-handler/pom.xml | 4 +-- .../pom.xml | 4 +-- components/ui-request-interceptor/pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../webapp-authenticator-framework/pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- features/analytics-mgt/grafana-mgt/pom.xml | 4 +-- features/analytics-mgt/pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- features/apimgt-extensions/pom.xml | 6 ++-- .../pom.xml | 4 +-- features/application-mgt/pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- features/cea-mgt-feature/pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- features/certificate-mgt/pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- features/device-mgt-extensions/pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- features/device-mgt/pom.xml | 6 ++-- .../pom.xml | 4 +-- features/heartbeat-management/pom.xml | 6 ++-- .../pom.xml | 4 +-- features/jwt-client/pom.xml | 6 ++-- .../pom.xml | 4 +-- features/logger/pom.xml | 6 ++-- .../pom.xml | 2 +- features/oauth-extensions/pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 6 ++-- .../pom.xml | 4 +-- features/policy-mgt/pom.xml | 6 ++-- .../pom.xml | 6 ++-- features/subtype-mgt/pom.xml | 6 ++-- .../pom.xml | 6 ++-- features/task-mgt/pom.xml | 6 ++-- .../pom.xml | 6 ++-- features/tenant-mgt/pom.xml | 6 ++-- .../pom.xml | 4 +-- features/transport-mgt/email-sender/pom.xml | 4 +-- features/transport-mgt/pom.xml | 6 ++-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- features/transport-mgt/sms-handler/pom.xml | 4 +-- .../pom.xml | 4 +-- features/ui-request-interceptor/pom.xml | 6 ++-- .../pom.xml | 4 +-- .../webapp-authenticator-framework/pom.xml | 6 ++-- pom.xml | 21 ++++++++------ 151 files changed, 418 insertions(+), 447 deletions(-) delete mode 100644 .gitlab-ci.yml delete mode 100644 .travis.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 2530bdcfa7..0000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,28 +0,0 @@ -image: charithag/docker-mvn-jdk8:latest - -variables: - MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode" - MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" - -cache: - paths: - - .m2/repository/ - - target/ - -build: - stage: build - script: - - mvn $MAVEN_CLI_OPTS clean install -Dmaven.test.skip=true - -test: - stage: test - script: - - mvn $MAVEN_CLI_OPTS test - -deploy: - stage: deploy - script: - - mvn $MAVEN_CLI_OPTS deploy -Dmaven.test.skip=true - only: - - master@entgra/carbon-device-mgt - - kernel-4.6.x@entgra/carbon-device-mgt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0cbd9fd904..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: java -jdk: - - oraclejdk8 -cache: - directories: - - .autoconf - - $HOME/.m2 -script: mvn clean install diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index b5c5bd3ac2..fc7ad23766 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api war - Entgra - Grafana Proxy API - Entgra - Grafana Proxy API + Entgra Device Management - Grafana Proxy API + Entgra Device Management - Grafana Proxy API http://entgra.io diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index b2a6031989..12194db89f 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common bundle - Entgra - Grafana API Handler Common - Entgra - Grafana API Handler Common + Entgra Device Management - Grafana API Handler Common + Entgra Device Management - Grafana API Handler Common http://entgra.io diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 4199ff7273..283f18a4ba 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core grafana-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core bundle - Entgra - Grafana API Handler Core - Entgra - Grafana API Handler Core + Entgra Device Management - Grafana API Handler Core + Entgra Device Management - Grafana API Handler Core http://entgra.io diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 456834371f..493dd39002 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core analytics-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 grafana-mgt pom - Entgra - Grafana API Handler Component + Entgra Device Management - Grafana API Handler Component http://entgra.io diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 7de259bada..004e13c7c5 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -17,18 +17,19 @@ ~ under the License. --> - + - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 analytics-mgt pom - Entgra - Analytics Management Component + Entgra Device Management - Analytics Management Component http://entgra.io 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 866cb6ce57..5df5fc5c3b 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,13 +20,13 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT 4.0.0 io.entgra.device.mgt.core.apimgt.analytics.extension bundle - Entgra - API mgt analytics extension + Entgra Device Management - API mgt analytics extension https://entgra.io diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index fba5591029..2f93aec028 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,15 +22,15 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.annotations bundle - WSO2 Carbon - API Management Annotations - WSO2 Carbon - API Management Custom Annotation Module + Entgra Device Management - API Management Annotations + Entgra Device Management - API Management Custom Annotation Module https://entgra.io diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 4be52ce94d..826c889929 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,14 +21,14 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.application.extension.api war - WSO2 Carbon - API Application Management API + Entgra Device Management - API Application Management API This module provides capability to create api manager application. https://entgra.io diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index fdf9c2dd68..dc88b032b3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,14 +22,14 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.application.extension bundle - WSO2 Carbon - API Application Management + Entgra Device Management - API Application Management This module provides capability to create api manager application. https://entgra.io 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 7f6cf515e0..016f981d93 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,15 +22,15 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.extension.rest.api bundle - Entgra - Device Management Extension for APIM REST API - Entgra - Device Management Extension for APIM REST API + Entgra Device Management - Device Management Extension for APIM REST API + Entgra Device Management - Device Management Extension for APIM REST API https://entgra.io diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 14b4f62707..78b0053f8f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,13 +21,13 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT 4.0.0 io.entgra.device.mgt.core.apimgt.keymgt.extension.api war - WSO2 Carbon - API Key Management API + Entgra Device Management - API Key Management API This module extends the API manager's key management apis. https://entgra.io diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index 25c942800f..eba5a485b1 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,14 +21,14 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.keymgt.extension bundle - WSO2 Carbon - API Key Management + Entgra Device Management - API Key Management This module extends the API manager's key management. https://entgra.io diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index b211a15d26..4882c2a16d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,15 +22,15 @@ apimgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.webapp.publisher bundle - WSO2 Carbon - API Management Webapp Publisher - WSO2 Carbon - API Management Webapp Publisher + Entgra Device Management - API Management Webapp Publisher + Entgra Device Management - API Management Webapp Publisher https://entgra.io diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 6bf36e1e82..3d2c974ad5 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions pom - WSO2 Carbon - API Management Extensions Component + Entgra Device Management - API Management Extensions Component https://entgra.io diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 482bc93ae9..2916292c5c 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core application-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.application.mgt.common bundle - Entgra - Application Management Common - Entgra - Application Management Common + Entgra Device Management - Application Management Common + Entgra Device Management - Application Management Common https://entgra.io diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 171fa4557d..126a3ebf37 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core application-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.application.mgt.core bundle - Entgra - Application Management Core - Entgra - Application Management Core + Entgra Device Management - Application Management Core + Entgra Device Management - Application Management Core https://entgra.io diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index c4a50c3705..d0702df536 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -21,16 +21,16 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 application-mgt pom - WSO2 Carbon - Application Management Component - WSO2 Carbon - Application Management Component + Entgra Device Management - Application Management Component + Entgra Device Management - Application Management Component https://entgra.io diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml index c75eae5479..0b28d6dfa5 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core cea-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.cea.mgt.admin.api war - Entgra IoT - CEA Management Admin API - Entgra IoT - Conditional Email Access Management Admin API + Entgra Device Management - CEA Management Admin API + Entgra Device Management - Conditional Email Access Management Admin API diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml index 9e8060e0b8..b560d70134 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -23,15 +23,15 @@ io.entgra.device.mgt.core cea-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.cea.mgt.common bundle - Entgra IoT - CEA Management Common - Entgra IoT - Conditional Email Access Management Common + Entgra Device Management - CEA Management Common + Entgra Device Management - Conditional Email Access Management Common diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml index a09c92436a..7055d7952a 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core cea-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.cea.mgt.core bundle - Entgra IoT - CEA Management Core - Entgra IoT - Conditional Email Access Management Core + Entgra Device Management - CEA Management Core + Entgra Device Management - Conditional Email Access Management Core diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml index c22f147d82..5f8eae52c7 100644 --- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core cea-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml io.entgra.device.mgt.core.cea.mgt.enforce 4.0.0 bundle - Entgra IoT - CEA Management Enforcement Service - Entgra IoT - Conditional Email Access Management Enforcement Service + Entgra Device Management - CEA Management Enforcement Service + Entgra Device Management - Conditional Email Access Management Enforcement Service diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml index 78b391bd6b..f1cc314598 100644 --- a/components/cea-mgt/pom.xml +++ b/components/cea-mgt/pom.xml @@ -21,16 +21,16 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 cea-mgt pom - Entgra IoT - CEA Management Component - Entgra IoT - Conditional Email Access Management Component + Entgra Device Management - CEA Management Component + Entgra Device Management - Conditional Email Access Management Component io.entgra.device.mgt.core.cea.mgt.core diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml index bf1dee7058..a2d8e37aa7 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml @@ -22,15 +22,15 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.certificate.mgt.api war - WSO2 Carbon - Certificate Management API - WSO2 Carbon - Certificate Management API + Entgra Device Management - Certificate Management API + Entgra Device Management - Certificate Management API https://entgra.io diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml index 3f9de89f2d..536ef97716 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml @@ -22,15 +22,15 @@ certificate-mgt io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.certificate.mgt.cert.admin.api war - WSO2 Carbon - Admin Certificate Management API - WSO2 Carbon - Admin Certificate Management API + Entgra Device Management - Admin Certificate Management API + Entgra Device Management - Admin Certificate Management API https://entgra.io diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index ff7cc19498..e2c5afc557 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core certificate-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.certificate.mgt.core bundle - WSO2 Carbon - Certificate Management Core - WSO2 Carbon - Certificate Management Core + Entgra Device Management - Certificate Management Core + Entgra Device Management - Certificate Management Core https://entgra.io diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index c733f7e373..36ade9905d 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 certificate-mgt pom - WSO2 Carbon - Certificate Management Component + Entgra Device Management - Certificate Management Component https://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index 888af70f81..b02123e4c4 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager bundle - Entgra IoT - Default User Roles Management Module - Entgra IoT - Default User Roles Management Module Implementation + Entgra Device Management - Default User Roles Management Module + Entgra Device Management - Default User Roles Management Module Implementation http://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml index 3cc512d792..a808eb1ab1 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml @@ -22,14 +22,14 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api war - Entgra IoT - API Device Organization Management API + Entgra Device Management - API Device Organization Management API This module extends the API manager's device organization management apis. http://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml index 61480722b1..b190b05aa7 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.device.organization bundle - Entgra IoT - Device Organization Module - Entgra IoT - Device Organization Module Implementation + Entgra Device Management - Device Organization Module + Entgra Device Management - Device Organization Module Implementation http://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index 2a04b62e41..a3f4e5ce42 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer bundle - WSO2 Carbon - Device Type Deployer - WSO2 Carbon - Device Type Deployer Implementation + Entgra Device Management - Device Type Deployer + Entgra Device Management - Device Type Deployer Implementation https://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml index aa4b2c1cf1..7266341f34 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml @@ -21,15 +21,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.logger bundle - Entgra IoT - Logger Impl - Entgra IoT - Entgra Logger Implementation + Entgra Device Management - Logger Impl + Entgra Device Management - Entgra Logger Implementation http://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index d1ea2bc255..8e8e19b364 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.pull.notification bundle - WSO2 Carbon - Pull Notification Provider Implementation - WSO2 Carbon - Pull Notification Provider Implementation + Entgra Device Management - Pull Notification Provider Implementation + Entgra Device Management - Pull Notification Provider Implementation https://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 01e0074adf..b72f93840f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm bundle - WSO2 Carbon - FCM Based Push Notification Provider Implementation - WSO2 Carbon - FCM Based Push Notification Provider Implementation + Entgra Device Management - FCM Based Push Notification Provider Implementation + Entgra Device Management - FCM Based Push Notification Provider Implementation https://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index 1ae1b328cf..edf6e15fb7 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http bundle - WSO2 Carbon - HTTP Based Push Notification Provider Implementation - WSO2 Carbon - HTTP Based Push Notification Provider Implementation + Entgra Device Management - HTTP Based Push Notification Provider Implementation + Entgra Device Management - HTTP Based Push Notification Provider Implementation https://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 0477011b9f..a37af5cc64 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt bundle - WSO2 Carbon - MQTT Based Push Notification Provider Implementation - WSO2 Carbon - MQTT Based Push Notification Provider Implementation + Entgra Device Management - MQTT Based Push Notification Provider Implementation + Entgra Device Management - MQTT Based Push Notification Provider Implementation https://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index d22a7befe7..1dd7608238 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp bundle - WSO2 Carbon - XMPP Based Push Notification Provider Implementation - WSO2 Carbon - XMPP Based Push Notification Provider Implementation + Entgra Device Management - XMPP Based Push Notification Provider Implementation + Entgra Device Management - XMPP Based Push Notification Provider Implementation https://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index 3cc4114dc9..5ac54dc0e8 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.stateengine bundle - Entgra IoT - State Engine - Entgra IoT - State Engine Components + Entgra Device Management - State Engine + Entgra Device Management - State Engine Components http://entgra.io diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index a6b55859df..cc6ee9fc21 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper bundle - Entgra IoT - User store role mapping Module - Entgra IoT - User store role mapping Module + Entgra Device Management - User store role mapping Module + Entgra Device Management - User store role mapping Module http://entgra.io diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 455aa0679c..daf2457a80 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -20,17 +20,17 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 device-mgt-extensions pom - WSO2 Carbon - Device Management Extensions - WSO2 Carbon - Device Management Extensions + Entgra Device Management - Device Management Extensions + Entgra Device Management - Device Management Extensions https://entgra.io diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 6ce3f3e666..e980421af9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -22,15 +22,15 @@ device-mgt io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.api war - WSO2 Carbon - Mobile Device Management API - WSO2 Carbon - Mobile Device Management API + Entgra Device Management - Mobile Device Management API + Entgra Device Management - Mobile Device Management API https://entgra.io diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml index cc9da3624c..3e9d8f7b0d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml @@ -21,15 +21,15 @@ device-mgt io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.common bundle - WSO2 Carbon - Device Management Commons - WSO2 Carbon - Device Management Commons + Entgra Device Management - Device Management Commons + Entgra Device Management - Device Management Commons https://entgra.io diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml index 62e006db4b..6cf9047e82 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml @@ -22,15 +22,15 @@ device-mgt io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.config.api war - Entgra Carbon - Mobile Device Management Configuration API - Entgra Carbon - Mobile Device Management Configuration API + Entgra Device Management - Device Management Configuration API + Entgra Device Management - Device Management Configuration API https://entgra.io diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 00788c96f4..43f48d94ed 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core device-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.core bundle - WSO2 Carbon - Device Management Core - WSO2 Carbon - Device Management Core + Entgra Device Management - Device Management Core + Entgra Device Management - Device Management Core https://entgra.io diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 2f7e1c60e4..3d8761c19d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -22,15 +22,15 @@ device-mgt io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions bundle - WSO2 Carbon - Device Management Extensions - WSO2 Carbon - Device Management Extensions + Entgra Device Management - Device Management Extensions + Entgra Device Management - Device Management Extensions https://entgra.io diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml index 0fc65c8a5d..36690a669c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml @@ -23,15 +23,15 @@ device-mgt io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.url.printer bundle - WSO2 Carbon - Device Management url printer - WSO2 Carbon - Device Management url printer + Entgra Device Management - Device Management url printer + Entgra Device Management - Device Management url printer https://entgra.io diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 1881c7f0ad..02403f68f6 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 device-mgt pom - WSO2 Carbon - Device Management Component + Entgra Device Management - Device Management Component https://entgra.io diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 1a44ac0544..8190256832 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -17,21 +17,22 @@ ~ under the License. --> - + io.entgra.device.mgt.core heartbeat-management - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.server.bootup.heartbeat.beacon bundle - Entgra - Heartbeat Beacon - Entgra - Server Startup and Heartbeat Monitoring Component - http://www.entgra.io + Entgra Device Management - Heartbeat Beacon + Entgra Server Startup and Heartbeat Monitoring Component + https://entgra.io @@ -53,7 +54,8 @@ ${project.artifactId} ${io.entgra.device.mgt.core.version} Server Startup Heart Beat Beacon Bundle - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.internal + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.internal + io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 7015a871d1..c8e1f9d4f1 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -17,20 +17,21 @@ ~ under the License. --> - + io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 heartbeat-management pom - Entgra - Task Allocation Framework - http://entgra.io + Entgra Device Management - Task Allocation Framework + https://entgra.io io.entgra.device.mgt.core.server.bootup.heartbeat.beacon diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml index e86a5947dc..3d0dde5be1 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core identity-extensions - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.oauth.extensions bundle - WSO2 Carbon - OAuth Extensions + Entgra Device Management - OAuth Extensions https://entgra.io diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml index 826280ae17..899434ada5 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core identity-extensions - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.identity.jwt.client.extension bundle - WSO2 Carbon - Device Management JWT Client Extensions - WSO2 Carbon - Device Management JWT Client Extensions + Entgra Device Management - Device Management JWT Client Extensions + Entgra Device Management - Device Management JWT Client Extensions https://entgra.io diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index ced68c877b..626cf97c0d 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 identity-extensions pom - WSO2 Carbon - Identity Extensions Component + Entgra Device Management - Identity Extensions Component https://entgra.io diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index dcf1f39304..b1e8750818 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -23,11 +23,11 @@ io.entgra.device.mgt.core logger - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT io.entgra.device.mgt.core.notification.logger - Entgra - Notification Logger + Entgra Device Management - Notification Logger bundle http://entgra.io diff --git a/components/logger/pom.xml b/components/logger/pom.xml index 97de565b35..8c4f741904 100644 --- a/components/logger/pom.xml +++ b/components/logger/pom.xml @@ -20,15 +20,15 @@ 4.0.0 - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml logger pom - Entgra - Notification Logger Component + Entgra Device Management - Notification Logger Component http://entgra.io diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index 158daff9f5..b2dc0ce6c5 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core operation-template-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.operation.template bundle - Entgra IoT - Operation Template Core - Entgra IoT - Operation Template Core + Entgra Device Management - Operation Template Core + Entgra Device Management - Operation Template Core http://entgra.io diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml index 9672e9df32..16f5356f2b 100644 --- a/components/operation-template-mgt/pom.xml +++ b/components/operation-template-mgt/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 operation-template-mgt pom - Entgra IoT - Operation Template Mgt Plugin + Entgra Device Management - Operation Template Mgt Plugin http://entgra.io diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 4c5d2b9fc1..513152f2f0 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core policy-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.policy.decision.point bundle - WSO2 Carbon - Policy Decision Point - WSO2 Carbon - Policy Decision Point + Entgra Device Management - Policy Decision Point + Entgra Device Management - Policy Decision Point https://entgra.io diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index 3e1678406c..a3ae255da7 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core policy-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml @@ -29,8 +29,8 @@ 4.0.0 io.entgra.device.mgt.core.policy.information.point bundle - WSO2 Carbon - Policy Information Point - WSO2 Carbon - Policy Information Point + Entgra Device Management - Policy Information Point + Entgra Device Management - Policy Information Point https://entgra.io diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 70346d54d1..860313c31d 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core policy-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.policy.mgt.common bundle - WSO2 Carbon - Policy Management Common - WSO2 Carbon - Policy Management Common + Entgra Device Management - Policy Management Common + Entgra Device Management - Policy Management Common https://entgra.io diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index ccfca465fd..39421174ef 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core policy-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.policy.mgt.core bundle - WSO2 Carbon - Policy Management Core - WSO2 Carbon - Policy Management Core + Entgra Device Management - Policy Management Core + Entgra Device Management - Policy Management Core https://entgra.io diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index f45e96501e..621b5e6d83 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 policy-mgt pom - WSO2 Carbon - Policy Management Component + Entgra Device Management - Policy Management Component https://entgra.io diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 6785609ff1..7001e25e3d 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -20,15 +20,15 @@ io.entgra.device.mgt.core subtype-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.subtype.mgt - Entgra IoT - Subtype Mgt Impl + Entgra Device Management - Subtype Mgt Impl bundle - Entgra IoT - Subtype Management Component Implementation + Entgra Device Management - Subtype Management Component Implementation http://entgra.io diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml index d67a6ffbd5..331e675a36 100644 --- a/components/subtype-mgt/pom.xml +++ b/components/subtype-mgt/pom.xml @@ -19,15 +19,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 subtype-mgt pom - Entgra IoT - Subtype Mgt + Entgra Device Management - Subtype Mgt http://entgra.io diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml index a6e832a947..ec125fccef 100755 --- a/components/task-mgt/pom.xml +++ b/components/task-mgt/pom.xml @@ -20,15 +20,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 task-mgt pom - Entgra IoT - Task Management Component + Entgra Device Management - Task Management Component http://entgra.io diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml index 3186715314..fda57bbdd6 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml @@ -20,15 +20,15 @@ task-manager io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.task.mgt.common bundle - Entgra IoT - Task Management Common - Entgra IoT - Task Management Common + Entgra Device Management - Task Management Common + Entgra Device Management - Task Management Common https://entgra.io diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index f5629cc955..e591310db6 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core task-manager - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.task.mgt.core bundle - Entgra IoT - Task manager Core - Entgra IoT - Task manager Core + Entgra Device Management - Task manager Core + Entgra Device Management - Task manager Core http://entgra.io diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml index 4169d327f4..2dc7d48b22 100755 --- a/components/task-mgt/task-manager/pom.xml +++ b/components/task-mgt/task-manager/pom.xml @@ -21,13 +21,13 @@ io.entgra.device.mgt.core task-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 task-manager - Entgra IoT - Task Manager Component + Entgra Device Management - Task Manager Component pom http://entgra.io diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index cc3b6f2684..38647f51f2 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core task-watcher - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.task.mgt.watcher bundle - Entgra IoT - Task Watcher - Entgra IoT - Task Watcher + Entgra Device Management - Task Watcher + Entgra Device Management - Task Watcher http://entgra.io diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml index bf1051bfcc..cc95321e06 100755 --- a/components/task-mgt/task-watcher/pom.xml +++ b/components/task-mgt/task-watcher/pom.xml @@ -21,13 +21,13 @@ io.entgra.device.mgt.core task-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 task-watcher - Entgra IoT - Task Watcher Component + Entgra Device Management - Task Watcher Component pom http://entgra.io diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml index 20f7435708..d011a19404 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml @@ -20,14 +20,14 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.tenant.mgt.common - Entgra IoT - Tenant Manager Common - Entgra IoT - Tenant Manager Common + Entgra Device Management - Tenant Manager Common + Entgra Device Management - Tenant Manager Common bundle diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index 6347269f93..b3d9e75a9c 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -20,14 +20,14 @@ tenant-mgt io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.tenant.mgt.core - Entgra IoT - Tenant Manager Core - Entgra IoT - Tenant Manager Core + Entgra Device Management - Tenant Manager Core + Entgra Device Management - Tenant Manager Core bundle diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml index cec5e7f315..e344e8158e 100644 --- a/components/tenant-mgt/pom.xml +++ b/components/tenant-mgt/pom.xml @@ -18,17 +18,17 @@ --> - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 tenant-mgt pom - Entgra IoT - Tenant Management Component - Entgra IoT - Tenant Management Component + Entgra Device Management - Tenant Management Component + Entgra Device Management - Tenant Management Component io.entgra.device.mgt.core.tenant.mgt.core diff --git a/components/test-coverage/pom.xml b/components/test-coverage/pom.xml index 7273a65793..d1cda60448 100644 --- a/components/test-coverage/pom.xml +++ b/components/test-coverage/pom.xml @@ -19,7 +19,7 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core 4.0.0-SNAPSHOT ../../pom.xml @@ -27,7 +27,7 @@ 4.0.0 test-coverage - WSO2 Carbon - Unit Test Coverage Generation + Entgra Device Management - Unit Test Coverage Generation target coverage-reports diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml index 3e713b580c..6dd1ba7ff5 100644 --- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core email-sender - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.transport.mgt.email.sender.core bundle - WSO2 Carbon - Email Sender Core - WSO2 Carbon - Email Sender Core + Entgra Device Management - Email Sender Core + Entgra Device Management - Email Sender Core https://entgra.io diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 6b2855be0c..9768cc5df5 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core transport-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 email-sender pom - WSO2 Carbon - Email Sender Component + Entgra Device Management - Email Sender Component https://entgra.io diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index f70c86664a..f57e38740b 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -19,16 +19,16 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 transport-mgt pom - Entgra - Transport Management Component + Entgra Device Management - Transport Management Component http://entgra.io diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml index 57aba948bf..a9f9ab1dea 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core sms-handler - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.transport.mgt.sms.handler.api war - Entgra - SMS Handler API - Entgra - SMS Handler API + Entgra Device Management - SMS Handler API + Entgra Device Management - SMS Handler API http://entgra.io diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml index 5d0abfd980..b2e5e1a3e1 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core sms-handler - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.transport.mgt.sms.handler.common bundle - Entgra - SMS Handler Common - Entgra - SMS Handler Common + Entgra Device Management - SMS Handler Common + Entgra Device Management - SMS Handler Common http://entgra.io diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index 3b98153af4..b2ce6f9333 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core sms-handler - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.transport.mgt.sms.handler.core bundle - Entgra - SMS Handler Core - Entgra - SMS Handler Core + Entgra Device Management - SMS Handler Core + Entgra Device Management - SMS Handler Core http://entgra.io diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 063ddaf4c8..0e77817355 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core transport-mgt - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 sms-handler pom - Entgra - SMS Handler Component + Entgra Device Management - SMS Handler Component http://entgra.io diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml index a384b894fe..14756b652d 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml @@ -21,13 +21,13 @@ ui-request-interceptor io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT 4.0.0 io.entgra.device.mgt.core.ui.request.interceptor war - Entgra - Request Handling Proxy Servlet + Entgra Device Management - Request Handling Proxy Servlet Proxy Service for Request Handling in Entgra EMM/IOT Server. https://entgra.io diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index deafa3edd0..849c3f6902 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -19,15 +19,15 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 ui-request-interceptor - Entgra - UI Request Interceptor Servlet + Entgra Device Management - UI Request Interceptor Servlet Proxy servlet to handle requests generated from UI applications to communicate with backend APIs diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index c0ca459167..e0bdc94163 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core webapp-authenticator-framework - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.webapp.authenticator.framework bundle - WSO2 Carbon - Web Application Authenticator Framework Bundle - WSO2 Carbon - Web Application Authenticator Framework Bundle + Entgra Device Management - Web Application Authenticator Framework Bundle + Entgra Device Management - Web Application Authenticator Framework Bundle https://entgra.io diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index 3fd0427bb6..a22657144e 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -21,8 +21,8 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework pom - WSO2 Carbon - Webapp Authenticator Framework + Entgra Device Management - Webapp Authenticator Framework https://entgra.io diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml index 06aa865282..4266167831 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature pom - Entgra - Grafana Proxy API Feature + Entgra Device Management - Grafana Proxy API Feature https://entgra.io This feature contains the APIs required for Grafana diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml index 668d4489ea..2bda622bac 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature pom - Entgra - Grafana Management Server Feature + Entgra Device Management - Grafana Management Server Feature https://entgra.io This feature contains the core bundles required for Back-end Grafana Management functionality diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 2699aa3c41..1817298702 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core analytics-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 grafana-mgt-feature pom - Entgra - Grafana Management Feature + Entgra Device Management - Grafana Management Feature http://entgra.io diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index e70f4c5593..198eeb62f2 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -19,16 +19,16 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 analytics-mgt-feature pom - Entgra - Analytics Management Feature + Entgra Device Management - Analytics Management Feature http://entgra.io 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 49792aa682..528f494156 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,14 +20,14 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.analytics.extension.feature pom - Entgra - APIM Analytics Extension Feature + Entgra Device Management - APIM Analytics Extension Feature http://entgra.io diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml index e376ed1fb7..0d0cf6d35d 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml @@ -21,14 +21,14 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.application.extension.feature pom - WSO2 Carbon - API Management Application Extension Feature + Entgra Device Management - API Management Application Extension Feature https://entgra.io This feature contains an implementation of a api application registration, which takes care of subscription and generating keys. diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml index 50f93a4051..dfd16e74ca 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.extension.rest.api.feature pom - Entgra - API management REST API feature + Entgra Device Management - API management REST API feature This feature contains an implementation of API manager REST API extension http://entgra.io diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml index a4cc71f07e..4f70694ab7 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml @@ -21,14 +21,14 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.keymgt.extension.feature pom - WSO2 Carbon - Api Key Mgt Extensions Feature + Entgra Device Management - Api Key Mgt Extensions Feature https://entgra.io This feature contains apimgt related key management extensions diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml index 09b90bc4ae..902aa5a801 100644 --- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml @@ -21,14 +21,14 @@ io.entgra.device.mgt.core apimgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.apimgt.webapp.publisher.feature pom - WSO2 Carbon - API Management Webapp Publisher Feature + Entgra Device Management - API Management Webapp Publisher Feature https://entgra.io This feature contains an implementation of a Tomcat lifecycle listener, which takes care of publishing JAX-RS web applications as 'Managed APIs' diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index b30032892c..3906798627 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -21,8 +21,8 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core apimgt-extensions-feature pom - WSO2 Carbon - API Management Extensions Feature + Entgra Device Management - API Management Extensions Feature https://entgra.io diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml index 6170579a5d..0552864649 100644 --- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core application-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core.application.mgt.server.feature pom - Entgra - Application Management Server Feature + Entgra Device Management - Application Management Server Feature https://entgra.io This feature contains the core bundles required for Back-end Application Management functionality diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 302bdfaab1..fc57f53c78 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 application-mgt-feature pom - WSO2 Carbon - Application Management Feature + Entgra Device Management - Application Management Feature https://entgra.io diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml index 2b79de5c78..c84bca9b9e 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.cea.mgt.admin.api.feature - Entgra IoT - CEA Management Admin API Feature - Entgra IoT - Conditional Email Access Management Admin API Feature + Entgra Device Management - CEA Management Admin API Feature + Entgra Device Management - Conditional Email Access Management Admin API Feature diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml index dceaa6269d..bdbad54f23 100644 --- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml +++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core cea-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.cea.mgt.server.feature - Entgra IoT - CEA Management Server Feature - Entgra IoT - Conditional Email Access Management Server Feature + Entgra Device Management - CEA Management Server Feature + Entgra Device Management - Conditional Email Access Management Server Feature diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml index 1a34604d22..83f379875e 100644 --- a/features/cea-mgt-feature/pom.xml +++ b/features/cea-mgt-feature/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 cea-mgt-feature pom - Entgra IoT - CEA Management Feature + Entgra Device Management - CEA Management Feature io.entgra.device.mgt.core.cea.mgt.server.feature diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml index ddf23673a7..e32bf210d6 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.certificate.mgt.api.feature pom - WSO2 Carbon - Certificate Management API Feature + Entgra Device Management - Certificate Management API Feature https://entgra.io This feature contains the APIs required for Certificate Management. diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml index ca84f08aee..c44623e0a2 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature pom - WSO2 Carbon - Admin Certificate Management API Feature + Entgra Device Management - Admin Certificate Management API Feature https://entgra.io This feature contains the APIs required for Admin Certificate Management. diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml index b595688ff1..b7226747f6 100644 --- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core certificate-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.certificate.mgt.server.feature pom - WSO2 Carbon - Certificate Management Server Feature + Entgra Device Management - Certificate Management Server Feature https://entgra.io This feature contains the core bundles required for back-end Certificate Management functionality diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 4862bc26b2..1ec7324b3b 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 certificate-mgt-feature pom - WSO2 Carbon - Certificate Management Feature + Entgra Device Management - Certificate Management Feature https://entgra.io diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml index 6961e1c4d0..e9ea94d319 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature pom - Entgra IoT - Default Role Manager Feature Impl + Entgra Device Management - Default Role Manager Feature Impl http://entgra.io This feature contains the core bundles required for Default Role Manager functionality diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml index c9be43a57e..9fb14ce026 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml @@ -22,13 +22,13 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature pom - Entgra IoT - Device Organization Management API Feature + Entgra Device Management - Device Organization Management API Feature http://entgra.io This feature contains the APIs required for Device Organization Management. diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml index b07e877518..0a6f1b748b 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml @@ -22,16 +22,16 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature pom - Entgra IoT - Device Organization Feature + Entgra Device Management - Device Organization Feature http://entgra.io - Entgra IoT - Device Organization Feature + Entgra Device Management - Device Organization Feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml index da8d09cc0d..828e4c1b7c 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,16 +22,16 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature pom - WSO2 Carbon - Device Type Deployer Feature + Entgra Device Management - Device Type Deployer Feature https://entgra.io - WSO2 Carbon - Device Type Deployer Feature + Entgra Device Management - Device Type Deployer Feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml index 801618cb67..501aa17d36 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.logger.feature pom - Entgra IoT - Logger Plugin Feature Impl + Entgra Device Management - Logger Plugin Feature Impl http://entgra.io This feature contains the core bundles required for logging functionality diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index b281a9ab5e..f8b072bf6d 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,16 +22,16 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature pom - WSO2 Carbon - FCM Based Push Notification Provider Feature + Entgra Device Management - FCM Based Push Notification Provider Feature https://entgra.io - WSO2 Carbon - MQTT Based Push Notification Provider Feature + Entgra Device Management - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index e7ed43fb8d..74fcb401a0 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,16 +22,16 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature pom - WSO2 Carbon - MQTT Based Push Notification Provider Feature + Entgra Device Management - MQTT Based Push Notification Provider Feature https://entgra.io - WSO2 Carbon - MQTT Based Push Notification Provider Feature + Entgra Device Management - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 2699079465..839e56a6aa 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,16 +22,16 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature pom - WSO2 Carbon - MQTT Based Push Notification Provider Feature + Entgra Device Management - MQTT Based Push Notification Provider Feature https://entgra.io - WSO2 Carbon - MQTT Based Push Notification Provider Feature + Entgra Device Management - MQTT Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index dc586b9ac9..72999f12ba 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,16 +22,16 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature pom - WSO2 Carbon - XMPP Based Push Notification Provider Feature + Entgra Device Management - XMPP Based Push Notification Provider Feature https://entgra.io - WSO2 Carbon - XMPP Based Push Notification Provider Feature + Entgra Device Management - XMPP Based Push Notification Provider Feature diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml index 6f4f899cbc..59b479d044 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature pom - Entgra IoT - State engine Plugin Feature Impl + Entgra Device Management - State engine Plugin Feature Impl http://entgra.io This feature contains the core bundles required for state engine functionality diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml index 5099df1347..8a6c556327 100644 --- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml +++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core device-mgt-extensions-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.feature pom - Entgra IoT - User store role mapper feature + Entgra Device Management - User store role mapper feature http://entgra.io This feature contains the core bundles required for user store role mapping functionality diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 91fb09e401..00ad899797 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 device-mgt-extensions-feature pom - WSO2 Carbon - Device Management Extensions Feature + Entgra Device Management - Device Management Extensions Feature https://entgra.io diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml index 4d7ed1e2c2..20e8ae776c 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.api.feature pom - WSO2 Carbon - Device Management API Feature + Entgra Device Management - Device Management API Feature https://entgra.io This feature contains the APIs required for Device Management console UI diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml index 1333c8acca..91aa55a3ae 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.basics.feature pom - WSO2 Carbon - Device Management Basics Feature + Entgra Device Management - Device Management Basics Feature https://entgra.io This feature contains the core bundles required for Basic Device Management functionality diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml index 97054900da..ce63bf6e92 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.extensions.feature pom - WSO2 Carbon - Device Management Extensions Feature + Entgra Device Management - Device Management Extensions Feature https://entgra.io This feature contains common extensions used by key device management functionalities diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml index 18eda1c211..d4a3b9dc0d 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.feature pom - WSO2 Carbon - Device Management Aggregate Feature + Entgra Device Management - Device Management Aggregate Feature https://entgra.io This feature contains all the bundles required for device management related functionalities diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml index c94d46583e..28bc9351f0 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core device-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.device.mgt.server.feature pom - WSO2 Carbon - Device Management Server Feature + Entgra Device Management - Device Management Server Feature https://entgra.io This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index e4178b397a..7caaee9050 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 device-mgt-feature pom - WSO2 Carbon - Device Management Feature + Entgra Device Management - Device Management Feature https://entgra.io diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml index b5ef62b8e7..d95f49517f 100644 --- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core heart-beat-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.server.heart.beat.feature pom - Entgra IoT - Heart Beat Feature + Entgra Device Management - Heart Beat Feature http://entgra.io This feature bundles for the heart beat beacon for Entgra IoT Server diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 36ced90a63..bc9a8296e6 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 heart-beat-feature pom - Entgra - Heart Beat Feature + Entgra Device Management - Heart Beat Feature http://entgra.io diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml index 95a977d2e0..a943fbeb18 100644 --- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml @@ -23,14 +23,14 @@ io.entgra.device.mgt.core jwt-client-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.identity.jwt.client.extension.feature pom - WSO2 Carbon - JWT Client Feature + Entgra Device Management - JWT Client Feature https://entgra.io This feature contains jwt client implementation from which we can get a access token using the jwt grant type handler diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 710785e849..dbc15d6a11 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 jwt-client-feature pom - WSO2 Carbon - JWT Client Extension Feature + Entgra Device Management - JWT Client Extension Feature https://entgra.io diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml index fdc21ef2e0..701567ca40 100644 --- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml +++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml @@ -23,14 +23,14 @@ io.entgra.device.mgt.core logger-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.notification.logger.feature pom - Entgra - Notification logger + Entgra Device Management - Notification logger http://entgra.io This feature bundles for the Entgra Notification logger diff --git a/features/logger/pom.xml b/features/logger/pom.xml index 93bb6e79ad..c5420690b3 100644 --- a/features/logger/pom.xml +++ b/features/logger/pom.xml @@ -22,15 +22,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 logger-feature pom - Entgra - Logger Feature + Entgra Device Management - Logger Feature http://entgra.io diff --git a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml index 29e96f43cd..f9a593ec9e 100644 --- a/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml +++ b/features/oauth-extensions/org.wso2.carbon.device.mgt.oauth.extensions.feature/pom.xml @@ -30,7 +30,7 @@ 4.0.0 io.entgra.device.mgt.core.device.mgt.oauth.extensions.feature pom - WSO2 Carbon - Device Mgt OAuth Extensions Feature + Entgra Device Management - Device Mgt OAuth Extensions Feature https://entgra.io This feature contains devicemgt related OAuth extensions diff --git a/features/oauth-extensions/pom.xml b/features/oauth-extensions/pom.xml index d40fd22467..328e517844 100644 --- a/features/oauth-extensions/pom.xml +++ b/features/oauth-extensions/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent + device-mgt-core 5.0.0-SNAPSHOT ../../pom.xml @@ -29,7 +29,7 @@ 4.0.0 oauth-extensions-feature pom - WSO2 Carbon - Device Management OAuth Extensions Feature + Entgra Device Management - Device Management OAuth Extensions Feature https://entgra.io diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml index 21db4997c9..2118812072 100644 --- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core operation-template-mgt-plugin-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.operation.template.feature pom - Entgra IoT - Operation Template Management Feature Impl + Entgra Device Management - Operation Template Management Feature Impl http://entgra.io This feature contains the core bundles required for Operation template management functionality diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml index a15e5ee1ac..89a3dc1cf3 100644 --- a/features/operation-template-mgt-plugin-feature/pom.xml +++ b/features/operation-template-mgt-plugin-feature/pom.xml @@ -20,16 +20,16 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 operation-template-mgt-plugin-feature pom - Entgra IoT - Subtype Management Feature + Entgra Device Management - Subtype Management Feature http://entgra.io diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml index 8ed8e5f49a..2e8c9b8a6c 100644 --- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml @@ -23,14 +23,14 @@ io.entgra.device.mgt.core policy-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.policy.mgt.server.feature pom - WSO2 Carbon - Policy Management Server Feature + Entgra Device Management - Policy Management Server Feature https://entgra.io This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 3adb3ad614..caf592dbf0 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -22,8 +22,8 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml @@ -31,7 +31,7 @@ io.entgra.device.mgt.core policy-mgt-feature pom - WSO2 Carbon - Policy Management Feature + Entgra Device Management - Policy Management Feature https://entgra.io diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml index a06223bd95..624737274c 100644 --- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml +++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml @@ -21,15 +21,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../../pom.xml 4.0.0 io.entgra.device.mgt.core.subtype.mgt.feature pom - Entgra IoT - Subtype Management Feature Impl + Entgra Device Management - Subtype Management Feature Impl http://entgra.io This feature contains the core bundles required for Subtype management functionality diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml index 580c256614..cc2cd63721 100644 --- a/features/subtype-mgt/pom.xml +++ b/features/subtype-mgt/pom.xml @@ -20,16 +20,16 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 subtype-mgt-feature pom - Entgra IoT - Subtype Management Feature + Entgra Device Management - Subtype Management Feature http://entgra.io diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml index d241eff822..a5d4a95fe0 100755 --- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml +++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml @@ -20,15 +20,15 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../../pom.xml 4.0.0 io.entgra.device.mgt.core.task.mgt.feature pom - Entgra IoT - Task Manager Feature + Entgra Device Management - Task Manager Feature https://entgra.io diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml index c0ee005cf7..81feb37d66 100755 --- a/features/task-mgt/pom.xml +++ b/features/task-mgt/pom.xml @@ -19,16 +19,16 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 task-mgt-feature pom - Entgra IoT - Task Management Feature + Entgra Device Management - Task Management Feature http://entgra.io diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml index 8f40306d87..73f9bad1f8 100644 --- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml +++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml @@ -20,14 +20,14 @@ tenant-mgt-feature io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.tenant.mgt.server.feature - Entgra IoT - Tenant Management Server Feature - Entgra IoT - Tenant Management Server Feature + Entgra Device Management - Tenant Management Server Feature + Entgra Device Management - Tenant Management Server Feature pom diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml index 7e7c235776..36f9b9622c 100644 --- a/features/tenant-mgt/pom.xml +++ b/features/tenant-mgt/pom.xml @@ -19,16 +19,16 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 tenant-mgt-feature pom - Entgra IoT - Tenant Management Feature + Entgra Device Management - Tenant Management Feature io.entgra.device.mgt.core.tenant.mgt.server.feature diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml index 6a50c3a704..3ef87e723d 100644 --- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core email-sender-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.email.sender.feature pom - WSO2 Carbon - Email Sender Feature + Entgra Device Management - Email Sender Feature https://entgra.io This feature contains the core bundles required for email sender related functionality diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index ec244897d7..7048fb7be3 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core email-sender-feature pom - WSO2 Carbon - Email Sender Feature + Entgra Device Management - Email Sender Feature https://entgra.io diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index f7907e59bb..c8a9120c12 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -19,16 +19,16 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 transport-mgt-feature pom - Entgra - Transport Management Feature + Entgra Device Management - Transport Management Feature http://entgra.io diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml index bf8a594c77..bf136b67b8 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature pom - Entgra - SMS Handler API Feature + Entgra Device Management - SMS Handler API Feature https://entgra.io This feature contains the APIs required for SMS Handler diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml index 679db11051..d1c19e9c36 100644 --- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core sms-handler-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature pom - Entgra - SMS Handler Server Feature + Entgra Device Management - SMS Handler Server Feature https://entgra.io This feature contains the core bundles required for Back-end SMS Handler functionality diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index ec0afa72b5..6c5a1334c8 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core transport-mgt-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 sms-handler-feature pom - Entgra - SMS Handler Feature + Entgra Device Management - SMS Handler Feature http://entgra.io diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml index 83c3643fa5..0fada165d2 100644 --- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml @@ -21,12 +21,12 @@ ui-request-interceptor-feature io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT 4.0.0 io.entgra.device.mgt.core.ui.request.interceptor.feature - Entgra - UI Request Interceptor Feature + Entgra Device Management - UI Request Interceptor Feature Proxy servlet to handle requests generated from UI applications to communicate with backend APIs diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index 6026538937..f8af153582 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -19,15 +19,15 @@ - io.entgra.device.mgt.core.parent + device-mgt-core io.entgra.device.mgt.core - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../../pom.xml 4.0.0 ui-request-interceptor-feature - Entgra - UI Request Interceptor Feature + Entgra Device Management - UI Request Interceptor Feature Proxy servlet to handle requests generated from UI applications to communicate with backend APIs diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml index b423ee65a0..7ed67e9574 100644 --- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml @@ -22,14 +22,14 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT ../pom.xml 4.0.0 io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature pom - WSO2 Carbon - Webapp Authenticator Framework Server Feature + Entgra Device Management - Webapp Authenticator Framework Server Feature https://entgra.io This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index b7579c8e1d..c4d70adbc5 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -21,8 +21,8 @@ io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent - 5.2.4-SNAPSHOT + device-mgt-core + 6.0.0-SNAPSHOT ../../pom.xml @@ -30,7 +30,7 @@ io.entgra.device.mgt.core webapp-authenticator-framework-feature pom - WSO2 Carbon - Webapp Authenticator Framework Feature + Entgra Device Management - Webapp Authenticator Framework Feature https://entgra.io diff --git a/pom.xml b/pom.xml index f0edb13595..50024d954b 100644 --- a/pom.xml +++ b/pom.xml @@ -17,16 +17,18 @@ ~ under the License. --> - + 4.0.0 io.entgra.device.mgt.core - io.entgra.device.mgt.core.parent + device-mgt-core pom - 5.2.4-SNAPSHOT - WSO2 Carbon - Device Management - Parent + 6.0.0-SNAPSHOT + Entgra Device Management - Parent https://entgra.io - WSO2 Connected Device Manager Components + Entgra Device Management Core Components Parent + org.wso2 wso2 @@ -70,7 +72,6 @@ features/tenant-mgt features/operation-template-mgt-plugin-feature features/cea-mgt-feature - @@ -2120,7 +2121,8 @@ [2.1.1, 3.0.0) [5.14.0, 6.0.0) - [6.0.0, 7.0.0) + [6.0.0, 7.0.0) + 4.9.20 @@ -2134,7 +2136,7 @@ 1.2.11-wso2v25 - 5.2.4-SNAPSHOT + 6.0.0-SNAPSHOT 4.9.2 @@ -2291,7 +2293,8 @@ 2.23.4 2.8.1.wso2v2 - 4.3.1.wso2v1 + 4.3.1.wso2v1 + 2.1.214.wso2v1 1.1.3 From 08a6917d533b44fd9a79c96c2628f1ede7ef7dfd Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Tue, 1 Oct 2024 07:22:54 +0530 Subject: [PATCH 322/343] Remove old configs --- .github/stale.yml | 15 --------------- pom.xml | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 9cbd495b14..0000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 10 -# Don't close isssues or pulls -daysUntilClose: false -# Issues with these labels will never be considered stale -exemptLabels: - - Resolution/Postponed -# Label to use when marking an issue as stale -staleLabel: Resolution/Stale -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false diff --git a/pom.xml b/pom.xml index 50024d954b..a5e0e2f595 100644 --- a/pom.xml +++ b/pom.xml @@ -2092,7 +2092,7 @@ 2.2.1 7.4.0 4.8.1 - [4.5.0, 5.0.0) + [4.8.0, 5.0.0) 5.1.2 From c78d272bb80b381ec42ebd16c9497d78c83d3070 Mon Sep 17 00:00:00 2001 From: Lasantha Dharmakeerthi Date: Tue, 1 Oct 2024 08:23:04 +0000 Subject: [PATCH 323/343] Add device status filters updating logic (#519) Co-authored-by: tcdlpds Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/519 Co-authored-by: Lasantha Dharmakeerthi Co-committed-by: Lasantha Dharmakeerthi --- .../api/DeviceStatusFilterService.java | 48 +++++++++++++++++-- .../impl/DeviceStatusFilterServiceImpl.java | 33 ++++++++----- .../mgt/DeviceStatusManagementService.java | 13 ++--- .../pom.xml | 1 - .../DeviceStatusManagementServiceImpl.java | 16 +++++-- 5 files changed, 85 insertions(+), 26 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceStatusFilterService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceStatusFilterService.java index 7c0d84de1d..dc7c5a70fd 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceStatusFilterService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceStatusFilterService.java @@ -115,7 +115,7 @@ public interface DeviceStatusFilterService { required = true) @PathParam ("device-type") String deviceType); @GET - @Path("/is-enabled") + @Path("/device-status-check") @ApiOperation( httpMethod = HTTPConstants.HEADER_GET, value = "Get device status filter", @@ -155,7 +155,7 @@ public interface DeviceStatusFilterService { Response getDeviceStatusCheck(); @PUT - @Path("/toggle-device-status") + @Path("/device-status-check") @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = HTTPConstants.HEADER_POST, @@ -201,6 +201,7 @@ public interface DeviceStatusFilterService { @QueryParam("isEnabled") boolean isEnabled); @PUT + @Path("/{deviceType}") @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = HTTPConstants.HEADER_POST, @@ -243,10 +244,51 @@ public interface DeviceStatusFilterService { name = "deviceType", value = "The device type for which you want to update device status filters.", required = true) - @QueryParam("deviceType") String deviceType, + @PathParam ("deviceType") String deviceType, @ApiParam( name = "deviceStatus", value = "A list of device status values to update for the given device type.", required = true) @QueryParam("deviceStatus") List deviceStatus); + + @POST + @Path("/default") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_POST, + value = "Add Default Device status filters", + notes = "Add Default Device status filters", + tags = "Tenant Metadata Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "dm:devicestatusfilter:update") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully add default device status filters.", + response = Response.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 500, + message = "Internal Server Error. " + + "\n Server error occurred while adding default device status filters.", + response = ErrorResponse.class) + }) + Response setDefaultStatusFilterData(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java index cc2a2c90e9..680a4e5516 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java @@ -52,7 +52,7 @@ public class DeviceStatusFilterServiceImpl implements DeviceStatusFilterService try { DeviceStatusManagementService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceStatusManagmentService(); return Response.status(Response.Status.OK).entity(deviceManagementProviderService - .getDeviceStatusFilters(deviceType, CarbonContext.getThreadLocalCarbonContext().getTenantId())).build(); + .getDeviceStatusFilters(deviceType)).build(); } catch (MetadataKeyNotFoundException e) { String msg = "Couldn't find the device status filter details for device type: " + deviceType; log.error(msg, e); @@ -65,7 +65,7 @@ public class DeviceStatusFilterServiceImpl implements DeviceStatusFilterService } @GET - @Path("/is-enabled") + @Path("/device-status-check") @Override public Response getDeviceStatusCheck() { boolean result; @@ -83,15 +83,14 @@ public class DeviceStatusFilterServiceImpl implements DeviceStatusFilterService @Override @PUT - @Path("/toggle-device-status") + @Path("/device-status-check") public Response updateDeviceStatusCheck( @QueryParam("isEnabled") boolean isEnabled) { boolean result; - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { DeviceStatusManagementService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceStatusManagmentService(); - result = deviceManagementProviderService.updateDefaultDeviceStatusCheck(tenantId, isEnabled); + result = deviceManagementProviderService.updateDefaultDeviceStatusCheck(isEnabled); if (result) { return Response.status(Response.Status.OK).entity("Successfully updated device status check.").build(); } else { @@ -106,16 +105,14 @@ public class DeviceStatusFilterServiceImpl implements DeviceStatusFilterService @Override @PUT + @Path("/{deviceType}") public Response updateDeviceStatusFilters( - @QueryParam("deviceType") - String deviceType, - @QueryParam("deviceStatus") - List deviceStatus + @PathParam("deviceType") String deviceType, + @QueryParam("deviceStatus") List deviceStatus ) { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { DeviceStatusManagementService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceStatusManagmentService(); - deviceManagementProviderService.updateDefaultDeviceStatusFilters(tenantId, deviceType, deviceStatus); + deviceManagementProviderService.updateDefaultDeviceStatusFilters(deviceType, deviceStatus); return Response.status(Response.Status.OK).entity("Successfully updated device status filters for " + deviceType).build(); } catch (MetadataManagementException e) { String msg = "Error occurred while updating device status for " + deviceType; @@ -123,4 +120,18 @@ public class DeviceStatusFilterServiceImpl implements DeviceStatusFilterService return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } + + @Override + public Response setDefaultStatusFilterData() { + DeviceStatusManagementService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceStatusManagmentService(); + try { + deviceManagementProviderService.resetToDefaultDeviceStatusFilter(); + return Response.status(Response.Status.OK).entity("Successfully updated device status filters to " + + "default values that is configured in the product").build(); + } catch (MetadataManagementException e) { + String msg = "Error occurred while updating device status for default values that is configured in the product"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/DeviceStatusManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/DeviceStatusManagementService.java index 5abb9c7e88..163ac9bbc4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/DeviceStatusManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/metadata/mgt/DeviceStatusManagementService.java @@ -34,18 +34,19 @@ public interface DeviceStatusManagementService { void addDefaultDeviceStatusFilterIfNotExist(int tenantId) throws MetadataManagementException; /** - * This method is useful to reset existing device status to default values in xml + * This method is useful to reset existing device status to default values and device status check value to + * default value that is defined in the ui-config * * @throws MetadataManagementException if error while resetting default device status */ - void resetToDefaultDeviceStatusFilter(int tenantId) throws MetadataManagementException; + void resetToDefaultDeviceStatusFilter() throws MetadataManagementException; /** * This method is useful to update existing allowed device status * * @throws MetadataManagementException if error while updating existing device status */ - void updateDefaultDeviceStatusFilters(int tenantId, String deviceType, List deviceStatus) + void updateDefaultDeviceStatusFilters(String deviceType, List deviceStatus) throws MetadataManagementException; /** @@ -53,21 +54,21 @@ public interface DeviceStatusManagementService { * * @throws MetadataManagementException if error while updating existing device status */ - boolean updateDefaultDeviceStatusCheck(int tenantId, boolean isChecked) + boolean updateDefaultDeviceStatusCheck(boolean isChecked) throws MetadataManagementException; /** * This method is useful to get existing device status filters * * @throws MetadataManagementException if error while getting existing device status */ - List getDeviceStatusFilters(int tenantId) throws MetadataManagementException; + List getDeviceStatusFilters() throws MetadataManagementException; /** * This method is useful to get existing device status filters by device type and tenant id * * @throws MetadataManagementException if error while getting existing device status */ - List getDeviceStatusFilters(String deviceType, int tenantId) throws MetadataManagementException; + List getDeviceStatusFilters(String deviceType) throws MetadataManagementException; /** * This method is useful to get existing device status filters diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 43f48d94ed..361c06b77d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -143,7 +143,6 @@ io.entgra.device.mgt.core.device.mgt.core.config.keymanager, io.entgra.device.mgt.core.device.mgt.core.config.license, io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt, - io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.documentation, io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.whitelabel, io.entgra.device.mgt.core.device.mgt.core.config.operation.timeout, io.entgra.device.mgt.core.device.mgt.core.config.pagination, diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java index 42c0966da5..351ba5a63f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java @@ -36,6 +36,7 @@ import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.MetadataManage import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util.MetadataConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import java.lang.reflect.Type; import java.sql.SQLException; @@ -80,7 +81,8 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement } @Override - public void resetToDefaultDeviceStatusFilter(int tenantId) throws MetadataManagementException { + public void resetToDefaultDeviceStatusFilter() throws MetadataManagementException { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { MetadataManagementDAOFactory.beginTransaction(); Metadata defaultDeviceStatusMetadata = constructDeviceStatusMetadata(getDefaultDeviceStatus()); @@ -104,7 +106,8 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement } @Override - public void updateDefaultDeviceStatusFilters(int tenantId, String deviceType, List deviceStatus) throws MetadataManagementException { + public void updateDefaultDeviceStatusFilters(String deviceType, List deviceStatus) throws MetadataManagementException { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { MetadataManagementDAOFactory.beginTransaction(); // Retrieve the current device status metadata @@ -141,7 +144,8 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement } @Override - public boolean updateDefaultDeviceStatusCheck(int tenantId, boolean isChecked) throws MetadataManagementException { + public boolean updateDefaultDeviceStatusCheck(boolean isChecked) throws MetadataManagementException { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { MetadataManagementDAOFactory.beginTransaction(); if (metadataDAO.isExist(tenantId, MetadataConstants.IS_DEVICE_STATUS_CHECK_META_KEY)) { @@ -166,7 +170,8 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement } @Override - public List getDeviceStatusFilters(int tenantId) throws MetadataManagementException { + public List getDeviceStatusFilters() throws MetadataManagementException { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { MetadataManagementDAOFactory.openConnection(); Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY); @@ -193,7 +198,8 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement } - public List getDeviceStatusFilters(String deviceType, int tenantId) throws MetadataManagementException { + public List getDeviceStatusFilters(String deviceType) throws MetadataManagementException { + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { MetadataManagementDAOFactory.openConnection(); Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY); From 900a707ce7fb3bcc7917c23dabf5188aef6d268a Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Tue, 1 Oct 2024 14:00:35 +0530 Subject: [PATCH 324/343] Fix issues with bundle imports --- .../pom.xml | 22 +-- .../pom.xml | 10 +- .../pom.xml | 8 +- .../pom.xml | 2 +- .../pom.xml | 8 +- .../pom.xml | 58 +++--- .../pom.xml | 12 +- .../pom.xml | 4 +- .../pom.xml | 8 +- .../pom.xml | 16 +- .../pom.xml | 4 +- .../pom.xml | 12 +- .../pom.xml | 10 +- .../pom.xml | 2 +- .../pom.xml | 178 +++++------------- .../pom.xml | 32 ++-- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 8 +- .../pom.xml | 6 +- .../pom.xml | 10 +- .../pom.xml | 32 ++-- .../pom.xml | 8 +- .../pom.xml | 12 +- .../pom.xml | 16 +- .../pom.xml | 26 +-- .../pom.xml | 12 +- .../pom.xml | 20 +- pom.xml | 1 + 30 files changed, 235 insertions(+), 314 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 283f18a4ba..db015d3895 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -83,7 +83,7 @@ com.google.common.cache;version="[32.1,33)";resolution:=optional, com.google.gson;version="[2.9,3)", - io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common.exception;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.bean, io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config, io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.config.xml.bean, @@ -96,16 +96,16 @@ io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.sql.query, io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.sql.query.encoder, io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core.util, - io.entgra.device.mgt.core.application.mgt.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.core.util;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.common.util;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config.datasource;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.dao;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.report.mgt.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.report.mgt.dao.common;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.core.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.core.util;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.common.util;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config.datasource;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.dao;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.report.mgt.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.report.mgt.dao.common;version="${io.entgra.device.mgt.core.version.range}", javax.xml.bind;version="[0.0,1)", javax.xml.bind.annotation;version="[0.0,1)", javax.xml.parsers, diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index dc88b032b3..4e86ea95a3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -125,11 +125,11 @@ io.entgra.device.mgt.core.apimgt.application.extension.bean, io.entgra.device.mgt.core.apimgt.application.extension.dto, io.entgra.device.mgt.core.apimgt.application.extension.exception, - io.entgra.device.mgt.core.identity.jwt.client.extension;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.identity.jwt.client.extension;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", org.apache.commons.lang;version="[2.6,3)", org.apache.commons.logging;version="[1.2,2)", org.json.simple;version="[1.1,2)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index eba5a485b1..dcd47ba1f7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -88,10 +88,10 @@ io.entgra.device.mgt.core.apimgt.keymgt.extension, io.entgra.device.mgt.core.apimgt.keymgt.extension.exception, io.entgra.device.mgt.core.apimgt.keymgt.extension.service, - io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config.keymanager;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config.keymanager;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="${io.entgra.device.mgt.core.version.range}", javax.cache;version="[1.0,2)", javax.net.ssl,okhttp3;version="[4.9,5)", org.apache.commons.lang;version="[2.4,3)", diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 4882c2a16d..82a630ed00 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -174,7 +174,7 @@ com.google.gson;version="[2.9,3)", com.google.gson.reflect;version="[2.9,3)", - io.entgra.device.mgt.core.apimgt.annotations;version="[5.0,6)", + io.entgra.device.mgt.core.apimgt.annotations;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.apimgt.extension.rest.api.*, io.entgra.device.mgt.core.apimgt.webapp.publisher.config, io.entgra.device.mgt.core.apimgt.webapp.publisher.dto, diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 2916292c5c..6fc308d4b6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -61,10 +61,10 @@ io.entgra.device.mgt.core.application.mgt.common.exception, io.entgra.device.mgt.core.application.mgt.common.response, io.entgra.device.mgt.core.application.mgt.common.wrapper, - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.common.exception;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.common.exception;version="${io.entgra.device.mgt.core.version.range}", io.swagger.annotations;version="[1.6,2)", javax.validation.constraints;version="[2.0,3)", javax.xml.bind.annotation;version="[0.0,1)" diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 126a3ebf37..5f663268d1 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -57,16 +57,16 @@ com.dd.plist;version="[1.21,2)", com.google.gson;version="[2.9,3)", com.google.gson.reflect;version="[2.9,3)", - io.entgra.device.mgt.core.apimgt.application.extension;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.application.extension.dto;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.application.extension.exception;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common.config;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common.dto;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common.response;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common.services;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common.wrapper;version="[5.0,6)", + io.entgra.device.mgt.core.apimgt.application.extension;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.apimgt.application.extension.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.apimgt.application.extension.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.common.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.common.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.common.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.common.response;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.common.services;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.common.wrapper;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.application.mgt.core.config, io.entgra.device.mgt.core.application.mgt.core.dao, io.entgra.device.mgt.core.application.mgt.core.dao.common, @@ -80,25 +80,25 @@ io.entgra.device.mgt.core.application.mgt.core.dao.impl.visibility, io.entgra.device.mgt.core.application.mgt.core.exception, io.entgra.device.mgt.core.application.mgt.core.serviceprovider, - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.app.mgt.android;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.common.util;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.dto;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.task.impl;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.util;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.app.mgt.android;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.common.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.common.util;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.service;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.task.impl;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.util;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="${io.entgra.device.mgt.core.version.range}", javax.annotation;version="[1.0,2)", javax.naming, javax.sql, diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml index e2c5afc557..29ba28fbef 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml @@ -65,12 +65,12 @@ io.entgra.device.mgt.core.certificate.mgt.core.dao, io.entgra.device.mgt.core.certificate.mgt.core.dto, io.entgra.device.mgt.core.certificate.mgt.core.exception, - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config.cache;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config.cache;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.service;version="${io.entgra.device.mgt.core.version.range}", io.swagger.annotations;version="[1.6,2)", javax.cache;version="[1.0,2)", javax.naming, diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml index b02123e4c4..8a2b0c836c 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml @@ -55,8 +55,8 @@ IoT - User Roles Management Bundle io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.internal - io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.bean;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.exception;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.bean;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.exception;version="${io.entgra.device.mgt.core.version.range}", javax.xml.bind;version="[0.0,1)", javax.xml.bind.annotation;version="[0.0,1)", javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml index a3f4e5ce42..9b06465acd 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml @@ -151,11 +151,11 @@ io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.* - io.entgra.device.mgt.core.device.mgt.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.spi;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.util, - io.entgra.device.mgt.core.device.mgt.extensions.device.type.template;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.exception;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.device.type.template;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.exception;version="${io.entgra.device.mgt.core.version.range}", javax.xml.bind;version="[0.0,1)", javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}", org.apache.axis2.context;version="[1.6,2)", diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml index 8e8e19b364..48443f1491 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml @@ -84,14 +84,14 @@ com.google.gson;version="[2.9,3)", - io.entgra.device.mgt.core.application.mgt.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common.services;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.pull.notification;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", - io.entgra.device.mgt.core.policy.mgt.core;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.common.services;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.pull.notification;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.service;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.policy.mgt.core;version="${io.entgra.device.mgt.core.version.range}", org.apache.commons.logging;version="[1.2,2)", org.osgi.service.*;version="${imp.package.version.osgi.service}" diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml index edf6e15fb7..c3dc7fa4cc 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -127,8 +127,8 @@ com.google.gson;version="[2.9,3)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.push.notification;version="${io.entgra.device.mgt.core.version.range}", org.apache.commons.httpclient;version="[3.1,4)", org.apache.commons.httpclient.methods;version="[3.1,4)", org.apache.commons.logging;version="[1.2,2)", diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index a37af5cc64..c53a421ffa 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -158,12 +158,12 @@ io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.* - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.push.notification;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.service;version="${io.entgra.device.mgt.core.version.range}", org.apache.commons.logging;version="[1.2,2)", org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.context;version="[4.8,5)", diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 1dd7608238..b54d6b8f92 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -135,11 +135,11 @@ io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.* - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.push.notification;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.service;version="${io.entgra.device.mgt.core.version.range}", org.apache.commons.logging;version="[1.2,2)", org.osgi.service.*;version="${imp.package.version.osgi.service}", org.wso2.carbon.event.output.adapter.core;version="[5.3,6)", diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml index 5ac54dc0e8..c73865c166 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml @@ -54,7 +54,7 @@ ${io.entgra.device.mgt.core.version} IoT Device Management State Engine Bundle - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.extensions.stateengine.dto, io.entgra.device.mgt.core.device.mgt.extensions.stateengine.exception, org.apache.commons.logging;version="[1.2,2)", diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 43f48d94ed..93bc5da774 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -86,135 +86,55 @@ com.google.common.reflect;version="[32.1,33)";resolution:=optional, com.google.gson;version="[2.9,3)", com.google.gson.reflect;version="[2.9,3)", - io.entgra.device.mgt.core.apimgt.annotations;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.extension.rest.api;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.extension.rest.api.dto;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.apimgt.extension.rest.api.util;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.app.mgt.android;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.app.mgt.ios;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.authorization;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.configuration.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.cost.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.device.details;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.enrollment.notification;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.event.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.general;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.geo.service;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.invitation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.license.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.notification.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.otp.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.pull.notification;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.report.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.roles.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.search;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.spi;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.type.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.app.mgt.config, - io.entgra.device.mgt.core.device.mgt.core.archival, - io.entgra.device.mgt.core.device.mgt.core.archival.dao, - io.entgra.device.mgt.core.device.mgt.core.archival.dao.impl, - io.entgra.device.mgt.core.device.mgt.core.cache, - io.entgra.device.mgt.core.device.mgt.core.cache.impl, - io.entgra.device.mgt.core.device.mgt.core.common.exception, - io.entgra.device.mgt.core.device.mgt.core.common.util, - io.entgra.device.mgt.core.device.mgt.core.config, - io.entgra.device.mgt.core.device.mgt.core.config.analytics, - io.entgra.device.mgt.core.device.mgt.core.config.analytics.operation, - io.entgra.device.mgt.core.device.mgt.core.config.archival, - io.entgra.device.mgt.core.device.mgt.core.config.cache, - io.entgra.device.mgt.core.device.mgt.core.config.datasource, - io.entgra.device.mgt.core.device.mgt.core.config.enrollment.guide, - io.entgra.device.mgt.core.device.mgt.core.config.geo.location, - io.entgra.device.mgt.core.device.mgt.core.config.identity, - io.entgra.device.mgt.core.device.mgt.core.config.keymanager, - io.entgra.device.mgt.core.device.mgt.core.config.license, - io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt, - io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.documentation, - io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.whitelabel, - io.entgra.device.mgt.core.device.mgt.core.config.operation.timeout, - io.entgra.device.mgt.core.device.mgt.core.config.pagination, - io.entgra.device.mgt.core.device.mgt.core.config.permission, - io.entgra.device.mgt.core.device.mgt.core.config.policy, - io.entgra.device.mgt.core.device.mgt.core.config.pull.notification, - io.entgra.device.mgt.core.device.mgt.core.config.push.notification, - io.entgra.device.mgt.core.device.mgt.core.config.remote.session, - io.entgra.device.mgt.core.device.mgt.core.config.status.task, - io.entgra.device.mgt.core.device.mgt.core.config.task, - io.entgra.device.mgt.core.device.mgt.core.config.tenant, - io.entgra.device.mgt.core.device.mgt.core.config.ui, - io.entgra.device.mgt.core.device.mgt.core.dao, - io.entgra.device.mgt.core.device.mgt.core.dao.impl, - io.entgra.device.mgt.core.device.mgt.core.dao.impl.device, - io.entgra.device.mgt.core.device.mgt.core.dao.impl.enrolment, - io.entgra.device.mgt.core.device.mgt.core.dao.impl.event, - io.entgra.device.mgt.core.device.mgt.core.dao.impl.geofence, - io.entgra.device.mgt.core.device.mgt.core.dao.impl.group, - io.entgra.device.mgt.core.device.mgt.core.dao.impl.tracker, - io.entgra.device.mgt.core.device.mgt.core.device.details.mgt, - io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao, - io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.dao.impl, - io.entgra.device.mgt.core.device.mgt.core.dto, - io.entgra.device.mgt.core.device.mgt.core.dto.event.config, - io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt, - io.entgra.device.mgt.core.device.mgt.core.geo.geoHash, - io.entgra.device.mgt.core.device.mgt.core.geo.task, - io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao, - io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.impl, - io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util, - io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.util, - io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao, - io.entgra.device.mgt.core.device.mgt.core.notification.mgt.dao.impl, - io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao, - io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl, - io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.impl.operation, - io.entgra.device.mgt.core.device.mgt.core.operation.mgt.dao.util, - io.entgra.device.mgt.core.device.mgt.core.operation.mgt.util, - io.entgra.device.mgt.core.device.mgt.core.operation.timeout.task, - io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao, - io.entgra.device.mgt.core.device.mgt.core.otp.mgt.dao.impl, - io.entgra.device.mgt.core.device.mgt.core.otp.mgt.exception, - io.entgra.device.mgt.core.device.mgt.core.otp.mgt.util, - io.entgra.device.mgt.core.device.mgt.core.privacy, - io.entgra.device.mgt.core.device.mgt.core.privacy.dao, - io.entgra.device.mgt.core.device.mgt.core.privacy.dao.impl, - io.entgra.device.mgt.core.device.mgt.core.report.mgt, - io.entgra.device.mgt.core.device.mgt.core.report.mgt.config, - io.entgra.device.mgt.core.device.mgt.core.search.mgt, - io.entgra.device.mgt.core.device.mgt.core.search.mgt.dao, - io.entgra.device.mgt.core.device.mgt.core.status.task, - io.entgra.device.mgt.core.device.mgt.core.task, - io.entgra.device.mgt.core.device.mgt.core.traccar.api.service, - io.entgra.device.mgt.core.device.mgt.core.traccar.api.service.impl, - io.entgra.device.mgt.core.device.mgt.core.traccar.common.beans, - io.entgra.device.mgt.core.device.mgt.core.traccar.common.config, - io.entgra.device.mgt.core.device.mgt.core.traccar.common.util, - io.entgra.device.mgt.core.device.mgt.core.traccar.core.config, - io.entgra.device.mgt.core.device.mgt.extensions.logger;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="[5.0,6)", - io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="[5.0,6)", - io.entgra.device.mgt.core.notification.logger;version="[5.0,6)", - io.entgra.device.mgt.core.notification.logger.impl;version="[5.0,6)", - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="[5.0,6)", - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="[5.0,6)", - io.entgra.device.mgt.core.transport.mgt.email.sender.core;version="[5.0,6)", - io.entgra.device.mgt.core.transport.mgt.email.sender.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.apimgt.annotations;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.apimgt.extension.rest.api;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.apimgt.extension.rest.api.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.apimgt.extension.rest.api.dto.APIInfo;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.apimgt.extension.rest.api.util;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.app.mgt.android;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.app.mgt.ios;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.app.mgt.windows;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.authorization;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.configuration.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.cost.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.device.details;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.enrollment.notification;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.event.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.general;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.geo.service;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.invitation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.license.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.notification.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.otp.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.pull.notification;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.push.notification;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.report.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.roles.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.search;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.spi;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.type.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.extensions.logger;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.identity.jwt.client.extension.service;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.notification.logger;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.notification.logger.impl;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.transport.mgt.email.sender.core;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.transport.mgt.email.sender.core.service;version="${io.entgra.device.mgt.core.version.range}", io.swagger.annotations;version="[1.6,2)", javax.cache;version="[1.0,2)", javax.naming, diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index 3d8761c19d..c407639b3f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -185,21 +185,21 @@ com.google.gson;version="[2.9,3)", - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.configuration.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.general;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.invitation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.license.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.pull.notification;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.push.notification;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.spi;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.type.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.app.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.configuration.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.general;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.invitation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.license.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.pull.notification;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.push.notification;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.spi;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.type.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.service;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.extensions.device.type.template, io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config, io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.dao, @@ -207,7 +207,7 @@ io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.feature, io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.policy.mgt, io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.pull.notification, - io.entgra.device.mgt.core.device.mgt.extensions.logger;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.logger;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.device.mgt.extensions.spi, javax.naming, javax.sql, diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml index 8190256832..e0fa9efd0c 100644 --- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml @@ -57,8 +57,8 @@ io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.internal - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.server.bootup.heartbeat.beacon, io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.config, io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.config.datasource, diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index b1e8750818..5a56856887 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -80,8 +80,8 @@ io.entgra.device.mgt.core.notification.logger, io.entgra.device.mgt.core.notification.logger.util, - io.entgra.device.mgt.core.device.mgt.extensions.logger;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.extensions.logger;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.extensions.logger.spi;version="${io.entgra.device.mgt.core.version.range}", org.slf4j, org.apache.commons.logging;version="[1.2,2)" diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml index b2dc0ce6c5..6083a4ab51 100644 --- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml +++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml @@ -56,8 +56,8 @@ com.google.common.cache;version="[32.1,33)";resolution:=optional, com.google.gson;version="[2.9,3)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.service;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.operation.template.cache, io.entgra.device.mgt.core.operation.template.dao, io.entgra.device.mgt.core.operation.template.dao.impl, diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml index 513152f2f0..e137e1e49a 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml @@ -54,13 +54,13 @@ Policy Decision Point Bundle io.entgra.device.mgt.core.policy.decision.point.internal - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.policy.decision.point.internal, io.entgra.device.mgt.core.policy.decision.point.merged, io.entgra.device.mgt.core.policy.decision.point.simple, - io.entgra.device.mgt.core.policy.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.policy.mgt.core;version="[5.0,6)", + io.entgra.device.mgt.core.policy.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.policy.mgt.core;version="${io.entgra.device.mgt.core.version.range}", org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}", org.osgi.service.*;version="${imp.package.version.osgi.service}", diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml index a3ae255da7..3c3fc651be 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml @@ -60,10 +60,10 @@ io.entgra.device.mgt.core.policy.information.point.* - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.policy.information.point, - io.entgra.device.mgt.core.policy.mgt.common;version="[5.0,6)", + io.entgra.device.mgt.core.policy.mgt.common;version="${io.entgra.device.mgt.core.version.range}", org.apache.commons.logging;version="[1.2,2)", org.osgi.framework.*;version="${imp.package.version.osgi.framework}" diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml index 860313c31d..ed94e7ccc6 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml @@ -54,11 +54,11 @@ ${io.entgra.device.mgt.core.version} Policy Management Common Bundle - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.dto;version="[5.0,6)" + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.dto;version="${io.entgra.device.mgt.core.version.range}" io.entgra.device.mgt.core.policy.mgt.common.* diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 39421174ef..4f0acc31ed 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -56,22 +56,22 @@ io.entgra.device.mgt.core.policy.mgt.core.internal com.google.gson;version="[2.9,3)", - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.configuration.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config.policy;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config.tenant;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.dto;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.task.impl;version="[5.0,6)", - io.entgra.device.mgt.core.policy.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.policy.mgt.common.monitor;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.configuration.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.group.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.policy.mgt.monitor;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config.policy;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config.tenant;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.service;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.task.impl;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.policy.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.policy.mgt.common.monitor;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.policy.mgt.core.cache, io.entgra.device.mgt.core.policy.mgt.core.cache.impl, io.entgra.device.mgt.core.policy.mgt.core.config, diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml index 7001e25e3d..23d7cca0e9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml @@ -55,10 +55,10 @@ com.fasterxml.jackson.core;version="[2.14,3)", com.google.common.cache;version="[32.1,33)";resolution:=optional, - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config.datasource;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config.datasource;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.service;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.subtype.mgt.cache, io.entgra.device.mgt.core.subtype.mgt.dao, io.entgra.device.mgt.core.subtype.mgt.dao.impl, diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml index e591310db6..b27391b7e5 100755 --- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml +++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml @@ -55,12 +55,12 @@ io.entgra.device.mgt.core.task.mgt.core.internal com.google.gson;version="[2.9,3)", - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="[5.0,6)", - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="[5.0,6)", - io.entgra.device.mgt.core.task.mgt.common.bean;version="[5.0,6)", - io.entgra.device.mgt.core.task.mgt.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.task.mgt.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.task.mgt.common.bean;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.task.mgt.common.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.task.mgt.common.spi;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.task.mgt.core.config, io.entgra.device.mgt.core.task.mgt.core.config.datasource, io.entgra.device.mgt.core.task.mgt.core.dao, diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml index 38647f51f2..d30dae8547 100755 --- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml +++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml @@ -54,14 +54,14 @@ Task Watcher Bundle io.entgra.device.mgt.core.task.mgt.watcher.internal - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="[5.0,6)", - io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="[5.0,6)", - io.entgra.device.mgt.core.task.mgt.common.bean;version="[5.0,6)", - io.entgra.device.mgt.core.task.mgt.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.task.mgt.common.spi;version="[5.0,6)", - io.entgra.device.mgt.core.task.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.task.mgt.core.util;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.task.mgt.common.bean;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.task.mgt.common.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.task.mgt.common.spi;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.task.mgt.core.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.task.mgt.core.util;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.task.mgt.watcher, io.entgra.device.mgt.core.task.mgt.watcher.internal, org.apache.commons.logging;version="[1.2,2)", diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml index b3d9e75a9c..55257748f7 100644 --- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml +++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml @@ -52,19 +52,19 @@ Tenant Management Core Bundle io.entgra.device.mgt.core.tenant.mgt.core.internal - io.entgra.device.mgt.core.application.mgt.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.common.services;version="[5.0,6)", - io.entgra.device.mgt.core.application.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.roles.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.config;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.dao;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.metadata.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.tenant.mgt.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.tenant.mgt.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.application.mgt.common.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.common.services;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.application.mgt.core.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.roles.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.dao;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.metadata.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.tenant.mgt.common.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.tenant.mgt.common.spi;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.tenant.mgt.core, org.apache.commons.logging;version="[1.2,2)", org.osgi.framework;version="${imp.package.version.osgi.framework}", diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml index b2ce6f9333..7a12df65bf 100644 --- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml @@ -81,12 +81,12 @@ SMS Management Core Bundle io.entgra.device.mgt.core.transport.mgt.sms.handler.core.internal - io.entgra.device.mgt.core.device.mgt.common.exceptions;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.util;version="[5.0,6)", - io.entgra.device.mgt.core.transport.mgt.sms.handler.common.bean;version="[5.0,6)", - io.entgra.device.mgt.core.transport.mgt.sms.handler.common.config;version="[5.0,6)", - io.entgra.device.mgt.core.transport.mgt.sms.handler.common.exception;version="[5.0,6)", - io.entgra.device.mgt.core.transport.mgt.sms.handler.common.spi;version="[5.0,6)", + io.entgra.device.mgt.core.device.mgt.common.exceptions;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.util;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.transport.mgt.sms.handler.common.bean;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.transport.mgt.sms.handler.common.config;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.transport.mgt.sms.handler.common.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.transport.mgt.sms.handler.common.spi;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.transport.mgt.sms.handler.core.config, javax.xml.bind;version="[0.0,1)", org.apache.commons.lang;version="[2.6,3)", diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml index e0bdc94163..5da570acdc 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml @@ -62,16 +62,16 @@ com.nimbusds.jose;version="[7.9,8)", com.nimbusds.jose.crypto;version="[7.9,8)", com.nimbusds.jwt;version="[7.9,8)", - io.entgra.device.mgt.core.certificate.mgt.core.dto;version="[5.0,6)", - io.entgra.device.mgt.core.certificate.mgt.core.exception;version="[5.0,6)", - io.entgra.device.mgt.core.certificate.mgt.core.scep;version="[5.0,6)", - io.entgra.device.mgt.core.certificate.mgt.core.service;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.common.spi;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="[5.0,6)", - io.entgra.device.mgt.core.device.mgt.core.util;version="[5.0,6)", + io.entgra.device.mgt.core.certificate.mgt.core.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.certificate.mgt.core.exception;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.certificate.mgt.core.scep;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.certificate.mgt.core.service;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.otp.mgt.dto;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.permission.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.common.spi;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.permission.mgt;version="${io.entgra.device.mgt.core.version.range}", + io.entgra.device.mgt.core.device.mgt.core.util;version="${io.entgra.device.mgt.core.version.range}", io.entgra.device.mgt.core.webapp.authenticator.framework.authenticator.oauth, io.entgra.device.mgt.core.webapp.authenticator.framework.authorizer, io.entgra.device.mgt.core.webapp.authenticator.framework.config, diff --git a/pom.xml b/pom.xml index a5e0e2f595..48cdcf3eb2 100644 --- a/pom.xml +++ b/pom.xml @@ -2137,6 +2137,7 @@ 6.0.0-SNAPSHOT + [6.0.0, 7.0.0) 4.9.2 From 634763a6db3b00309532d46aa38cc19db979cb85 Mon Sep 17 00:00:00 2001 From: uddhika Date: Tue, 1 Oct 2024 14:26:20 +0530 Subject: [PATCH 325/343] changes to 204 status code handling --- .../ui/request/interceptor/util/HandlerUtil.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 57ccd146ad..98d8e42c64 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -104,14 +104,14 @@ public class HandlerUtil { final HttpEntity responseEntity = response.getEntity(); ProxyResponse handlerResponse = new ProxyResponse(); int statusCode = response.getCode(); + if (statusCode == 204) { + handlerResponse.setCode(statusCode); + handlerResponse.setStatus(ProxyResponse.Status.SUCCESS); + handlerResponse.setExecutorResponse("SUCCESS"); + handlerResponse.setHeaders(response.getHeaders()); + return handlerResponse; + } if (responseEntity == null) { - if (statusCode == 204) { - handlerResponse.setCode(statusCode); - handlerResponse.setStatus(ProxyResponse.Status.SUCCESS); - handlerResponse.setExecutorResponse("SUCCESS"); - handlerResponse.setHeaders(response.getHeaders()); - return handlerResponse; - } log.error("Received null response for http request : " + httpRequest.getMethod() + " " + httpRequest.getRequestUri()); handlerResponse.setCode(HandlerConstants.INTERNAL_ERROR_CODE); handlerResponse.setStatus(ProxyResponse.Status.ERROR); From 10e647efb35050ffdbdd5094bdde724f0dc3a4bc Mon Sep 17 00:00:00 2001 From: nipuni Date: Wed, 2 Oct 2024 11:05:36 +0530 Subject: [PATCH 326/343] Add improvements for Allowed Device Status View --- .../jaxrs/service/impl/DeviceStatusFilterServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java index 680a4e5516..b2f958754b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceStatusFilterServiceImpl.java @@ -74,8 +74,12 @@ public class DeviceStatusFilterServiceImpl implements DeviceStatusFilterService DeviceStatusManagementService deviceManagementProviderService = DeviceMgtAPIUtils.getDeviceStatusManagmentService(); result = deviceManagementProviderService.getDeviceStatusCheck(tenantId); return Response.status(Response.Status.OK).entity(result).build(); + } catch (MetadataKeyNotFoundException e) { + String msg = "Couldn't find the device status check metadata for tenant ID: " + tenantId; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } catch (MetadataManagementException e) { - String msg = "Error occurred while getting device status filter of the tenant."; + String msg = "Error occurred while getting device status check for the tenant."; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } From f13342493dbbb6246efdce80f5f405bf83d8f170 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Mon, 7 Oct 2024 15:34:56 +0530 Subject: [PATCH 327/343] Add credentials name instead of cred ids --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1420c9f347..1ca3c229ba 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,7 +71,7 @@ pipeline { if (env.CHANGE_ID) { def url = swaggerEndPoint.call() echo "Fetching from URL: ${url}" - withCredentials([usernamePassword(credentialsId: '4093a0bf-073a-4874-b929-be5b69273f4a', passwordVariable: 'password', usernameVariable: 'username')]) { + withCredentials([usernamePassword(credentialsId: 'entgra-gitea-credentials', passwordVariable: 'password', usernameVariable: 'username')]) { def response = sh(script: """curl -X GET "${url}" -H 'accept: application/json' -u \$username:\$password""", returnStdout: true).trim() echo "API Response: ${response}" isPendingUpstreamDependenciesExists = sh(script: "echo '${response}' | jq 'contains({\"labels\": [{ \"name\": \"pending upstream\"}]})'", returnStdout: true).trim().toBoolean() @@ -93,7 +93,7 @@ pipeline { echo '[Jenkinsfile] Entering testing phase.' try { checkout scm - withCredentials([usernamePassword(credentialsId: 'builder2-deployer', passwordVariable: 'password', usernameVariable: 'username')]) { + withCredentials([usernamePassword(credentialsId: 'builder2-deployer-nexus', passwordVariable: 'password', usernameVariable: 'username')]) { sh """/opt/scripts/run-test.sh -u \$username -p \$password""" } currentBuild.result = 'SUCCESS' @@ -134,7 +134,7 @@ pipeline { steps { script { if (true) { - withCredentials([usernamePassword(credentialsId: '4093a0bf-073a-4874-b929-be5b69273f4a', passwordVariable: 'password', usernameVariable: 'username')]) { + withCredentials([usernamePassword(credentialsId: 'entgra-gitea-credentials', passwordVariable: 'password', usernameVariable: 'username')]) { def url = swaggerEndPoint.call() + '/reviews' echo "[Jenkinsfile] Notifying pull request build status to ${url}" def response = sh(script: """curl -X POST "${url}" -H 'accept: application/json' -H 'Content-Type: application/json' -u \$username:\$password -d '{ "body": "${message}" }'""", returnStdout: true).trim() From 0ac795903f03dfab35429dc24197e4fe383ada93 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Mon, 14 Oct 2024 11:24:02 +0530 Subject: [PATCH 328/343] Remove code quality check from PRs --- Jenkinsfile | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1ca3c229ba..11676b7a12 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,6 @@ pipeline { environment { def isPendingUpstreamDependenciesExists = false def triggeredViaPush = false - SCANNER_HOME = tool 'sonar-scanner' JAVA_HOME = '/usr/lib/jvm/java-11-openjdk' PATH = "${JAVA_HOME}/bin:${env.PATH}" } @@ -48,22 +47,6 @@ pipeline { } } } - - stage('Check SonarQube Installation') { - steps { - script { - echo "Initial JAVA_HOME: ${env.JAVA_HOME}" - echo "Initial PATH: ${env.PATH}" - - withEnv(["JAVA_HOME=${env.JAVA_HOME}", "PATH=${env.JAVA_HOME}/bin:${env.PATH}"]) { - sh """ - java -version - ${SCANNER_HOME}/bin/sonar-scanner --version - """ - } - } - } -} stage('Fetch Pending Upstream Dependencies') { steps { @@ -111,24 +94,6 @@ pipeline { } } } - - stage('Code Quality Check') { - steps { - script { - def projectName = "device-mgt-core-${env.CHANGE_ID}" - def projectKey = "device-mgt-core-${env.CHANGE_ID}" - - withSonarQubeEnv('sonar') { - sh """ - $SCANNER_HOME/bin/sonar-scanner \ - -Dsonar.projectName=${projectName} \ - -Dsonar.projectKey=${projectKey} \ - -Dsonar.java.binaries=target - """ - } - } - } -} stage('Report Job Status') { steps { From cba9f7ce080de366543b594be3b13206296db85a Mon Sep 17 00:00:00 2001 From: nipuni Date: Tue, 15 Oct 2024 19:04:43 +0530 Subject: [PATCH 329/343] Fix the validation issue when the APK file and screenshot names contain spaces --- .../application/mgt/core/util/APIUtil.java | 45 ++++++++++--------- .../application/mgt/core/util/Constants.java | 5 +++ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java index 4a0687052a..2ac54352fe 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java @@ -48,6 +48,8 @@ import org.apache.commons.validator.routines.UrlValidator; import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.ws.rs.core.Response; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -503,31 +505,29 @@ public class APIUtil { applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions()); applicationRelease.setRating(applicationReleaseDTO.getRating()); applicationRelease.setIconPath( - basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName()); - - if (!StringUtils.isEmpty(applicationReleaseDTO.getBannerName())){ + basePath + Constants.ICON_ARTIFACT + Constants.FILE_NAME_PARAM + + URLEncoder.encode(applicationReleaseDTO.getIconName(), StandardCharsets.UTF_8)); + if (!StringUtils.isEmpty(applicationReleaseDTO.getBannerName())) { applicationRelease.setBannerPath( - basePath + Constants.BANNER_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO - .getBannerName()); + basePath + Constants.BANNER_ARTIFACT + Constants.FILE_NAME_PARAM + + URLEncoder.encode(applicationReleaseDTO.getBannerName(), StandardCharsets.UTF_8)); } - - applicationRelease.setInstallerPath(constructInstallerPath(applicationReleaseDTO.getInstallerName(), - applicationReleaseDTO.getAppHashValue())); - + applicationRelease.setInstallerPath( + constructInstallerPath(applicationReleaseDTO.getInstallerName(), applicationReleaseDTO.getAppHashValue())); if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName1())) { - screenshotPaths - .add(basePath + Constants.SCREENSHOT_ARTIFACT + 1 + Constants.FORWARD_SLASH + applicationReleaseDTO - .getScreenshotName1()); + screenshotPaths.add( + basePath + Constants.SCREENSHOT_ARTIFACT + 1 + Constants.FILE_NAME_PARAM + + URLEncoder.encode(applicationReleaseDTO.getScreenshotName1(), StandardCharsets.UTF_8)); } if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName2())) { - screenshotPaths - .add(basePath + Constants.SCREENSHOT_ARTIFACT + 2 + Constants.FORWARD_SLASH + applicationReleaseDTO - .getScreenshotName2()); + screenshotPaths.add( + basePath + Constants.SCREENSHOT_ARTIFACT + 2 + Constants.FILE_NAME_PARAM + + URLEncoder.encode(applicationReleaseDTO.getScreenshotName2(), StandardCharsets.UTF_8)); } if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName3())) { - screenshotPaths - .add(basePath + Constants.SCREENSHOT_ARTIFACT + 3 + Constants.FORWARD_SLASH + applicationReleaseDTO - .getScreenshotName3()); + screenshotPaths.add( + basePath + Constants.SCREENSHOT_ARTIFACT + 3 + Constants.FILE_NAME_PARAM + + URLEncoder.encode(applicationReleaseDTO.getScreenshotName3(), StandardCharsets.UTF_8)); } applicationRelease.setScreenshots(screenshotPaths); return applicationRelease; @@ -543,9 +543,12 @@ public class APIUtil { public static String constructInstallerPath(String installerName, String appHash) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); UrlValidator urlValidator = new UrlValidator(); - String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + appHash + Constants.FORWARD_SLASH; - return urlValidator.isValid(installerName) ? installerName - : basePath + Constants.APP_ARTIFACT + Constants.FORWARD_SLASH + installerName; + String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + + appHash + Constants.FORWARD_SLASH; + return urlValidator.isValid(installerName) + ? installerName + : basePath + Constants.APP_ARTIFACT + Constants.FILE_NAME_PARAM + + URLEncoder.encode(installerName, StandardCharsets.UTF_8); } public static String getArtifactDownloadBaseURL() throws ApplicationManagementException { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java index 81e5bef788..57ed6b7189 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java @@ -140,6 +140,11 @@ public class Constants { public static final String DB_TYPE_POSTGRESQL = "PostgreSQL"; } + /** + * Query parameter for specifying the filename in the App artifact URL. + */ + public static final String FILE_NAME_PARAM = "?fileName="; + /** * Directory name of the icon artifact that are saved in the file system. */ From b7e0580112f6e138054a706a6f918b367c3695e6 Mon Sep 17 00:00:00 2001 From: nipuni Date: Mon, 21 Oct 2024 13:48:27 +0530 Subject: [PATCH 330/343] Fix missing commit by moving transaction commit after metadata update. --- .../core/metadata/mgt/DeviceStatusManagementServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java index 351ba5a63f..c04e5deae8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/metadata/mgt/DeviceStatusManagementServiceImpl.java @@ -151,9 +151,9 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement if (metadataDAO.isExist(tenantId, MetadataConstants.IS_DEVICE_STATUS_CHECK_META_KEY)) { // Add default device status check metadata entries metadataDAO.updateMetadata(tenantId, constructDeviceStatusCheckMetadata(isChecked)); + MetadataManagementDAOFactory.commitTransaction(); return true; } - MetadataManagementDAOFactory.commitTransaction(); } catch (MetadataManagementDAOException e) { MetadataManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while updating device status check metadata entry."; From 8f47c448bdf0d5e140ed0e0f3269cbed89f7c186 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Thu, 17 Oct 2024 23:58:56 +0530 Subject: [PATCH 331/343] Fix login issues in sub tenants --- .../ui/request/interceptor/LoginHandler.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java index 6a97630e99..e699bc7675 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/LoginHandler.java @@ -37,6 +37,8 @@ import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.NameValuePair; import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; import org.apache.hc.core5.http.message.BasicNameValuePair; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; @@ -44,6 +46,10 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Base64; @@ -61,6 +67,8 @@ public class LoginHandler extends HttpServlet { private static String uiConfigUrl; private static String iotCoreUrl; private static String kmManagerUrl; + private static String adminUsername; + private static String adminPassword; @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) { @@ -87,14 +95,14 @@ public class LoginHandler extends HttpServlet { LoginCache loginCache = HandlerUtil.getLoginCache(httpSession); OAuthAppCacheKey oAuthAppCacheKey = new OAuthAppCacheKey(applicationName, username); OAuthApp oAuthApp = loginCache.getOAuthAppCache(oAuthAppCacheKey); - if (oAuthApp == null) { + initializeAdminCredentials(); ArrayList supportedGrantTypes = new ArrayList<>(); supportedGrantTypes.add(HandlerConstants.PASSWORD_GRANT_TYPE); supportedGrantTypes.add(HandlerConstants.REFRESH_TOKEN_GRANT_TYPE); ClassicHttpRequest apiRegEndpoint = ClassicRequestBuilder.post(gatewayUrl + HandlerConstants.APP_REG_ENDPOINT) .setEntity(HandlerUtil.constructAppRegPayload(tags, applicationName, - username, password, null, supportedGrantTypes)) + adminUsername, adminPassword, null, supportedGrantTypes)) .setHeader(org.apache.hc.core5.http.HttpHeaders.CONTENT_TYPE, org.apache.hc.core5.http.ContentType.APPLICATION_JSON.toString()) .setHeader(org.apache.hc.core5.http.HttpHeaders.AUTHORIZATION, HandlerConstants.BASIC + Base64.getEncoder().encodeToString((username + HandlerConstants.COLON + password).getBytes())) @@ -143,6 +151,10 @@ public class LoginHandler extends HttpServlet { log.error("Error occurred while sending the response into the socket. ", e); } catch (JsonSyntaxException e) { log.error("Error occurred while parsing the response. ", e); + } catch (ParserConfigurationException e) { + log.error("Error while creating the document builder. "); + } catch (SAXException e) { + log.error("Error while parsing xml file. ", e); } catch (LoginException e) { log.error("Error occurred while getting token data. ", e); } @@ -251,4 +263,21 @@ public class LoginHandler extends HttpServlet { .build(); return HandlerUtil.execute(tokenEndpoint); } + + /** + * Initialize the admin credential variables + * + * @throws ParserConfigurationException - Throws when error occur during initializing the document builder + * @throws IOException - Throws when error occur during document parsing + * @throws SAXException - Throws when error occur during document parsing + */ + private void initializeAdminCredentials() throws ParserConfigurationException, IOException, SAXException { + File userMgtConf = new File("repository/conf/user-mgt.xml"); + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + Document doc = dBuilder.parse(userMgtConf); + + adminUsername = doc.getElementsByTagName("UserName").item(0).getTextContent(); + adminPassword = doc.getElementsByTagName("Password").item(0).getTextContent(); + } } From 20df0c879f88a0bc8afffcfd1ac1cef33b3b3988 Mon Sep 17 00:00:00 2001 From: pramilaniroshan Date: Wed, 23 Oct 2024 09:13:59 +0530 Subject: [PATCH 332/343] Improved SQL query with DESC sorting --- .../mgt/core/dao/impl/GenericCertificateDAOImpl.java | 2 +- .../certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java | 2 +- .../mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java | 2 +- .../mgt/core/dao/impl/SQLServerCertificateDAOImpl.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java index 92891754ed..26217b4667 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/GenericCertificateDAOImpl.java @@ -139,7 +139,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl { isCertificateUsernameProvided = true; } - query += "ORDER BY ID LIMIT ?,?"; + query += "ORDER BY ID DESC LIMIT ?,?"; try (PreparedStatement stmt = conn.prepareStatement(query)) { int paramIdx = 1; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java index 9fd87d6ed0..716d5df388 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/OracleCertificateDAOImpl.java @@ -78,7 +78,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl { isCertificateUsernameProvided = true; } - query += "ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + query += "ORDER BY ID DESC OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement stmt = conn.prepareStatement(query)) { int paramIdx = 1; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java index ef06ec0000..2d1cc90851 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/PostgreSQLCertificateDAOImpl.java @@ -78,7 +78,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl { isCertificateUsernameProvided = true; } - query += "ORDER BY ID LIMIT ? OFFSET ?"; + query += "ORDER BY ID DESC LIMIT ? OFFSET ?"; try (PreparedStatement stmt = conn.prepareStatement(query)) { int paramIdx = 1; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java index 22874dd7b7..a9f37a6143 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/dao/impl/SQLServerCertificateDAOImpl.java @@ -78,7 +78,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl { isCertificateUsernameProvided = true; } - query += "ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + query += "ORDER BY ID DESC OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement stmt = conn.prepareStatement(query)) { int paramIdx = 1; From 0e82c9c304117468a97fce39bd9fd98bccc7cebd Mon Sep 17 00:00:00 2001 From: Subodhinie Date: Wed, 23 Oct 2024 16:57:32 +0530 Subject: [PATCH 333/343] Remove unused windows os updates scopes --- .../src/main/resources/conf/mdm-ui-config.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 45c3ebe581..31350a1f6f 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -392,7 +392,6 @@ win:ops:os-updates-info win:microsoft-store:search win:updates:read - win:update:modify admin:tenant:view dm:admin:devices:usage:view and:ops:clear-app From 00633e34f5b1e3d9480d911e24f3789ce11268a2 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Sat, 31 Aug 2024 00:42:35 +0530 Subject: [PATCH 334/343] Fix client cert verification issue in sub tenants --- .../mgt/core/impl/CertificateGenerator.java | 31 ++++++++++++++----- .../util/CertificateManagementConstants.java | 1 + .../certificate/mgt/core/util/CommonUtil.java | 26 ++++++++++++++++ 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index 75f4266b1c..6147618664 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -29,6 +29,7 @@ import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagement import io.entgra.device.mgt.core.certificate.mgt.core.util.CommonUtil; import io.entgra.device.mgt.core.certificate.mgt.core.util.Serializer; import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.bouncycastle.asn1.ASN1Encodable; @@ -429,19 +430,34 @@ public class CertificateGenerator { generateCertificate(byteArrayInputStream); if (reqCert != null && reqCert.getSerialNumber() != null) { - log.debug("looking up certificate for serial: " + reqCert.getSerialNumber().toString()); - CertificateResponse lookUpCertificate = keyStoreReader.getCertificateBySerial( - reqCert.getSerialNumber().toString()); + if (log.isDebugEnabled()) { + log.debug("looking up certificate for serial: " + reqCert.getSerialNumber().toString()); + } + String orgUnit = CommonUtil.getSubjectDnAttribute(reqCert, + CertificateManagementConstants.ORG_UNIT_ATTRIBUTE); + CertificateResponse lookUpCertificate; + if (StringUtils.isNotEmpty(orgUnit)) { + int tenantId = Integer.parseInt(orgUnit.split(("_"))[1]); + lookUpCertificate = keyStoreReader.getCertificateBySerial(reqCert.getSerialNumber().toString(), + tenantId); + } else { + lookUpCertificate = keyStoreReader.getCertificateBySerial( + reqCert.getSerialNumber().toString()); + } if (lookUpCertificate != null && lookUpCertificate.getCertificate() != null) { - log.debug("certificate found for serial: " + reqCert.getSerialNumber() - .toString()); + if (log.isDebugEnabled()) { + log.debug("certificate found for serial: " + reqCert.getSerialNumber() + .toString()); + } Certificate certificate = (Certificate) Serializer.deserialize(lookUpCertificate.getCertificate()); if (certificate instanceof X509Certificate) { return (X509Certificate) certificate; } } else { - log.debug("certificate not found for serial: " + reqCert.getSerialNumber() - .toString()); + if (log.isDebugEnabled()) { + log.debug("certificate not found for serial: " + reqCert.getSerialNumber() + .toString()); + } } } @@ -464,7 +480,6 @@ public class CertificateGenerator { log.error(errorMsg); throw new KeystoreException(errorMsg, e); } - return null; } diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagementConstants.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagementConstants.java index f851bd05f0..35da404ef8 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagementConstants.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagementConstants.java @@ -35,6 +35,7 @@ public final class CertificateManagementConstants { public static final String DES_EDE = "DESede"; public static final String CONF_LOCATION = "conf.location"; public static final String DEFAULT_PRINCIPAL = "O=WSO2, OU=Mobile, C=LK"; + public static final String ORG_UNIT_ATTRIBUTE = "OU="; public static final String RSA_PRIVATE_KEY_BEGIN_TEXT = "-----BEGIN RSA PRIVATE KEY-----\n"; public static final String RSA_PRIVATE_KEY_END_TEXT = "-----END RSA PRIVATE KEY-----"; public static final String EMPTY_TEXT = ""; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java index 0b1d317721..a18dd057fa 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java @@ -17,7 +17,10 @@ */ package io.entgra.device.mgt.core.certificate.mgt.core.util; +import org.apache.commons.lang.StringUtils; + import java.math.BigInteger; +import java.security.cert.X509Certificate; import java.util.Calendar; import java.util.Date; @@ -42,4 +45,27 @@ public class CommonUtil { public static synchronized BigInteger generateSerialNumber() { return BigInteger.valueOf(System.currentTimeMillis()); } + + /** + * Returns the value of the given attribute from the subject distinguished name. eg: "entgra.net" + * from "CN=entgra.net" + * @param requestCertificate {@link X509Certificate} that needs to extract an attribute from + * @param attribute the attribute name that needs to be extracted from the cert. eg: "CN=" + * @return the value of the attribute + */ + public static String getSubjectDnAttribute(X509Certificate requestCertificate, String attribute) { + String distinguishedName = requestCertificate.getSubjectDN().getName(); + if (StringUtils.isNotEmpty(distinguishedName)) { + String[] dnSplits = distinguishedName.split(","); + for (String dnSplit : dnSplits) { + if (dnSplit.contains(attribute)) { + String[] cnSplits = dnSplit.split("="); + if (StringUtils.isNotEmpty(cnSplits[1])) { + return cnSplits[1]; + } + } + } + } + return null; + } } From b2b4c5c676cbd0f71b83f0c62c3d823ab152125d Mon Sep 17 00:00:00 2001 From: Arshana Date: Thu, 31 Oct 2024 10:36:03 +0530 Subject: [PATCH 335/343] Add scpeific instructions in java doc comment --- .../DeviceManagementProviderServiceImpl.java | 55 +++++++++---------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index df57af8444..902dcfee81 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -546,14 +546,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId); - boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId); - boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(device.getType(), - device.getEnrolmentInfo().getStatus().name(),tenantId); - if (updatedRows == 1 && !deviceStatusManagementService.getDeviceStatusCheck(tenantId)){ - enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus()); - } else if (updatedRows ==1 && isEnableDeviceStatusCheck && isValidState ) { - enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus()); - } + addDeviceStatus(deviceStatusManagementService, tenantId, updatedRows, device.getEnrolmentInfo(), + device.getType()); DeviceManagementDAOFactory.commitTransaction(); log.info("Device enrollment modified successfully", @@ -672,13 +666,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder .getInstance().getDeviceStatusManagementService(); int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId); - boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId); - boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(device.getType(),device.getEnrolmentInfo().getStatus().name(),tenantId); - if (updatedRows == 1 && !deviceStatusManagementService.getDeviceStatusCheck(tenantId)){ - enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus()); - } else if (updatedRows ==1 && isEnableDeviceStatusCheck && isValidState ) { - enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus()); - } + addDeviceStatus(deviceStatusManagementService, tenantId, updatedRows, device.getEnrolmentInfo(), device.getType()); DeviceManagementDAOFactory.commitTransaction(); this.removeDeviceFromCache(deviceId); @@ -3475,17 +3463,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv String type = deviceIdentifier.getType(); DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder .getInstance().getDeviceStatusManagementService(); - DeviceManagementDAOFactory.commitTransaction(); if (updatedRows > 0) { isUpdatedEnrollment = true; } - boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId); - boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(type, enrolmentInfo.getStatus().name(), tenantId); - if (updatedRows == 1 && !deviceStatusManagementService.getDeviceStatusCheck(tenantId)) { - enrollmentDAO.addDeviceStatus(enrolmentInfo.getId(), enrolmentInfo.getStatus()); - } else if (updatedRows == 1 && isEnableDeviceStatusCheck && isValidState) { - enrollmentDAO.addDeviceStatus(enrolmentInfo.getId(), enrolmentInfo.getStatus()); - } + addDeviceStatus(deviceStatusManagementService, tenantId, updatedRows, enrolmentInfo, type); + DeviceManagementDAOFactory.commitTransaction(); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); @@ -3503,6 +3485,24 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return isUpdatedEnrollment; } + /** + * Save the status according to status check(allowed device status) + * Before invoking this method the calling function should have started a transaction + * @param deviceStatusManagementService instance of deviceStatusManagementService + * @param tenantId ID of the tenant + * @param updatedRows number of updated rows + * @param enrolmentInfo enrollment info of the device + * @param type type of the device + */ + private void addDeviceStatus(DeviceStatusManagementService deviceStatusManagementService, int tenantId, + int updatedRows,EnrolmentInfo enrolmentInfo,String type) + throws MetadataManagementException, DeviceManagementDAOException { + boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId); + boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(type, enrolmentInfo.getStatus().name(), tenantId); + if (updatedRows == 1 && (!isEnableDeviceStatusCheck || isValidState)) { + enrollmentDAO.addDeviceStatus(enrolmentInfo.getId(), enrolmentInfo.getStatus()); + } + } private int getTenantId() { return CarbonContext.getThreadLocalCarbonContext().getTenantId(); @@ -4523,13 +4523,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder .getInstance().getDeviceStatusManagementService(); int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId); - boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId); - boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(type, String.valueOf(EnrolmentInfo.Status.REMOVED),tenantId); - if (updatedRows == 1 && !deviceStatusManagementService.getDeviceStatusCheck(tenantId)){ - enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus()); - } else if (updatedRows ==1 && isEnableDeviceStatusCheck && isValidState ) { - enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus()); - } + addDeviceStatus(deviceStatusManagementService, tenantId, updatedRows, device.getEnrolmentInfo(), + type); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Error occurred while dis-enrolling device: " + From 1aa32528b0c738621d11bf0e5bfde0218e4a3d1d Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Wed, 6 Nov 2024 15:12:13 +0530 Subject: [PATCH 336/343] Fix test case failure when extracting cert from signature --- .../mgt/core/impl/CertificateGenerator.java | 3 +-- .../util/CertificateManagementConstants.java | 1 + .../certificate/mgt/core/util/CommonUtil.java | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index 6147618664..2d65fe4710 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -29,7 +29,6 @@ import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagement import io.entgra.device.mgt.core.certificate.mgt.core.util.CommonUtil; import io.entgra.device.mgt.core.certificate.mgt.core.util.Serializer; import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.bouncycastle.asn1.ASN1Encodable; @@ -436,7 +435,7 @@ public class CertificateGenerator { String orgUnit = CommonUtil.getSubjectDnAttribute(reqCert, CertificateManagementConstants.ORG_UNIT_ATTRIBUTE); CertificateResponse lookUpCertificate; - if (StringUtils.isNotEmpty(orgUnit)) { + if (CommonUtil.isScepOrgUnit(orgUnit)) { int tenantId = Integer.parseInt(orgUnit.split(("_"))[1]); lookUpCertificate = keyStoreReader.getCertificateBySerial(reqCert.getSerialNumber().toString(), tenantId); diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagementConstants.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagementConstants.java index 35da404ef8..a423ccbd8e 100644 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagementConstants.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CertificateManagementConstants.java @@ -36,6 +36,7 @@ public final class CertificateManagementConstants { public static final String CONF_LOCATION = "conf.location"; public static final String DEFAULT_PRINCIPAL = "O=WSO2, OU=Mobile, C=LK"; public static final String ORG_UNIT_ATTRIBUTE = "OU="; + public static final String ORG_UNIT_TENANT_PREFIX = "tenant_"; public static final String RSA_PRIVATE_KEY_BEGIN_TEXT = "-----BEGIN RSA PRIVATE KEY-----\n"; public static final String RSA_PRIVATE_KEY_END_TEXT = "-----END RSA PRIVATE KEY-----"; public static final String EMPTY_TEXT = ""; diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java index a18dd057fa..b839917fb5 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/util/CommonUtil.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.certificate.mgt.core.util; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; import java.math.BigInteger; import java.security.cert.X509Certificate; @@ -68,4 +69,24 @@ public class CommonUtil { } return null; } + + /** + * Checks if the organizational unit (OU) attribute has a valid tenant id in order to verify that it is + * a SCEP certificate. eg: OU=tenant_1 + *

+ * Refer to engineering mail SCEP implementation for Android + * @param orgUnit organizational unit (OU) of the certificate + * @return true if it is a valid SCEP org unit else false + */ + public static boolean isScepOrgUnit(String orgUnit) { + if (StringUtils.isNotEmpty(orgUnit)) { + if (orgUnit.contains(CertificateManagementConstants.ORG_UNIT_TENANT_PREFIX)) { + String[] orgUnitArray = orgUnit.split(("_")); + if (orgUnitArray.length > 1) { + return NumberUtils.isNumber(orgUnitArray[1]); + } + } + } + return false; + } } From ae4978cee88d1fd5df99223d374cf017384ef731 Mon Sep 17 00:00:00 2001 From: uddhika Date: Wed, 6 Nov 2024 17:16:59 +0530 Subject: [PATCH 337/343] scopes related to tagging feature --- .../src/main/resources/conf/mdm-ui-config.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 43e5c59f98..23b52bb978 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -427,6 +427,9 @@ dm:admin:cea:sync am:pub:app:upload dm:devices:ops:status:update + tm:tags:mapping:create + tm:tags:mapping:delete + perm:rmr:admin:view-last-profile-reading device-mgt From 4792f4af7245e9d6fa0bc47fe5dce74892c792c8 Mon Sep 17 00:00:00 2001 From: uddhika Date: Wed, 6 Nov 2024 17:18:45 +0530 Subject: [PATCH 338/343] fixes scope lines --- .../src/main/resources/conf/mdm-ui-config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 23b52bb978..7e65645411 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -427,9 +427,9 @@ dm:admin:cea:sync am:pub:app:upload dm:devices:ops:status:update + tm:tags:view tm:tags:mapping:create tm:tags:mapping:delete - perm:rmr:admin:view-last-profile-reading device-mgt From bd8ecb87186a514100b5d6db92046666ae34d891 Mon Sep 17 00:00:00 2001 From: uddhika Date: Wed, 6 Nov 2024 17:22:46 +0530 Subject: [PATCH 339/343] further added scope lines --- .../src/main/resources/conf/mdm-ui-config.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 7e65645411..c078c262b0 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -428,8 +428,12 @@ am:pub:app:upload dm:devices:ops:status:update tm:tags:view + tm:tags:create + tm:tags:update + tm:tags:delete tm:tags:mapping:create tm:tags:mapping:delete + device-mgt From 85d7ed641a9e36d3c2d357399de90c6c89271eca Mon Sep 17 00:00:00 2001 From: uddhika Date: Wed, 6 Nov 2024 18:43:35 +0530 Subject: [PATCH 340/343] removed new line --- .../src/main/resources/conf/mdm-ui-config.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index c078c262b0..8dda1588b0 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -433,7 +433,6 @@ tm:tags:delete tm:tags:mapping:create tm:tags:mapping:delete - device-mgt From 16b7c4f3e7a956b7487aaa77b91e7e291e646847 Mon Sep 17 00:00:00 2001 From: nipuni Date: Tue, 29 Oct 2024 17:27:46 +0530 Subject: [PATCH 341/343] Fix error response formatting issue. --- .../interceptor/beans/ErrorResponse.java | 55 +++++++++++++++++++ .../request/interceptor/util/HandlerUtil.java | 32 ++++++++--- 2 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ErrorResponse.java diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ErrorResponse.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ErrorResponse.java new file mode 100644 index 0000000000..febfa20df0 --- /dev/null +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/beans/ErrorResponse.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018 - 2024, 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.ui.request.interceptor.beans; + +public class ErrorResponse { + private int code; + private String data; + private int status; + + public ErrorResponse(int code, String data, int status) { + this.code = code; + this.data = data; + this.status = status; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } +} + diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java index 98d8e42c64..f1a33fb2f7 100644 --- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/src/main/java/io/entgra/device/mgt/core/ui/request/interceptor/util/HandlerUtil.java @@ -20,17 +20,16 @@ package io.entgra.device.mgt.core.ui.request.interceptor.util; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.TextNode; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import io.entgra.device.mgt.core.ui.request.interceptor.beans.AuthData; +import io.entgra.device.mgt.core.ui.request.interceptor.beans.ErrorResponse; import io.entgra.device.mgt.core.ui.request.interceptor.cache.LoginCache; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; @@ -227,16 +226,37 @@ public class HandlerUtil { proxyResponse.setExecutorResponse(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + HandlerUtil .getStatusKey(HandlerConstants.INTERNAL_ERROR_CODE)); } + JsonNode dataNode = proxyResponse.getData(); + String responseData = extractDataAsString(dataNode); resp.setStatus(proxyResponse.getCode()); resp.setContentType(ContentType.APPLICATION_JSON.getMimeType()); resp.setCharacterEncoding(Consts.UTF_8.name()); proxyResponse.setExecutorResponse(null); + proxyResponse.setData(null); + ErrorResponse errorResponse = new ErrorResponse( + proxyResponse.getCode(), + responseData, + proxyResponse.getStatus() + ); try (PrintWriter writer = resp.getWriter()) { - writer.write(gson.toJson(proxyResponse)); + writer.write(gson.toJson(errorResponse)); } } + /** + * Extracts a string representation from the given JsonNode. + * + * @param dataNode the JsonNode from which to extract the string representation (can be null). + * @return the string representation of the JsonNode, or null if the dataNode is null. + */ + private static String extractDataAsString(JsonNode dataNode) { + if (dataNode == null) { + return null; + } + return dataNode.isTextual() ? dataNode.asText() : dataNode.toString(); + } + /** * Handle error requests with custom error codes. * @@ -772,9 +792,7 @@ public class HandlerUtil { try { finalNode = objectMapper.readTree(content); } catch (JsonProcessingException e) { - ObjectNode objectNode = objectMapper.createObjectNode(); - objectNode.put("message", content); - finalNode = objectMapper.valueToTree(objectNode); + finalNode = new TextNode(content); } } return finalNode; From 5853e529c7bba778ac60058a86f84d23a223f570 Mon Sep 17 00:00:00 2001 From: nipuni Date: Tue, 29 Oct 2024 21:46:03 +0530 Subject: [PATCH 342/343] Fix throwing NullPointerException when getting a fileName with a query param. --- .../impl/FileDownloaderServiceProvider.java | 53 +++++++++++++------ .../util/FileTransferServiceHelperUtil.java | 10 +++- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java index f8fe6f2f94..7c8ad99533 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java @@ -132,9 +132,21 @@ public class FileDownloaderServiceProvider { } /** - * Extracting file name segments by parsing the URL - * @param url Remote URL to extract file name segments - * @return Array containing file name segments or null when failed to extract + * Extracts file name segments (name and extension) by parsing the given URL. + * This method handles two types of URL formats: + * - If the URL includes a query parameter in the format `?fileName=`, the file name + * is extracted from this query parameter (ex: when referencing an existing + * screenshot or icon from the main release) + * - If the URL does not have the `fileName` query parameter, the method attempts to + * extract the file name from the URL path. (ex: this applies to cases where new files are + * uploaded, and only a path-based URL is provided) + * After locating the file name (from either the query parameter or path), the method + * splits the name into segments based on the last dot (`.`), returning the base name and + * extension as a two-element array. If file name cannot be extracted, `null` is returned. + * + * @param url Remote URL to extract file name segments from, which may contain a file name + * as either a query parameter (`fileName=...`) or in the path. + * @return An array containing the file name and extension segments, or null if extraction fails. */ public static String[] extractFileNameSegmentsFromUrl(URL url) { if (url == null) { @@ -143,24 +155,35 @@ public class FileDownloaderServiceProvider { } return null; } - - String []urlSegments = url.toString().split("/"); - if (urlSegments.length < 1) { - if (log.isDebugEnabled()) { - log.debug("Cannot determine the file name for the remote file"); + String fullQualifiedName = null; + String query = url.getQuery(); + if (query != null && query.startsWith("fileName=")) { + String[] queryParts = query.split("=", 2); + if (queryParts.length > 1 && !queryParts[1].isEmpty()) { + fullQualifiedName = queryParts[1]; } - return null; } - - String fullQualifiedName = urlSegments[urlSegments.length - 1]; - String []fileNameSegments = fullQualifiedName.split("\\.(?=[^.]+$)"); - if (fileNameSegments.length != 2) { + if (fullQualifiedName == null) { + String[] urlSegments = url.getPath().split("/"); + if (urlSegments.length > 0) { + fullQualifiedName = urlSegments[urlSegments.length - 1]; + } + } + if (fullQualifiedName != null) { + String[] fileNameSegments = fullQualifiedName.split("\\.(?=[^.]+$)"); + if (fileNameSegments.length == 2) { + return fileNameSegments; + } else { + if (log.isDebugEnabled()) { + log.debug("Error encountered when constructing file name"); + } + } + } else { if (log.isDebugEnabled()) { log.debug("Error encountered when constructing file name"); } - return null; } - return fileNameSegments; + return null; } /** diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java index 856faf4944..0542aba5a6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/FileTransferServiceHelperUtil.java @@ -183,6 +183,15 @@ public class FileTransferServiceHelperUtil { return fileDescriptorResolvedFromRelease; } + String file = urlPathSegments[urlPathSegments.length - 1]; + String query = downloadUrl.getQuery(); + if (query != null && query.startsWith("fileName=")) { + String[] queryParts = query.split("=", 2); + if (queryParts.length > 1 && !queryParts[1].isEmpty()) { + file = queryParts[1]; + } + } + if (urlPathSegments.length < 2) { if (log.isDebugEnabled()) { log.debug("URL patch segments contain less than 2 segments"); @@ -190,7 +199,6 @@ public class FileTransferServiceHelperUtil { return null; } - String file = urlPathSegments[urlPathSegments.length - 1]; String artifactHolder = urlPathSegments[urlPathSegments.length - 2]; try { FileDescriptor fileDescriptor = new FileDescriptor(); From ba3e4623df0ee4c130e158ec691e5313a52c41eb Mon Sep 17 00:00:00 2001 From: nipuni Date: Tue, 12 Nov 2024 20:28:09 +0530 Subject: [PATCH 343/343] Fix NullPointerException in getFileMetaEntry method for URLs with chunked transfer encoding. --- .../mgt/core/impl/FileDownloaderServiceProvider.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java index 7c8ad99533..d0ca149bcb 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java @@ -122,7 +122,10 @@ public class FileDownloaderServiceProvider { } FileMetaEntry fileMetaEntry = new FileMetaEntry(); - fileMetaEntry.setSize(Long.parseLong(Objects.requireNonNull(response.header("Content-Length")))); + String contentLength = response.header("Content-Length"); + if (contentLength != null) { + fileMetaEntry.setSize(Long.parseLong(contentLength)); + } fileMetaEntry.setFileName(fileNameSegments[0]); fileMetaEntry.setExtension(fileNameSegments[1]); return fileMetaEntry;