Add application installation response via pull notification

feature/appm-store/pbac
Charitha Goonetilleke 5 years ago committed by Dharmakeerthi Lasantha
parent d45b153a9a
commit 5cf89ec24c

@ -54,6 +54,11 @@
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.common</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
@ -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.*
</Import-Package>
</instructions>
</configuration>

@ -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);
}
}

@ -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;
}
}

@ -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);
}
}

@ -111,6 +111,11 @@
<groupId>org.wso2.carbon.analytics-common</groupId>
<artifactId>org.wso2.carbon.event.output.adapter.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.common</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
@ -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.*
</Import-Package>
</instructions>
</configuration>

@ -1,7 +1,7 @@
/*
* 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,
* 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
@ -14,6 +14,7 @@
* 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();
}
}

@ -77,6 +77,11 @@
<artifactId>org.wso2.carbon.device.mgt.extensions.pull.notification</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.application.mgt.common</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database.wso2</groupId>
<artifactId>h2-database-engine</artifactId>

Loading…
Cancel
Save