Adapting LicenseManager changes introduced in org.wso2.carbon.device.mgt.core and org.wso2.carbon.device.mgt.extensions

revert-dabc3590
prabathabey 10 years ago
parent d07c226dd5
commit 29a6f0706a

@ -76,6 +76,7 @@
org.wso2.carbon.registry.core.service,
org.wso2.carbon.registry.core.session,
org.wso2.carbon.registry.api,
org.wso2.carbon.device.mgt.extensions.license.mgt
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.mobile.internal,
@ -127,6 +128,10 @@
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>

@ -43,10 +43,11 @@ import java.util.List;
public class AndroidDeviceManagementService implements DeviceManagementService {
private DeviceManager deviceManager;
public static final String DEVICE_TYPE_ANDROID = "android";
@Override
public String getType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID;
return AndroidDeviceManagementService.DEVICE_TYPE_ANDROID;
}
@Override

@ -24,13 +24,18 @@ import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
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.LicenseManager;
import org.wso2.carbon.device.mgt.extensions.license.mgt.RegistryBasedLicenseManager;
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.AndroidDAOFactory;
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import org.wso2.carbon.registry.api.Collection;
import org.wso2.carbon.registry.api.Registry;
import org.wso2.carbon.registry.api.Resource;
import org.wso2.carbon.registry.api.RegistryException;
@ -42,10 +47,18 @@ public class AndroidDeviceManager implements DeviceManager {
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
private static final Log log = LogFactory.getLog(AndroidDeviceManagementService.class);
private FeatureManager featureManager = new AndroidFeatureManager();
private License license;
private LicenseManager licenseManager;
public AndroidDeviceManager() {
mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
this.mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
try {
Registry registry =
MobileDeviceManagementDataHolder.getInstance().getRegistryService().getConfigSystemRegistry();
this.licenseManager = new RegistryBasedLicenseManager(registry);
} catch (org.wso2.carbon.registry.core.exceptions.RegistryException e) {
throw new IllegalStateException("Error occurred while retrieving config system registry of the tenant, " +
"which in turns fails the initialization of Android Device Manager", e);
}
}
@Override
@ -90,9 +103,11 @@ public class AndroidDeviceManager implements DeviceManager {
ConfigurationEntry entry;
Resource resource;
try {
String androidRegPath = MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants.
String androidRegPath =
MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants.
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
dsCollection = (Collection) MobileDeviceManagementUtil.getRegistryResource(androidRegPath);
dsCollection =
(Collection) MobileDeviceManagementUtil.getRegistryResource(androidRegPath);
String[] dsmPaths = dsCollection.getChildren();
for (String dsmPath : dsmPaths) {
entry = new ConfigurationEntry();
@ -152,8 +167,7 @@ public class AndroidDeviceManager implements DeviceManager {
log.debug("Modifying the Android device enrollment data");
}
AndroidDAOFactory.beginTransaction();
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.updateMobileDevice(mobileDevice);
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice);
AndroidDAOFactory.commitTransaction();
} catch (MobileDeviceManagementDAOException e) {
try {
@ -265,6 +279,16 @@ public class AndroidDeviceManager implements DeviceManager {
return false;
}
@Override
public License getLicense(String languageCode) throws LicenseManagementException {
return licenseManager.getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, languageCode);
}
@Override
public void addLicense(License license) throws LicenseManagementException {
licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, license);
}
@Override
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device)
throws DeviceManagementException {

@ -40,10 +40,11 @@ import java.util.List;
public class WindowsDeviceManagementService implements DeviceManagementService {
private DeviceManager deviceManager;
public static final String DEVICE_TYPE_WINDOWS = "windows";
@Override
public String getType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS;
return WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS;
}
@Override

@ -21,24 +21,38 @@ package org.wso2.carbon.device.mgt.mobile.impl.windows;
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.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
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.LicenseManager;
import org.wso2.carbon.device.mgt.extensions.license.mgt.RegistryBasedLicenseManager;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.impl.windows.dao.WindowsDAOFactory;
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import org.wso2.carbon.registry.api.Registry;
import java.util.List;
import java.util.Map;
public class WindowsDeviceManager implements DeviceManager {
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
private MobileDeviceManagementDAOFactory daoFactory;
private LicenseManager licenseManager;
private static final Log log = LogFactory.getLog(WindowsDeviceManagementService.class);
public WindowsDeviceManager() {
mobileDeviceManagementDAOFactory = new WindowsDAOFactory();
daoFactory = new WindowsDAOFactory();
try {
Registry registry =
MobileDeviceManagementDataHolder.getInstance().getRegistryService().getConfigSystemRegistry();
this.licenseManager = new RegistryBasedLicenseManager(registry);
} catch (org.wso2.carbon.registry.core.exceptions.RegistryException e) {
throw new IllegalStateException("Error occurred while retrieving config system registry of the tenant, " +
"which in turns fails the initialization of Android Device Manager", e);
}
}
@Override
@ -110,7 +124,18 @@ public class WindowsDeviceManager implements DeviceManager {
}
@Override
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
public License getLicense(String languageCode) throws LicenseManagementException {
return licenseManager.getLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, languageCode);
}
@Override
public void addLicense(License license) throws LicenseManagementException {
licenseManager.addLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, license);
}
@Override
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier,
Device device) throws DeviceManagementException {
return true;
}
@ -119,13 +144,10 @@ public class WindowsDeviceManager implements DeviceManager {
boolean status;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try {
status = mobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
mobileDevice);
status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while enrolling the Windows device : " +
device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
throw new DeviceManagementException("Error while enrolling the Windows device '" +
device.getDeviceIdentifier() + "'", e);
}
return status;
}

@ -23,16 +23,16 @@ import org.wso2.carbon.registry.core.service.RegistryService;
/**
* DataHolder class of Mobile plugins component.
*/
public class MobileDeviceManagementServiceDataHolder {
public class MobileDeviceManagementDataHolder {
private RegistryService registryService;
private static MobileDeviceManagementServiceDataHolder thisInstance = new MobileDeviceManagementServiceDataHolder();
private static MobileDeviceManagementDataHolder thisInstance = new MobileDeviceManagementDataHolder();
private MobileDeviceManagementServiceDataHolder() {
private MobileDeviceManagementDataHolder() {
}
public static MobileDeviceManagementServiceDataHolder getInstance() {
public static MobileDeviceManagementDataHolder getInstance() {
return thisInstance;
}

@ -157,11 +157,11 @@ public class MobileDeviceManagementServiceComponent {
if (log.isDebugEnabled()) {
log.debug("RegistryService acquired");
}
MobileDeviceManagementServiceDataHolder.getInstance().setRegistryService(registryService);
MobileDeviceManagementDataHolder.getInstance().setRegistryService(registryService);
}
protected void unsetRegistryService(RegistryService registryService) {
MobileDeviceManagementServiceDataHolder.getInstance().setRegistryService(null);
MobileDeviceManagementDataHolder.getInstance().setRegistryService(null);
}
}

@ -30,7 +30,8 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants;
import org.wso2.carbon.device.mgt.mobile.dto.*;
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementServiceDataHolder;
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder;
import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource;
import org.wso2.carbon.registry.core.Registry;
@ -201,7 +202,7 @@ public class MobileDeviceManagementUtil {
public static Registry getRegistry() throws MobileDeviceMgtPluginException {
try {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
return MobileDeviceManagementServiceDataHolder.getInstance().getRegistryService()
return MobileDeviceManagementDataHolder.getInstance().getRegistryService()
.getConfigSystemRegistry(
tenantId);
} catch (RegistryException e) {

@ -214,6 +214,11 @@
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>

Loading…
Cancel
Save