revert-dabc3590
milanperera 9 years ago
commit b3e6f24b17

@ -33,12 +33,10 @@ 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.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; 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.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.device.mgt.mobile.util.MobileDeviceManagementUtil;
import org.wso2.carbon.registry.api.Collection; 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; import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -52,14 +50,7 @@ public class AndroidDeviceManager implements DeviceManager {
public AndroidDeviceManager() { public AndroidDeviceManager() {
this.mobileDeviceManagementDAOFactory = new AndroidDAOFactory(); this.mobileDeviceManagementDAOFactory = new AndroidDAOFactory();
try { this.licenseManager = new RegistryBasedLicenseManager();
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 @Override
@ -70,7 +61,7 @@ public class AndroidDeviceManager implements DeviceManager {
@Override @Override
public boolean saveConfiguration(TenantConfiguration tenantConfiguration) public boolean saveConfiguration(TenantConfiguration tenantConfiguration)
throws DeviceManagementException { throws DeviceManagementException {
boolean status = false; boolean status;
Resource resource; Resource resource;
try { try {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -96,38 +87,40 @@ public class AndroidDeviceManager implements DeviceManager {
return status; return status;
} }
@Override @Override
public TenantConfiguration getConfiguration() throws DeviceManagementException { public TenantConfiguration getConfiguration() throws DeviceManagementException {
Collection dsCollection = null; Collection dsCollection = null;
TenantConfiguration tenantConfiguration; TenantConfiguration tenantConfiguration;
List<ConfigurationEntry> configs = new ArrayList<ConfigurationEntry>(); List<ConfigurationEntry> configs = new ArrayList<ConfigurationEntry>();
ConfigurationEntry entry; ConfigurationEntry entry;
Resource resource; Resource resource;
try { try {
String androidRegPath = MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants. String androidRegPath =
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants.
dsCollection = (Collection) MobileDeviceManagementUtil.getRegistryResource(androidRegPath); MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
String[] dsmPaths = dsCollection.getChildren(); dsCollection =
for (String dsmPath : dsmPaths) { (Collection) MobileDeviceManagementUtil.getRegistryResource(androidRegPath);
entry = new ConfigurationEntry(); String[] dsmPaths = dsCollection.getChildren();
resource = MobileDeviceManagementUtil.getRegistryResource(dsmPath); for (String dsmPath : dsmPaths) {
entry.setValue(resource.getContent()); entry = new ConfigurationEntry();
entry.setName(resource.getId()); resource = MobileDeviceManagementUtil.getRegistryResource(dsmPath);
configs.add(entry); entry.setValue(resource.getContent());
} entry.setName(resource.getId());
tenantConfiguration = new TenantConfiguration(); configs.add(entry);
tenantConfiguration.setConfiguration(configs); }
tenantConfiguration.setType(DeviceManagementConstants. tenantConfiguration = new TenantConfiguration();
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); tenantConfiguration.setConfiguration(configs);
} catch (MobileDeviceMgtPluginException e) { tenantConfiguration.setType(DeviceManagementConstants.
throw new DeviceManagementException( MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
"Error occurred while retrieving the Registry instance : " + e.getMessage(), e); } catch (MobileDeviceMgtPluginException e) {
} catch (RegistryException e) { throw new DeviceManagementException(
throw new DeviceManagementException( "Error occurred while retrieving the Registry instance : " + e.getMessage(), e);
"Error occurred while retrieving the Registry data : " + e.getMessage(), e); } catch (RegistryException e) {
} throw new DeviceManagementException(
return tenantConfiguration; "Error occurred while retrieving the Registry data : " + e.getMessage(), e);
} }
return tenantConfiguration;
}
@Override @Override
public boolean enrollDevice(Device device) throws DeviceManagementException { public boolean enrollDevice(Device device) throws DeviceManagementException {

@ -30,9 +30,7 @@ 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.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; 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.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.device.mgt.mobile.util.MobileDeviceManagementUtil;
import org.wso2.carbon.registry.api.Registry;
import java.util.List; import java.util.List;
@ -44,15 +42,8 @@ public class WindowsDeviceManager implements DeviceManager {
private static final Log log = LogFactory.getLog(WindowsDeviceManagementService.class); private static final Log log = LogFactory.getLog(WindowsDeviceManagementService.class);
public WindowsDeviceManager() { public WindowsDeviceManager() {
daoFactory = new WindowsDAOFactory(); this.daoFactory = new WindowsDAOFactory();
try { this.licenseManager = new RegistryBasedLicenseManager();
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 @Override

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>1.9.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.mobile.url.printer</artifactId>
<version>1.9.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Startup Handler That Prints MDM End-User Web-App URL</name>
<description>WSO2 Carbon - Startup Handler That Prints MDM End-User Web-App URL</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.mobile.device.mgt.version}</Bundle-Version>
<Bundle-Description>Bundle Containing The Startup Handler That Prints MDM End-User Web-App URL</Bundle-Description>
<Private-Package>org.wso2.carbon.device.mgt.mobile.url.printer.internal</Private-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.apache.commons.logging,
org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.wso2.carbon.core,
org.wso2.carbon.utils.*,
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.mobile.url.printer.internal,
org.wso2.carbon.device.mgt.mobile.url.printer,
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,64 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* 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
*
* 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.mobile.url.printer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.mobile.url.printer.internal.URLPrinterDataHolder;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.ConfigurationContextService;
import org.wso2.carbon.utils.NetworkUtils;
public class URLPrinterStartupHandler implements ServerStartupObserver {
private static final Log log = LogFactory.getLog(URLPrinterStartupHandler.class);
@Override
public void completingServerStartup() {
}
@Override
public void completedServerStartup() {
log.info("EMM Console URL : " + this.getEmmUrl());
}
private String getEmmUrl() {
// Hostname
String hostName = "localhost";
try {
hostName = NetworkUtils.getMgtHostName();
} catch (Exception ignored) {
}
// HTTPS port
String mgtConsoleTransport = CarbonUtils.getManagementTransport();
ConfigurationContextService configContextService =
URLPrinterDataHolder.getInstance().getConfigurationContextService();
int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport);
int httpsProxyPort =
CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(),
mgtConsoleTransport);
if (httpsProxyPort > 0) {
port = httpsProxyPort;
}
return "https://" + hostName + ":" + port + "/mdm";
}
}

@ -0,0 +1,42 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* 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
*
* 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.mobile.url.printer.internal;
import org.wso2.carbon.utils.ConfigurationContextService;
public class URLPrinterDataHolder {
private ConfigurationContextService configurationContextService;
private static URLPrinterDataHolder thisInstance = new URLPrinterDataHolder();
private URLPrinterDataHolder() {}
public static URLPrinterDataHolder getInstance() {
return thisInstance;
}
public ConfigurationContextService getConfigurationContextService() {
return configurationContextService;
}
public void setConfigurationContextService(ConfigurationContextService configurationContextService) {
this.configurationContextService = configurationContextService;
}
}

@ -0,0 +1,73 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* 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
*
* 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.mobile.url.printer.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.mobile.url.printer.URLPrinterStartupHandler;
import org.wso2.carbon.utils.ConfigurationContextService;
/**
* @scr.component name="org.wso2.carbon.device.mgt.mobile.url.printer.URLPrinterStartupHandlerServiceComponent"
* immediate="true"
* @scr.reference name="config.context.service"
* interface="org.wso2.carbon.utils.ConfigurationContextService"
* cardinality="0..1"
* policy="dynamic"
* bind="setConfigurationContextService"
* unbind="unsetConfigurationContextService"
*/
public class URLPrinterStartupHandlerServiceComponent {
private static final Log log = LogFactory.getLog(URLPrinterStartupHandlerServiceComponent.class);
@SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) {
try {
BundleContext bundleContext = componentContext.getBundleContext();
/* Registering URL printer start-up handler */
bundleContext.registerService(ServerStartupObserver.class, new URLPrinterStartupHandler(), null);
} catch (Throwable e) {
log.error("Error occurred while activating URL printer server start-up handler service component", e);
}
}
@SuppressWarnings("unused")
protected void deactivate(ComponentContext componentContext) {
//do nothing
}
protected void setConfigurationContextService(ConfigurationContextService configurationContextService) {
if (log.isDebugEnabled()) {
log.debug("Setting ConfigurationContextService");
}
URLPrinterDataHolder.getInstance().setConfigurationContextService(configurationContextService);
}
protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) {
if (log.isDebugEnabled()) {
log.debug("Un-setting ConfigurationContextService");
}
URLPrinterDataHolder.getInstance().setConfigurationContextService(null);
}
}

@ -36,6 +36,7 @@
<modules> <modules>
<module>org.wso2.carbon.device.mgt.mobile.impl</module> <module>org.wso2.carbon.device.mgt.mobile.impl</module>
<module>org.wso2.carbon.device.mgt.mobile.url.printer</module>
</modules> </modules>
<build> <build>

@ -30,7 +30,7 @@
<artifactId>org.wso2.carbon.device.mgt.mobile.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.mobile.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.9.2-SNAPSHOT</version> <version>1.9.2-SNAPSHOT</version>
<name>WSO2 Carbon - Mobile Implementation of Device Management</name> <name>WSO2 Carbon - Mobile Device Management Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains the core bundles required for Mobile Device Management functionality <description>This feature contains the core bundles required for Mobile Device Management functionality
</description> </description>
@ -44,6 +44,10 @@
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId> <artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.mobile.url.printer</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.server.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.server.feature</artifactId>
@ -104,9 +108,8 @@
</properties> </properties>
</adviceFile> </adviceFile>
<bundles> <bundles>
<bundleDef> <bundleDef>org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.impl:${carbon.mobile.device.mgt.version}</bundleDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.impl:${carbon.mobile.device.mgt.version} <bundleDef>org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.url.printer:${carbon.mobile.device.mgt.version}</bundleDef>
</bundleDef>
</bundles> </bundles>
<importFeatures> <importFeatures>
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}</importFeatureDef> <importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}</importFeatureDef>

@ -248,6 +248,11 @@
<artifactId>org.wso2.carbon.device.mgt.mobile.impl</artifactId> <artifactId>org.wso2.carbon.device.mgt.mobile.impl</artifactId>
<version>${carbon.mobile.device.mgt.version}</version> <version>${carbon.mobile.device.mgt.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.mobile.url.printer</artifactId>
<version>${carbon.mobile.device.mgt.version}</version>
</dependency>
<!--Osgi dependencies--> <!--Osgi dependencies-->
<dependency> <dependency>
@ -501,7 +506,11 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
<version>${axis2.orbit.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -513,6 +522,10 @@
<carbon.p2.plugin.version>1.5.4</carbon.p2.plugin.version> <carbon.p2.plugin.version>1.5.4</carbon.p2.plugin.version>
<!-- Axis2 -->
<axis2.osgi.version.range>[1.6.1.wso2v11, 1.7.0)</axis2.osgi.version.range>
<axis2.orbit.version>1.6.1.wso2v11</axis2.orbit.version>
<!--Maven build number plugin--> <!--Maven build number plugin-->
<maven-buildnumber-plugin.version>1.3</maven-buildnumber-plugin.version> <maven-buildnumber-plugin.version>1.3</maven-buildnumber-plugin.version>

Loading…
Cancel
Save