mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Added mobile device management related db classes
This commit is contained in:
parent
a5018afadf
commit
4a419f3ebf
@ -34,7 +34,7 @@ public final class DeviceManagementConstants {
|
|||||||
public static final String SECURE_VAULT_NS = "http://org.wso2.securevault/configuration";
|
public static final String SECURE_VAULT_NS = "http://org.wso2.securevault/configuration";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MobileDeviceTypes {
|
public static final class MobileDeviceTypes {
|
||||||
private MobileDeviceTypes() {
|
private MobileDeviceTypes() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,11 +109,15 @@ public final class DeviceManagementDAOUtil {
|
|||||||
deviceBO.setName(device.getName());
|
deviceBO.setName(device.getName());
|
||||||
deviceBO.setDateOfEnrollment(device.getDateOfEnrolment());
|
deviceBO.setDateOfEnrollment(device.getDateOfEnrolment());
|
||||||
deviceBO.setDateOfLastUpdate(device.getDateOfLastUpdate());
|
deviceBO.setDateOfLastUpdate(device.getDateOfLastUpdate());
|
||||||
deviceBO.setStatus(Status.valueOf(String.valueOf(device.isStatus())));
|
if (!device.isStatus()){
|
||||||
|
deviceBO.setStatus(Status.INACTIVE);
|
||||||
|
}else{
|
||||||
|
deviceBO.setStatus(Status.ACTIVE);
|
||||||
|
}
|
||||||
deviceBO.setOwnerId(device.getOwner());
|
deviceBO.setOwnerId(device.getOwner());
|
||||||
deviceBO.setOwnerShip(device.getOwnership());
|
deviceBO.setOwnerShip(device.getOwnership());
|
||||||
deviceBO.setTenantId(DeviceManagementDAOUtil.getTenantId());
|
deviceBO.setTenantId(DeviceManagementDAOUtil.getTenantId());
|
||||||
deviceBO.setDeviceType(Integer.parseInt(device.getType()));
|
//deviceBO.setDeviceType(Integer.parseInt(device.getType()));
|
||||||
return deviceBO;
|
return deviceBO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -74,10 +74,13 @@
|
|||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.osgi</groupId>
|
<groupId>org.eclipse.osgi</groupId>
|
||||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||||
<version>3.2.0.v20090520-1800</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@ -86,4 +86,6 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//should implement equals and hashcode in all service bundles
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* software distributed under the License is distributed on an
|
*
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* KIND, either express or implied. See the License for the
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* specific language governing permissions and limitations
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* under the License.
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.config;
|
package org.wso2.carbon.device.mgt.mobile.impl.config;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
|
import org.wso2.carbon.device.mgt.mobile.impl.util.MobileDeviceManagerUtil;
|
||||||
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||||
import org.wso2.carbon.utils.CarbonUtils;
|
import org.wso2.carbon.utils.CarbonUtils;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
@ -31,43 +31,46 @@ import java.io.File;
|
|||||||
*/
|
*/
|
||||||
public class MobileDeviceConfigurationManager {
|
public class MobileDeviceConfigurationManager {
|
||||||
|
|
||||||
private MobileDeviceManagementConfig currentDeviceConfig;
|
private static final String MOBILE_DEVICE_CONFIG_XML_NAME = "mobile-config.xml";
|
||||||
private static MobileDeviceConfigurationManager deviceConfigManager;
|
private MobileDeviceManagementConfig currentMobileDeviceConfig;
|
||||||
|
private static MobileDeviceConfigurationManager mobileDeviceConfigManager;
|
||||||
|
|
||||||
private final String deviceMgtConfigXMLPath = CarbonUtils.getCarbonConfigDirPath() + File.separator +
|
private final String mobileDeviceMgtConfigXMLPath =
|
||||||
DeviceManagementConstants.DataSourceProperties.DEVICE_CONFIG_XML_NAME;
|
CarbonUtils.getCarbonConfigDirPath() + File.separator +
|
||||||
|
MOBILE_DEVICE_CONFIG_XML_NAME;
|
||||||
|
|
||||||
public static MobileDeviceConfigurationManager getInstance() {
|
public static MobileDeviceConfigurationManager getInstance() {
|
||||||
if (deviceConfigManager == null) {
|
if (mobileDeviceConfigManager == null) {
|
||||||
synchronized (MobileDeviceConfigurationManager.class) {
|
synchronized (MobileDeviceConfigurationManager.class) {
|
||||||
if (deviceConfigManager == null) {
|
if (mobileDeviceConfigManager == null) {
|
||||||
deviceConfigManager = new MobileDeviceConfigurationManager();
|
mobileDeviceConfigManager = new MobileDeviceConfigurationManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return deviceConfigManager;
|
return mobileDeviceConfigManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void initConfig() throws DeviceManagementException {
|
public synchronized void initConfig() throws DeviceManagementException {
|
||||||
try {
|
try {
|
||||||
File deviceMgtConfig = new File(deviceMgtConfigXMLPath);
|
File mobileDeviceMgtConfig = new File(mobileDeviceMgtConfigXMLPath);
|
||||||
Document doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
|
Document doc = MobileDeviceManagerUtil.convertToDocument(mobileDeviceMgtConfig);
|
||||||
|
JAXBContext mobileDeviceMgmtContext =
|
||||||
/* Un-marshaling Device Management configuration */
|
JAXBContext.newInstance(MobileDeviceManagementConfig.class);
|
||||||
JAXBContext rssContext = JAXBContext.newInstance(MobileDeviceManagementConfig.class);
|
Unmarshaller unmarshaller = mobileDeviceMgmtContext.createUnmarshaller();
|
||||||
Unmarshaller unmarshaller = rssContext.createUnmarshaller();
|
this.currentMobileDeviceConfig =
|
||||||
this.currentDeviceConfig = (MobileDeviceManagementConfig) unmarshaller.unmarshal(doc);
|
(MobileDeviceManagementConfig) unmarshaller.unmarshal(doc);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new DeviceManagementException("Error occurred while initializing RSS config", e);
|
throw new DeviceManagementException(
|
||||||
|
"Error occurred while initializing Mobile Device Management config", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MobileDeviceManagementConfig getDeviceManagementConfig() {
|
public MobileDeviceManagementConfig getMobileDeviceManagementConfig() {
|
||||||
return currentDeviceConfig;
|
return currentMobileDeviceConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataSourceConfig getDataSourceConfig() {
|
public MobileDataSourceConfig getMobileDataSourceConfig() {
|
||||||
return currentDeviceConfig.getMobileDeviceMgtRepository().getDataSourceConfig();
|
return currentMobileDeviceConfig.getMobileDeviceMgtRepository().getMobileDataSourceConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,20 +19,21 @@ import javax.xml.bind.annotation.XmlElement;
|
|||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents Device Mgt configuration.
|
* Represents Mobile Device Mgt configuration.
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "MobileDeviceMgtConfiguration")
|
@XmlRootElement(name = "MobileDeviceMgtConfiguration")
|
||||||
public final class MobileDeviceManagementConfig {
|
public final class MobileDeviceManagementConfig {
|
||||||
|
|
||||||
private DeviceManagementRepository deviceMgtRepository;
|
private MobileDeviceManagementRepository mobileDeviceMgtRepository;
|
||||||
|
|
||||||
@XmlElement(name = "ManagementRepository", nillable = false)
|
@XmlElement(name = "ManagementRepository", nillable = false)
|
||||||
public DeviceManagementRepository getDeviceMgtRepository() {
|
public MobileDeviceManagementRepository getMobileDeviceMgtRepository() {
|
||||||
return deviceMgtRepository;
|
return mobileDeviceMgtRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceMgtRepository(DeviceManagementRepository deviceMgtRepository) {
|
public void setMobileDeviceMgtRepository(
|
||||||
this.deviceMgtRepository = deviceMgtRepository;
|
MobileDeviceManagementRepository mobileDeviceMgtRepository) {
|
||||||
|
this.mobileDeviceMgtRepository = mobileDeviceMgtRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.config;
|
package org.wso2.carbon.device.mgt.mobile.impl.config;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
|
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
@ -26,15 +26,15 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
@XmlRootElement(name = "ManagementRepository")
|
@XmlRootElement(name = "ManagementRepository")
|
||||||
public class MobileDeviceManagementRepository {
|
public class MobileDeviceManagementRepository {
|
||||||
|
|
||||||
private DataSourceConfig dataSourceConfig;
|
private MobileDataSourceConfig mobileDataSourceConfig;
|
||||||
|
|
||||||
@XmlElement(name = "DataSourceConfiguration", nillable = false)
|
@XmlElement(name = "DataSourceConfiguration", nillable = false)
|
||||||
public DataSourceConfig getDataSourceConfig() {
|
public MobileDataSourceConfig getMobileDataSourceConfig() {
|
||||||
return dataSourceConfig;
|
return mobileDataSourceConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataSourceConfig(DataSourceConfig dataSourceConfig) {
|
public void setMobileDataSourceConfig(MobileDataSourceConfig mobileDataSourceConfig) {
|
||||||
this.dataSourceConfig = dataSourceConfig;
|
this.mobileDataSourceConfig = mobileDataSourceConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* software distributed under the License is distributed on an
|
*
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* KIND, either express or implied. See the License for the
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* specific language governing permissions and limitations
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* under the License.
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.config.datasource;
|
package org.wso2.carbon.device.mgt.mobile.impl.config.datasource;
|
||||||
@ -19,7 +20,7 @@ import javax.xml.bind.annotation.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for hold JndiLookupDefinition of rss-manager.xml at parsing with JAXB
|
* Class for hold JndiLookupDefinition of mobile-config.xml at parsing with JAXB
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "JndiLookupDefinition")
|
@XmlRootElement(name = "JndiLookupDefinition")
|
||||||
public class JNDILookupDefinition {
|
public class JNDILookupDefinition {
|
||||||
|
|||||||
@ -19,7 +19,8 @@ package org.wso2.carbon.device.mgt.mobile.impl.dao;
|
|||||||
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice;
|
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the key operations associated with persisting mobile-device related information.
|
* This class represents the key operations associated with persisting mobile-device related
|
||||||
|
* information.
|
||||||
*/
|
*/
|
||||||
public interface MobileDeviceDAO {
|
public interface MobileDeviceDAO {
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,8 @@ public class MobileDeviceManagementDAOException extends Exception {
|
|||||||
private static final long serialVersionUID = 2021891706072918865L;
|
private static final long serialVersionUID = 2021891706072918865L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new exception with the specified detail message and nested exception.
|
* Constructs a new MobileDeviceManagementDAOException with the specified detail message and
|
||||||
|
* nested exception.
|
||||||
*
|
*
|
||||||
* @param message error message
|
* @param message error message
|
||||||
* @param nestedException exception
|
* @param nestedException exception
|
||||||
@ -36,7 +37,8 @@ public class MobileDeviceManagementDAOException extends Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new exception with the specified detail message and cause.
|
* Constructs a new MobileDeviceManagementDAOException with the specified detail message
|
||||||
|
* and cause.
|
||||||
*
|
*
|
||||||
* @param message the detail message.
|
* @param message the detail message.
|
||||||
* @param cause the cause of this exception.
|
* @param cause the cause of this exception.
|
||||||
@ -47,7 +49,7 @@ public class MobileDeviceManagementDAOException extends Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new exception with the specified detail message
|
* Constructs a new MobileDeviceManagementDAOException with the specified detail message
|
||||||
*
|
*
|
||||||
* @param message the detail message.
|
* @param message the detail message.
|
||||||
*/
|
*/
|
||||||
@ -57,7 +59,7 @@ public class MobileDeviceManagementDAOException extends Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new exception with the specified and cause.
|
* Constructs a new MobileDeviceManagementDAOException with the specified and cause.
|
||||||
*
|
*
|
||||||
* @param cause the cause of this exception.
|
* @param cause the cause of this exception.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,7 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed 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.impl.dao;
|
package org.wso2.carbon.device.mgt.mobile.impl.dao;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.JNDILookupDefinition;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceDAOImpl;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceModelDAOImpl;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceVendorDAOImpl;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileOSVersionDAOImpl;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDeviceManagementDAOUtil;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by harshan on 12/15/14.
|
* Factory class used to create MobileDeviceManagement related DAO objects.
|
||||||
*/
|
*/
|
||||||
public class MobileDeviceManagementDAOFactory {
|
public class MobileDeviceManagementDAOFactory {
|
||||||
|
|
||||||
|
private static DataSource dataSource;
|
||||||
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOFactory.class);
|
||||||
|
|
||||||
|
public static MobileDeviceDAO getMobileDeviceDAO() {
|
||||||
|
return new MobileDeviceDAOImpl(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MobileDeviceModelDAO getMobileDeviceModelDAO() {
|
||||||
|
return new MobileDeviceModelDAOImpl(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MobileDeviceVendorDAO getMobileDeviceVendorDAO() {
|
||||||
|
return new MobileDeviceVendorDAOImpl(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MobileOSVersionDAO getMobileOSVersionDAO() {
|
||||||
|
return new MobileOSVersionDAOImpl(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(MobileDataSourceConfig config) {
|
||||||
|
dataSource = resolveDataSource(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(DataSource dtSource) {
|
||||||
|
dataSource = dtSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve data source from the data source definition
|
||||||
|
*
|
||||||
|
* @param config data source configuration
|
||||||
|
* @return data source resolved from the data source definition
|
||||||
|
*/
|
||||||
|
private static DataSource resolveDataSource(MobileDataSourceConfig config) {
|
||||||
|
DataSource dataSource = null;
|
||||||
|
if (config == null) {
|
||||||
|
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||||
|
"is null and thus, is not initialized");
|
||||||
|
}
|
||||||
|
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||||
|
if (jndiConfig != null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||||
|
"Lookup Definition");
|
||||||
|
}
|
||||||
|
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
|
||||||
|
jndiConfig.getJndiProperties();
|
||||||
|
if (jndiPropertyList != null) {
|
||||||
|
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
||||||
|
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||||
|
jndiProperties.put(prop.getName(), prop.getValue());
|
||||||
|
}
|
||||||
|
dataSource =
|
||||||
|
MobileDeviceManagementDAOUtil
|
||||||
|
.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
||||||
|
} else {
|
||||||
|
dataSource = MobileDeviceManagementDAOUtil
|
||||||
|
.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataSource getDataSource() {
|
||||||
|
return dataSource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,14 +16,26 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.dao.impl;
|
package org.wso2.carbon.device.mgt.mobile.impl.dao.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceDAO;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceDAO;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice;
|
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of MobileDeviceDAO.
|
* Implementation of MobileDeviceDAO.
|
||||||
*/
|
*/
|
||||||
public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
private static final Log log = LogFactory.getLog(MobileDeviceDAOImpl.class);
|
||||||
|
|
||||||
|
public MobileDeviceDAOImpl(DataSource dataSource) {
|
||||||
|
this.dataSource = dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException {
|
public MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -16,14 +16,26 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.dao.impl;
|
package org.wso2.carbon.device.mgt.mobile.impl.dao.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceVendorDAO;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceVendorDAO;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceVendor;
|
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceVendor;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of MobileDeviceVendorDAO.
|
* Implementation of MobileDeviceVendorDAO.
|
||||||
*/
|
*/
|
||||||
public class MobileDeviceVendorDAOImpl implements MobileDeviceVendorDAO {
|
public class MobileDeviceVendorDAOImpl implements MobileDeviceVendorDAO {
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
private static final Log log = LogFactory.getLog(MobileDeviceVendorDAOImpl.class);
|
||||||
|
|
||||||
|
public MobileDeviceVendorDAOImpl(DataSource dataSource) {
|
||||||
|
this.dataSource = dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MobileDeviceVendor getDeviceModel(String vendorId)
|
public MobileDeviceVendor getDeviceModel(String vendorId)
|
||||||
throws MobileDeviceManagementDAOException {
|
throws MobileDeviceManagementDAOException {
|
||||||
|
|||||||
@ -16,14 +16,26 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.dao.impl;
|
package org.wso2.carbon.device.mgt.mobile.impl.dao.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileOSVersionDAO;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileOSVersionDAO;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileOSVersion;
|
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileOSVersion;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of MobileOSVersionDAO.
|
* Implementation of MobileOSVersionDAO.
|
||||||
*/
|
*/
|
||||||
public class MobileOSVersionDAOImpl implements MobileOSVersionDAO {
|
public class MobileOSVersionDAOImpl implements MobileOSVersionDAO {
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
private static final Log log = LogFactory.getLog(MobileOSVersionDAOImpl.class);
|
||||||
|
|
||||||
|
public MobileOSVersionDAOImpl(DataSource dataSource) {
|
||||||
|
this.dataSource = dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public MobileOSVersion getMobileOSVersion(String versionId)
|
@Override public MobileOSVersion getMobileOSVersion(String versionId)
|
||||||
throws MobileDeviceManagementDAOException {
|
throws MobileDeviceManagementDAOException {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -16,8 +16,67 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.dao.util;
|
package org.wso2.carbon.device.mgt.mobile.impl.dao.util;
|
||||||
|
|
||||||
|
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.mobile.impl.dao.MobileDeviceManagementDAOException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice;
|
||||||
|
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method required by MobileDeviceManagement DAO classes.
|
* Utility method required by MobileDeviceManagement DAO classes.
|
||||||
*/
|
*/
|
||||||
public class MobileDeviceManagementDAOUtil {
|
public class MobileDeviceManagementDAOUtil {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class);
|
||||||
|
|
||||||
|
public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) {
|
||||||
|
if (rs != null) {
|
||||||
|
try {
|
||||||
|
rs.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.warn("Error occurred while closing result set", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (stmt != null) {
|
||||||
|
try {
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.warn("Error occurred while closing prepared statement", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conn != null) {
|
||||||
|
try {
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.warn("Error occurred while closing database connection", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataSource lookupDataSource(String dataSourceName,
|
||||||
|
final Hashtable<Object, Object> jndiProperties) {
|
||||||
|
try {
|
||||||
|
if (jndiProperties == null || jndiProperties.isEmpty()) {
|
||||||
|
return (DataSource) InitialContext.doLookup(dataSourceName);
|
||||||
|
}
|
||||||
|
final InitialContext context = new InitialContext(jndiProperties);
|
||||||
|
return (DataSource) context.doLookup(dataSourceName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MobileDevice convertToMobileDevice(Device device)
|
||||||
|
throws MobileDeviceManagementDAOException {
|
||||||
|
MobileDevice mobileDeviceBO = new MobileDevice();
|
||||||
|
return mobileDeviceBO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,9 +21,15 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.osgi.framework.BundleActivator;
|
import org.osgi.framework.BundleActivator;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
import org.osgi.framework.ServiceRegistration;
|
import org.osgi.framework.ServiceRegistration;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
|
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.config.MobileDeviceConfigurationManager;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.config.MobileDeviceManagementConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
|
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.util.MobileDeviceManagementSchemaInitializer;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
|
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
|
||||||
|
|
||||||
public class MobileDeviceManagementBundleActivator implements BundleActivator {
|
public class MobileDeviceManagementBundleActivator implements BundleActivator {
|
||||||
@ -36,6 +42,25 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator {
|
|||||||
@Override
|
@Override
|
||||||
public void start(BundleContext bundleContext) throws Exception {
|
public void start(BundleContext bundleContext) throws Exception {
|
||||||
try {
|
try {
|
||||||
|
//Initialize Mobile Device Management datasource
|
||||||
|
MobileDeviceConfigurationManager.getInstance().initConfig();
|
||||||
|
MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance()
|
||||||
|
.getMobileDeviceManagementConfig();
|
||||||
|
MobileDataSourceConfig
|
||||||
|
dsConfig = config.getMobileDeviceMgtRepository().getMobileDataSourceConfig();
|
||||||
|
MobileDeviceManagementDAOFactory.init(dsConfig);
|
||||||
|
|
||||||
|
/* If -Dsetup option enabled then create device management database schema */
|
||||||
|
String setupOption = System.getProperty("setup");
|
||||||
|
if (setupOption != null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug(
|
||||||
|
"-Dsetup is enabled. Mobile Device management repository schema initialization is about " +
|
||||||
|
"to begin");
|
||||||
|
}
|
||||||
|
setupMobileDeviceManagementSchema(dsConfig);
|
||||||
|
}
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Activating Mobile Device Management Service bundle");
|
log.debug("Activating Mobile Device Management Service bundle");
|
||||||
}
|
}
|
||||||
@ -52,7 +77,22 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator {
|
|||||||
log.debug("Mobile Device Management Service bundle is activated");
|
log.debug("Mobile Device Management Service bundle is activated");
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("Error occurred while activating Mobile Device Management Service Component", e);
|
log.error("Error occurred while activating Mobile Device Management Service Component",
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupMobileDeviceManagementSchema(MobileDataSourceConfig config) throws
|
||||||
|
DeviceManagementException {
|
||||||
|
MobileDeviceManagementSchemaInitializer initializer =
|
||||||
|
new MobileDeviceManagementSchemaInitializer(config);
|
||||||
|
log.info("Initializing mobile device management repository database schema");
|
||||||
|
try {
|
||||||
|
initializer.createRegistryDatabase();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new DeviceManagementException(
|
||||||
|
"Error occurred while initializing Mobile Device Management " +
|
||||||
|
"database schema", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,23 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* software distributed under the License is distributed on an
|
*
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* KIND, either express or implied. See the License for the
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* specific language governing permissions and limitations
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* under the License.
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.util;
|
package org.wso2.carbon.device.mgt.mobile.impl.util;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
|
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||||
import org.wso2.carbon.utils.CarbonUtils;
|
import org.wso2.carbon.utils.CarbonUtils;
|
||||||
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
|
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
|
||||||
|
|
||||||
@ -25,12 +26,13 @@ import java.io.File;
|
|||||||
|
|
||||||
public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreator {
|
public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreator {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(DeviceManagementSchemaInitializer.class);
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementSchemaInitializer.class);
|
||||||
private static final String setupSQLScriptBaseLocation =
|
private static final String setupSQLScriptBaseLocation =
|
||||||
CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator + "cdm" + File.separator;
|
CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator + "cdm" +
|
||||||
|
File.separator + "plugins";
|
||||||
|
|
||||||
public MobileDeviceManagementSchemaInitializer(DataSourceConfig config) {
|
public MobileDeviceManagementSchemaInitializer(MobileDataSourceConfig config) {
|
||||||
super(DeviceManagerUtil.resolveDataSource(config));
|
super(MobileDeviceManagerUtil.resolveDataSource(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getDbScriptLocation(String databaseType) {
|
protected String getDbScriptLocation(String databaseType) {
|
||||||
|
|||||||
@ -1,7 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Licensed 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.impl.util;
|
package org.wso2.carbon.device.mgt.mobile.impl.util;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.JNDILookupDefinition;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDeviceManagementDAOUtil;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by harshan on 12/15/14.
|
* Created by harshan on 12/15/14.
|
||||||
*/
|
*/
|
||||||
public class MobileDeviceManagerUtil {
|
public class MobileDeviceManagerUtil {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(MobileDeviceManagerUtil.class);
|
||||||
|
|
||||||
|
public static Document convertToDocument(File file) throws DeviceManagementException {
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
factory.setNamespaceAware(true);
|
||||||
|
try {
|
||||||
|
DocumentBuilder docBuilder = factory.newDocumentBuilder();
|
||||||
|
return docBuilder.parse(file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new DeviceManagementException(
|
||||||
|
"Error occurred while parsing file, while converting " +
|
||||||
|
"to a org.w3c.dom.Document : " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve data source from the data source definition
|
||||||
|
*
|
||||||
|
* @param config data source configuration
|
||||||
|
* @return data source resolved from the data source definition
|
||||||
|
*/
|
||||||
|
public static DataSource resolveDataSource(MobileDataSourceConfig config) {
|
||||||
|
DataSource dataSource = null;
|
||||||
|
if (config == null) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Mobile Device Management Repository data source configuration " +
|
||||||
|
"is null and thus, is not initialized");
|
||||||
|
}
|
||||||
|
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||||
|
if (jndiConfig != null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug(
|
||||||
|
"Initializing Mobile Device Management Repository data source using the JNDI " +
|
||||||
|
"Lookup Definition");
|
||||||
|
}
|
||||||
|
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
|
||||||
|
jndiConfig.getJndiProperties();
|
||||||
|
if (jndiPropertyList != null) {
|
||||||
|
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
||||||
|
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||||
|
jndiProperties.put(prop.getName(), prop.getValue());
|
||||||
|
}
|
||||||
|
dataSource =
|
||||||
|
MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(),
|
||||||
|
jndiProperties);
|
||||||
|
} else {
|
||||||
|
dataSource = MobileDeviceManagementDAOUtil
|
||||||
|
.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataSource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ Licensed 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<MobileDeviceMgtConfiguration>
|
||||||
|
<ManagementRepository>
|
||||||
|
<DataSourceConfiguration>
|
||||||
|
<JndiLookupDefinition>
|
||||||
|
<Name>jdbc/WSO2MOBILE_DB</Name>
|
||||||
|
</JndiLookupDefinition>
|
||||||
|
</DataSourceConfiguration>
|
||||||
|
</ManagementRepository>
|
||||||
|
</MobileDeviceMgtConfiguration>
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
instructions.configure = \
|
||||||
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\
|
||||||
@ -50,6 +50,9 @@ public class Device {
|
|||||||
} finally {
|
} finally {
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
|
if(log.isDebugEnabled()){
|
||||||
|
log.debug("Get all devices");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (dmService != null) {
|
if (dmService != null) {
|
||||||
result = dmService.getAllDevices(
|
result = dmService.getAllDevices(
|
||||||
@ -85,6 +88,9 @@ public class Device {
|
|||||||
DeviceManagementService dmService;
|
DeviceManagementService dmService;
|
||||||
org.wso2.carbon.device.mgt.common.Device device =
|
org.wso2.carbon.device.mgt.common.Device device =
|
||||||
new org.wso2.carbon.device.mgt.common.Device();
|
new org.wso2.carbon.device.mgt.common.Device();
|
||||||
|
if(log.isDebugEnabled()){
|
||||||
|
log.debug("Get device id : " + id);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
dmService = AndroidAPIUtils.getDeviceManagementService();
|
dmService = AndroidAPIUtils.getDeviceManagementService();
|
||||||
} finally {
|
} finally {
|
||||||
@ -130,6 +136,9 @@ public class Device {
|
|||||||
} finally {
|
} finally {
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
|
if(log.isDebugEnabled()){
|
||||||
|
log.debug("Update device id : " + id + ", payload : " + jsonPayload);
|
||||||
|
}
|
||||||
org.wso2.carbon.device.mgt.common.Device device =
|
org.wso2.carbon.device.mgt.common.Device device =
|
||||||
AndroidAPIUtils.convertToDeviceObject(jsonPayload);
|
AndroidAPIUtils.convertToDeviceObject(jsonPayload);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -48,6 +48,9 @@ public class Enrollment {
|
|||||||
} finally {
|
} finally {
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
|
if(log.isDebugEnabled()){
|
||||||
|
log.debug("Device Enroll >>> " + jsonPayload);
|
||||||
|
}
|
||||||
Device device = AndroidAPIUtils.convertToDeviceObject(jsonPayload);
|
Device device = AndroidAPIUtils.convertToDeviceObject(jsonPayload);
|
||||||
try {
|
try {
|
||||||
if (dmService != null) {
|
if (dmService != null) {
|
||||||
@ -86,6 +89,9 @@ public class Enrollment {
|
|||||||
} finally {
|
} finally {
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
|
if(log.isDebugEnabled()){
|
||||||
|
log.debug("Device is enrolled >>> " + id);
|
||||||
|
}
|
||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
try {
|
try {
|
||||||
if (dmService != null) {
|
if (dmService != null) {
|
||||||
@ -124,6 +130,9 @@ public class Enrollment {
|
|||||||
} finally {
|
} finally {
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
|
if(log.isDebugEnabled()){
|
||||||
|
log.debug("Modify Enrollment >>> id : " + id + ", payload : " + jsonPayload);
|
||||||
|
}
|
||||||
Device device = AndroidAPIUtils.convertToDeviceObject(jsonPayload);
|
Device device = AndroidAPIUtils.convertToDeviceObject(jsonPayload);
|
||||||
try {
|
try {
|
||||||
if (dmService != null) {
|
if (dmService != null) {
|
||||||
@ -162,6 +171,9 @@ public class Enrollment {
|
|||||||
} finally {
|
} finally {
|
||||||
PrivilegedCarbonContext.endTenantFlow();
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
}
|
}
|
||||||
|
if(log.isDebugEnabled()){
|
||||||
|
log.debug("DisenrollDevice >>> id : " + id );
|
||||||
|
}
|
||||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
try {
|
try {
|
||||||
if (dmService != null) {
|
if (dmService != null) {
|
||||||
|
|||||||
@ -328,6 +328,15 @@
|
|||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
|
|
||||||
|
<!--cdm plugin config file-->
|
||||||
|
<file>
|
||||||
|
<source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/mobile-config.xml
|
||||||
|
</source>
|
||||||
|
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf</outputDirectory>
|
||||||
|
<filtered>true</filtered>
|
||||||
|
<fileMode>644</fileMode>
|
||||||
|
</file>
|
||||||
|
|
||||||
|
|
||||||
<file>
|
<file>
|
||||||
<source>
|
<source>
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<datasources>
|
<datasources>
|
||||||
<datasource>
|
<datasource>
|
||||||
<name>WSO2DEVICE_DB</name>
|
<name>WSO2DEVICE_DB</name>
|
||||||
<description>The datasource used for EMM</description>
|
<description>The datasource used for CDM</description>
|
||||||
<jndiConfig>
|
<jndiConfig>
|
||||||
<name>jdbc/WSO2DEVICE_DB</name>
|
<name>jdbc/WSO2DEVICE_DB</name>
|
||||||
</jndiConfig>
|
</jndiConfig>
|
||||||
@ -24,5 +24,25 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</definition>
|
</definition>
|
||||||
</datasource>
|
</datasource>
|
||||||
|
<datasource>
|
||||||
|
<name>WSO2MOBILE_DB</name>
|
||||||
|
<description>The datasource used for CDM Mobile Device Management</description>
|
||||||
|
<jndiConfig>
|
||||||
|
<name>jdbc/WSO2MOBILE_DB</name>
|
||||||
|
</jndiConfig>
|
||||||
|
<definition type="RDBMS">
|
||||||
|
<configuration>
|
||||||
|
<url>jdbc:h2:repository/database/WSO2MOBILE_DB;DB_CLOSE_ON_EXIT=FALSE</url>
|
||||||
|
<username>wso2carbon</username>
|
||||||
|
<password>wso2carbon</password>
|
||||||
|
<driverClassName>org.h2.Driver</driverClassName>
|
||||||
|
<maxActive>50</maxActive>
|
||||||
|
<maxWait>60000</maxWait>
|
||||||
|
<testOnBorrow>true</testOnBorrow>
|
||||||
|
<validationQuery>SELECT 1</validationQuery>
|
||||||
|
<validationInterval>30000</validationInterval>
|
||||||
|
</configuration>
|
||||||
|
</definition>
|
||||||
|
</datasource>
|
||||||
</datasources>
|
</datasources>
|
||||||
</datasources-configuration>
|
</datasources-configuration>
|
||||||
|
|||||||
@ -0,0 +1,38 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS MBL_OS_VERSION
|
||||||
|
(
|
||||||
|
VERSION_ID INT NOT NULL AUTO_INCREMENT,
|
||||||
|
NAME VARCHAR(45) NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (VERSION_ID)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS MBL_DEVICE_MODEL
|
||||||
|
(
|
||||||
|
MODEL_ID INT NOT NULL AUTO_INCREMENT,
|
||||||
|
MODEL VARCHAR(45) NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (MODEL_ID)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS MBL_VENDOR
|
||||||
|
(
|
||||||
|
VENDOR_ID INT NOT NULL AUTO_INCREMENT,
|
||||||
|
VENDOR VARCHAR(45) NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (VENDOR_ID)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS MBL_DEVICE
|
||||||
|
(
|
||||||
|
MOBILE_DEVICE_ID VARCHAR(45) NOT NULL,
|
||||||
|
REG_ID VARCHAR(45) NOT NULL,
|
||||||
|
IMEI VARCHAR(45) NOT NULL,
|
||||||
|
IMSI VARCHAR(45) NOT NULL,
|
||||||
|
OS_VERSION_ID INT NOT NULL,
|
||||||
|
DEVICE_MODEL_ID INT NOT NULL,
|
||||||
|
VENDOR_ID INT NOT NULL,
|
||||||
|
PRIMARY KEY (MOBILE_DEVICE_ID),
|
||||||
|
CONSTRAINT fk_DEVICE_OS_VERSION1 FOREIGN KEY (OS_VERSION_ID )
|
||||||
|
REFERENCES MBL_OS_VERSION (VERSION_ID ) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT fk_DEVICE_DEVICE_MODEL2 FOREIGN KEY (DEVICE_MODEL_ID )
|
||||||
|
REFERENCES MBL_DEVICE_MODEL (MODEL_ID ) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT fk_DEVICE_VENDOR1 FOREIGN KEY (VENDOR_ID )
|
||||||
|
REFERENCES MBL_VENDOR (VENDOR_ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
|
);
|
||||||
@ -45,17 +45,17 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
|||||||
INDEX `fk_DEVICE_VENDOR1_idx` (`VENDOR_ID` ASC),
|
INDEX `fk_DEVICE_VENDOR1_idx` (`VENDOR_ID` ASC),
|
||||||
CONSTRAINT `fk_DEVICE_OS_VERSION1`
|
CONSTRAINT `fk_DEVICE_OS_VERSION1`
|
||||||
FOREIGN KEY (`OS_VERSION_ID`)
|
FOREIGN KEY (`OS_VERSION_ID`)
|
||||||
REFERENCES `mydb`.`MBL_OS_VERSION` (`VERSION_ID`)
|
REFERENCES `MBL_OS_VERSION` (`VERSION_ID`)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION,
|
ON UPDATE NO ACTION,
|
||||||
CONSTRAINT `fk_DEVICE_DEVICE_MODEL2`
|
CONSTRAINT `fk_DEVICE_DEVICE_MODEL2`
|
||||||
FOREIGN KEY (`DEVICE_MODEL_ID`)
|
FOREIGN KEY (`DEVICE_MODEL_ID`)
|
||||||
REFERENCES `mydb`.`MBL_DEVICE_MODEL` (`MODEL_ID`)
|
REFERENCES `MBL_DEVICE_MODEL` (`MODEL_ID`)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION,
|
ON UPDATE NO ACTION,
|
||||||
CONSTRAINT `fk_DEVICE_VENDOR1`
|
CONSTRAINT `fk_DEVICE_VENDOR1`
|
||||||
FOREIGN KEY (`VENDOR_ID`)
|
FOREIGN KEY (`VENDOR_ID`)
|
||||||
REFERENCES `mydb`.`MBL_VENDOR` (`VENDOR_ID`)
|
REFERENCES `MBL_VENDOR` (`VENDOR_ID`)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION)
|
ON UPDATE NO ACTION)
|
||||||
ENGINE = InnoDB;
|
ENGINE = InnoDB;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user