made policy manager to be part of device type mgt service

revert-dabc3590
ayyoob 8 years ago
parent ff5659ec1a
commit 3fa679a3e9

@ -39,7 +39,7 @@ import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
import org.wso2.carbon.mdm.services.android.util.Message;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import javax.validation.Valid;

@ -55,7 +55,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
import org.wso2.carbon.mdm.services.android.bean.ErrorResponse;
import org.wso2.carbon.mdm.services.android.exception.BadRequestException;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import javax.ws.rs.core.MediaType;

@ -27,6 +27,7 @@ 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;
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants;
@ -47,6 +48,7 @@ public class AndroidDeviceManagementService implements DeviceManagementService {
private static final String NOTIFIER_PROPERTY = "notifierType";
private static final String GCM_API_KEY = "gcmAPIKey";
private static final String GCM_SENDER_ID = "gcmSenderId";
private PolicyMonitoringManager policyMonitoringManager;
@Override
public String getType() {
@ -61,6 +63,7 @@ public class AndroidDeviceManagementService implements DeviceManagementService {
@Override
public void init() throws DeviceManagementException {
this.deviceManager = new AndroidDeviceManager();
this.policyMonitoringManager = new AndroidPolicyMonitoringManager();
}
@Override
@ -105,6 +108,11 @@ public class AndroidDeviceManagementService implements DeviceManagementService {
return null;
}
@Override
public PolicyMonitoringManager getPolicyMonitoringManager() {
return policyMonitoringManager;
}
private String getConfigProperty(List<ConfigurationEntry> configs, String propertyName) {
for (ConfigurationEntry entry : configs) {
if (propertyName.equals(entry.getName())) {

@ -25,39 +25,27 @@ 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.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.mobile.android.impl.gcm.GCMService;
import org.wso2.carbon.device.mgt.mobile.android.internal.AndroidDeviceManagementDataHolder;
import org.wso2.carbon.policy.mgt.common.Policy;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import java.util.ArrayList;
import java.util.List;
public class AndroidPolicyMonitoringService implements PolicyMonitoringService {
public class AndroidPolicyMonitoringManager implements PolicyMonitoringManager {
private static Log log = LogFactory.getLog(AndroidPolicyMonitoringService.class);
private static Log log = LogFactory.getLog(AndroidPolicyMonitoringManager.class);
@Override
public void notifyDevices(List<Device> list) throws PolicyComplianceException {
GCMService gcmService = AndroidDeviceManagementDataHolder.getInstance().getGCMService();
if (gcmService.isGCMEnabled() && !list.isEmpty()) {
gcmService.sendNotification("POLICY_BUNDLE", list);
}
}
@Override
public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy,
public NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy,
Object compliancePayload) throws PolicyComplianceException {
if (log.isDebugEnabled()) {
log.debug("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'");
}
ComplianceData complianceData = new ComplianceData();
NonComplianceData complianceData = new NonComplianceData();
if (compliancePayload == null || policy == null) {
return complianceData;
}
@ -93,8 +81,4 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService {
return complianceData;
}
@Override
public String getType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID;
}
}

@ -25,10 +25,8 @@ import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidDeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidPolicyMonitoringService;
import org.wso2.carbon.device.mgt.mobile.android.impl.gcm.GCMService;
import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import org.wso2.carbon.registry.core.service.RegistryService;
/**
@ -75,8 +73,8 @@ public class AndroidDeviceManagementServiceComponent {
// Policy management service
bundleContext.registerService(PolicyMonitoringService.class,
new AndroidPolicyMonitoringService(), null);
// bundleContext.registerService(PolicyMonitoringManager.class,
// new AndroidPolicyMonitoringManager(), null);
AndroidDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService(
androidDeviceManagementService);

@ -35,9 +35,9 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils
import org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml.beans.Profile;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.*;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import java.util.ArrayList;
import java.util.List;

@ -33,7 +33,7 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml.beans.Wifi;
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.*;
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
import java.util.ArrayList;
import java.util.List;

@ -23,6 +23,7 @@ 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;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
@ -34,6 +35,7 @@ public class WindowsDeviceManagementService implements DeviceManagementService {
private DeviceManager deviceManager;
public static final String DEVICE_TYPE_WINDOWS = "windows";
private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
private PolicyMonitoringManager policyMonitoringManager;
@Override
public String getType() {
@ -48,6 +50,7 @@ public class WindowsDeviceManagementService implements DeviceManagementService {
@Override
public void init() throws DeviceManagementException {
this.deviceManager = new WindowsDeviceManager();
this.policyMonitoringManager = new WindowsPolicyMonitoringManager();
}
@Override
@ -70,4 +73,9 @@ public class WindowsDeviceManagementService implements DeviceManagementService {
return null;
}
@Override
public PolicyMonitoringManager getPolicyMonitoringManager() {
return policyMonitoringManager;
}
}

@ -20,36 +20,29 @@ package org.wso2.carbon.device.mgt.mobile.windows.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.policy.mgt.common.Policy;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
import java.util.ArrayList;
import java.util.List;
public class WindowsPolicyMonitoringService implements PolicyMonitoringService {
public class WindowsPolicyMonitoringManager implements PolicyMonitoringManager {
private static Log log = LogFactory.getLog(WindowsPolicyMonitoringService.class);
private static Log log = LogFactory.getLog(WindowsPolicyMonitoringManager.class);
@Override
public void notifyDevices(List<Device> list) throws PolicyComplianceException {
}
@Override
public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object compliancePayload)
public NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object compliancePayload)
throws PolicyComplianceException {
if (log.isDebugEnabled()) {
log.debug("checking policy compliance status of device '" + deviceIdentifier.getId() + "'");
}
List<ComplianceFeature> complianceFeatures = (List<ComplianceFeature>) compliancePayload;
List<ComplianceFeature> nonComplianceFeatures = new ArrayList<>();
ComplianceData complianceData = new ComplianceData();
NonComplianceData complianceData = new NonComplianceData();
if (policy == null || compliancePayload == null) {
return complianceData;
@ -66,8 +59,4 @@ public class WindowsPolicyMonitoringService implements PolicyMonitoringService {
return complianceData;
}
@Override
public String getType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS;
}
}

@ -23,11 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.windows.impl.WindowsDeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.windows.impl.WindowsPolicyMonitoringService;
import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import org.wso2.carbon.registry.core.service.RegistryService;
/**
@ -67,8 +63,8 @@ public class WindowsDeviceManagementServiceComponent {
// Policy management service
bundleContext.registerService(PolicyMonitoringService.class,
new WindowsPolicyMonitoringService(), null);
// bundleContext.registerService(PolicyMonitoringManager.class,
// new WindowsPolicyMonitoringManager(), null);
if (log.isDebugEnabled()) {
log.debug("Android Mobile Device Management Service Component has been successfully activated");

@ -253,11 +253,11 @@
</propertyDef>
</properties>
</adviceFile>
<bundles>
<bundleDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android:${carbon.devicemgt.plugins.version}
</bundleDef>
</bundles>
<!--<bundles>-->
<!--<bundleDef>-->
<!--org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android:${carbon.devicemgt.plugins.version}-->
<!--</bundleDef>-->
<!--</bundles>-->
<importFeatures>
<importFeatureDef>
org.wso2.carbon.core.server:${carbon.kernel.version}

@ -348,4 +348,5 @@
</Operation>
</Operations>
</TaskConfiguration>
<PolicyMonitoring enabled="true"/>
</DeviceTypeConfiguration>

@ -202,11 +202,11 @@
</propertyDef>
</properties>
</adviceFile>
<bundles>
<bundleDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.windows:${carbon.devicemgt.plugins.version}
</bundleDef>
</bundles>
<!--<bundles>-->
<!--<bundleDef>-->
<!--org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.windows:${carbon.devicemgt.plugins.version}-->
<!--</bundleDef>-->
<!--</bundles>-->
<importFeatures>
<importFeatureDef>
org.wso2.carbon.core.server:${carbon.kernel.version}

@ -124,4 +124,6 @@
<authorizationRequired>false</authorizationRequired>
</DeviceAuthorizationConfig>
<PolicyMonitoring enabled="true"/>
</DeviceTypeConfiguration>

Loading…
Cancel
Save