From a5f6662198c8903f426ba96c8a498139f60c4828 Mon Sep 17 00:00:00 2001 From: Harshan Liyanage Date: Tue, 4 Apr 2017 16:09:49 +0530 Subject: [PATCH] Revert "Merge branch 'master' into cloud-3.1.0" This reverts commit e9c2f3e72dc1997d9577eb60b642bd064f2e21ae, reversing changes made to 6e00753c39118e0badc33b11c66dd1c625049978. --- README.md | 2 - .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../APIManagementProviderServiceImpl.java | 2 +- .../org.wso2.carbon.apimgt.handlers/pom.xml | 4 +- .../pom.xml | 7 +- .../pom.xml | 13 +- .../pom.xml | 4 +- .../webapp/publisher/APIPublisherUtil.java | 3 +- .../lifecycle/util/AnnotationProcessor.java | 2 +- components/apimgt-extensions/pom.xml | 4 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 4 +- components/certificate-mgt/pom.xml | 4 +- .../pom.xml | 2 +- .../type/deployer/config/Claimable.java | 104 - .../config/DeviceTypeConfiguration.java | 45 +- .../config/InitialOperationConfig.java | 39 - .../deployer/template/DeviceTypeManager.java | 8 +- .../template/DeviceTypeManagerService.java | 25 +- .../src/test/resources/sample.xml | 2 - .../pom.xml | 14 +- .../GCMBasedPushNotificationProvider.java} | 10 +- .../gcm/GCMNotificationStrategy.java} | 48 +- .../provider/gcm/internal/GCMDataHolder.java} | 8 +- .../GCMPushNotificationServiceComponent.java} | 19 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../XMPPPushNotificationServiceComponent.java | 2 +- components/device-mgt-extensions/pom.xml | 4 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.device.mgt.api/pom.xml | 9 +- .../mgt/jaxrs/beans/BasePaginatedResult.java | 6 +- .../service/api/DeviceManagementService.java | 85 +- .../impl/DeviceManagementServiceImpl.java | 52 +- .../impl/UserManagementServiceImpl.java | 26 - .../mgt/jaxrs/util/DeviceMgtAPIUtils.java | 33 - .../org.wso2.carbon.device.mgt.common/pom.xml | 2 +- .../mgt/common/InitialOperationConfig.java | 36 - .../device/mgt/common/search/Condition.java | 2 +- .../common/spi/DeviceManagementService.java | 9 +- .../org.wso2.carbon.device.mgt.core/pom.xml | 2 +- .../carbon/device/mgt/core/dao/DeviceDAO.java | 7 + .../core/dao/impl/AbstractDeviceDAOImpl.java | 22 + .../internal/DeviceManagementDataHolder.java | 5 + .../DeviceManagementProviderService.java | 12 +- .../DeviceManagementProviderServiceImpl.java | 126 +- .../task/impl/DeviceDetailsRetrieverTask.java | 51 +- .../mgt/core/TestDeviceManagementService.java | 10 +- .../pom.xml | 2 +- .../org.wso2.carbon.device.mgt.ui/pom.xml | 2 +- .../devicemgt/app/conf/config.json | 4 +- .../modules/business-controllers/operation.js | 16 +- .../app/modules/business-controllers/user.js | 5 +- .../jaggeryapps/devicemgt/app/modules/init.js | 6 +- .../app/modules/oauth/token-handlers.js | 94 +- .../public/js/bottomJs.js | 4 +- .../pages/cdmf.page.group.create/create.hbs | 2 +- .../overview-section.hbs | 41 +- .../app/units/cdmf.unit.device.view/view.hbs | 1 - .../units/cdmf.unit.lib.editable/editable.hbs | 8 - .../cdmf.unit.lib.editable/editable.json | 4 - .../public/css/editable.css | 663 -- .../public/img/clear.png | Bin 509 -> 0 bytes .../public/img/loading.gif | Bin 1849 -> 0 bytes .../public/js/editable.js | 6807 ----------------- .../public/js/editable.min.js | 7 - .../user-menu.hbs | 8 +- .../public/css/custom-desktop.css | 7 - .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../org.wso2.carbon.email.sender.core/pom.xml | 2 +- components/email-sender/pom.xml | 2 +- .../dynamic-client-web-proxy/pom.xml | 2 +- .../dynamic-client-web/pom.xml | 2 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../dynamic-client-registration/pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../org.wso2.carbon.policy.mgt.common/pom.xml | 4 +- .../org.wso2.carbon.policy.mgt.core/pom.xml | 4 +- .../policy/mgt/core/task/MonitoringTask.java | 141 +- components/policy-mgt/pom.xml | 4 +- .../pom.xml | 4 +- .../webapp-authenticator-framework/pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 7 +- .../pom.xml | 4 +- features/apimgt-extensions/pom.xml | 4 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 4 +- features/certificate-mgt/pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 14 +- .../src/main/resources/build.properties | 0 .../src/main/resources/p2.inf | 0 .../pom.xml | 4 +- .../pom.xml | 4 +- features/device-mgt-extensions/pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 2 +- .../pom.xml | 4 +- .../pom.xml | 2 +- .../pom.xml | 4 +- .../src/main/resources/conf/cdm-config.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 4 +- features/dynamic-client-registration/pom.xml | 4 +- .../pom.xml | 4 +- features/email-sender/pom.xml | 4 +- .../pom.xml | 4 +- features/jwt-client/pom.xml | 4 +- .../pom.xml | 4 +- features/oauth-extensions/pom.xml | 4 +- .../pom.xml | 4 +- features/policy-mgt/pom.xml | 4 +- .../pom.xml | 4 +- .../webapp-authenticator-framework/pom.xml | 4 +- pom.xml | 6 +- 132 files changed, 496 insertions(+), 8435 deletions(-) delete mode 100644 components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Claimable.java delete mode 100644 components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/InitialOperationConfig.java rename components/device-mgt-extensions/{org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm => org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm}/pom.xml (94%) rename components/device-mgt-extensions/{org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java => org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMBasedPushNotificationProvider.java} (84%) rename components/device-mgt-extensions/{org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java => org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMNotificationStrategy.java} (76%) rename components/device-mgt-extensions/{org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMDataHolder.java => org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMDataHolder.java} (88%) rename components/device-mgt-extensions/{org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java => org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMPushNotificationServiceComponent.java} (78%) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/InitialOperationConfig.java delete mode 100755 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/editable.hbs delete mode 100755 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/editable.json delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/public/css/editable.css delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/public/img/clear.png delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/public/img/loading.gif delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/public/js/editable.js delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.editable/public/js/editable.min.js rename features/device-mgt-extensions/{org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature => org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature}/pom.xml (93%) rename features/device-mgt-extensions/{org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature => org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature}/src/main/resources/build.properties (100%) rename features/device-mgt-extensions/{org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature => org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature}/src/main/resources/p2.inf (100%) diff --git a/README.md b/README.md index e07bdc37059..5ff98b8ff5b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # carbon-device-mgt - - WSO2 CONNECTED DEVICE MANAGEMENT COMPONENTS WSO2 Connected Device Manager (WSO2 CDM) is a comprehensive platform that helps solve mobile computing challenges enterprises face today when dealing with both corporate owned, personally enabled (COPE) devices and employee owned devices as part of a bring your own device (BYOD) program. diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index 59dac719561..8174536bd22 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT bundle WSO2 Carbon - API Management Annotations WSO2 Carbon - API Management Custom Annotation Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index d4639c7ac63..4894c6a3ba6 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,12 +21,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT org.wso2.carbon.apimgt.application.extension.api war WSO2 Carbon - API Application Management API diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index f9eec4c0642..c72fcb0b8e2 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,12 +22,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT org.wso2.carbon.apimgt.application.extension bundle WSO2 Carbon - API Application Management diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index fa9699050ab..ef01e368830 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -90,7 +90,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe } catch (FeignException e) { attempts++; try { - Thread.sleep(500); + Thread.sleep(1000); } catch (InterruptedException ex) { log.warn("Interrupted the waiting for tier availability."); } 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 60a240a4a79..272d0c5e349 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml @@ -21,13 +21,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handlers - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT bundle WSO2 Carbon - API Security Handler Component WSO2 Carbon - API Management Security Handler Module 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 600a37c0952..8756c25905d 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 @@ -8,18 +8,19 @@ License for the ~ specific language governing permissions and limitations ~ under the License. --> - + apimgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client 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 45c73d28396..aa6c82acf84 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 @@ -8,20 +8,21 @@ License for the ~ specific language governing permissions and limitations ~ under the License. --> - + apimgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.generated.client - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT bundle - WSO2 Carbon - API Management Integration Generated Client + WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client http://wso2.org @@ -200,7 +201,5 @@ jackson-datatype-joda - - true - + diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index b5c7204eb75..040588814cd 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT bundle WSO2 Carbon - API Management Webapp Publisher WSO2 Carbon - API Management Webapp Publisher diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java index a3f8608de4d..839658ec2a1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java @@ -218,7 +218,7 @@ public class APIPublisherUtil { JsonObject httpVerb = new JsonObject(); httpVerb.add("responses", response); - httpVerb.addProperty("x-auth-type", uriTemplate.getAuthType()); + httpVerb.addProperty("x-auth-type", "Application%20%26%20Application%20User"); httpVerb.addProperty("x-throttling-tier", "Unlimited"); if (uriTemplate.getScope() != null) { httpVerb.addProperty("x-scope", uriTemplate.getScope().getKey()); @@ -289,6 +289,5 @@ public class APIPublisherUtil { } } } - apiConfig.setUriTemplates(templates); } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java index dfc8dd74540..52dc1477903 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java @@ -53,7 +53,7 @@ public class AnnotationProcessor { private static final Log log = LogFactory.getLog(AnnotationProcessor.class); - private static final String AUTH_TYPE = "Application & Application User"; + private static final String AUTH_TYPE = "Any"; private static final String STRING_ARR = "string_arr"; private static final String STRING = "string"; private static final String PACKAGE_ORG_APACHE = "org.apache"; diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 6d23a37141d..747dc0d3946 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT pom WSO2 Carbon - API Management Extensions Component http://wso2.org diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index b567e83cd77..948ba6691bf 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index 992199ec4de..955bb55fa2c 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index a74d2b88102..764f381934b 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -21,13 +21,13 @@ org.wso2.carbon.devicemgt certificate-mgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT bundle WSO2 Carbon - Certificate Management Core WSO2 Carbon - Certificate Management Core diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 1c48533dd60..44988a66b42 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT pom WSO2 Carbon - Certificate Management Component http://wso2.org diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index 9f667e301e0..435730554ea 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Claimable.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Claimable.java deleted file mode 100644 index 661778e62d0..00000000000 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/Claimable.java +++ /dev/null @@ -1,104 +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.extensions.device.type.deployer.config; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; - - -/** - *

Java class for DeviceDetails complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="DeviceDetails">
- *   <simpleContent>
- *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
- *       <attribute name="table-id" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </extension>
- *   </simpleContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "Claimable", propOrder = { - "value" -}) -public class Claimable { - - @XmlValue - protected String value; - @XmlAttribute(name = "enabled") - protected boolean enabled; - - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } - - /** - * Gets the value of the enabled property. - * - * @return - * possible object is - * {@link String } - * - */ - public boolean isEnabled() { - return enabled; - } - - /** - * Sets the value of the enabled property. - * - * @param enabled - * allowed object is - * {@link String } - * - */ - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - -} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java index 00d20b4ebec..2a43797e9d9 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java @@ -18,8 +18,11 @@ */ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; -import javax.xml.bind.annotation.*; -import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; /** @@ -53,8 +56,6 @@ public class DeviceTypeConfiguration { @XmlElement(name = "DeviceDetails", required = true) protected DeviceDetails deviceDetails; - @XmlElement(name = "Claimable", required = true) - protected Claimable claimable; @XmlElement(name = "Features", required = true) protected Features features; @XmlElement(name = "ProvisioningConfig", required = true) @@ -73,21 +74,6 @@ public class DeviceTypeConfiguration { protected String name; @XmlElement(name = "PolicyMonitoring", required = true) protected PolicyMonitoring policyMonitoring; - @XmlElementWrapper(name = "InitialOperationConfig") - @XmlElement(name = "Operation", required = true) - protected List operations; - - public List getOperations() { - return operations; - } - - public void setOperations(List operations) { - this.operations = operations; - } - - - - /** * Gets the value of the taskConfiguration property. @@ -133,27 +119,6 @@ public class DeviceTypeConfiguration { this.deviceDetails = value; } - /** - * Gets the value of the Claimable property. - * - * @return possible object is - * {@link DeviceDetails } - */ - public Claimable getClaimable() { - return claimable; - } - - /** - * Sets the value of the deviceDetails property. - * - * @param value allowed object is - * {@link DeviceDetails } - */ - public void setClaimable(Claimable value) { - this.claimable = value; - } - - /** * Gets the value of the policyMonitoring property. * diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/InitialOperationConfig.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/InitialOperationConfig.java deleted file mode 100644 index e172d7b009c..00000000000 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/InitialOperationConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.wso2.carbon.device.mgt.extensions.device.type.deployer.config; - -import javax.xml.bind.annotation.*; -import java.util.List; - -/** - *

Java class for InitialOperationConfig complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="InitialOperationConfig">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="Operations" type="{http://www.w3.org/2001/XMLSchema}list"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlRootElement(name = "InitialOperationConfig") -public class InitialOperationConfig { - - private List operations; - - @XmlElementWrapper(name = "Operations", required = true) - @XmlElement(name = "Operation", required = true) - public List getOperations() { - return operations; - } - - public void setOperationsll(List operations) { - this.operations = operations; - } -} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java index 98c5ef28708..eba2f18721a 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManager.java @@ -65,7 +65,6 @@ public class DeviceTypeManager implements DeviceManager { private LicenseManager licenseManager; private boolean propertiesExist; private boolean requiredDeviceTypeAuthorization; - private boolean claimable; private FeatureManager featureManager; @@ -102,13 +101,8 @@ public class DeviceTypeManager implements DeviceManager { String msg = "Error occurred while adding default license for " + deviceType + " devices"; throw new DeviceTypeDeployerFileException(msg, e); } - claimable = false; - if (deviceTypeConfiguration.getClaimable() != null ) { - claimable = deviceTypeConfiguration.getClaimable().isEnabled(); - } DeviceDetails deviceDetails = deviceTypeConfiguration.getDeviceDetails(); - if (deviceDetails != null) { //Check whether device dao definition exist. @@ -347,7 +341,7 @@ public class DeviceTypeManager implements DeviceManager { @Override public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException { - return claimable; + return false; } @Override diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java index bf05136bc0d..6cb819fc8e5 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java @@ -20,7 +20,11 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.DeviceManager; +import org.wso2.carbon.device.mgt.common.MonitoringOperation; +import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; +import org.wso2.carbon.device.mgt.common.ProvisioningConfig; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; @@ -53,8 +57,6 @@ public class DeviceTypeManagerService implements DeviceManagementService { private OperationMonitoringTaskConfig operationMonitoringConfigs; private List monitoringOperations; private PolicyMonitoringManager policyMonitoringManager; - private InitialOperationConfig initialOperationConfig; - private List operations; public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, DeviceTypeConfiguration deviceTypeConfiguration) { @@ -64,8 +66,7 @@ public class DeviceTypeManagerService implements DeviceManagementService { this.populatePushNotificationConfig(deviceTypeConfiguration.getPushNotificationProvider()); this.operationMonitoringConfigs = new OperationMonitoringTaskConfig(); this.setOperationMonitoringConfig(deviceTypeConfiguration); - this.setInitialOperationConfig(deviceTypeConfiguration); - if (deviceTypeConfiguration.getPolicyMonitoring() != null ) { + if (deviceTypeConfiguration.getPolicyMonitoring() != null) { this.policyMonitoringManager = new DefaultPolicyMonitoringManager(); } } @@ -155,11 +156,6 @@ public class DeviceTypeManagerService implements DeviceManagementService { return policyMonitoringManager; } - @Override - public InitialOperationConfig getInitialOperationConfig() { - return initialOperationConfig; - } - private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) { if (deviceTypeConfiguration.getProvisioningConfig() != null) { boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants(); @@ -169,15 +165,6 @@ public class DeviceTypeManagerService implements DeviceManagementService { } } - protected void setInitialOperationConfig(DeviceTypeConfiguration deviceTypeConfiguration) { - if (deviceTypeConfiguration.getOperations() != null) { - List ops = deviceTypeConfiguration.getOperations(); - if (ops != null && !ops.isEmpty()) { - initialOperationConfig.setOperations(ops); - } - } - } - private void setType(String type) { this.type = type; } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml index 414bcaa8ddf..6542d9629b2 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml @@ -36,8 +36,6 @@ - - temperature sensor fitted diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml similarity index 94% rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml index 995df87a580..e4af0cccb00 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/pom.xml @@ -22,15 +22,15 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm + org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm bundle - WSO2 Carbon - FCM Based Push Notification Provider Implementation - WSO2 Carbon - FCM Based Push Notification Provider Implementation + WSO2 Carbon - GCM Based Push Notification Provider Implementation + WSO2 Carbon - GCM Based Push Notification Provider Implementation http://wso2.org @@ -128,10 +128,10 @@ ${project.artifactId} ${project.artifactId} ${carbon.device.mgt.version} - FCM Based Push Notification Provider Bundle + GCM Based Push Notification Provider Bundle - !org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal, - org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.* + !org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal, + org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.* com.google.gson, diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMBasedPushNotificationProvider.java similarity index 84% rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMBasedPushNotificationProvider.java index 30affceb278..5168e25e258 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMBasedPushNotificationProvider.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMBasedPushNotificationProvider.java @@ -16,24 +16,24 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm; +package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider; -public class FCMBasedPushNotificationProvider implements PushNotificationProvider { +public class GCMBasedPushNotificationProvider implements PushNotificationProvider { - private static final String PS_PROVIDER_FCM = "FCM"; + private static final String PS_PROVIDER_GCM = "GCM"; @Override public String getType() { - return PS_PROVIDER_FCM; + return PS_PROVIDER_GCM; } @Override public NotificationStrategy getNotificationStrategy(PushNotificationConfig config) { - return new FCMNotificationStrategy(config); + return new GCMNotificationStrategy(config); } } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMNotificationStrategy.java similarity index 76% rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMNotificationStrategy.java index 6dd66f08367..af93b692a47 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/FCMNotificationStrategy.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/GCMNotificationStrategy.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm; +package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -27,7 +27,7 @@ import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException; -import org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal.FCMDataHolder; +import org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal.GCMDataHolder; import java.io.IOException; import java.io.OutputStream; @@ -35,16 +35,16 @@ import java.net.HttpURLConnection; import java.net.URL; import java.util.List; -public class FCMNotificationStrategy implements NotificationStrategy { +public class GCMNotificationStrategy implements NotificationStrategy { - 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_API_KEY = "fcmAPIKey"; + private static final String GCM_TOKEN = "GCM_TOKEN"; + private final static String GCM_ENDPOINT = "https://fcm.googleapis.com/fcm/send"; + private static final String GCM_API_KEY = "gcmAPIKey"; private static final int TIME_TO_LIVE = 60; private static final int HTTP_STATUS_CODE_OK = 200; private PushNotificationConfig config; - public FCMNotificationStrategy(PushNotificationConfig config) { + public GCMNotificationStrategy(PushNotificationConfig config) { this.config = config; } @@ -57,7 +57,7 @@ public class FCMNotificationStrategy implements NotificationStrategy { public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException { try { Device device = - FCMDataHolder.getInstance().getDeviceManagementProviderService().getDevice(ctx.getDeviceId()); + GCMDataHolder.getInstance().getDeviceManagementProviderService().getDevice(ctx.getDeviceId()); this.sendWakeUpCall(ctx.getOperation().getCode(), device); } catch (DeviceManagementException e) { throw new PushNotificationExecutionFailedException("Error occurred while retrieving device information", e); @@ -79,13 +79,13 @@ public class FCMNotificationStrategy implements NotificationStrategy { private void sendWakeUpCall(String message, Device device) throws IOException, PushNotificationExecutionFailedException { OutputStream os = null; - byte[] bytes = getFCMRequest(message, getFCMToken(device.getProperties())).getBytes(); + byte[] bytes = getGCMRequest(message, getGCMToken(device.getProperties())).getBytes(); HttpURLConnection conn = null; try { - conn = (HttpURLConnection) new URL(FCM_ENDPOINT).openConnection(); + conn = (HttpURLConnection) new URL(GCM_ENDPOINT).openConnection(); conn.setRequestProperty("Content-Type", "application/json"); - conn.setRequestProperty("Authorization", "key=" + config.getProperty(FCM_API_KEY)); + conn.setRequestProperty("Authorization", "key=" + config.getProperty(GCM_API_KEY)); conn.setRequestMethod("POST"); conn.setDoOutput(true); os = conn.getOutputStream(); @@ -102,35 +102,35 @@ public class FCMNotificationStrategy implements NotificationStrategy { } } - private static String getFCMRequest(String message, String registrationId) { - JsonObject fcmRequest = new JsonObject(); - fcmRequest.addProperty("delay_while_idle", false); - fcmRequest.addProperty("time_to_live", TIME_TO_LIVE); + private static String getGCMRequest(String message, String registrationId) { + JsonObject gcmRequest = new JsonObject(); + gcmRequest.addProperty("delay_while_idle", false); + gcmRequest.addProperty("time_to_live", TIME_TO_LIVE); - //Add message to FCM request + //Add message to GCM request JsonObject data = new JsonObject(); if (message != null && !message.isEmpty()) { data.addProperty("data", message); - fcmRequest.add("data", data); + gcmRequest.add("data", data); } //Set device reg-id JsonArray regIds = new JsonArray(); regIds.add(new JsonPrimitive(registrationId)); - fcmRequest.add("registration_ids", regIds); - return fcmRequest.toString(); + gcmRequest.add("registration_ids", regIds); + return gcmRequest.toString(); } - private static String getFCMToken(List properties) { - String fcmToken = null; + private static String getGCMToken(List properties) { + String gcmToken = null; for (Device.Property property : properties) { - if (FCM_TOKEN.equals(property.getName())) { - fcmToken = property.getValue(); + if (GCM_TOKEN.equals(property.getName())) { + gcmToken = property.getValue(); break; } } - return fcmToken; + return gcmToken; } } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMDataHolder.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMDataHolder.java similarity index 88% rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMDataHolder.java rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMDataHolder.java index 64569d7fb6c..67b44109afd 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMDataHolder.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMDataHolder.java @@ -16,16 +16,16 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal; +package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -public class FCMDataHolder { +public class GCMDataHolder { private DeviceManagementProviderService deviceManagementProviderService; - private static FCMDataHolder thisInstance = new FCMDataHolder(); + private static GCMDataHolder thisInstance = new GCMDataHolder(); - public static FCMDataHolder getInstance() { + public static GCMDataHolder getInstance() { return thisInstance; } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMPushNotificationServiceComponent.java similarity index 78% rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMPushNotificationServiceComponent.java index 8993e6928a9..6e5171ec4be 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/fcm/internal/FCMPushNotificationServiceComponent.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/gcm/internal/GCMPushNotificationServiceComponent.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal; +package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -24,7 +24,7 @@ import org.osgi.service.component.ComponentContext; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; /** - * @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal.FCMPushNotificationServiceComponent" immediate="true" + * @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal.GCMPushNotificationServiceComponent" immediate="true" * @scr.reference name="carbon.device.mgt.provider" * interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService" * cardinality="1..1" @@ -32,20 +32,23 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; * bind="setDeviceManagementProviderService" * unbind="unsetDeviceManagementProviderService" */ -public class FCMPushNotificationServiceComponent { +public class GCMPushNotificationServiceComponent { - private static final Log log = LogFactory.getLog(FCMPushNotificationServiceComponent.class); + private static final Log log = LogFactory.getLog(GCMPushNotificationServiceComponent.class); @SuppressWarnings("unused") protected void activate(ComponentContext componentContext) { try { + if (log.isDebugEnabled()) { + log.debug("Initializing GCM based push notification provider implementation bundle"); + } //Do nothing if (log.isDebugEnabled()) { - log.debug("FCM based push notification provider implementation bundle has been successfully " + + log.debug("GCM based push notification provider implementation bundle has been successfully " + "initialized"); } } catch (Throwable e) { - log.error("Error occurred while initializing FCM based push notification provider " + + log.error("Error occurred while initializing GCM based push notification provider " + "implementation bundle", e); } } @@ -56,12 +59,12 @@ public class FCMPushNotificationServiceComponent { protected void setDeviceManagementProviderService( DeviceManagementProviderService deviceManagementProviderService) { - FCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); + GCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); } protected void unsetDeviceManagementProviderService( DeviceManagementProviderService deviceManagementProviderService) { - FCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); + GCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService); } } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 113938c4c8b..01626d2475c 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 75f8bf70dbc..47cd64f41ec 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java index 71dada3b663..7085191dc84 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/XMPPPushNotificationServiceComponent.java @@ -25,7 +25,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; /** - * @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.internal.XMPPPushNotificationServiceComponent" immediate="true" + * @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal.XMPPPushNotificationServiceComponent" immediate="true" * @scr.reference name="carbon.device.mgt.provider" * interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService" * cardinality="1..1" diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 79cf3593220..f1a3bc5edd8 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../../pom.xml @@ -34,7 +34,7 @@ http://wso2.org - org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm + org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp org.wso2.carbon.device.mgt.extensions.device.type.deployer diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml index 5e27ea47735..8bd503dc20c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.dashboard/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt device-mgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 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 d97af674a9b..7a35748c119 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 @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index a99a720874c..56d1b5b78b5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml @@ -291,13 +291,6 @@ org.wso2.carbon.identity.jwt.client.extension provided - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.user.store.count - ${carbon.identity.framework.version} - provided - -
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java index 5c2936a1a3d..8d1c82d8d75 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java @@ -30,13 +30,13 @@ public class BasePaginatedResult { value = "Number of total resources.", example = "1") @JsonProperty("count") - private long count; + private int count; - public long getCount() { + public int getCount() { return count; } - public void setCount(long count) { + public void setCount(int count) { this.count = count; } } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index ddbdfcdc08b..82aa78e1f97 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -32,7 +32,6 @@ import io.swagger.annotations.Tag; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; @@ -49,7 +48,6 @@ 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; @@ -136,13 +134,7 @@ import javax.ws.rs.core.Response; description = "Getting Policy Compliance Details of a Device", key = "perm:devices:compliance-data", permissions = {"/device-mgt/devices/owning-device/view"} - ), - @Scope( - name = "Change device status.", - description = "Change device status.", - key = "perm:devices:change-status", - permissions = {"/device-mgt/devices/change-status"} - ), + ) } ) @Path("/devices") @@ -1158,79 +1150,4 @@ public interface DeviceManagementService { @PathParam("id") @Size(max = 45) String id); - - @PUT - @Path("/{type}/{id}/changestatus") - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - consumes = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Change device status by device id.", - notes = "Returns the status of the changed device operation.", - tags = "Device Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:change-status") - }) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully changed the device status.", - response = Device.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. Empty body because the client already has the latest " + - "version of the requested resource."), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error.", - response = ErrorResponse.class), - @ApiResponse( - code = 404, - message = "Not Found. \n No device is found under the provided type and id.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while retrieving information requested device.", - response = ErrorResponse.class) - }) - Response changeDeviceStatus( - @ApiParam( - name = "type", - value = "The device type, such as ios, android or windows.", - required = true) - @PathParam("type") - @Size(max = 45) - String type, - @ApiParam( - name = "id", - value = "Device id", - required = true) - @PathParam("id") - @Size(max = 45) - String id, - @ApiParam( - name = "newStatus", - value = "New status of the device.", - required = true) - @QueryParam("newStatus") - EnrolmentInfo.Status newStatus); - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index 3f3185a30d1..e4da6a1ed66 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -23,14 +23,7 @@ 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.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.EnrolmentInfo; -import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.common.FeatureManager; -import org.wso2.carbon.device.mgt.common.PaginationRequest; -import org.wso2.carbon.device.mgt.common.PaginationResult; +import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; @@ -60,16 +53,7 @@ import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; 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.text.ParseException; @@ -569,36 +553,4 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } } - /** - * Change device status. - * - * @param type Device type - * @param id Device id - * @param newsStatus Device new status - * @return {@link Response} object - */ - @PUT - @Path("/{type}/{id}/changestatus") - public Response changeDeviceStatus(@PathParam("type") @Size(max = 45) String type, - @PathParam("id") @Size(max = 45) String id, - @QueryParam("newStatus") EnrolmentInfo.Status newsStatus) { - RequestValidationUtil.validateDeviceIdentifier(type, id); - DeviceManagementProviderService deviceManagementProviderService = - DeviceMgtAPIUtils.getDeviceManagementService(); - try { - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(id, type); - Device persistedDevice = deviceManagementProviderService.getDevice(deviceIdentifier); - if (persistedDevice == null) { - return Response.status(Response.Status.NOT_FOUND).build(); - } - boolean response = deviceManagementProviderService.changeDeviceStatus(deviceIdentifier, newsStatus); - return Response.status(Response.Status.OK).entity(response).build(); - } catch (DeviceManagementException e) { - String msg = "Error occurred while changing device status of type : " + type + " and " + - "device id : " + id; - log.error(msg); - return Response.status(Response.Status.BAD_REQUEST).entity( - new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); - } - } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index ca1ad45d1d3..2b5a2e8d455 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -38,8 +38,6 @@ import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; -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.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; import org.wso2.carbon.utils.CarbonUtils; @@ -397,30 +395,6 @@ public class UserManagementServiceImpl implements UserManagementService { @Path("/count") @Override public Response getUserCount() { - try { - UserStoreCountRetriever userStoreCountRetrieverService = DeviceMgtAPIUtils.getUserStoreCountRetrieverService(); - if (userStoreCountRetrieverService != null) { - long count = userStoreCountRetrieverService.countUsers(""); - if (count != -1) { - BasicUserInfoList result = new BasicUserInfoList(); - result.setCount(count); - return Response.status(Response.Status.OK).entity(result).build(); - } - } - } catch (UserStoreCounterException e) { - String msg = - "Error occurred while retrieving the count of users that exist within the current tenant"; - log.error(msg, e); - } - return getUserCountViaUserStoreManager(); - } - - /** - * This method returns the count of users using UserStoreManager. - * - * @return user count - */ - private Response getUserCountViaUserStoreManager() { if (log.isDebugEnabled()) { log.debug("Getting the user count"); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index 888b1c42eee..87d055c34f7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -37,21 +37,14 @@ import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException; import org.wso2.carbon.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 org.wso2.carbon.policy.mgt.common.PolicyMonitoringTaskException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.api.AuthorizationManager; -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.core.jdbc.JDBCUserStoreManager; import org.wso2.carbon.user.core.service.RealmService; import javax.ws.rs.core.MediaType; @@ -113,32 +106,6 @@ public class DeviceMgtAPIUtils { return deviceManagementProviderService; } - public static UserStoreCountRetriever getUserStoreCountRetrieverService() - throws UserStoreCounterException { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - List countRetrieverFactories = ctx.getOSGiServices(AbstractCountRetrieverFactory.class, null); - RealmService realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); - RealmConfiguration realmConfiguration = realmService.getBootstrapRealmConfiguration(); - String userStoreType; - //Ignoring Sonar warning as getUserStoreClass() returning string name of the class. So cannot use 'instanceof'. - if (JDBCUserStoreManager.class.getName().equals(realmConfiguration.getUserStoreClass())) { - userStoreType = JDBCCountRetrieverFactory.JDBC; - } else { - userStoreType = InternalCountRetrieverFactory.INTERNAL; - } - AbstractCountRetrieverFactory countRetrieverFactory = null; - for (Object countRetrieverFactoryObj : countRetrieverFactories) { - countRetrieverFactory = (AbstractCountRetrieverFactory) countRetrieverFactoryObj; - if (userStoreType.equals(countRetrieverFactory.getCounterType())) { - break; - } - } - if (countRetrieverFactory == null) { - return null; - } - return countRetrieverFactory.buildCountRetriever(realmConfiguration); - } - public static DeviceAccessAuthorizationService getDeviceAccessAuthorizationService() { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); DeviceAccessAuthorizationService deviceAccessAuthorizationService = diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index d44753056ae..00678175751 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/InitialOperationConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/InitialOperationConfig.java deleted file mode 100644 index 758ba549f25..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/InitialOperationConfig.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.device.mgt.common; - -import java.util.List; - -public class InitialOperationConfig { - private List operations; - - public List getOperations() { - return operations; - } - - public void setOperations(List operations) { - this.operations = operations; - } - - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/search/Condition.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/search/Condition.java index 8483788e9d2..2007a3f121b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/search/Condition.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/search/Condition.java @@ -25,7 +25,7 @@ import io.swagger.annotations.ApiModelProperty; @ApiModel(value = "Condition", description = "Contains the advance search parameters.") public class Condition { - @ApiModelProperty(name = "key", value = "Provide the operation code. You can assign the following operation " + + @ApiModelProperty(name = "conditions", value = "Provide the operation code. You can assign the following operation " + "codes:\n" + "DEVICE_MODEL : The model of the device.\n" + "VENDOR : The name of the device vendor.\n" + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java index 7e6f7303372..197275600ef 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java @@ -18,7 +18,10 @@ */ package org.wso2.carbon.device.mgt.common.spi; -import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.DeviceManager; +import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; +import org.wso2.carbon.device.mgt.common.ProvisioningConfig; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; @@ -45,8 +48,4 @@ public interface DeviceManagementService { PolicyMonitoringManager getPolicyMonitoringManager(); - InitialOperationConfig getInitialOperationConfig(); - - - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 4f57a513d47..f2b7a661a40 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java index 1eb39fc5020..a634fe93b67 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java @@ -420,5 +420,12 @@ public interface DeviceDAO { */ List getEnrolmentsByStatus(List deviceIds, Status status, int tenantId) throws DeviceManagementDAOException; + + /** + * Retrieving the tenants which are have device enrolled. + * @return + * @throws DeviceManagementDAOException + */ + List getDeviceEnrolledTenants() throws DeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 4e37aca0007..09557518c47 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -1063,4 +1063,26 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { return devices; } + public List getDeviceEnrolledTenants() throws DeviceManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + List tenants = new ArrayList<>(); + try { + conn = this.getConnection(); + String sql = "SELECT distinct(TENANT_ID) FROM DM_DEVICE"; + stmt = conn.prepareStatement(sql); + rs = stmt.executeQuery(); + while (rs.next()) { + tenants.add(rs.getInt("TENANT_ID")); + } + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving tenants which have " + + "device registered.", e); + } finally { + DeviceManagementDAOUtil.cleanupResources(stmt, rs); + } + return tenants; + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index f7e8e0a177d..7de29280653 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -62,6 +62,11 @@ public class DeviceManagementDataHolder { private Map map = new HashMap<>(); + + public void addToMap(OperationMonitoringTaskConfig taskConfig) { + this.map.put("aa", taskConfig); + } + public Map getMap(){ return this.map; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index a48cb423c8d..bef274e572c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -307,14 +307,6 @@ public interface DeviceManagementProviderService { PolicyMonitoringManager getPolicyMonitoringManager(String deviceType); - /** - * Change device status. - * - * @param deviceIdentifier {@link DeviceIdentifier} object - * @param newStatus New status of the device - * @return Whether status is changed or not - * @throws DeviceManagementException on errors while trying to change device status - */ - boolean changeDeviceStatus(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status newStatus) - throws DeviceManagementException; + List getDeviceEnrolledTenants() throws DeviceManagementException; + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index f7d268642f8..8bde4d8e06c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -23,7 +23,20 @@ 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.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.DeviceManager; +import org.wso2.carbon.device.mgt.common.DeviceNotFoundException; +import org.wso2.carbon.device.mgt.common.DeviceTypeIdentifier; +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.common.FeatureManager; +import org.wso2.carbon.device.mgt.common.InvalidDeviceException; +import org.wso2.carbon.device.mgt.common.MonitoringOperation; +import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; +import org.wso2.carbon.device.mgt.common.TransactionManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; @@ -53,7 +66,6 @@ import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener; -import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.email.sender.core.ContentProviderInfo; import org.wso2.carbon.email.sender.core.EmailContext; @@ -245,8 +257,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv if (status) { addDeviceToGroups(deviceIdentifier, device.getEnrolmentInfo().getOwnership()); - addInitialOperations(deviceIdentifier, device.getType()); - } return status; } @@ -1269,6 +1279,21 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return dms.getPolicyMonitoringManager(); } + @Override + public List getDeviceEnrolledTenants() throws DeviceManagementException { + try { + DeviceManagementDAOFactory.openConnection(); + return deviceDAO.getDeviceEnrolledTenants(); + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementException("Error occurred while retrieving the tenants " + + "which have device enrolled.", e); + } catch (SQLException e) { + throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); + } finally { + DeviceManagementDAOFactory.closeConnection(); + } + } + @Override public List getDevicesOfUser(String username) throws DeviceManagementException { List devices = new ArrayList<>(); @@ -1956,68 +1981,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return false; } - /** - * Change device status. - * - * @param deviceIdentifier {@link DeviceIdentifier} object - * @param newStatus New status of the device - * @return Whether status is changed or not - * @throws DeviceManagementException on errors while trying to change device status - */ - @Override - public boolean changeDeviceStatus(DeviceIdentifier deviceIdentifier, EnrolmentInfo.Status newStatus) - throws DeviceManagementException { - boolean isDeviceUpdated = false; - Device device = getDevice(deviceIdentifier); - int deviceId = device.getId(); - EnrolmentInfo enrolmentInfo = device.getEnrolmentInfo(); - enrolmentInfo.setStatus(newStatus); - int tenantId = this.getTenantId(); - switch (newStatus) { - case ACTIVE: - isDeviceUpdated = updateEnrollment(deviceId, enrolmentInfo, tenantId); - break; - case INACTIVE: - isDeviceUpdated = updateEnrollment(deviceId, enrolmentInfo, tenantId); - break; - case REMOVED: - isDeviceUpdated = disenrollDevice(deviceIdentifier); - break; - default: - throw new DeviceManagementException("Invalid status retrieved. Status : " + newStatus); - } - return isDeviceUpdated; - } - - private boolean updateEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, int tenantId) - throws DeviceManagementException { - boolean isUpdatedEnrollment = false; - boolean isAutoCommit = true; - try { - DeviceManagementDAOFactory.openConnection(); - isAutoCommit = DeviceManagementDAOFactory.getConnection().getAutoCommit(); - DeviceManagementDAOFactory.getConnection().setAutoCommit(true); - int updatedRows = enrollmentDAO.updateEnrollment(deviceId, enrolmentInfo, tenantId); - if (updatedRows > 0) { - isUpdatedEnrollment = true; - } - } catch (SQLException e) { - throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); - } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while updating the enrollment information device for" + - "id '" + deviceId + "' ." , e); - } finally { - try { - DeviceManagementDAOFactory.getConnection().setAutoCommit(isAutoCommit); - } catch (SQLException e) { - log.error("Exception occurred while setting auto commit."); - } - DeviceManagementDAOFactory.closeConnection(); - } - return isUpdatedEnrollment; - } - - private int getTenantId() { return CarbonContext.getThreadLocalCarbonContext().getTenantId(); } @@ -2074,37 +2037,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } } - private void addInitialOperations(DeviceIdentifier deviceIdentifier, String deviceType) throws DeviceManagementException { - DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance(). - getDeviceManagementProvider(); - DeviceManagementService deviceManagementService = - pluginRepository.getDeviceManagementService(deviceType, this.getTenantId()); - InitialOperationConfig init = deviceManagementService.getInitialOperationConfig(); - List deviceIdentifiers = new ArrayList<>(); - deviceIdentifiers.add(deviceIdentifier); - if (init != null) { - List initialOperations = init.getOperations(); - - for (String str : initialOperations) { - CommandOperation operation = new CommandOperation(); - operation.setEnabled(true); - operation.setType(Operation.Type.COMMAND); - operation.setCode(str); - try { - deviceManagementProviderService. - addOperation(deviceType, - operation, deviceIdentifiers); - } catch (OperationManagementException e) { - throw new DeviceManagementException("Unable to find the device with the id: '" + deviceIdentifier.getId(), - e); - } catch (InvalidDeviceException e) { - throw new DeviceManagementException("Unable to find the device with the id: '" + deviceIdentifier.getId(), - e); - } - } - } - } - /** * Checks for the default group existence and create group based on device ownership * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java index 6d1228563c1..9040af66544 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/task/impl/DeviceDetailsRetrieverTask.java @@ -22,17 +22,25 @@ package org.wso2.carbon.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 org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; +import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException; import org.wso2.carbon.device.mgt.core.task.DeviceTaskManager; import org.wso2.carbon.ntask.core.Task; +import org.wso2.carbon.user.api.Tenant; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import java.util.List; +import java.util.List; import java.util.Map; public class DeviceDetailsRetrieverTask implements Task { private static Log log = LogFactory.getLog(DeviceDetailsRetrieverTask.class); -// private DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(); + // private DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(); private String deviceType; private String oppConfig; private OperationMonitoringTaskConfig operationMonitoringTaskConfig; @@ -57,18 +65,41 @@ public class DeviceDetailsRetrieverTask implements Task { if (log.isDebugEnabled()) { log.debug("Device details retrieving task started to run."); } - - DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType, - operationMonitoringTaskConfig); - //pass the configurations also from here, monitoring tasks try { - deviceTaskManager.addOperations(); - } catch (DeviceMgtTaskException e) { - log.error( - "Error occurred while trying to add the operations to device to retrieve device details.", - e); +// Tenant tenants[] = DeviceManagementDataHolder.getInstance(). +// getRealmService().getTenantManager().getAllTenants(); + + List tenants = DeviceManagementDataHolder.getInstance(). + getDeviceManagementProvider().getDeviceEnrolledTenants(); + for (Integer tenant : tenants) { + String tenantDomain = DeviceManagementDataHolder.getInstance(). + getRealmService().getTenantManager().getDomain(tenant); + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant); + DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType, + operationMonitoringTaskConfig); + //pass the configurations also from here, monitoring tasks + try { + deviceTaskManager.addOperations(); + } catch (DeviceMgtTaskException e) { + log.error("Error occurred while trying to add the operations to " + + "device to retrieve device details.", e); + } + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } + } catch (UserStoreException e) { + log.error("Error occurred while trying to get the available tenants", e); + } catch (DeviceManagementException e) { + log.error("Error occurred while trying to get the available tenants " + + "from device manager provider service.", e); } + } } + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java index d425133ce52..e30cdf43897 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java @@ -17,7 +17,10 @@ */ package org.wso2.carbon.device.mgt.core; -import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.DeviceManager; +import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; +import org.wso2.carbon.device.mgt.common.ProvisioningConfig; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; @@ -72,9 +75,4 @@ public class TestDeviceManagementService implements DeviceManagementService { return null; } - @Override - public InitialOperationConfig getInitialOperationConfig() { - return null; - } - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index f1518f1e982..6b799048d07 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml 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 ed5305f49d1..8476e6b9623 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 @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 2.0.36-SNAPSHOT + 2.0.16-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 5caf20f31fa..0a1d5bc659e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -1,6 +1,6 @@ { "appContext": "/devicemgt/", - "isCloud": false, + "isCloud": true, "httpsURL": "https://%iot.gateway.host%:%iot.gateway.https.port%", "httpURL": "http://%iot.gateway.host%:%iot.gateway.http.port", "wssURL": "https://%iot.analytics.host%:%iot.analytics.https.port%", @@ -182,4 +182,4 @@ "backendRestEndpoints": { "deviceMgt": "/api/device-mgt/v1.0" } -} +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js index dd200cdfbe4..e9c07ee0ba9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js @@ -81,11 +81,21 @@ var operationModule = function () { publicMethods.getControlOperations = function (deviceType) { var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation"); + var features = utility.getDeviceTypeConfig(deviceType).deviceType.features; for (var op in operations) { var iconIdentifier = operations[op].operation; - var icon = utility.getOperationIcon(deviceType, iconIdentifier); - if (icon) { - operations[op]["icon"] = icon; + if (features && features[iconIdentifier]) { + var icon = features[iconIdentifier].icon; + if (icon) { + operations[op]["iconFont"] = icon; + } else if (iconPath) { + var iconPath = utility.getOperationIcon(deviceType, iconIdentifier); + operations[op]["icon"] = iconPath; + } + var formParams = features[iconIdentifier].formParams; + if (formParams) { + operations[op]["uiParams"] = formParams; + } } } return operations; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index e85f46c3477..96f4d280bc6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -174,7 +174,7 @@ var userModule = function () { } try { utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/count"; + var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users?offset=0&limit=1"; return serviceInvokers.XMLHttp.get( url, function (responsePayload) { return parse(responsePayload["responseText"])["count"]; @@ -609,9 +609,6 @@ var userModule = function () { if (publicMethods.isAuthorized("/permission/admin/device-mgt/platform-configs/view")) { permissions["TENANT_CONFIGURATION"] = true; } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/change-status")) { - permissions["CHANGE_DEVICE_STATUS"] = true; - } return permissions; }; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js index f6ee8587ec0..beaa90c56b2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js @@ -33,14 +33,12 @@ var permissions = { "/permission/admin/device-mgt/device/api/subscribe": ["ui.execute"], "/permission/admin/device-mgt/devices/enroll": ["ui.execute"], "/permission/admin/device-mgt/devices/disenroll": ["ui.execute"], - "/permission/admin/device-mgt/devices/owning-device/view": ["ui.execute"], - "/permission/admin/manage/portal": ["ui.execute"] + "/permission/admin/device-mgt/devices/owning-device/view": ["ui.execute"] }; var adminPermissions = { "/permission/admin/device-mgt": ["ui.execute"], - "/permission/admin/manage/api": ["ui.execute"], - "/permission/admin/manage/portal": ["ui.execute"] + "/permission/admin/manage/api": ["ui.execute"] }; //On Startup, admin user will get both roles: devicemgt-admin and devicemgt-user diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js index 0fa1fbb0dc9..22da9284955 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js @@ -40,7 +40,7 @@ var handlers = function () { "as input - setupTokenPairByPasswordGrantType(x, y)"); } else { privateMethods.setUpEncodedTenantBasedClientAppCredentials(username); - privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username); + //privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username); var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]); if (!encodedClientAppCredentials) { throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair by " + @@ -84,7 +84,7 @@ var handlers = function () { "as input - setupTokenPairBySamlGrantType(x, y)"); } else { privateMethods.setUpEncodedTenantBasedClientAppCredentials(username); - privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username); + //privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username); var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]); if (!encodedClientAppCredentials) { throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair " + @@ -129,7 +129,7 @@ var handlers = function () { "as input - setupTokenPairBySamlGrantType(x, y)"); } else { privateMethods.setUpEncodedTenantBasedClientAppCredentials(username); - privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username); + //privateMethods.setUpEncodedTenantBasedWebSocketClientAppCredentials(username); var encodedClientAppCredentials = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]); if (!encodedClientAppCredentials) { throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up access token pair " + @@ -158,13 +158,13 @@ var handlers = function () { // setting up access token pair into session context as a string session.put(constants["TOKEN_PAIR"], stringify(tokenPair)); - var scopes = tokenData.scopes.split(" "); - // adding allowed scopes to the session - session.put(constants["ALLOWED_SCOPES"], scopes); - } - } - } - }; + var scopes = tokenData.scopes.split(" "); + // adding allowed scopes to the session + session.put(constants["ALLOWED_SCOPES"], scopes); + } + } + } + }; publicMethods["refreshTokenPair"] = function () { var currentTokenPair = parse(session.get(constants["TOKEN_PAIR"])); @@ -224,44 +224,44 @@ var handlers = function () { } }; - privateMethods["setUpEncodedTenantBasedWebSocketClientAppCredentials"] = function (username) { - if (!username) { - throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + - "client credentials to session context. No username of logged in user is found as " + - "input - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)"); - } else { - if (devicemgtProps["gatewayEnabled"]) { - var tenantBasedWebSocketClientAppCredentials - = tokenUtil.getTenantBasedWebSocketClientAppCredentials(username); - if (!tenantBasedWebSocketClientAppCredentials) { - throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant " + - "based client credentials to session context as the server is unable " + - "to obtain such credentials - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)"); - } else { - var encodedTenantBasedWebSocketClientAppCredentials = - tokenUtil.encode(tenantBasedWebSocketClientAppCredentials["clientId"] + ":" + - tenantBasedWebSocketClientAppCredentials["clientSecret"]); - // setting up encoded tenant based client credentials to session context. - session.put(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"], - encodedTenantBasedWebSocketClientAppCredentials); - } - } else { - var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials(); - if (!dynamicClientAppCredentials) { - throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + - "client credentials to session context as the server is unable to obtain " + - "dynamic client credentials - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)"); - } - var encodedTenantBasedWebSocketClientAppCredentials = - tokenUtil.encode(dynamicClientAppCredentials["clientId"] + ":" + - dynamicClientAppCredentials["clientSecret"]); - // setting up encoded tenant based client credentials to session context. - session.put(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"], - encodedTenantBasedWebSocketClientAppCredentials); - } +// privateMethods["setUpEncodedTenantBasedWebSocketClientAppCredentials"] = function (username) { +// if (!username) { +// throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + +// "client credentials to session context. No username of logged in user is found as " + +// "input - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)"); +// } else { +// if (devicemgtProps["gatewayEnabled"]) { +// var tenantBasedWebSocketClientAppCredentials +// = tokenUtil.getTenantBasedWebSocketClientAppCredentials(username); +// if (!tenantBasedWebSocketClientAppCredentials) { +// throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant " + +// "based client credentials to session context as the server is unable " + +// "to obtain such credentials - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)"); +// } else { +// var encodedTenantBasedWebSocketClientAppCredentials = +// tokenUtil.encode(tenantBasedWebSocketClientAppCredentials["clientId"] + ":" + +// tenantBasedWebSocketClientAppCredentials["clientSecret"]); +// // setting up encoded tenant based client credentials to session context. +// session.put(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"], +// encodedTenantBasedWebSocketClientAppCredentials); +// } +// } else { +// var dynamicClientAppCredentials = tokenUtil.getDynamicClientAppCredentials(); +// if (!dynamicClientAppCredentials) { +// throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant based " + +// "client credentials to session context as the server is unable to obtain " + +// "dynamic client credentials - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)"); +// } +// var encodedTenantBasedWebSocketClientAppCredentials = +// tokenUtil.encode(dynamicClientAppCredentials["clientId"] + ":" + +// dynamicClientAppCredentials["clientSecret"]); +// // setting up encoded tenant based client credentials to session context. +// session.put(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"], +// encodedTenantBasedWebSocketClientAppCredentials); +// } - } - }; +// } +// }; return publicMethods; }(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/js/bottomJs.js index 66c17190527..68a4292ea87 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/js/bottomJs.js @@ -44,7 +44,7 @@ var dynamicForm = '
- **/ - tpl: '', - /** - Placeholder attribute of input. Shown when input is empty. - - @property placeholder - @type string - @default null - **/ - placeholder: null, - - /** - Whether to show `clear` button - - @property clear - @type boolean - @default true - **/ - clear: true - }); - - $.fn.editabletypes.text = Text; - -}(window.jQuery)); - -/** -Textarea input - -@class textarea -@extends abstractinput -@final -@example -awesome comment! - -**/ -(function ($) { - "use strict"; - - var Textarea = function (options) { - this.init('textarea', options, Textarea.defaults); - }; - - $.fn.editableutils.inherit(Textarea, $.fn.editabletypes.abstractinput); - - $.extend(Textarea.prototype, { - render: function () { - this.setClass(); - this.setAttr('placeholder'); - this.setAttr('rows'); - - //ctrl + enter - this.$input.keydown(function (e) { - if (e.ctrlKey && e.which === 13) { - $(this).closest('form').submit(); - } - }); - }, - - //using `white-space: pre-wrap` solves \n <--> BR conversion very elegant! - /* - value2html: function(value, element) { - var html = '', lines; - if(value) { - lines = value.split("\n"); - for (var i = 0; i < lines.length; i++) { - lines[i] = $('
').text(lines[i]).html(); - } - html = lines.join('
'); - } - $(element).html(html); - }, - - html2value: function(html) { - if(!html) { - return ''; - } - - var regex = new RegExp(String.fromCharCode(10), 'g'); - var lines = html.split(//i); - for (var i = 0; i < lines.length; i++) { - var text = $('
').html(lines[i]).text(); - - // Remove newline characters (\n) to avoid them being converted by value2html() method - // thus adding extra
tags - text = text.replace(regex, ''); - - lines[i] = text; - } - return lines.join("\n"); - }, - */ - activate: function() { - $.fn.editabletypes.text.prototype.activate.call(this); - } - }); - - Textarea.defaults = $.extend({}, $.fn.editabletypes.abstractinput.defaults, { - /** - @property tpl - @default - **/ - tpl:'', - /** - @property inputclass - @default input-large - **/ - inputclass: 'input-large', - /** - Placeholder attribute of input. Shown when input is empty. - - @property placeholder - @type string - @default null - **/ - placeholder: null, - /** - Number of rows in textarea - - @property rows - @type integer - @default 7 - **/ - rows: 7 - }); - - $.fn.editabletypes.textarea = Textarea; - -}(window.jQuery)); - -/** -Select (dropdown) - -@class select -@extends list -@final -@example - - -**/ -(function ($) { - "use strict"; - - var Select = function (options) { - this.init('select', options, Select.defaults); - }; - - $.fn.editableutils.inherit(Select, $.fn.editabletypes.list); - - $.extend(Select.prototype, { - renderList: function() { - this.$input.empty(); - - var fillItems = function($el, data) { - var attr; - if($.isArray(data)) { - for(var i=0; i', attr), data[i].children)); - } else { - attr.value = data[i].value; - if(data[i].disabled) { - attr.disabled = true; - } - $el.append($('