diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml index ff9eca7c0f6..b297b309333 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml @@ -54,6 +54,11 @@ org.wso2.carbon.devicemgt org.wso2.carbon.policy.mgt.core + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.application.mgt.common + provided + @@ -85,7 +90,9 @@ org.wso2.carbon.policy.mgt.core.*, org.wso2.carbon.policy.mgt.core, com.google.gson, - org.wso2.carbon.device.mgt.core.service.* + org.wso2.carbon.device.mgt.core.service.*, + org.wso2.carbon.device.application.mgt.common.*, + org.wso2.carbon.device.application.mgt.common.services.* diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java index bcf8dece8ac..532c89dea0a 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/PullNotificationSubscriberImpl.java @@ -24,7 +24,11 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; +import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; @@ -44,6 +48,7 @@ public class PullNotificationSubscriberImpl implements PullNotificationSubscribe throw new AssertionError(); } public static final String POLICY_MONITOR = "POLICY_MONITOR"; + public static final String INSTALL_APPLICATION = "INSTALL_APPLICATION"; } @@ -68,8 +73,12 @@ public class PullNotificationSubscriberImpl implements PullNotificationSubscribe } else { PullNotificationDataHolder.getInstance().getDeviceManagementProviderService().updateOperation( deviceIdentifier, operation); + if (OperationCodes.INSTALL_APPLICATION.equals(operation.getCode()) + && Operation.Status.COMPLETED == operation.getStatus()) { + updateAppSubStatus(deviceIdentifier, operation.getId(), operation.getCode()); + } } - } catch (OperationManagementException e) { + } catch (OperationManagementException | DeviceManagementException | ApplicationManagementException e) { throw new PullNotificationExecutionFailedException(e); } catch (PolicyComplianceException e) { throw new PullNotificationExecutionFailedException("Invalid payload format compliant feature", e); @@ -99,4 +108,11 @@ public class PullNotificationSubscriberImpl implements PullNotificationSubscribe } return complianceFeatures; } + + private void updateAppSubStatus(DeviceIdentifier deviceIdentifier, int operationId, String status) + throws DeviceManagementException, ApplicationManagementException { + ApplicationManager applicationManager = PullNotificationDataHolder.getInstance().getApplicationManager(); + Device device = PullNotificationDataHolder.getInstance().getDeviceManagementProviderService().getDevice(deviceIdentifier); + applicationManager.updateSubsStatus(device.getId(), operationId, status); + } } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/internal/PullNotificationDataHolder.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/internal/PullNotificationDataHolder.java index a9f7888c433..fd257ea28c1 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/internal/PullNotificationDataHolder.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/internal/PullNotificationDataHolder.java @@ -18,6 +18,7 @@ */ package org.wso2.carbon.device.mgt.extensions.pull.notification.internal; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; @@ -25,6 +26,7 @@ public class PullNotificationDataHolder { private DeviceManagementProviderService deviceManagementProviderService; private PolicyManagerService policyManagerService; + private ApplicationManager applicationManager; private static PullNotificationDataHolder thisInstance = new PullNotificationDataHolder(); @@ -47,4 +49,12 @@ public class PullNotificationDataHolder { public void setPolicyManagerService(PolicyManagerService policyManagerService) { this.policyManagerService = policyManagerService; } + + public ApplicationManager getApplicationManager() { + return applicationManager; + } + + public void setApplicationManager(ApplicationManager applicationManager) { + this.applicationManager = applicationManager; + } } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/internal/PullNotificationServiceComponent.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/internal/PullNotificationServiceComponent.java index 351e5147069..4c3971bf7d2 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/internal/PullNotificationServiceComponent.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/src/main/java/org/wso2/carbon/device/mgt/extensions/pull/notification/internal/PullNotificationServiceComponent.java @@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.extensions.pull.notification.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; @@ -38,6 +39,12 @@ import org.wso2.carbon.policy.mgt.core.PolicyManagerService; * policy="dynamic" * bind="setPolicyManagerService" * unbind="unsetPolicyManagerService" + * @scr.reference name="org.wso2.carbon.application.mgt.service" + * interface="org.wso2.carbon.device.application.mgt.common.services.ApplicationManager" + * cardinality="1..1" + * policy="dynamic" + * bind="setApplicationManagerService" + * unbind="unsetApplicationManagerService" */ public class PullNotificationServiceComponent { @@ -77,4 +84,12 @@ public class PullNotificationServiceComponent { PullNotificationDataHolder.getInstance().setPolicyManagerService(null); } + protected void setApplicationManagerService(ApplicationManager applicationManagerService){ + PullNotificationDataHolder.getInstance().setApplicationManager(applicationManagerService); + } + + protected void unsetApplicationManagerService(ApplicationManager applicationManagerService){ + PullNotificationDataHolder.getInstance().setApplicationManager(null); + } + } 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 81fcbf86cb7..5c686d6420f 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 @@ -111,6 +111,11 @@ org.wso2.carbon.analytics-common org.wso2.carbon.event.output.adapter.core + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.application.mgt.common + provided + org.testng testng @@ -148,12 +153,15 @@ org.wso2.carbon.device.mgt.common.operation.mgt, org.wso2.carbon.device.mgt.common.push.notification, org.wso2.carbon.device.mgt.common, + org.wso2.carbon.device.mgt.common.exceptions, org.wso2.carbon.device.mgt.core.service, org.wso2.carbon.event.output.adapter.core, org.wso2.carbon.event.output.adapter.core.exception, org.osgi.framework, org.wso2.carbon.device.mgt.core.operation.mgt, - org.wso2.carbon.core + org.wso2.carbon.core, + org.wso2.carbon.device.application.mgt.common.*, + org.wso2.carbon.device.application.mgt.common.services.* diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AttributeType.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AttributeType.java index 1fde19f8a91..32302986e76 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AttributeType.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AttributeType.java @@ -1,19 +1,20 @@ /* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * 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 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. */ package org.wso2.carbon.device.mgt.jaxrs.beans.analytics; @@ -22,5 +23,9 @@ package org.wso2.carbon.device.mgt.jaxrs.beans.analytics; */ public enum AttributeType { STRING, LONG, BOOL, INT, FLOAT, DOUBLE; -} + @Override + public String toString() { + return super.toString().toLowerCase(); + } +} \ No newline at end of file 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 3e77a56e722..106a2942b57 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 @@ -77,6 +77,11 @@ org.wso2.carbon.device.mgt.extensions.pull.notification test + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.application.mgt.common + test + com.h2database.wso2 h2-database-engine