|
|
@ -21,7 +21,6 @@ import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.wso2.carbon.context.CarbonContext;
|
|
|
|
import org.wso2.carbon.context.CarbonContext;
|
|
|
|
import org.wso2.carbon.device.mgt.common.*;
|
|
|
|
import org.wso2.carbon.device.mgt.common.*;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
|
|
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
|
|
|
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
|
@ -68,11 +67,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
DeviceManagementServiceComponent.registerPluginInitializationListener(this);
|
|
|
|
DeviceManagementServiceComponent.registerPluginInitializationListener(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String getProviderType() {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public FeatureManager getFeatureManager() {
|
|
|
|
public FeatureManager getFeatureManager() {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
@ -81,14 +75,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public FeatureManager getFeatureManager(String type) {
|
|
|
|
public FeatureManager getFeatureManager(String type) {
|
|
|
|
DeviceManager dms =
|
|
|
|
DeviceManager dms =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(type);
|
|
|
|
this.getPluginRepository().getDeviceManagementService(type).getDeviceManager();
|
|
|
|
return dms.getFeatureManager();
|
|
|
|
return dms.getFeatureManager();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
|
|
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
|
|
|
DeviceManager dms =
|
|
|
|
DeviceManager dms =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType());
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType()).getDeviceManager();
|
|
|
|
boolean status = dms.enrollDevice(device);
|
|
|
|
boolean status = dms.enrollDevice(device);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (dms.isClaimable(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()))) {
|
|
|
|
if (dms.isClaimable(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()))) {
|
|
|
@ -134,7 +128,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
|
|
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
|
|
|
DeviceManager dms =
|
|
|
|
DeviceManager dms =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType());
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType()).getDeviceManager();
|
|
|
|
boolean status = dms.modifyEnrollment(device);
|
|
|
|
boolean status = dms.modifyEnrollment(device);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
@ -167,7 +161,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
|
|
|
|
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
DeviceManager dms =
|
|
|
|
DeviceManager dms =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType());
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType()).getDeviceManager();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Device device = deviceDAO.getDevice(deviceId,tenantId);
|
|
|
|
Device device = deviceDAO.getDevice(deviceId,tenantId);
|
|
|
|
DeviceType deviceType = deviceTypeDAO.getDeviceType(device.getType());
|
|
|
|
DeviceType deviceType = deviceTypeDAO.getDeviceType(device.getType());
|
|
|
@ -188,14 +182,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
DeviceManager dms =
|
|
|
|
DeviceManager dms =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType());
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType()).getDeviceManager();
|
|
|
|
return dms.isEnrolled(deviceId);
|
|
|
|
return dms.isEnrolled(deviceId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
DeviceManager dms =
|
|
|
|
DeviceManager dms =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType());
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType()).getDeviceManager();
|
|
|
|
return dms.isActive(deviceId);
|
|
|
|
return dms.isActive(deviceId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -203,7 +197,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
public boolean setActive(DeviceIdentifier deviceId, boolean status)
|
|
|
|
public boolean setActive(DeviceIdentifier deviceId, boolean status)
|
|
|
|
throws DeviceManagementException {
|
|
|
|
throws DeviceManagementException {
|
|
|
|
DeviceManager dms =
|
|
|
|
DeviceManager dms =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType());
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType()).getDeviceManager();
|
|
|
|
return dms.setActive(deviceId, status);
|
|
|
|
return dms.setActive(deviceId, status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -227,7 +221,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Device device : allDevices) {
|
|
|
|
for (Device device : allDevices) {
|
|
|
|
Device dmsDevice =
|
|
|
|
Device dmsDevice =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType()).getDevice(
|
|
|
|
this.getPluginRepository().getDeviceManagementService(
|
|
|
|
|
|
|
|
device.getType()).getDeviceManager().getDevice(
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
device.setFeatures(dmsDevice.getFeatures());
|
|
|
|
device.setFeatures(dmsDevice.getFeatures());
|
|
|
|
device.setProperties(dmsDevice.getProperties());
|
|
|
|
device.setProperties(dmsDevice.getProperties());
|
|
|
@ -257,7 +252,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
|
|
|
|
|
|
|
|
for (Device device : allDevices) {
|
|
|
|
for (Device device : allDevices) {
|
|
|
|
Device dmsDevice =
|
|
|
|
Device dmsDevice =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType()).getDevice(
|
|
|
|
this.getPluginRepository().getDeviceManagementService(
|
|
|
|
|
|
|
|
device.getType()).getDeviceManager().getDevice(
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
device.setFeatures(dmsDevice.getFeatures());
|
|
|
|
device.setFeatures(dmsDevice.getFeatures());
|
|
|
|
device.setProperties(dmsDevice.getProperties());
|
|
|
|
device.setProperties(dmsDevice.getProperties());
|
|
|
@ -407,7 +403,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (device != null) {
|
|
|
|
if (device != null) {
|
|
|
|
DeviceManager dms = this.getPluginRepository().getDeviceManagementService(deviceId.getType());
|
|
|
|
DeviceManager dms =
|
|
|
|
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType()).getDeviceManager();
|
|
|
|
Device pluginSpecificInfo = dms.getDevice(deviceId);
|
|
|
|
Device pluginSpecificInfo = dms.getDevice(deviceId);
|
|
|
|
device.setProperties(pluginSpecificInfo.getProperties());
|
|
|
|
device.setProperties(pluginSpecificInfo.getProperties());
|
|
|
|
device.setFeatures(pluginSpecificInfo.getFeatures());
|
|
|
|
device.setFeatures(pluginSpecificInfo.getFeatures());
|
|
|
@ -418,7 +415,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
|
|
|
|
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
|
|
|
|
DeviceManager dms =
|
|
|
|
DeviceManager dms =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType());
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType()).getDeviceManager();
|
|
|
|
return dms.updateDeviceInfo(deviceIdentifier, device);
|
|
|
|
return dms.updateDeviceInfo(deviceIdentifier, device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -426,14 +423,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
|
|
|
|
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
|
|
|
|
throws DeviceManagementException {
|
|
|
|
throws DeviceManagementException {
|
|
|
|
DeviceManager dms =
|
|
|
|
DeviceManager dms =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType());
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType()).getDeviceManager();
|
|
|
|
return dms.setOwnership(deviceId, ownershipType);
|
|
|
|
return dms.setOwnership(deviceId, ownershipType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isClaimable(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
public boolean isClaimable(DeviceIdentifier deviceId) throws DeviceManagementException {
|
|
|
|
DeviceManager dms =
|
|
|
|
DeviceManager dms =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType());
|
|
|
|
this.getPluginRepository().getDeviceManagementService(deviceId.getType()).getDeviceManager();
|
|
|
|
return dms.isClaimable(deviceId);
|
|
|
|
return dms.isClaimable(deviceId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -552,7 +549,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
|
|
|
|
|
|
|
|
for (Device device : userDevices) {
|
|
|
|
for (Device device : userDevices) {
|
|
|
|
Device dmsDevice =
|
|
|
|
Device dmsDevice =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType()).getDevice(
|
|
|
|
this.getPluginRepository().getDeviceManagementService(
|
|
|
|
|
|
|
|
device.getType()).getDeviceManager().getDevice(
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
device.setFeatures(dmsDevice.getFeatures());
|
|
|
|
device.setFeatures(dmsDevice.getFeatures());
|
|
|
|
device.setProperties(dmsDevice.getProperties());
|
|
|
|
device.setProperties(dmsDevice.getProperties());
|
|
|
@ -594,7 +592,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Device device : userDevices) {
|
|
|
|
for (Device device : userDevices) {
|
|
|
|
Device dmsDevice =
|
|
|
|
Device dmsDevice =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType()).getDevice(
|
|
|
|
this.getPluginRepository().getDeviceManagementService(
|
|
|
|
|
|
|
|
device.getType()).getDeviceManager().getDevice(
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
device.setFeatures(dmsDevice.getFeatures());
|
|
|
|
device.setFeatures(dmsDevice.getFeatures());
|
|
|
|
device.setProperties(dmsDevice.getProperties());
|
|
|
|
device.setProperties(dmsDevice.getProperties());
|
|
|
@ -641,7 +640,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Device device : allDevices) {
|
|
|
|
for (Device device : allDevices) {
|
|
|
|
Device dmsDevice =
|
|
|
|
Device dmsDevice =
|
|
|
|
this.getPluginRepository().getDeviceManagementService(device.getType()).getDevice(
|
|
|
|
this.getPluginRepository().getDeviceManagementService(
|
|
|
|
|
|
|
|
device.getType()).getDeviceManager().getDevice(
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
|
|
|
device.setFeatures(dmsDevice.getFeatures());
|
|
|
|
device.setFeatures(dmsDevice.getFeatures());
|
|
|
|
device.setProperties(dmsDevice.getProperties());
|
|
|
|
device.setProperties(dmsDevice.getProperties());
|
|
|
@ -673,7 +673,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
pluginRepository.addDeviceManagementProvider(deviceManagementService);
|
|
|
|
pluginRepository.addDeviceManagementProvider(deviceManagementService);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
log.error("Error occurred while registering device management plugin '" +
|
|
|
|
log.error("Error occurred while registering device management plugin '" +
|
|
|
|
deviceManagementService.getProviderType() + "'", e);
|
|
|
|
deviceManagementService.getType() + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -683,7 +683,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
pluginRepository.removeDeviceManagementProvider(deviceManagementService);
|
|
|
|
pluginRepository.removeDeviceManagementProvider(deviceManagementService);
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
log.error("Error occurred while un-registering device management plugin '" +
|
|
|
|
log.error("Error occurred while un-registering device management plugin '" +
|
|
|
|
deviceManagementService.getProviderType() + "'", e);
|
|
|
|
deviceManagementService.getType() + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|