Create pluin level databases

merge-requests/1/head
manoj 10 years ago
commit 2ece5764d3

@ -66,7 +66,6 @@
org.wso2.carbon.core,
org.wso2.carbon.utils.*,
org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.apimgt.*;
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.mobile.internal,
@ -117,14 +116,6 @@
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.api</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>

@ -28,15 +28,13 @@ import java.util.List;
public abstract class AbstractMobileOperationManager implements OperationManager {
@Override
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
throws OperationManagementException {
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
return null;
}
@Override
public boolean addOperation(Operation operation,
List<DeviceIdentifier> devices)
throws OperationManagementException {
List<DeviceIdentifier> devices) throws OperationManagementException {
return true;
}

@ -1,87 +0,0 @@
/*
* 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;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.api.APIProvider;
import org.wso2.carbon.apimgt.impl.APIManagerFactory;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.config.APIConfig;
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager;
import org.wso2.carbon.device.mgt.mobile.util.DeviceManagementAPIPublisherUtil;
import java.util.List;
public class MobileDeviceManagementStartupObserver implements ServerStartupObserver {
private static final Log log = LogFactory.getLog(MobileDeviceManagementStartupObserver.class);
public void completingServerStartup() {
}
public void completedServerStartup() {
try {
this.initAPIConfigs();
/* Publish all mobile device management related JAX-RS services as APIs */
this.publishAPIs();
} catch (DeviceManagementException e) {
log.error("Error occurred while publishing Mobile Device Management related APIs", e);
}
}
private void initAPIConfigs() throws DeviceManagementException {
if (log.isDebugEnabled()) {
log.debug("Initializing Mobile Device Management related APIs");
}
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) {
try {
APIProvider provider =
APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner());
apiConfig.init(provider);
} catch (APIManagementException e) {
throw new DeviceManagementException("Error occurred while initializing API Config '" +
apiConfig.getName() + "'", e);
}
}
}
private void publishAPIs() throws DeviceManagementException {
if (log.isDebugEnabled()) {
log.debug("Publishing Mobile Device Management related APIs");
}
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) {
DeviceManagementAPIPublisherUtil.publishAPI(apiConfig);
if (log.isDebugEnabled()) {
log.debug("Successfully published API '" + apiConfig.getName() + "' with the context '" +
apiConfig.getContext() + "' and version '" + apiConfig.getVersion() + "'");
}
}
}
}

@ -1,101 +0,0 @@
/*
* 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
* 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.config;
import org.wso2.carbon.apimgt.api.APIProvider;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
@XmlRootElement(name = "API")
public class APIConfig {
private String name;
private String owner;
private String context;
private String endpoint;
private String version;
private String transports;
private APIProvider provider;
public void init(APIProvider provider) {
this.provider = provider;
}
@XmlTransient
public APIProvider getProvider() {
return provider;
}
@XmlElement(name = "Name", nillable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlElement(name = "Owner", nillable = false)
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
@XmlElement(name = "Context", nillable = false)
public String getContext() {
return context;
}
public void setContext(String context) {
this.context = context;
}
@XmlElement(name = "Endpoint", nillable = false)
public String getEndpoint() {
return endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
@XmlElement(name = "Version", nillable = false)
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
@XmlElement(name = "Transports", nillable = false)
public String getTransports() {
return transports;
}
public void setTransports(String transports) {
this.transports = transports;
}
}

@ -1,41 +0,0 @@
/*
* 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
* 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.config;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "APIPublisher")
public class APIPublisherConfig {
private List<APIConfig> apis;
@XmlElementWrapper(name = "APIs", nillable = false, required = true)
@XmlElement(name = "API", nillable = false)
public List<APIConfig> getAPIs() {
return apis;
}
public void setAPIs(List<APIConfig> apis) {
this.apis = apis;
}
}

@ -28,7 +28,6 @@ import javax.xml.bind.annotation.XmlRootElement;
public final class MobileDeviceManagementConfig {
private MobileDeviceManagementRepository mobileDeviceMgtRepository;
private APIPublisherConfig apiPublisherConfig;
@XmlElement(name = "ManagementRepository", nillable = false)
public MobileDeviceManagementRepository getMobileDeviceMgtRepository() {
@ -40,13 +39,4 @@ public final class MobileDeviceManagementConfig {
this.mobileDeviceMgtRepository = mobileDeviceMgtRepository;
}
@XmlElement(name = "APIPublisher")
public APIPublisherConfig getApiPublisherConfig() {
return apiPublisherConfig;
}
public void setApiPublisherConfig(APIPublisherConfig apiPublisherConfig) {
this.apiPublisherConfig = apiPublisherConfig;
}
}

@ -54,7 +54,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
conn = this.getConnection();
String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE" +
"LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM AD_DEVICE" +
" WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, mblDeviceId);
@ -98,7 +98,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_DEVICE(MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION," +
"INSERT INTO AD_DEVICE(MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION," +
"DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, " +
"UNLOCK_TOKEN) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
@ -144,7 +144,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_DEVICE SET PUSH_TOKEN = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," +
"UPDATE AD_DEVICE SET PUSH_TOKEN = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," +
"DEVICE_MODEL = ?, VENDOR = ? , LATITUDE = ?, LONGITUDE = ?, CHALLENGE = ?," +
"SERIAL = ?, TOKEN = ?, UNLOCK_TOKEN = ? WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
@ -188,7 +188,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?";
"DELETE FROM AD_DEVICE WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, mblDeviceId);
int rows = stmt.executeUpdate();
@ -219,7 +219,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
conn = this.getConnection();
String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR," +
"LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE";
"LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM AD_DEVICE";
stmt = conn.prepareStatement(selectDBQuery);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {

@ -55,7 +55,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_DEVICE_OPERATION_MAPPING (DEVICE_ID, OPERATION_ID, SENT_DATE, " +
"INSERT INTO AD_DEVICE_OPERATION_MAPPING (DEVICE_ID, OPERATION_ID, SENT_DATE, " +
"RECEIVED_DATE, STATUS) VALUES (?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
@ -77,7 +77,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
String msg = "Error occurred while adding device id - '" +
mblDeviceOperationMapping.getDeviceId() + " and operation id - " +
mblDeviceOperationMapping.getOperationId() +
" to mapping table MBL_DEVICE_OPERATION";
" to mapping table AD_DEVICE_OPERATION";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
@ -95,7 +95,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, " +
"UPDATE AD_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, " +
"STATUS = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setLong(1, mblDeviceOperation.getSentDate());
@ -132,7 +132,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, STATUS = ? " +
"UPDATE AD_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, STATUS = ? " +
"WHERE DEVICE_ID = ? AND OPERATION_ID=?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setLong(1, new Date().getTime());
@ -170,7 +170,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_DEVICE_OPERATION_MAPPING SET RECEIVED_DATE = ?, STATUS = ? " +
"UPDATE AD_DEVICE_OPERATION_MAPPING SET RECEIVED_DATE = ?, STATUS = ? " +
"WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setLong(1, new Date().getTime());
@ -207,7 +207,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND " +
"DELETE FROM AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND " +
"OPERATION_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, mblDeviceId);
@ -222,7 +222,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
}
} catch (SQLException e) {
String msg =
"Error occurred while deleting the table entry MBL_DEVICE_OPERATION with " +
"Error occurred while deleting the table entry AD_DEVICE_OPERATION with " +
" device id - '" + mblDeviceId + " and operation id - " + operationId;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
@ -243,7 +243,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
conn = this.getConnection();
String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " +
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
"AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, mblDeviceId);
stmt.setInt(2, operationId);
@ -285,7 +285,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
conn = this.getConnection();
String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " +
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?";
"AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, mblDeviceId);
ResultSet resultSet = stmt.executeQuery();
@ -327,7 +327,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
conn = this.getConnection();
String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM" +
" MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND STATUS = ?";
" AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND STATUS = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, mblDeviceId);
stmt.setString(2, MobileDeviceOperationMapping.Status.NEW.name());

@ -54,7 +54,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_FEATURE(CODE, NAME, DESCRIPTION, DEVICE_TYPE) VALUES (?, ?, ?, ?)";
"INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION, DEVICE_TYPE) VALUES (?, ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, mobileFeature.getCode());
@ -67,7 +67,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
if (rs != null && rs.next()) {
status = rs.getInt(1);
}
if (log.isDebugEnabled()) {
if (log.isDebugEnabled()) {
log.debug("Added a new MobileFeature " + mobileFeature.getCode() + " to the" +
" MDM database.");
}
@ -92,7 +92,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ?, DEVICE_TYPE = ?" +
"UPDATE AD_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ?, DEVICE_TYPE = ?" +
" WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, mobileFeature.getCode());
@ -127,7 +127,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_FEATURE WHERE CODE = ?";
"DELETE FROM AD_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, mblFeatureCode);
int rows = stmt.executeUpdate();
@ -157,7 +157,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_FEATURE WHERE FEATURE_ID = ?";
"DELETE FROM AD_FEATURE WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, mblFeatureId);
int rows = stmt.executeUpdate();
@ -187,7 +187,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE " +
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE " +
"WHERE CODE = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, mblFeatureCode);
@ -224,7 +224,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE" +
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE" +
" WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, mblFeatureId);
@ -261,7 +261,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE";
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE";
stmt = conn.prepareStatement(selectDBQuery);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
@ -296,7 +296,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE" +
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE" +
" WHERE DEVICE_TYPE = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceType);

@ -54,7 +54,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)";
"INSERT INTO AD_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, mblFeatureProperty.getProperty());
@ -87,7 +87,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?";
"UPDATE AD_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setInt(1, mblFeatureProperty.getFeatureID());
stmt.setString(2, mblFeatureProperty.getProperty());
@ -118,7 +118,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?";
"DELETE FROM AD_FEATURE_PROPERTY WHERE PROPERTY = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, property);
int rows = stmt.executeUpdate();
@ -148,7 +148,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
"DELETE FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, mblFeatureId);
int rows = stmt.executeUpdate();
@ -179,7 +179,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?";
"SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE PROPERTY = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, property);
ResultSet resultSet = stmt.executeQuery();
@ -213,7 +213,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
"SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, mblFeatureId);
ResultSet resultSet = stmt.executeQuery();

@ -53,7 +53,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)";
"INSERT INTO AD_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)";
stmt = conn.prepareStatement(createDBQuery, new String[] { COLUMN_OPERATION_ID });
stmt.setString(1, mblOperation.getFeatureCode());
stmt.setLong(2, mblOperation.getCreatedDate());
@ -88,7 +88,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE " +
"UPDATE AD_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE " +
"OPERATION_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, mblOperation.getFeatureCode());
@ -123,7 +123,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_OPERATION WHERE OPERATION_ID = ?";
"DELETE FROM AD_OPERATION WHERE OPERATION_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, mblOperationId);
int rows = stmt.executeUpdate();
@ -153,7 +153,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE " +
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM AD_OPERATION WHERE " +
"OPERATION_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, mblOperationId);

@ -54,7 +54,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) " +
"INSERT INTO AD_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) " +
"VALUES ( ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setInt(1, mblOperationProperty.getOperationId());
@ -90,7 +90,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
try {
conn = this.getConnection();
String createDBQuery =
"UPDATE MBL_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND " +
"UPDATE AD_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND " +
"PROPERTY = ?";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, mblOperationProperty.getValue());
@ -125,7 +125,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
"DELETE FROM AD_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, mblOperationId);
int rows = stmt.executeUpdate();
@ -158,7 +158,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " +
"SELECT OPERATION_ID, PROPERTY, VALUE FROM AD_OPERATION_PROPERTY WHERE " +
"OPERATION_ID = ? AND PROPERTY = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, mblOperationId);
@ -197,7 +197,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " +
"SELECT OPERATION_ID, PROPERTY, VALUE FROM AD_OPERATION_PROPERTY WHERE " +
"OPERATION_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, mblOperationId);

@ -78,6 +78,10 @@ public class MobileDeviceManagementDAOUtil {
}
}
public static void cleanupResources(PreparedStatement stmt, ResultSet rs) {
cleanupResources(null, stmt, rs);
}
/**
* Creates the mobile device management schema.
*

@ -33,12 +33,12 @@ import java.util.List;
/**
* This represents the Android implementation of DeviceManagerService.
*/
public class AndroidDeviceManagerService implements DeviceManager {
public class AndroidDeviceManager implements DeviceManager {
private static final Log log = LogFactory.getLog(AndroidDeviceManagerService.class);
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
private static final Log log = LogFactory.getLog(AndroidDeviceManager.class);
public AndroidDeviceManagerService() {
public AndroidDeviceManager() {
mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
}
@ -50,7 +50,7 @@ public class AndroidDeviceManagerService implements DeviceManager {
@Override
public FeatureManager getFeatureManager() {
return null;
return new AndroidFeatureManager();
}
@Override

@ -0,0 +1,96 @@
/*
* 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.impl.android;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.FeatureManagementException;
import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureDAO;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOFactory;
import java.util.List;
public class AndroidFeatureManager implements FeatureManager {
private FeatureDAO featureDAO;
private static final Log log = LogFactory.getLog(AndroidFeatureManager.class);
public AndroidFeatureManager() {
this.featureDAO = FeatureManagementDAOFactory.getFeatureDAO();
}
@Override
public boolean addFeature(Feature feature) throws DeviceManagementException {
try {
FeatureManagementDAOFactory.beginTransaction();
featureDAO.addFeature(feature);
FeatureManagementDAOFactory.commitTransaction();
return true;
} catch (FeatureManagementDAOException e) {
try {
FeatureManagementDAOFactory.rollbackTransaction();
} catch (FeatureManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e);
}
throw new DeviceManagementException("Error occurred while adding the feature", e);
}
}
@Override
public Feature getFeature(String name) throws DeviceManagementException {
try {
FeatureManagementDAOFactory.beginTransaction();
Feature feature = featureDAO.getFeature(name);
FeatureManagementDAOFactory.commitTransaction();
return feature;
} catch (FeatureManagementDAOException e) {
try {
FeatureManagementDAOFactory.rollbackTransaction();
} catch (FeatureManagementDAOException e1) {
log.warn("Error occurred while roll-backing the transaction", e);
}
throw new DeviceManagementException("Error occurred while retrieving the feature", e);
}
}
@Override
public List<Feature> getFeatures() throws DeviceManagementException {
try {
return featureDAO.getFeatures();
} catch (FeatureManagementDAOException e) {
throw new DeviceManagementException("Error occurred while retrieving the list of features registered " +
"for Android platform", e);
}
}
@Override
public boolean removeFeature(String name) throws DeviceManagementException {
try {
featureDAO.removeFeature(name);
return true;
} catch (FeatureManagementDAOException e) {
throw new DeviceManagementException("Error occurred while removing the feature", e);
}
}
}

@ -0,0 +1,35 @@
/*
* 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.impl.android.dao;
import org.wso2.carbon.device.mgt.common.Feature;
import java.util.List;
public interface FeatureDAO {
void addFeature(Feature feature) throws FeatureManagementDAOException;
void removeFeature(String name) throws FeatureManagementDAOException;
Feature getFeature(String name) throws FeatureManagementDAOException;
List<Feature> getFeatures() throws FeatureManagementDAOException;
}

@ -0,0 +1,77 @@
/*
* 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.impl.android.dao;
public class FeatureManagementDAOException extends Exception {
private String message;
private static final long serialVersionUID = 2021891706072918865L;
/**
* Constructs a new MobileDeviceManagementDAOException with the specified detail message and
* nested exception.
*
* @param message error message
* @param nestedException exception
*/
public FeatureManagementDAOException(String message, Exception nestedException) {
super(message, nestedException);
setErrorMessage(message);
}
/**
* Constructs a new MobileDeviceManagementDAOException with the specified detail message
* and cause.
*
* @param message the detail message.
* @param cause the cause of this exception.
*/
public FeatureManagementDAOException(String message, Throwable cause) {
super(message, cause);
setErrorMessage(message);
}
/**
* Constructs a new MobileDeviceManagementDAOException with the specified detail message.
*
* @param message the detail message.
*/
public FeatureManagementDAOException(String message) {
super(message);
setErrorMessage(message);
}
/**
* Constructs a new MobileDeviceManagementDAOException with the specified and cause.
*
* @param cause the cause of this exception.
*/
public FeatureManagementDAOException(Throwable cause) {
super(cause);
}
public String getMessage() {
return message;
}
public void setErrorMessage(String errorMessage) {
this.message = errorMessage;
}
}

@ -0,0 +1,93 @@
/*
* 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.impl.android.dao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.impl.FeatureDAOImpl;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
public class FeatureManagementDAOFactory {
private static DataSource dataSource;
private static ThreadLocal<Connection> currentConnection = new ThreadLocal<Connection>();
private static final Log log = LogFactory.getLog(FeatureManagementDAOFactory.class);
public static FeatureDAO getFeatureDAO() {
return new FeatureDAOImpl();
}
public static void init(DataSource dtSource) {
dataSource = dtSource;
}
public static void beginTransaction() throws FeatureManagementDAOException {
try {
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
currentConnection.set(conn);
} catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while retrieving datasource connection", e);
}
}
public static Connection getConnection() {
return currentConnection.get();
}
public static void commitTransaction() throws FeatureManagementDAOException {
try {
Connection conn = currentConnection.get();
if (conn != null) {
conn.commit();
} else {
if (log.isDebugEnabled()) {
log.debug("Datasource connection associated with the current thread is null, hence commit " +
"has not been attempted");
}
}
} catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while committing the transaction", e);
}
}
public static void rollbackTransaction() throws FeatureManagementDAOException {
try {
Connection conn = currentConnection.get();
if (conn != null) {
conn.rollback();
} else {
if (log.isDebugEnabled()) {
log.debug("Datasource connection associated with the current thread is null, hence rollback " +
"has not been attempted");
}
}
} catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while rollbacking the transaction", e);
}
}
public static DataSource getDataSource() {
return dataSource;
}
}

@ -0,0 +1,128 @@
/*
* 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.impl.android.dao.impl;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureDAO;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.android.dao.FeatureManagementDAOFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class FeatureDAOImpl implements FeatureDAO {
@Override
public void addFeature(Feature feature) throws FeatureManagementDAOException {
PreparedStatement stmt = null;
try {
Connection conn = FeatureManagementDAOFactory.getConnection();
String sql = "INSERT INTO MBL_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
stmt = conn.prepareStatement(sql);
stmt.setString(1, feature.getCode());
stmt.setString(2, feature.getName());
stmt.setString(3, feature.getDescription());
stmt.executeUpdate();
} catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while adding feature '" +
feature.getName() + "' into the metadata repository", e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public void removeFeature(String code) throws FeatureManagementDAOException {
PreparedStatement stmt = null;
try {
Connection conn = FeatureManagementDAOFactory.getConnection();
String sql = "DELETE FROM MBL_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, code);
stmt.execute();
} catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while adding feature '" +
code + "' into the metadata repository", e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
}
}
@Override
public Feature getFeature(String code) throws FeatureManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
try {
Connection conn = FeatureManagementDAOFactory.getConnection();
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(sql);
stmt.setString(1, code);
rs = stmt.executeQuery();
Feature feature = null;
if (rs.next()) {
feature = new Feature();
feature.setId(rs.getInt("ID"));
feature.setCode(rs.getString("CODE"));
feature.setName(rs.getString("NAME"));
feature.setDescription(rs.getString("DESCRIPTION"));
}
return feature;
} catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while retrieving feature metadata '" +
code + "' from the feature metadata repository", e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
}
@Override
public List<Feature> getFeatures() throws FeatureManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
List<Feature> features = new ArrayList<Feature>();
try {
Connection conn = FeatureManagementDAOFactory.getConnection();
String sql = "SELECT ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE";
stmt = conn.prepareStatement(sql);
rs = stmt.executeQuery();
while (rs.next()) {
Feature feature = new Feature();
feature.setId(rs.getInt("ID"));
feature.setCode(rs.getString("CODE"));
feature.setName(rs.getString("NAME"));
feature.setDescription(rs.getString("DESCRIPTION"));
}
return features;
} catch (SQLException e) {
throw new FeatureManagementDAOException("Error occurred while retrieving all feature metadata from the " +
"feature metadata repository", e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
}
}

@ -32,17 +32,17 @@ import java.util.List;
/**
* This represents the iOS implementation of DeviceManagerService.
*/
public class IOSDeviceManagerService implements DeviceManager {
public class IOSDeviceManager implements DeviceManager {
private static final Log log = LogFactory.getLog(IOSDeviceManagerService.class);
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
private static final Log log = LogFactory.getLog(IOSDeviceManager.class);
@Override
public String getProviderType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS;
}
public IOSDeviceManagerService() {
public IOSDeviceManager() {
mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(DeviceManagementConstants
.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS);
}

@ -32,8 +32,9 @@ import java.util.List;
/**
* This represents the Windows implementation of DeviceManagerService.
*/
public class WindowsDeviceManagerService implements DeviceManager {
public class WindowsDeviceManager implements DeviceManager {
<<<<<<< HEAD:components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagerService.java
private static final Log log = LogFactory.getLog(WindowsDeviceManagerService.class);
private MobileDeviceManagementDAOFactory mobileDeviceManagementDAOFactory;
@ -41,6 +42,9 @@ public class WindowsDeviceManagerService implements DeviceManager {
mobileDeviceManagementDAOFactory = new MobileDeviceManagementDAOFactory(DeviceManagementConstants
.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
}
=======
private static final Log log = LogFactory.getLog(WindowsDeviceManager.class);
>>>>>>> 2c5cc4c28de5586b7450887d02c49a4c9973b40a:components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManager.java
@Override
public String getProviderType() {

@ -21,21 +21,15 @@ package org.wso2.carbon.device.mgt.mobile.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.*;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.api.APIProvider;
import org.wso2.carbon.apimgt.impl.APIManagerFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
import org.wso2.carbon.device.mgt.mobile.DataSourceListener;
import org.wso2.carbon.device.mgt.mobile.config.APIConfig;
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager;
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig;
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.util.DeviceManagementAPIPublisherUtil;
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManager;
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManager;
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManager;
import java.util.ArrayList;
import java.util.List;
@ -76,18 +70,13 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
androidServiceRegRef =
bundleContext.registerService(DeviceManager.class.getName(),
new AndroidDeviceManagerService(), null);
new AndroidDeviceManager(), null);
iOSServiceRegRef =
bundleContext.registerService(DeviceManager.class.getName(),
new IOSDeviceManagerService(), null);
new IOSDeviceManager(), null);
windowsServiceRegRef =
bundleContext.registerService(DeviceManager.class.getName(),
new WindowsDeviceManagerService(), null);
/* Initialize all API configurations with corresponding API Providers */
this.initAPIConfigs();
/* Publish all mobile device management related JAX-RS services as APIs */
this.publishAPIs();
new WindowsDeviceManager(), null);
if (log.isDebugEnabled()) {
log.debug("Mobile Device Management Service bundle is activated");
@ -108,10 +97,6 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
windowsServiceRegRef.unregister();
bundleContext.removeBundleListener(this);
/* Removing all APIs published upon start-up for mobile device management related JAX-RS
services */
this.removeAPIs();
} catch (Throwable e) {
log.error("Error occurred while de-activating Mobile Device Management bundle", e);
}
@ -138,39 +123,5 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
return dataSourceListeners;
}
private void initAPIConfigs() throws DeviceManagementException {
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) {
try {
APIProvider provider =
APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner());
apiConfig.init(provider);
} catch (APIManagementException e) {
throw new DeviceManagementException(
"Error occurred while initializing API Config '" +
apiConfig.getName() + "'", e);
}
}
}
private void publishAPIs() throws DeviceManagementException {
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) {
DeviceManagementAPIPublisherUtil.publishAPI(apiConfig);
}
}
private void removeAPIs() throws DeviceManagementException {
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) {
DeviceManagementAPIPublisherUtil.removeAPI(apiConfig);
}
}
}

@ -23,35 +23,23 @@ import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
import org.wso2.carbon.device.mgt.mobile.MobileDeviceManagementStartupObserver;
import org.wso2.carbon.device.mgt.mobile.config.APIConfig;
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager;
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig;
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.util.DeviceManagementAPIPublisherUtil;
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManager;
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManager;
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManager;
import javax.sql.DataSource;
import java.util.List;
import java.util.Map;
/**
* @scr.component name="org.wso2.carbon.device.mgt.mobile.impl.internal.MobileDeviceManagementServiceComponent"
* immediate="true"
* @scr.reference name="api.manager.config.service"
* interface="org.wso2.carbon.apimgt.impl.APIManagerConfigurationService"
* cardinality="1..1"
* policy="dynamic"
* bind="setAPIManagerConfigurationService"
* unbind="unsetAPIManagerConfigurationService"
* <p/>
* Adding reference to API Manager Configuration service is an unavoidable hack to get rid of NPEs thrown while
* initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up
@ -59,25 +47,25 @@ import java.util.Map;
*/
public class MobileDeviceManagementServiceComponent {
private ServiceRegistration androidServiceRegRef;
private ServiceRegistration iOSServiceRegRef;
private ServiceRegistration windowsServiceRegRef;
private ServiceRegistration serverStartupObserverRef;
private ServiceRegistration androidServiceRegRef;
private ServiceRegistration iOSServiceRegRef;
private ServiceRegistration windowsServiceRegRef;
private ServiceRegistration serverStartupObserverRef;
private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class);
private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class);
protected void activate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("Activating Mobile Device Management Service Component");
}
try {
BundleContext bundleContext = ctx.getBundleContext();
protected void activate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("Activating Mobile Device Management Service Component");
}
try {
BundleContext bundleContext = ctx.getBundleContext();
/* Initialize the data source configuration */
MobileDeviceConfigurationManager.getInstance().initConfig();
MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance()
.getMobileDeviceManagementConfig();
Map<String,MobileDataSourceConfig> dsConfigMap =
Map<String, MobileDataSourceConfig> dsConfigMap =
config.getMobileDeviceMgtRepository().getMobileDataSourceConfigMap();
MobileDeviceManagementDAOFactory.setMobileDataSourceConfigMap(dsConfigMap);
@ -90,8 +78,8 @@ public class MobileDeviceManagementServiceComponent {
"to begin");
}
try {
Map<String,DataSource> dataSourceMap = MobileDeviceManagementDAOFactory.getDataSourceMap();
for(DataSource dataSource:dataSourceMap.values()) {
Map<String, DataSource> dataSourceMap = MobileDeviceManagementDAOFactory.getDataSourceMap();
for (DataSource dataSource : dataSourceMap.values()) {
MobileDeviceManagementDAOUtil
.setupMobileDeviceManagementSchema(dataSource);
}
@ -101,17 +89,12 @@ public class MobileDeviceManagementServiceComponent {
}
androidServiceRegRef =
bundleContext.registerService(DeviceManager.class.getName(),
new AndroidDeviceManagerService(), null);
bundleContext.registerService(DeviceManager.class.getName(), new AndroidDeviceManager(), null);
iOSServiceRegRef =
bundleContext.registerService(DeviceManager.class.getName(),
new IOSDeviceManagerService(), null);
bundleContext.registerService(DeviceManager.class.getName(), new IOSDeviceManager(), null);
windowsServiceRegRef =
bundleContext.registerService(DeviceManager.class.getName(),
new WindowsDeviceManagerService(), null);
bundleContext.registerService(DeviceManager.class.getName(), new WindowsDeviceManager(), null);
serverStartupObserverRef = bundleContext.registerService(ServerStartupObserver.class,
new MobileDeviceManagementStartupObserver(), null);
if (log.isDebugEnabled()) {
log.debug("Mobile Device Management Service Component has been successfully activated");
}
@ -130,33 +113,13 @@ public class MobileDeviceManagementServiceComponent {
windowsServiceRegRef.unregister();
serverStartupObserverRef.unregister();
/* Removing all APIs published upon start-up for mobile device management related JAX-RS
services */
this.removeAPIs();
if (log.isDebugEnabled()) {
log.debug(
"Mobile Device Management Service Component has been successfully de-activated");
}
} catch (Throwable e) {
log.error("Error occurred while de-activating Mobile Device Management bundle", e);
}
}
private void removeAPIs() throws DeviceManagementException {
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) {
DeviceManagementAPIPublisherUtil.removeAPI(apiConfig);
}
}
protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) {
//do nothing
}
protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) {
//do nothing
}
if (log.isDebugEnabled()) {
log.debug(
"Mobile Device Management Service Component has been successfully de-activated");
}
} catch (Throwable e) {
log.error("Error occurred while de-activating Mobile Device Management bundle", e);
}
}
}

@ -1,112 +0,0 @@
/*
* 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.util;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.api.APIProvider;
import org.wso2.carbon.apimgt.api.model.API;
import org.wso2.carbon.apimgt.api.model.APIIdentifier;
import org.wso2.carbon.apimgt.api.model.APIStatus;
import org.wso2.carbon.apimgt.api.model.URITemplate;
import org.wso2.carbon.apimgt.impl.APIConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.config.APIConfig;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
public class DeviceManagementAPIPublisherUtil {
enum HTTPMethod {
GET, POST, DELETE, PUT, OPTIONS
}
private static List<HTTPMethod> httpMethods;
static {
httpMethods = new ArrayList<HTTPMethod>();
httpMethods.add(HTTPMethod.GET);
httpMethods.add(HTTPMethod.POST);
httpMethods.add(HTTPMethod.DELETE);
httpMethods.add(HTTPMethod.PUT);
httpMethods.add(HTTPMethod.OPTIONS);
}
public static void publishAPI(APIConfig config) throws DeviceManagementException {
APIProvider provider = config.getProvider();
APIIdentifier id = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion());
API api = new API(id);
try {
api.setContext(config.getContext());
api.setUrl(config.getVersion());
api.setUriTemplates(getURITemplates(config.getEndpoint(),
APIConstants.AUTH_APPLICATION_OR_USER_LEVEL_TOKEN));
api.setVisibility(APIConstants.API_GLOBAL_VISIBILITY);
api.addAvailableTiers(provider.getTiers());
api.setEndpointSecured(false);
api.setStatus(APIStatus.PUBLISHED);
api.setTransports(config.getTransports());
provider.addAPI(api);
} catch (APIManagementException e) {
throw new DeviceManagementException("Error occurred while registering the API", e);
}
}
public static void removeAPI(APIConfig config) throws DeviceManagementException {
try {
APIProvider provider = config.getProvider();
APIIdentifier id = new APIIdentifier(config.getOwner(), config.getName(), config.getVersion());
provider.deleteAPI(id);
} catch (APIManagementException e) {
throw new DeviceManagementException("Error occurred while removing API", e);
}
}
private static Set<URITemplate> getURITemplates(String endpoint, String authType) {
Set<URITemplate> uriTemplates = new LinkedHashSet<URITemplate>();
if (APIConstants.AUTH_NO_AUTHENTICATION.equals(authType)) {
for (HTTPMethod method : httpMethods) {
URITemplate template = new URITemplate();
template.setAuthType(APIConstants.AUTH_NO_AUTHENTICATION);
template.setHTTPVerb(method.toString());
template.setResourceURI(endpoint);
template.setUriTemplate("/*");
uriTemplates.add(template);
}
} else {
for (HTTPMethod method : httpMethods) {
URITemplate template = new URITemplate();
if (HTTPMethod.OPTIONS.equals(method)) {
template.setAuthType(APIConstants.AUTH_NO_AUTHENTICATION);
} else {
template.setAuthType(APIConstants.AUTH_APPLICATION_OR_USER_LEVEL_TOKEN);
}
template.setHTTPVerb(method.toString());
template.setResourceURI(endpoint);
template.setUriTemplate("/*");
uriTemplates.add(template);
}
}
return uriTemplates;
}
}

@ -0,0 +1,98 @@
-- -----------------------------------------------------
-- Table AD_DEVICE
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AD_FEATURE(
ID INTEGER NOT NULL,
CODE VARCHAR(50) NOT NULL,
NAME VARCHAR(100) NOT NULL,
DESCRIPTION VARCHAR(200) NOT NULL,
)
-- -----------------------------------------------------
-- Table AD_DEVICE
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AD_DEVICE (
MOBILE_DEVICE_ID VARCHAR(45) NOT NULL ,
PUSH_TOKEN VARCHAR(45) NULL DEFAULT NULL ,
IMEI VARCHAR(45) NULL DEFAULT NULL ,
IMSI VARCHAR(45) NULL DEFAULT NULL ,
OS_VERSION VARCHAR(45) NULL DEFAULT NULL ,
DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL ,
VENDOR VARCHAR(45) NULL DEFAULT NULL ,
LATITUDE VARCHAR(45) NULL DEFAULT NULL,
LONGITUDE VARCHAR(45) NULL DEFAULT NULL,
CHALLENGE VARCHAR(45) NULL DEFAULT NULL,
TOKEN VARCHAR(500) NULL DEFAULT NULL,
UNLOCK_TOKEN VARCHAR(500) NULL DEFAULT NULL,
SERIAL VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (MOBILE_DEVICE_ID) );
-- -----------------------------------------------------
-- Table AD_FEATURE
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AD_FEATURE (
FEATURE_ID INT NOT NULL AUTO_INCREMENT ,
CODE VARCHAR(45) NOT NULL,
NAME VARCHAR(100) NULL ,
DESCRIPTION VARCHAR(200) NULL ,
DEVICE_TYPE VARCHAR(50) NULL ,
PRIMARY KEY (FEATURE_ID) );
-- -----------------------------------------------------
-- Table AD_OPERATION
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AD_OPERATION (
OPERATION_ID INT NOT NULL AUTO_INCREMENT ,
FEATURE_CODE VARCHAR(45) NOT NULL ,
CREATED_DATE BIGINT NULL ,
PRIMARY KEY (OPERATION_ID));
-- -----------------------------------------------------
-- Table AD_DEVICE_OPERATION_MAPPING
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AD_DEVICE_OPERATION_MAPPING (
DEVICE_ID VARCHAR(45) NOT NULL ,
OPERATION_ID INT NOT NULL ,
SENT_DATE BIGINT NULL ,
RECEIVED_DATE BIGINT NULL ,
STATUS VARCHAR(10) NOT NULL ,
PRIMARY KEY (DEVICE_ID, OPERATION_ID) ,
CONSTRAINT fk_AD_DEVICE_OPERATION_AD_DEVICE
FOREIGN KEY (DEVICE_ID )
REFERENCES AD_DEVICE (MOBILE_DEVICE_ID )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_AD_DEVICE_OPERATION_AD_OPERATION1
FOREIGN KEY (OPERATION_ID )
REFERENCES AD_OPERATION (OPERATION_ID )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table AD_OPERATION_PROPERTY
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AD_OPERATION_PROPERTY (
OPERATION_ID INT NOT NULL ,
PROPERTY VARCHAR(45) NOT NULL ,
VALUE TEXT NULL ,
PRIMARY KEY (OPERATION_ID, PROPERTY) ,
CONSTRAINT fk_AD_OPERATION_PROPERTY_AD_OPERATION1
FOREIGN KEY (OPERATION_ID )
REFERENCES AD_OPERATION (OPERATION_ID )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table AD_FEATURE_PROPERTY
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS AD_FEATURE_PROPERTY (
PROPERTY VARCHAR(45) NOT NULL ,
FEATURE_ID INT NOT NULL ,
PRIMARY KEY (PROPERTY) ,
CONSTRAINT fk_AD_FEATURE_PROPERTY_AD_FEATURE1
FOREIGN KEY (FEATURE_ID )
REFERENCES AD_FEATURE (FEATURE_ID )
ON DELETE NO ACTION
ON UPDATE NO ACTION);

@ -85,8 +85,7 @@ public class MobileDeviceDAOTestSuite {
}
@Test
public void addMobileDeviceTest()
throws MobileDeviceManagementDAOException {
public void addMobileDeviceTest() throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement preparedStatement = null;
@ -111,7 +110,7 @@ public class MobileDeviceDAOTestSuite {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " +
"LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM AD_DEVICE " +
"WHERE MOBILE_DEVICE_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
@ -209,8 +208,7 @@ public class MobileDeviceDAOTestSuite {
@Test(dependsOnMethods = { "addMobileDeviceTest", "getMobileDeviceTest",
"getAllMobileDevicesTest" })
public void updateMobileDeviceTest()
throws MobileDeviceManagementDAOException {
public void updateMobileDeviceTest() throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement preparedStatement = null;
@ -235,7 +233,7 @@ public class MobileDeviceDAOTestSuite {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " +
"LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM AD_DEVICE " +
"WHERE MOBILE_DEVICE_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
@ -279,7 +277,7 @@ public class MobileDeviceDAOTestSuite {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " +
"LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM AD_DEVICE " +
"WHERE MOBILE_DEVICE_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
@ -296,4 +294,5 @@ public class MobileDeviceDAOTestSuite {
}
Assert.assertTrue(deleted, "MobileDevice has deleted ");
}
}

@ -155,7 +155,7 @@ public class MobileDeviceOperationMappingDAOTestSuite {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " +
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?";
"AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
ResultSet resultSet = preparedStatement.executeQuery();
@ -252,7 +252,7 @@ public class MobileDeviceOperationMappingDAOTestSuite {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, STATUS FROM " +
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
"AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
preparedStatement.setInt(2, mblOperationId1);
@ -296,7 +296,7 @@ public class MobileDeviceOperationMappingDAOTestSuite {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, RECEIVED_DATE, STATUS FROM " +
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
"AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
preparedStatement.setInt(2, mblOperationId1);
@ -348,7 +348,7 @@ public class MobileDeviceOperationMappingDAOTestSuite {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, RECEIVED_DATE, SENT_DATE, STATUS FROM " +
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
"AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
preparedStatement.setInt(2, mblOperationId1);
@ -422,7 +422,7 @@ public class MobileDeviceOperationMappingDAOTestSuite {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, RECEIVED_DATE, SENT_DATE, STATUS FROM " +
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
"AD_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
preparedStatement.setInt(2, mblOperationId1);

@ -91,7 +91,7 @@ public class MobileFeatureDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE WHERE CODE = ?";
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE WHERE CODE = ?";
preparedStatement = conn.prepareStatement(query);
preparedStatement.setString(1, MBL_FEATURE_CODE);
ResultSet resultSet = preparedStatement.executeQuery();
@ -174,7 +174,7 @@ public class MobileFeatureDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = ?";
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(query);
stmt.setString(1, MBL_FEATURE_UPDATED_CODE);
ResultSet resultSet = stmt.executeQuery();
@ -207,7 +207,7 @@ public class MobileFeatureDAOTestSuite {
boolean status = mblFeatureDAO.deleteMobileFeatureById(mblFeatureId);
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query = "SELECT FEATURE_ID, CODE FROM MBL_FEATURE WHERE FEATURE_ID = ?";
String query = "SELECT FEATURE_ID, CODE FROM AD_FEATURE WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(query);
stmt.setInt(1, mblFeatureId);
ResultSet resultSet = stmt.executeQuery();
@ -240,7 +240,7 @@ public class MobileFeatureDAOTestSuite {
boolean status = mblFeatureDAO.deleteMobileFeatureByCode(MBL_FEATURE_CODE);
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query = "SELECT FEATURE_ID, CODE FROM MBL_FEATURE WHERE CODE = ?";
String query = "SELECT FEATURE_ID, CODE FROM AD_FEATURE WHERE CODE = ?";
preparedStatement = conn.prepareStatement(query);
preparedStatement.setString(1, MBL_FEATURE_CODE);
ResultSet resultSet = preparedStatement.executeQuery();

@ -107,7 +107,7 @@ public class MobileFeaturePropertyDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query =
"SELECT FEATURE_ID, PROPERTY FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
"SELECT FEATURE_ID, PROPERTY FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
preparedStatement = conn.prepareStatement(query);
preparedStatement.setInt(1, mblFeatureId);
ResultSet resultSet = preparedStatement.executeQuery();
@ -187,7 +187,7 @@ public class MobileFeaturePropertyDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query =
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?";
"SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE PROPERTY = ?";
preparedStatement = conn.prepareStatement(query);
preparedStatement.setString(1, MBL_FEATURE_PROP_2);
ResultSet resultSet = preparedStatement.executeQuery();
@ -217,7 +217,7 @@ public class MobileFeaturePropertyDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String query =
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
"SELECT PROPERTY, FEATURE_ID FROM AD_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
preparedStatement = conn.prepareStatement(query);
preparedStatement.setInt(1, mblFeatureId);
ResultSet resultSet = preparedStatement.executeQuery();

@ -83,7 +83,7 @@ public class MobileOperationDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?";
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM AD_OPERATION WHERE OPERATION_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setInt(1, mblOperationId);
ResultSet resultSet = preparedStatement.executeQuery();
@ -133,7 +133,7 @@ public class MobileOperationDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?";
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM AD_OPERATION WHERE OPERATION_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setInt(1, mblOperationId);
ResultSet resultSet = preparedStatement.executeQuery();
@ -167,7 +167,7 @@ public class MobileOperationDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?";
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM AD_OPERATION WHERE OPERATION_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setInt(1, mblOperationId);
ResultSet resultSet = preparedStatement.executeQuery();

@ -111,7 +111,7 @@ public class MobileOperationPropertyDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
"SELECT OPERATION_ID, PROPERTY, VALUE FROM AD_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setInt(1, mblOperationId);
ResultSet resultSet = preparedStatement.executeQuery();
@ -181,7 +181,7 @@ public class MobileOperationPropertyDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE" +
"SELECT OPERATION_ID, PROPERTY, VALUE FROM AD_OPERATION_PROPERTY WHERE" +
" OPERATION_ID = ? AND PROPERTY = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setInt(1, mblOperationId);
@ -217,7 +217,7 @@ public class MobileOperationPropertyDAOTestSuite {
try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery =
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE" +
"SELECT OPERATION_ID, PROPERTY, VALUE FROM AD_OPERATION_PROPERTY WHERE" +
" OPERATION_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setInt(1, mblOperationId);

@ -103,7 +103,7 @@ public class MobileDatabaseUtils {
Class.forName(testDBConf.getDriverClassName());
conn = DriverManager.getConnection(testDBConf.getConnectionURL());
stmt = conn.createStatement();
stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'");
stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/h2.sql'");
} finally {
cleanupResources(conn, stmt, null);
}

@ -2,7 +2,7 @@
-- -----------------------------------------------------
-- Table `MBL_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
CREATE TABLE IF NOT EXISTS `AD_DEVICE` (
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL ,
`PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL ,
`IMEI` VARCHAR(45) NULL DEFAULT NULL ,
@ -20,9 +20,9 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
-- -----------------------------------------------------
-- Table `MBL_FEATURE`
-- Table `AD_FEATURE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
CREATE TABLE IF NOT EXISTS `AD_FEATURE` (
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
`CODE` VARCHAR(45) NOT NULL,
`NAME` VARCHAR(100) NULL ,
@ -31,58 +31,58 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
PRIMARY KEY (`FEATURE_ID`) );
-- -----------------------------------------------------
-- Table `MBL_OPERATION`
-- Table `AD_OPERATION`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
CREATE TABLE IF NOT EXISTS `AD_OPERATION` (
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
`FEATURE_CODE` VARCHAR(45) NOT NULL ,
`CREATED_DATE` BIGINT NULL ,
PRIMARY KEY (`OPERATION_ID`));
-- -----------------------------------------------------
-- Table `MBL_DEVICE_OPERATION_MAPPING`
-- Table `AD_DEVICE_OPERATION_MAPPING`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
CREATE TABLE IF NOT EXISTS `AD_DEVICE_OPERATION_MAPPING` (
`DEVICE_ID` VARCHAR(45) NOT NULL ,
`OPERATION_ID` INT NOT NULL ,
`SENT_DATE` BIGINT NULL ,
`RECEIVED_DATE` BIGINT NULL ,
`STATUS` VARCHAR(10) NOT NULL ,
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
CONSTRAINT `fk_AD_DEVICE_OPERATION_AD_DEVICE`
FOREIGN KEY (`DEVICE_ID` )
REFERENCES `MBL_DEVICE` (`MOBILE_DEVICE_ID` )
REFERENCES `AD_DEVICE` (`MOBILE_DEVICE_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1`
CONSTRAINT `fk_AD_DEVICE_OPERATION_AD_OPERATION1`
FOREIGN KEY (`OPERATION_ID` )
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
REFERENCES `AD_OPERATION` (`OPERATION_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `MBL_OPERATION_PROPERTY`
-- Table `AD_OPERATION_PROPERTY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
CREATE TABLE IF NOT EXISTS `AD_OPERATION_PROPERTY` (
`OPERATION_ID` INT NOT NULL ,
`PROPERTY` VARCHAR(45) NOT NULL ,
`VALUE` TEXT NULL ,
PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) ,
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
CONSTRAINT `fk_AD_OPERATION_PROPERTY_AD_OPERATION1`
FOREIGN KEY (`OPERATION_ID` )
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
REFERENCES `AD_OPERATION` (`OPERATION_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `MBL_FEATURE_PROPERTY`
-- Table `AD_FEATURE_PROPERTY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
CREATE TABLE IF NOT EXISTS `AD_FEATURE_PROPERTY` (
`PROPERTY` VARCHAR(45) NOT NULL ,
`FEATURE_ID` INT NOT NULL ,
PRIMARY KEY (`PROPERTY`) ,
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
CONSTRAINT `fk_AD_FEATURE_PROPERTY_AD_FEATURE1`
FOREIGN KEY (`FEATURE_ID` )
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
REFERENCES `AD_FEATURE` (`FEATURE_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);

@ -0,0 +1,93 @@
-- -----------------------------------------------------
-- Table `MBL_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL ,
`PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL ,
`IMEI` VARCHAR(45) NULL DEFAULT NULL ,
`IMSI` VARCHAR(45) NULL DEFAULT NULL ,
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
`VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
`CHALLENGE` VARCHAR(45) NULL DEFAULT NULL,
`TOKEN` VARCHAR(50) NULL DEFAULT NULL,
`UNLOCK_TOKEN` VARCHAR(2000) NULL DEFAULT NULL,
`SERIAL` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`) );
-- -----------------------------------------------------
-- Table `MBL_FEATURE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
`DEVICE_TYPE` VARCHAR(45) NOT NULL ,
`CODE` VARCHAR(45) NOT NULL ,
`NAME` VARCHAR(100) NULL ,
`DESCRIPTION` VARCHAR(200) NULL ,
PRIMARY KEY (`FEATURE_ID`) );
-- -----------------------------------------------------
-- Table `MBL_OPERATION`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
`FEATURE_CODE` VARCHAR(45) NOT NULL ,
`CREATED_DATE` BIGINT NULL ,
PRIMARY KEY (`OPERATION_ID`));
-- -----------------------------------------------------
-- Table `MBL_DEVICE_OPERATION_MAPPING`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
`DEVICE_ID` VARCHAR(45) NOT NULL ,
`OPERATION_ID` INT NOT NULL ,
`SENT_DATE` BIGINT NULL ,
`RECEIVED_DATE` BIGINT NULL ,
`STATUS` VARCHAR(10) NOT NULL ,
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
FOREIGN KEY (`DEVICE_ID` )
REFERENCES `MBL_DEVICE` (`MOBILE_DEVICE_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1`
FOREIGN KEY (`OPERATION_ID` )
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `MBL_OPERATION_PROPERTY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
`OPERATION_ID` INT NOT NULL ,
`PROPERTY` VARCHAR(45) NOT NULL ,
`VALUE` TEXT NULL ,
PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) ,
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
FOREIGN KEY (`OPERATION_ID` )
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `MBL_FEATURE_PROPERTY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
`PROPERTY` VARCHAR(45) NOT NULL ,
`FEATURE_ID` INT NOT NULL ,
PRIMARY KEY (`PROPERTY`) ,
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
FOREIGN KEY (`FEATURE_ID` )
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Inserts
-- -----------------------------------------------------
INSERT INTO MBL_FEATURE (DEVICE_TYPE,NAME,CODE, DESCRIPTION) VALUES ('android','DEVICE_LOCK','503A','Device Lock'),('android','WIPE','504A','Device Wipe'),('android','CLEARPASSCODE','505A','Clear Passcode'),('android','APPLIST','502A','Get All Applications'),('android','LOCATION','501A','Location'),('android','INFO','500A','Device Information'),('android','NOTIFICATION','506A','Message'),('android','WIFI','507A','Setup Wifi'),('android','CAMERA','508A','Camera Control'),('android','MUTE','513A','Mute Device'),('android','INSTALLAPP','509A','Install Application'),('android','UNINSTALLAPP','510A','Uninstall Application'),('android','ENCRYPT','511A','Encrypt Storage'),('android','APN','512A','APN'),('android','WEBCLIP','518A','Create Webclips'),('android','PASSWORDPOLICY','519A','Passcode Policy'),('android','EMAIL','520A','Email Configuration'),('android','GOOGLECALENDAR','521A','Calender Subscription'),('android','VPN','523A','VPN'),('android','LDAP','524A','LDAP'),('android','CHANGEPASSWORD','526A','Set Passcode'),('android','ENTERPRISEWIPE','527A','Enterprise Wipe'),('android','POLICY','500P','Policy Enforcement'),('android','MONITORING','501P','Policy Monitoring '),('android','BLACKLISTAPPS','528B','Blacklist Apps'),('android','REVOKEPOLICY','502P','Revoke Policy');

@ -0,0 +1,103 @@
-- -----------------------------------------------------
-- Table `MBL_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL,
`PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL,
`IMEI` VARCHAR(45) NULL DEFAULT NULL,
`IMSI` VARCHAR(45) NULL DEFAULT NULL,
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL,
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL,
`VENDOR` VARCHAR(45) NULL DEFAULT NULL,
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
`CHALLENGE` VARCHAR(45) NULL DEFAULT NULL,
`TOKEN` VARCHAR(50) NULL DEFAULT NULL,
`UNLOCK_TOKEN` VARCHAR(2000) NULL DEFAULT NULL,
`SERIAL` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_FEATURE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT,
`DEVICE_TYPE` VARCHAR(45) NOT NULL ,
`CODE` VARCHAR(45) NULL,
`NAME` VARCHAR(100) NULL,
`DESCRIPTION` VARCHAR(200) NULL,
PRIMARY KEY (`FEATURE_ID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_OPERATION`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT,
`FEATURE_CODE` VARCHAR(45) NULL,
`CREATED_DATE` INT NULL,
PRIMARY KEY (`OPERATION_ID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_DEVICE_OPERATION_MAPING`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
`DEVICE_ID` VARCHAR(45) NOT NULL,
`OPERATION_ID` INT NOT NULL,
`SENT_DATE` INT NULL,
`RECEIVED_DATE` INT NULL,
`STATUS` VARCHAR(10) NOT NULL,
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`),
INDEX `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1_idx` (`OPERATION_ID` ASC),
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
FOREIGN KEY (`DEVICE_ID`)
REFERENCES `MBL_DEVICE` (`MOBILE_DEVICE_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1`
FOREIGN KEY (`OPERATION_ID`)
REFERENCES `MBL_OPERATION` (`OPERATION_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_OPERATION_PROPERTY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
`OPERATION_ID` INT NULL,
`PROPERTY` VARCHAR(45) NOT NULL ,,
`VALUE` TEXT NULL,
PRIMARY KEY (`OPERATION_ID`, `PROPERTY`),
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
FOREIGN KEY (`OPERATION_ID`)
REFERENCES `MBL_OPERATION` (`OPERATION_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_FEATURE_PROPERTY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
`PROPERTY` VARCHAR(45) NOT NULL ,
`FEATURE_ID` INT NOT NULL ,
PRIMARY KEY (`PROPERTY`),
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
FOREIGN KEY (`FEATURE_ID`)
REFERENCES `MBL_FEATURE` (`FEATURE_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Inserts
-- -----------------------------------------------------
INSERT INTO MBL_FEATURE (DEVICE_TYPE,NAME,CODE, DESCRIPTION) VALUES ('android','DEVICE_LOCK','503A','Device Lock'),('android','WIPE','504A','Device Wipe'),('android','CLEARPASSCODE','505A','Clear Passcode'),('android','APPLIST','502A','Get All Applications'),('android','LOCATION','501A','Location'),('android','INFO','500A','Device Information'),('android','NOTIFICATION','506A','Message'),('android','WIFI','507A','Setup Wifi'),('android','CAMERA','508A','Camera Control'),('android','MUTE','513A','Mute Device'),('android','INSTALLAPP','509A','Install Application'),('android','UNINSTALLAPP','510A','Uninstall Application'),('android','ENCRYPT','511A','Encrypt Storage'),('android','APN','512A','APN'),('android','WEBCLIP','518A','Create Webclips'),('android','PASSWORDPOLICY','519A','Passcode Policy'),('android','EMAIL','520A','Email Configuration'),('android','GOOGLECALENDAR','521A','Calender Subscription'),('android','VPN','523A','VPN'),('android','LDAP','524A','LDAP'),('android','CHANGEPASSWORD','526A','Set Passcode'),('android','ENTERPRISEWIPE','527A','Enterprise Wipe'),('android','POLICY','500P','Policy Enforcement'),('android','MONITORING','501P','Policy Monitoring '),('android','BLACKLISTAPPS','528B','Blacklist Apps'),('android','REVOKEPOLICY','502P','Revoke Policy');

@ -1,2 +1,3 @@
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);\
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);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins,overwrite:true);\

@ -0,0 +1,47 @@
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java
index 719a38b..5a63eef 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java
@@ -28,15 +28,13 @@ import java.util.List;
public abstract class AbstractMobileOperationManager implements OperationManager {
@Override
- public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
- throws OperationManagementException {
+ public List<Operation> getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
return null;
}
@Override
public boolean addOperation(Operation operation,
- List<DeviceIdentifier> devices)
- throws OperationManagementException {
+ List<DeviceIdentifier> devices) throws OperationManagementException {
return true;
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java
index 17b347b..1aa3289 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/FeatureDAO.java
@@ -19,7 +19,6 @@
package org.wso2.carbon.device.mgt.mobile.impl.android.dao;
import org.wso2.carbon.device.mgt.common.Feature;
-import org.wso2.carbon.device.mgt.common.FeatureManagementException;
import java.util.List;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java
index 38280e2..6607600 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/ios/IOSMobileOperationManager.java
@@ -20,8 +20,6 @@ package org.wso2.carbon.device.mgt.mobile.impl.ios;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
-import org.wso2.carbon.device.mgt.common.Feature;
-import org.wso2.carbon.device.mgt.common.FeatureManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager;
Loading…
Cancel
Save