Conflicts:
	product/modules/p2-profile-gen/pom.xml
revert-dabc3590
manoj 10 years ago
commit d0603f3e0b

@ -61,7 +61,7 @@
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
!org.wso2.carbon.device.mgt.mobile.internal, !org.wso2.carbon.device.mgt.mobile.internal,
org.wso2.carbon.device.mgt.mobile.impl.* org.wso2.carbon.device.mgt.mobile.*
</Export-Package> </Export-Package>
<DynamicImport-Package>*</DynamicImport-Package> <DynamicImport-Package>*</DynamicImport-Package>
</instructions> </instructions>
@ -103,6 +103,16 @@
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.apimgt.core</artifactId> <artifactId>org.wso2.carbon.apimgt.core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -16,6 +16,7 @@
package org.wso2.carbon.device.mgt.mobile.config; package org.wso2.carbon.device.mgt.mobile.config;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.util.List; import java.util.List;
@ -24,12 +25,13 @@ public class APIPublisherConfig {
private List<APIConfig> apis; private List<APIConfig> apis;
@XmlElement(name = "APIs") @XmlElementWrapper(name = "APIs", nillable = false, required = true)
public List<APIConfig> getApis() { @XmlElement(name = "API", nillable = false)
public List<APIConfig> getAPIs() {
return apis; return apis;
} }
public void setApis(List<APIConfig> apis) { public void setAPIs(List<APIConfig> apis) {
this.apis = apis; this.apis = apis;
} }

@ -32,12 +32,13 @@ import java.io.File;
public class MobileDeviceConfigurationManager { public class MobileDeviceConfigurationManager {
private static final String MOBILE_DEVICE_CONFIG_XML_NAME = "mobile-config.xml"; private static final String MOBILE_DEVICE_CONFIG_XML_NAME = "mobile-config.xml";
private static final String MOBILE_DEVICE_PLUGIN_DIRECTORY = "mobile";
private MobileDeviceManagementConfig currentMobileDeviceConfig; private MobileDeviceManagementConfig currentMobileDeviceConfig;
private static MobileDeviceConfigurationManager mobileDeviceConfigManager; private static MobileDeviceConfigurationManager mobileDeviceConfigManager;
private final String mobileDeviceMgtConfigXMLPath = private final String mobileDeviceMgtConfigXMLPath =
CarbonUtils.getCarbonConfigDirPath() + File.separator + CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-mgt-plugin-configs" + File.separator +
MOBILE_DEVICE_CONFIG_XML_NAME; MOBILE_DEVICE_PLUGIN_DIRECTORY + File.separator + MOBILE_DEVICE_CONFIG_XML_NAME;
public static MobileDeviceConfigurationManager getInstance() { public static MobileDeviceConfigurationManager getInstance() {
if (mobileDeviceConfigManager == null) { if (mobileDeviceConfigManager == null) {

@ -0,0 +1,63 @@
package org.wso2.carbon.device.mgt.mobile.dao;
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation;
import java.util.List;
/**
* This class represents the mapping between device and operations.
*/
public interface DeviceOperationDAO {
/**
* Add a new mapping to plugin device_operation table.
*
* @param deviceOperation DeviceOperation object that holds data related to the DeviceOperation
* to be inserted.
* @return The status of the operation. If the insert was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean addDeviceOperation(DeviceOperation deviceOperation)
throws MobileDeviceManagementDAOException;
/**
* Update a feature in the feature table.
*
* @param deviceOperation DeviceOperation object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean updateDeviceOperation(DeviceOperation deviceOperation)
throws MobileDeviceManagementDAOException;
/**
* Delete a given device operation from device operation table.
*
* @param deviceId Device id of the mapping to be deleted.
* @param operationId Operation id of the mapping to be deleted.
* @return The status of the operation. If the deletion was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean deleteDeviceOperation(String deviceId, int operationId)
throws MobileDeviceManagementDAOException;
/**
* Retrieve a given device operation from plugin database.
*
* @param deviceId Device id of the mapping to be retrieved.
* @param operationId Operation id of the mapping to be retrieved.
* @return DeviceOperation object that holds data of the device operation mapping represented by
* deviceId and operationId.
* @throws MobileDeviceManagementDAOException
*/
DeviceOperation getDeviceOperation(String deviceId, int operationId)
throws MobileDeviceManagementDAOException;
/**
* Retrieve all the device operation mapping from plugin database.
*
* @return Device operation mapping object list.
* @throws MobileDeviceManagementDAOException
*/
List<DeviceOperation> getAllDeviceOperationOfDevice(String deviceId)
throws MobileDeviceManagementDAOException;
}

@ -0,0 +1,74 @@
package org.wso2.carbon.device.mgt.mobile.dao;
import org.wso2.carbon.device.mgt.mobile.dto.Feature;
import java.util.List;
/**
* This class represents the key operations associated with persisting feature related
* information.
*/
public interface FeatureDAO {
/**
* Add a new feature to feature table.
*
* @param feature Feature object that holds data related to the feature to be inserted.
* @return The status of the operation. If the insert was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean addFeature(Feature feature) throws MobileDeviceManagementDAOException;
/**
* Update a feature in the feature table.
*
* @param feature Feature object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean updateFeature(Feature feature) throws MobileDeviceManagementDAOException;
/**
* Delete a feature from feature table when the feature id is given.
*
* @param featureId Feature id of the feature to be deleted.
* @return The status of the operation. If the operationId was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean deleteFeatureById(String featureId) throws MobileDeviceManagementDAOException;
/**
* Delete a feature from feature table when the feature code is given.
*
* @param featureCode Feature code of the feature to be deleted.
* @return The status of the operation. If the operationId was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean deleteFeatureByCode(String featureCode) throws MobileDeviceManagementDAOException;
/**
* Retrieve a given feature from feature table when the feature id is given.
*
* @param featureId Feature id of the feature to be retrieved.
* @return Feature object that holds data of the feature represented by featureId.
* @throws MobileDeviceManagementDAOException
*/
Feature getFeatureById(String featureId) throws MobileDeviceManagementDAOException;
/**
* Retrieve a given feature from feature table when the feature code is given.
*
* @param featureCode Feature code of the feature to be retrieved.
* @return Feature object that holds data of the feature represented by featureCode.
* @throws MobileDeviceManagementDAOException
*/
Feature getFeatureByCode(String featureCode) throws MobileDeviceManagementDAOException;
/**
* Retrieve all the features from plugin specific database.
*
* @return Feature object list.
* @throws MobileDeviceManagementDAOException
*/
List<Feature> getAllFeatures() throws MobileDeviceManagementDAOException;
}

@ -0,0 +1,60 @@
package org.wso2.carbon.device.mgt.mobile.dao;
import org.wso2.carbon.device.mgt.mobile.dto.FeatureProperty;
import java.util.List;
/**
* This class represents the key operations associated with persisting feature property related
* information.
*/
public interface FeaturePropertyDAO {
/**
* Add a new feature property to feature property table.
*
* @param featureProperty Feature property object that holds data related to the feature property to be inserted.
* @return The status of the operation. If the insert was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean addFeatureProperty(FeatureProperty featureProperty)
throws MobileDeviceManagementDAOException;
/**
* Update a feature property in the feature property table.
*
* @param featureProperty Feature property object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean updateFeatureProperty(FeatureProperty featureProperty)
throws MobileDeviceManagementDAOException;
/**
* Delete a given feature property from feature property table.
*
* @param propertyId Id of the feature property to be deleted.
* @return The status of the operation. If the operationId was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean deleteFeatureProperty(int propertyId) throws MobileDeviceManagementDAOException;
/**
* Retrieve a given feature property from feature property table.
*
* @param propertyId Id of the feature property to be retrieved.
* @return Feature property object that holds data of the feature property represented by propertyId.
* @throws MobileDeviceManagementDAOException
*/
FeatureProperty getFeatureProperty(int propertyId) throws MobileDeviceManagementDAOException;
/**
* Retrieve a list of feature property corresponds to a feature id .
*
* @param featureId feature id of the feature property to be retrieved.
* @return Feature property object that holds data of the feature property represented by propertyId.
* @throws MobileDeviceManagementDAOException
*/
List<FeatureProperty> getFeaturePropertyOfFeature(String featureId)
throws MobileDeviceManagementDAOException;
}

@ -17,6 +17,7 @@
package org.wso2.carbon.device.mgt.mobile.dao; package org.wso2.carbon.device.mgt.mobile.dao;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import java.util.List;
/** /**
* This class represents the key operations associated with persisting mobile-device related * This class represents the key operations associated with persisting mobile-device related
@ -32,4 +33,6 @@ public interface MobileDeviceDAO {
boolean deleteDevice(String deviceId) throws MobileDeviceManagementDAOException; boolean deleteDevice(String deviceId) throws MobileDeviceManagementDAOException;
List<MobileDevice> getAllDevices() throws MobileDeviceManagementDAOException;
} }

@ -0,0 +1,45 @@
package org.wso2.carbon.device.mgt.mobile.dao;
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
import java.util.List;
/**
* This class represents the key operations associated with persisting operation related
* information.
*/
public interface OperationDAO {
/**
* Add a new operation to plugin operation table.
* @param operation Operation object that holds data related to the operation to be inserted.
* @return The status of the operation. If the insert was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean addOperation(Operation operation) throws MobileDeviceManagementDAOException;
/**
* Update a operation in the operation table.
* @param operation Operation object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean updateOperation(Operation operation) throws MobileDeviceManagementDAOException;
/**
* Delete a given operation from plugin database.
* @param operationId Operation code of the operation to be deleted.
* @return The status of the operation. If the operationId was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean deleteOperation(int operationId) throws MobileDeviceManagementDAOException;
/**
* Retrieve a given operation from plugin database.
* @param operationId Operation id of the operation to be retrieved.
* @return Operation object that holds data of the feature represented by operationId.
* @throws MobileDeviceManagementDAOException
*/
Operation getOperation(int operationId) throws MobileDeviceManagementDAOException;
}

@ -0,0 +1,61 @@
package org.wso2.carbon.device.mgt.mobile.dao;
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
import java.util.List;
/**
* This class represents the key operations associated with persisting operation property related
* information.
*/
public interface OperationPropertyDAO {
/**
* Add a new mapping to plugin operation property table.
*
* @param operationProperty OperationProperty object that holds data related to the operation property to be inserted.
* @return The status of the operation. If the insert was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean addOperationProperty(OperationProperty operationProperty)
throws MobileDeviceManagementDAOException;
/**
* Update a feature in the feature table.
*
* @param operationProperty DeviceOperation object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean updateOperationProperty(OperationProperty operationProperty)
throws MobileDeviceManagementDAOException;
/**
* Delete a given device operation from plugin database.
*
* @param operationPropertyId Device id of the mapping to be deleted.
* @return The status of the operation. If the deletion was successful or not.
* @throws MobileDeviceManagementDAOException
*/
boolean deleteOperationProperty(int operationPropertyId)
throws MobileDeviceManagementDAOException;
/**
* Retrieve a given device operation from plugin database.
*
* @param deviceId Device id of the mapping to be retrieved.
* @param operationId Operation id of the mapping to be retrieved.
* @return DeviceOperation object that holds data of the device operation mapping represented by deviceId and operationId.
* @throws MobileDeviceManagementDAOException
*/
OperationProperty getOperationProperty(String deviceId, int operationId)
throws MobileDeviceManagementDAOException;
/**
* Retrieve all the device operation mapping from plugin database.
*
* @return Device operation mapping object list.
* @throws MobileDeviceManagementDAOException
*/
List<OperationProperty> getAllDeviceOperationOfDevice(String deviceId)
throws MobileDeviceManagementDAOException;
}

@ -0,0 +1,196 @@
package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.DeviceOperationDAO;
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.dto.DeviceOperation;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* Implementation of DeviceOperationDAO
*/
public class DeviceOperationDAOImpl implements DeviceOperationDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(DeviceOperationDAOImpl.class);
public DeviceOperationDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public boolean addDeviceOperation(DeviceOperation deviceOperation)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_DEVICE_OPERATION(DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE) VALUES (?, ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, deviceOperation.getDeviceId());
stmt.setInt(2, deviceOperation.getOperationId());
stmt.setInt(3, deviceOperation.getSentDate());
stmt.setInt(4, deviceOperation.getReceivedDate());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while adding device id - '" +
deviceOperation.getDeviceId() + " and operation id - " + deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean updateDeviceOperation(DeviceOperation deviceOperation)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? and OPERATION_ID=?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setInt(1, deviceOperation.getSentDate());
stmt.setInt(2, deviceOperation.getReceivedDate());
stmt.setString(3, deviceOperation.getDeviceId());
stmt.setInt(4, deviceOperation.getOperationId());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while updating device id - '" +
deviceOperation.getDeviceId() + " and operation id - " + deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean deleteDeviceOperation(String deviceId, int operationId)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? and OPERATION_ID=?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, deviceId);
stmt.setInt(2, operationId);
int rows = stmt.executeUpdate();
if(rows>0){
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while deleting mapping table MBL_DEVICE_OPERATION with device id - '" +
deviceId + " and operation id - " + operationId;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public DeviceOperation getDeviceOperation(String deviceId, int operationId)
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
DeviceOperation deviceOperation = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? and OPERATION_ID=?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId);
stmt.setInt(2, operationId);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
deviceOperation = new DeviceOperation();
deviceOperation.setDeviceId(resultSet.getString(1));
deviceOperation.setOperationId(resultSet.getInt(2));
deviceOperation.setSentDate(resultSet.getInt(3));
deviceOperation.setReceivedDate(resultSet.getInt(4));
break;
}
} catch (SQLException e) {
String msg = "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" +
deviceId + " and operation id - " + operationId;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return deviceOperation;
}
@Override
public List<DeviceOperation> getAllDeviceOperationOfDevice(String deviceId)
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
DeviceOperation deviceOperation = null;
List<DeviceOperation> deviceOperations=new ArrayList<DeviceOperation>();
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
deviceOperation = new DeviceOperation();
deviceOperation.setDeviceId(resultSet.getString(1));
deviceOperation.setOperationId(resultSet.getInt(2));
deviceOperation.setSentDate(resultSet.getInt(3));
deviceOperation.setReceivedDate(resultSet.getInt(4));
deviceOperations.add(deviceOperation);
break;
}
} catch (SQLException e) {
String msg = "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" +
deviceId;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return deviceOperations;
}
private Connection getConnection() throws MobileDeviceManagementDAOException {
try {
return dataSource.getConnection();
} catch (SQLException e) {
String msg = "Error occurred while obtaining a connection from the mobile device " +
"management metadata repository datasource.";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
}
}
}

@ -0,0 +1,245 @@
package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.FeatureDAO;
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.dto.Feature;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* Implementation of FeatureDAO
*/
public class FeatureDAOImpl implements FeatureDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(FeatureDAOImpl.class);
public FeatureDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public boolean addFeature(Feature feature) throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_FEATURE(CODE, NAME, DESCRIPTION) VALUES (?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, feature.getCode());
stmt.setString(2, feature.getName());
stmt.setString(3, feature.getDescription());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while adding feature code - '" +
feature.getCode() + "' to feature table";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean updateFeature(Feature feature)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ? WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, feature.getCode());
stmt.setString(2, feature.getName());
stmt.setString(3, feature.getDescription());
stmt.setInt(4, feature.getId());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while updating the feature with feature code - '" +
feature.getId() + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean deleteFeatureByCode(String featureCode)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, featureCode);
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while deleting feature with code - " + featureCode;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean deleteFeatureById(String featureId)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_FEATURE WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, featureId);
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while deleting feature with id - " + featureId;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public Feature getFeatureByCode(String featureCode)
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
Feature feature = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, featureCode);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
feature = new Feature();
feature.setId(resultSet.getInt(1));
feature.setCode(resultSet.getString(2));
feature.setName(resultSet.getString(3));
feature.setDescription(resultSet.getString(4));
break;
}
} catch (SQLException e) {
String msg = "Error occurred while fetching feature code - '" +
featureCode + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return feature;
}
@Override
public Feature getFeatureById(String featureID)
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
Feature feature = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, featureID);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
feature = new Feature();
feature.setId(resultSet.getInt(1));
feature.setCode(resultSet.getString(2));
feature.setName(resultSet.getString(3));
feature.setDescription(resultSet.getString(4));
break;
}
} catch (SQLException e) {
String msg = "Error occurred while fetching feature id - '" +
featureID + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return feature;
}
@Override
public List<Feature> getAllFeatures() throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
Feature feature;
List<Feature> features = new ArrayList<Feature>();
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE";
stmt = conn.prepareStatement(selectDBQuery);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
feature = new Feature();
feature.setId(resultSet.getInt(1));
feature.setCode(resultSet.getString(2));
feature.setName(resultSet.getString(3));
feature.setDescription(resultSet.getString(4));
features.add(feature);
}
return features;
} catch (SQLException e) {
String msg = "Error occurred while fetching all features.'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
}
private Connection getConnection() throws MobileDeviceManagementDAOException {
try {
return dataSource.getConnection();
} catch (SQLException e) {
String msg = "Error occurred while obtaining a connection from the mobile specific " +
"datasource.";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
}
}
}

@ -0,0 +1,186 @@
package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.FeaturePropertyDAO;
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.dto.FeatureProperty;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* Implementation of FeaturePropertyDAO
*/
public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(FeaturePropertyDAOImpl.class);
public FeaturePropertyDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public boolean addFeatureProperty(FeatureProperty featureProperty)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, featureProperty.getProperty());
stmt.setString(2, featureProperty.getFeatureID());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while adding property id - '" +
featureProperty.getFeatureID() + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean updateFeatureProperty(FeatureProperty featureProperty)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_FEATURE_PROPERTY SET PROPERTY = ?, FEATURE_ID = ? WHERE PROPERTY_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, featureProperty.getProperty());
stmt.setString(2, featureProperty.getFeatureID());
stmt.setInt(3, featureProperty.getPropertyId());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while updating the feature property with property id - '" +
featureProperty.getPropertyId() + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean deleteFeatureProperty(int propertyId)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_FEATURE_PROPERTY WHERE PROPERTY_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, propertyId);
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while deleting feature property with property Id - " +
propertyId;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public FeatureProperty getFeatureProperty(int propertyId)
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
FeatureProperty featureProperty = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, propertyId);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
featureProperty = new FeatureProperty();
featureProperty.setProperty(resultSet.getString(1));
featureProperty.setFeatureID(resultSet.getString(2));
break;
}
} catch (SQLException e) {
String msg = "Error occurred while fetching property Id - '" +
propertyId + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return featureProperty;
}
@Override
public List<FeatureProperty> getFeaturePropertyOfFeature(String featureId)
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
FeatureProperty featureProperty = null;
List<FeatureProperty> FeatureProperties = new ArrayList<FeatureProperty>();
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT PROPERTY_ID,PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, featureId);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
featureProperty = new FeatureProperty();
featureProperty.setPropertyId(resultSet.getInt(1));
featureProperty.setProperty(resultSet.getString(2));
featureProperty.setFeatureID(resultSet.getString(3));
FeatureProperties.add(featureProperty);
}
return FeatureProperties;
} catch (SQLException e) {
String msg = "Error occurred while fetching all feature property.'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
}
private Connection getConnection() throws MobileDeviceManagementDAOException {
try {
return dataSource.getConnection();
} catch (SQLException e) {
String msg = "Error occurred while obtaining a connection from the mobile device " +
"management metadata repository datasource.";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
}
}
}

@ -28,6 +28,8 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/** /**
* Implementation of MobileDeviceDAO. * Implementation of MobileDeviceDAO.
@ -169,6 +171,39 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
return status; return status;
} }
@Override
public List<MobileDevice> getAllDevices() throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
MobileDevice mobileDevice;
List<MobileDevice> mobileDevices=new ArrayList<MobileDevice>();
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT * FROM MBL_DEVICE";
stmt = conn.prepareStatement(selectDBQuery);
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
mobileDevice = new MobileDevice();
mobileDevice.setMobileDeviceId(resultSet.getString(1));
mobileDevice.setRegId(resultSet.getString(2));
mobileDevice.setImei(resultSet.getString(3));
mobileDevice.setImsi(resultSet.getString(4));
mobileDevice.setOsVersion(resultSet.getString(5));
mobileDevice.setModel(resultSet.getString(6));
mobileDevice.setVendor(resultSet.getString(7));
mobileDevices.add(mobileDevice);
}
return mobileDevices;
} catch (SQLException e) {
String msg = "Error occurred while fetching all mobile device data'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
}
private Connection getConnection() throws MobileDeviceManagementDAOException { private Connection getConnection() throws MobileDeviceManagementDAOException {
try { try {
return dataSource.getConnection(); return dataSource.getConnection();

@ -0,0 +1,151 @@
package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.OperationDAO;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Implementation of OperationDAO
*/
public class OperationDAOImpl implements OperationDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(OperationDAOImpl.class);
public OperationDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public boolean addOperation(Operation operation)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, operation.getFeatureCode());
stmt.setInt(2, operation.getCreatedDate());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while adding feature code - '" +
operation.getFeatureCode() + "' to operations table";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean updateOperation(Operation operation)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE OPERATION_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, operation.getFeatureCode());
stmt.setInt(2, operation.getCreatedDate());
stmt.setInt(3, operation.getOperationId());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while updating the operation with operation id - '" +
operation.getOperationId() + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean deleteOperation(int operationId)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM MBL_OPERATION WHERE OPERATION_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, operationId);
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while deleting operation with operation Id - ";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public Operation getOperation(int operationId)
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
Operation operation = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, operation.getOperationId());
ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) {
operation = new Operation();
operation.setOperationId(resultSet.getInt(1));
break;
}
} catch (SQLException e) {
String msg = "Error occurred while fetching operationId - '" +
operationId + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return operation;
}
private Connection getConnection() throws MobileDeviceManagementDAOException {
try {
return dataSource.getConnection();
} catch (SQLException e) {
String msg = "Error occurred while obtaining a connection from the mobile device " +
"management metadata repository datasource.";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
}
}
}

@ -0,0 +1,87 @@
package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.OperationPropertyDAO;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
/**
* Implementation of OperationPropertyDAO
*/
public class OperationPropertyDAOImpl implements OperationPropertyDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(OperationPropertyDAOImpl.class);
public OperationPropertyDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public boolean addOperationProperty(OperationProperty operationProperty)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY_ID, VALUE) VALUES ( ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setInt(1, operationProperty.getOperationId());
stmt.setInt(2, operationProperty.getPropertyId());
stmt.setString(3, operationProperty.getValue());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while adding feature property to operation property table";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override public boolean updateOperationProperty(OperationProperty operationProperty)
throws MobileDeviceManagementDAOException {
return false;
}
@Override public boolean deleteOperationProperty(int operationPropertyId)
throws MobileDeviceManagementDAOException {
return false;
}
@Override public OperationProperty getOperationProperty(String deviceId, int operationId)
throws MobileDeviceManagementDAOException {
return null;
}
@Override public List<OperationProperty> getAllDeviceOperationOfDevice(String deviceId)
throws MobileDeviceManagementDAOException {
return null;
}
private Connection getConnection() throws MobileDeviceManagementDAOException {
try {
return dataSource.getConnection();
} catch (SQLException e) {
String msg = "Error occurred while obtaining a connection from the mobile device " +
"management metadata repository datasource.";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
}
}
}

@ -0,0 +1,44 @@
package org.wso2.carbon.device.mgt.mobile.dto;
/**
* DTO of Operations.
*/
public class DeviceOperation {
String deviceId;
int operationId;
int sentDate;
int receivedDate;
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public int getOperationId() {
return operationId;
}
public void setOperationId(int operationId) {
this.operationId = operationId;
}
public int getSentDate() {
return sentDate;
}
public void setSentDate(int sentDate) {
this.sentDate = sentDate;
}
public int getReceivedDate() {
return receivedDate;
}
public void setReceivedDate(int receivedDate) {
this.receivedDate = receivedDate;
}
}

@ -0,0 +1,46 @@
package org.wso2.carbon.device.mgt.mobile.dto;
import java.io.Serializable;
/**
* DTO of features.
*/
public class Feature implements Serializable {
int id;
String code;
String name;
String description;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

@ -0,0 +1,35 @@
package org.wso2.carbon.device.mgt.mobile.dto;
/**
* DTO of feature property. Represents a property of a feature.
*/
public class FeatureProperty {
int propertyId;
String property;
String featureID;
public String getFeatureID() {
return featureID;
}
public void setFeatureID(String featureID) {
this.featureID = featureID;
}
public int getPropertyId() {
return propertyId;
}
public void setPropertyId(int propertyId) {
this.propertyId = propertyId;
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
}

@ -0,0 +1,36 @@
package org.wso2.carbon.device.mgt.mobile.dto;
/**
* DTO of operation.
*/
public class Operation {
int operationId;
String featureCode;
int createdDate;
public int getOperationId() {
return operationId;
}
public void setOperationId(int operationId) {
this.operationId = operationId;
}
public String getFeatureCode() {
return featureCode;
}
public void setFeatureCode(String featureCode) {
this.featureCode = featureCode;
}
public int getCreatedDate() {
return createdDate;
}
public void setCreatedDate(int createdDate) {
this.createdDate = createdDate;
}
}

@ -0,0 +1,44 @@
package org.wso2.carbon.device.mgt.mobile.dto;
/**
* DTO of operation property.
*/
public class OperationProperty {
int operationPropertyId;
int getOperationId;
int propertyId;
String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public int getOperationPropertyId() {
return operationPropertyId;
}
public void setOperationPropertyId(int operationPropertyId) {
this.operationPropertyId = operationPropertyId;
}
public int getOperationId() {
return getOperationId;
}
public void setOperationId(int getOperationId) {
this.getOperationId = getOperationId;
}
public int getPropertyId() {
return propertyId;
}
public void setPropertyId(int propertyId) {
this.propertyId = propertyId;
}
}

@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -33,11 +34,11 @@ import java.util.List;
public class AndroidDeviceManagerService implements DeviceManagerService { public class AndroidDeviceManagerService implements DeviceManagerService {
private static final Log log = LogFactory.getLog(AndroidDeviceManagerService.class); private static final Log log = LogFactory.getLog(AndroidDeviceManagerService.class);
private OperationManager operationManager; private OperationManager operationManager;
public AndroidDeviceManagerService() { public AndroidDeviceManagerService() {
this.operationManager = new AndroidMobileOperationManager(); this.operationManager = new AndroidMobileOperationManager();
} }
@Override @Override
public String getProviderType() { public String getProviderType() {
@ -64,7 +65,8 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
boolean status = false; boolean status = false;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try { try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().updateDevice(mobileDevice); status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.updateDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while updating the enrollment of the Android device : " + String msg = "Error while updating the enrollment of the Android device : " +
device.getDeviceIdentifier(); device.getDeviceIdentifier();
@ -78,7 +80,8 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
boolean status = false; boolean status = false;
try { try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().deleteDevice(deviceId.getId()); status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.deleteDevice(deviceId.getId());
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while removing the Android device : " + deviceId.getId(); String msg = "Error while removing the Android device : " + deviceId.getId();
log.error(msg, e); log.error(msg, e);
@ -94,7 +97,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
MobileDevice mobileDevice = MobileDevice mobileDevice =
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getDevice( MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getDevice(
deviceId.getId()); deviceId.getId());
if(mobileDevice!=null){ if (mobileDevice != null) {
isEnrolled = true; isEnrolled = true;
} }
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
@ -117,11 +120,6 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
return true; return true;
} }
@Override
public List<Device> getAllDevices() throws DeviceManagementException {
return null;
}
@Override @Override
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
Device device = null; Device device = null;
@ -143,23 +141,46 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
return true; return true;
} }
@Override @Override
public boolean updateDeviceInfo(Device device) throws DeviceManagementException { public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
boolean status = false; boolean status = false;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try { try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().updateDevice(mobileDevice); status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.updateDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while updating the Android device : " + device.getDeviceIdentifier(); String msg =
"Error while updating the Android device : " + device.getDeviceIdentifier();
log.error(msg, e); log.error(msg, e);
throw new DeviceManagementException(msg, e); throw new DeviceManagementException(msg, e);
} }
return status; return status;
} }
@Override @Override
public OperationManager getOperationManager() throws DeviceManagementException { public List<Device> getAllDevices() throws DeviceManagementException {
return operationManager; List<Device> devices = null;
} try {
List<MobileDevice> mobileDevices =
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
getAllDevices();
if (mobileDevices != null) {
devices = new ArrayList<Device>();
for (int x = 0; x < mobileDevices.size(); x++) {
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevices.get(x)));
}
}
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while fetching all Android devices.";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return devices;
}
@Override
public OperationManager getOperationManager() throws DeviceManagementException {
return operationManager;
}
} }

@ -133,7 +133,7 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
private void initAPIConfigs() throws DeviceManagementException { private void initAPIConfigs() throws DeviceManagementException {
List<APIConfig> apiConfigs = List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getApis(); getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) { for (APIConfig apiConfig : apiConfigs) {
try { try {
APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner()); APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner());
@ -148,7 +148,7 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
private void publishAPIs() throws DeviceManagementException { private void publishAPIs() throws DeviceManagementException {
List<APIConfig> apiConfigs = List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getApis(); getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) { for (APIConfig apiConfig : apiConfigs) {
DeviceManagementAPIPublisherUtil.publishAPI(apiConfig); DeviceManagementAPIPublisherUtil.publishAPI(apiConfig);
} }
@ -157,7 +157,7 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
private void removeAPIs() throws DeviceManagementException { private void removeAPIs() throws DeviceManagementException {
List<APIConfig> apiConfigs = List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getApis(); getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) { for (APIConfig apiConfig : apiConfigs) {
DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); DeviceManagementAPIPublisherUtil.removeAPI(apiConfig);
} }

@ -0,0 +1,29 @@
/*
* 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.impl.common;
public enum DBTypes {
Oracle("Oracle"),H2("H2"),MySql("MySql");
String dbName ;
DBTypes(String dbStrName) {
dbName = dbStrName;
}
}

@ -0,0 +1,90 @@
/*
* 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.impl.common;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "DBType")
public class TestDBConfiguration {
private String connectionUrl;
private String driverClass;
private String userName;
private String pwd;
@Override public String toString() {
return "TestDBConfiguration{" +
"connectionUrl='" + connectionUrl + '\'' +
", driverClass='" + driverClass + '\'' +
", userName='" + userName + '\'' +
", pwd='" + pwd + '\'' +
", dbType='" + dbType + '\'' +
'}';
}
private String dbType;
@XmlElement(name = "connectionurl", nillable = false)
public String getConnectionUrl() {
return connectionUrl;
}
public void setConnectionUrl(String connectionUrl) {
this.connectionUrl = connectionUrl;
}
@XmlElement(name = "driverclass", nillable = false)
public String getDriverClass() {
return driverClass;
}
public void setDriverClass(String driverClass) {
this.driverClass = driverClass;
}
@XmlElement(name = "userName", nillable = false)
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@XmlElement(name = "pwd", nillable = false)
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
@XmlAttribute(name = "typeName")
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
}

@ -0,0 +1,39 @@
/*
* 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.impl.common;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "DeviceMgtTestDBConfigurations")
public class TestDBConfigurations {
private List<TestDBConfiguration> dbTypesList;
@XmlElement(name = "DBType")
public List<TestDBConfiguration> getDbTypesList() {
return dbTypesList;
}
public void setDbTypesList(List<TestDBConfiguration> dbTypesList) {
this.dbTypesList = dbTypesList;
}
}

@ -0,0 +1,143 @@
/*
* 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.impl.dao;
import org.apache.commons.dbcp.BasicDataSource;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.impl.common.DBTypes;
import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfiguration;
import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfigurations;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.impl.FeatureDAOImpl;
import org.wso2.carbon.device.mgt.mobile.dto.*;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.File;
import java.sql.*;
import java.util.Date;
import java.util.Iterator;
public class FeatureDAOTestSuite {
private TestDBConfiguration testDBConfiguration;
private Connection conn = null;
private Statement stmt = null;
private FeatureDAOImpl featureDAO;
@BeforeClass
@Parameters("dbType")
public void setUpDB(String dbTypeStr) throws Exception {
DBTypes dbType = DBTypes.valueOf(dbTypeStr);
testDBConfiguration = getTestDBConfiguration(dbType);
switch (dbType) {
case H2:
createH2DB(testDBConfiguration);
BasicDataSource testDataSource = new BasicDataSource();
testDataSource.setDriverClassName(testDBConfiguration.getDriverClass());
testDataSource.setUrl(testDBConfiguration.getConnectionUrl());
testDataSource.setUsername(testDBConfiguration.getUserName());
testDataSource.setPassword(testDBConfiguration.getPwd());
featureDAO = new FeatureDAOImpl(testDataSource);
default:
}
}
private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws
MobileDeviceManagementDAOException,
DeviceManagementException {
File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml");
Document doc = null;
testDBConfiguration = null;
TestDBConfigurations testDBConfigurations = null;
doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
JAXBContext testDBContext = null;
try {
testDBContext = JAXBContext.newInstance(TestDBConfigurations.class);
Unmarshaller unmarshaller = testDBContext.createUnmarshaller();
testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc);
} catch (JAXBException e) {
throw new MobileDeviceManagementDAOException("Error parsing test db configurations", e);
}
Iterator<TestDBConfiguration> itrDBConfigs = testDBConfigurations.getDbTypesList().iterator();
while (itrDBConfigs.hasNext()) {
testDBConfiguration = itrDBConfigs.next();
if (testDBConfiguration.getDbType().equals(dbType.toString())) {
break;
}
}
return testDBConfiguration;
}
private void createH2DB(TestDBConfiguration testDBConf) throws Exception {
Class.forName(testDBConf.getDriverClass());
conn = DriverManager.getConnection(testDBConf.getConnectionUrl());
stmt = conn.createStatement();
stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'");
stmt.close();
conn.close();
}
@Test
public void addFeature() throws MobileDeviceManagementDAOException, DeviceManagementException {
Feature feature = new Feature();
feature.setCode("Camera");
feature.setDescription("Camera enable or disable");
feature.setName("Camera");
boolean added = featureDAO.addFeature(feature);
// Long deviceId = null;
// try {
// conn = DeviceManagementDAOFactory.getDataSource().getConnection();
// stmt = conn.createStatement();
// ResultSet resultSet = stmt
// .executeQuery("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'");
//
// while (resultSet.next()) {
// deviceId = resultSet.getLong(1);
// }
// conn.close();
// } catch (SQLException sqlEx) {
// throw new DeviceManagementDAOException("error in fetch device by device identification id", sqlEx);
// }
Assert.assertTrue(added, "Device Id is null");
}
}

@ -0,0 +1,24 @@
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE
(
ID INT auto_increment NOT NULL,
NAME VARCHAR(300) NULL DEFAULT NULL,
PRIMARY KEY (ID)
);
CREATE TABLE IF NOT EXISTS DM_DEVICE
(
ID INT auto_increment NOT NULL,
DESCRIPTION TEXT NULL DEFAULT NULL,
NAME VARCHAR(100) NULL DEFAULT NULL,
DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL,
DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL,
OWNERSHIP VARCHAR(45) NULL DEFAULT NULL,
STATUS VARCHAR(15) NULL DEFAULT NULL,
DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL,
DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL,
OWNER VARCHAR(45) NULL DEFAULT NULL,
TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (ID),
CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID )
REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
);

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
~ 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.
-->
<DeviceMgtTestDBConfigurations>
<DBType typeName="H2">
<connectionurl>jdbc:h2:mem:cdm-test-db;DB_CLOSE_DELAY=-1</connectionurl>
<driverclass>org.h2.Driver</driverclass>
<userName></userName>
<pwd></pwd>
</DBType>
</DeviceMgtTestDBConfigurations>

@ -0,0 +1,28 @@
<!--
~ 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.
~ 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.
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="EMM-core-initializer">
<parameter name="useDefaultListeners" value="false"/>
<test name="DAO Unit Tests" preserve-order="true">
<parameter name="dbType" value="H2"/>
<classes>
<class name="org.wso2.carbon.device.mgt.mobile.impl.dao.FeatureDAOTestSuite"/>
</classes>
</test>
</suite>

@ -42,6 +42,61 @@
<module>org.wso2.carbon.device.mgt.mobile.impl</module> <module>org.wso2.carbon.device.mgt.mobile.impl</module>
</modules> </modules>
<!-- <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.8.1.v20120830-144521</version>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
<version>3.6.100.v20120522-1841</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
<version>4.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
<version>3.3.100.v20120522-1822</version>
</dependency>
<dependency>
<groupId>com.h2database.wso2</groupId>
<artifactId>h2-database-engine</artifactId>
<version>${orbit.version.h2.engine}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.apimgt.core</artifactId>
<version>${apim.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.apimgt.impl</artifactId>
<version>${apim.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.wso2</groupId>
<artifactId>tomcat</artifactId>
<version>${orbit.version.tomcat}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.tomcat.ext</artifactId>
<version>4.3.0</version>
</dependency>
</dependencies>
</dependencyManagement>-->
<build> <build>
<pluginManagement> <pluginManagement>
<plugins> <plugins>

@ -19,19 +19,21 @@
<ManagementRepository> <ManagementRepository>
<DataSourceConfiguration> <DataSourceConfiguration>
<JndiLookupDefinition> <JndiLookupDefinition>
<Name>jdbc/WSO2MOBILE_DB</Name> <Name>jdbc/MOBILE_MGT_DS</Name>
</JndiLookupDefinition> </JndiLookupDefinition>
</DataSourceConfiguration> </DataSourceConfiguration>
</ManagementRepository> </ManagementRepository>
<APIPublisher> <APIPublisher>
<API> <APIs>
<Name>enrollment</Name> <API>
<Provider>admin</Provider> <Name>enrollment</Name>
<Context>enrollment</Context> <Provider>admin</Provider>
<Version>1.0.0</Version> <Context>enrollment</Context>
<Endpoint>http://localhost:9763/</Endpoint> <Version>1.0.0</Version>
<Transports>http,https</Transports> <Endpoint>http://localhost:9763/</Endpoint>
</API> <Transports>http,https</Transports>
</API>
</APIs>
</APIPublisher> </APIPublisher>
</MobileDeviceMgtConfiguration> </MobileDeviceMgtConfiguration>

@ -18,7 +18,7 @@
<ManagementRepository> <ManagementRepository>
<DataSourceConfiguration> <DataSourceConfiguration>
<JndiLookupDefinition> <JndiLookupDefinition>
<Name>jdbc/WSO2DEVICE_DB</Name> <Name>jdbc/DEVICE_MGT_DS</Name>
</JndiLookupDefinition> </JndiLookupDefinition>
</DataSourceConfiguration> </DataSourceConfiguration>
</ManagementRepository> </ManagementRepository>

@ -77,6 +77,7 @@
<version>${stub.version}</version> <version>${stub.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.core</artifactId> <artifactId>org.wso2.carbon.user.core</artifactId>
@ -93,11 +94,13 @@
<artifactId>org.wso2.carbon.user.api</artifactId> <artifactId>org.wso2.carbon.user.api</artifactId>
<version>${carbon.kernel.version}</version> <version>${carbon.kernel.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId> <artifactId>org.wso2.carbon.utils</artifactId>
<version>${carbon.kernel.version}</version> <version>${carbon.kernel.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId> <artifactId>org.wso2.carbon.logging</artifactId>
@ -151,6 +154,11 @@
<artifactId>testng</artifactId> <artifactId>testng</artifactId>
<version>${testng.version}</version> <version>${testng.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
<version>${carbon.kernel.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.core</artifactId> <artifactId>org.wso2.carbon.core</artifactId>
@ -166,6 +174,38 @@
<artifactId>org.wso2.carbon.ndatasource.rdbms</artifactId> <artifactId>org.wso2.carbon.ndatasource.rdbms</artifactId>
<version>${carbon.kernel.version}</version> <version>${carbon.kernel.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.transaction.manager</artifactId>
<version>${carbon.platform.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.1_spec</artifactId>
<version>${jboss-transaction-api.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.8.1.v20120830-144521</version>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
<version>3.6.100.v20120522-1841</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
<version>${carbon.kernel.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<version>${cdm.version}</version>
</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>

@ -0,0 +1,45 @@
/**
* 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.cdm.agent.services;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
/**
* Local notification is a communication mechanism that essentially,
* polls to server based on a predefined to retrieve pending data.
*/
public class LocalNotification {
public static void startPolling(Context context) {
int interval=10000;
// int interval=Preference.getInt(context, context.getResources().getString(R.string.shared_pref_interval));
//TODO:remove hard coded value
long firstTime = SystemClock.elapsedRealtime();
firstTime += 1000;
Intent downloader = new Intent(context, AlarmReceiver.class);
PendingIntent recurringDownload = PendingIntent.getBroadcast(context,
0, downloader, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarms = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE);
alarms.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime,
interval, recurringDownload);
}
}

@ -51,15 +51,6 @@
</jaxrs:providers> </jaxrs:providers>
</jaxrs:server> </jaxrs:server>
<jaxrs:server id="testService" address="/test">
<jaxrs:serviceBeans>
<ref bean="testServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<bean id="deviceMgtServiceBean" class="cdm.api.android.Device"/> <bean id="deviceMgtServiceBean" class="cdm.api.android.Device"/>
<bean id="enrollmentServiceBean" class="cdm.api.android.Enrollment"/> <bean id="enrollmentServiceBean" class="cdm.api.android.Enrollment"/>
<bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/> <bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>

@ -34,6 +34,13 @@
<name>WSO2 Connected Device Manager (CDM) - Distribution</name> <name>WSO2 Connected Device Manager (CDM) - Distribution</name>
<description>WSO2 Connected Device Manager (CDM) Distribution</description> <description>WSO2 Connected Device Manager (CDM) Distribution</description>
<dependencies>
<dependency>
<groupId>com.h2database.wso2</groupId>
<artifactId>h2-database-engine</artifactId>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -91,6 +98,40 @@
<artifactId>maven-antrun-plugin</artifactId> <artifactId>maven-antrun-plugin</artifactId>
<!--<version>${maven-antrun-plugin.version}</version>--> <!--<version>${maven-antrun-plugin.version}</version>-->
<executions> <executions>
<execution>
<!-- Creating IDP Management schema -->
<id>create-idp-mgt-schema</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo
message="########### Create IDP Management H2 Schema ###########"/>
<property name="db.dir"
value="target/wso2carbon-core-${carbon.kernel.version}/repository/database"/>
<property name="userid" value="wso2carbon"/>
<property name="password" value="wso2carbon"/>
<property name="dbURL"
value="jdbc:h2:file:${basedir}/${db.dir}/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE"/>
<sql driver="org.h2.Driver"
url="${dbURL}"
userid="${userid}" password="${password}"
autocommit="true" onerror="continue">
<classpath refid="maven.dependency.classpath"/>
<classpath refid="maven.compile.classpath"/>
<classpath refid="maven.runtime.classpath"/>
<fileset file="${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/identity/application-mgt/h2.sql"/>
</sql>
<echo
message="##################### END ####################"/>
</tasks>
</configuration>
</execution>
<execution> <execution>
<id>3-extract-docs-from-components</id> <id>3-extract-docs-from-components</id>
<phase>package</phase> <phase>package</phase>
@ -149,7 +190,7 @@
<phase>package</phase> <phase>package</phase>
<configuration> <configuration>
<tasks> <tasks>
<mkdir dir="target/wso2carbon-core-${project.version}/repository/deployment/server/webapps"/> <mkdir dir="target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/webapps"/>
<!--<copy todir="target/wso2carbon-core-${carbon.kernel.version}/modules" <!--<copy todir="target/wso2carbon-core-${carbon.kernel.version}/modules"
overwrite="true"> overwrite="true">
@ -182,7 +223,7 @@
<delete dir="target/dependency-maven-plugin-markers"/> <delete dir="target/dependency-maven-plugin-markers"/>
<delete dir="target/maven-archiver"/> <delete dir="target/maven-archiver"/>
<delete dir="target/wso2carbon-core-${carbon.kernel.version}"/> <delete dir="target/wso2carbon-core-${carbon.kernel.version}"/>
<delete dir="target/wso2carbon-core-${project.version}"/> <delete dir="target/wso2carbon-core-${carbon.kernel.version}"/>
<delete file="target/wso2cdm-${project.version}.jar"/> <delete file="target/wso2cdm-${project.version}.jar"/>
<delete dir="target/sources"/> <delete dir="target/sources"/>
<delete dir="target/site"/> <delete dir="target/site"/>

@ -81,7 +81,6 @@
</includes> </includes>
</fileSet> </fileSet>
<!-- copy documentation --> <!-- copy documentation -->
<fileSet> <fileSet>
<directory>target/site</directory> <directory>target/site</directory>
@ -120,6 +119,13 @@
<include>**/trusted-idp-config.xml</include> <include>**/trusted-idp-config.xml</include>
</includes> </includes>
</fileSet> </fileSet>
<fileSet>
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/rxts/
</directory>
<outputDirectory>wso2cdm-${project.version}/repository/resources/rxts/</outputDirectory>
</fileSet>
<fileSet> <fileSet>
<directory>src/repository/conf/datasources</directory> <directory>src/repository/conf/datasources</directory>
<outputDirectory>wso2cdm-${project.version}/repository/conf/datasources</outputDirectory> <outputDirectory>wso2cdm-${project.version}/repository/conf/datasources</outputDirectory>
@ -142,7 +148,7 @@
<fileMode>755</fileMode> <fileMode>755</fileMode>
</fileSet> </fileSet>
<fileSet> <fileSet>
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.version}/lib/runtimes</directory> <directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/lib/runtimes</directory>
<outputDirectory>wso2cdm-${project.version}/lib/runtimes/</outputDirectory> <outputDirectory>wso2cdm-${project.version}/lib/runtimes/</outputDirectory>
<includes> <includes>
<include>*/**</include> <include>*/**</include>
@ -156,6 +162,16 @@
<include>*/**</include> <include>*/**</include>
</includes> </includes>
</fileSet> </fileSet>
<!-- Copying identity related dbscripts -->
<fileSet>
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/identity</directory>
<outputDirectory>wso2cdm-${project.version}/dbscripts/identity</outputDirectory>
<includes>
<include>*/**</include>
</includes>
</fileSet>
<fileSet> <fileSet>
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/modules</directory> <directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/modules</directory>
<outputDirectory>wso2cdm-${project.version}/modules/</outputDirectory> <outputDirectory>wso2cdm-${project.version}/modules/</outputDirectory>
@ -173,7 +189,10 @@
<include>*/**</include> <include>*/**</include>
</includes> </includes>
</fileSet> </fileSet>
<fileSet>
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources</directory>
<outputDirectory>${project.artifactId}-${project.version}/repository/resources</outputDirectory>
</fileSet>
</fileSets> </fileSets>
<dependencySets> <dependencySets>
@ -267,6 +286,38 @@
<fileMode>644</fileMode> <fileMode>644</fileMode>
</file> </file>
<!-- Copying logging-config.xml -->
<file>
<source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/logging-config.xml</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/etc</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<!-- Copying event-broker.xml -->
<file>
<source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/event-broker.xml</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<!-- Copying application-authentication.xml -->
<file>
<source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/security/application-authentication.xml</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf/security</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<!-- Copying thrift-authentication.xml -->
<file>
<source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/thrift-authentication.xml</source>
<outputDirectory>wso2cdm-${project.version}/repository/conf</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<!--copy default xacml policy to repository/resources/security --> <!--copy default xacml policy to repository/resources/security -->
<!-- <file> <!-- <file>
<source>src/repository/resources/policies/xacml/default/admin.xml</source> <source>src/repository/resources/policies/xacml/default/admin.xml</source>
@ -327,12 +378,10 @@
<file> <file>
<source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/mobile-config.xml <source>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/mobile-config.xml
</source> </source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf</outputDirectory> <outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/etc/device-mgt-plugin-configs/mobile</outputDirectory>
<filtered>true</filtered> <filtered>true</filtered>
<fileMode>644</fileMode> <fileMode>644</fileMode>
</file> </file>
<file> <file>
<source> <source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading-environments.xml ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading-environments.xml

@ -5,14 +5,14 @@
<datasources> <datasources>
<datasource> <datasource>
<name>WSO2DEVICE_DB</name> <name>DEVICE_MGT_DS</name>
<description>The datasource used for CDM</description> <description>The datasource used for CDM</description>
<jndiConfig> <jndiConfig>
<name>jdbc/WSO2DEVICE_DB</name> <name>jdbc/DEVICE_MGT_DS</name>
</jndiConfig> </jndiConfig>
<definition type="RDBMS"> <definition type="RDBMS">
<configuration> <configuration>
<url>jdbc:h2:repository/database/WSO2DEVICE_DB;DB_CLOSE_ON_EXIT=FALSE</url> <url>jdbc:h2:repository/database/WSO2DEVICEMGT_DB;DB_CLOSE_ON_EXIT=FALSE</url>
<username>wso2carbon</username> <username>wso2carbon</username>
<password>wso2carbon</password> <password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName> <driverClassName>org.h2.Driver</driverClassName>
@ -25,10 +25,10 @@
</definition> </definition>
</datasource> </datasource>
<datasource> <datasource>
<name>WSO2MOBILE_DB</name> <name>MOBILE_MGT_DS</name>
<description>The datasource used for CDM Mobile Device Management</description> <description>The datasource used for CDM Mobile Device Management</description>
<jndiConfig> <jndiConfig>
<name>jdbc/WSO2MOBILE_DB</name> <name>jdbc/MOBILE_MGT_DS</name>
</jndiConfig> </jndiConfig>
<definition type="RDBMS"> <definition type="RDBMS">
<configuration> <configuration>
@ -44,5 +44,25 @@
</configuration> </configuration>
</definition> </definition>
</datasource> </datasource>
<datasource>
<name>WSO2DEVICE_DB</name>
<description>The datasource used for CDM</description>
<jndiConfig>
<name>jdbc/WSO2AM_DB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:repository/database/WSO2AM_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>

@ -1,11 +1,88 @@
CREATE TABLE IF NOT EXISTS MBL_DEVICE
( -- -----------------------------------------------------
MOBILE_DEVICE_ID VARCHAR(45) NOT NULL, -- Table `MBL_DEVICE`
REG_ID VARCHAR(45) NOT NULL, -- -----------------------------------------------------
IMEI VARCHAR(45) NOT NULL, CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
IMSI VARCHAR(45), `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL ,
OS_VERSION VARCHAR(45) NOT NULL, `REG_ID` VARCHAR(45) NULL DEFAULT NULL ,
DEVICE_MODEL VARCHAR(45) NOT NULL, `IMEI` VARCHAR(45) NULL DEFAULT NULL ,
VENDOR VARCHAR(45) NOT NULL, `IMSI` VARCHAR(45) NULL DEFAULT NULL ,
PRIMARY KEY (MOBILE_DEVICE_ID) `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
); `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
`VENDOR` 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 ,
`CODE` VARCHAR(45) 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) NULL ,
`CREATED_DATE` INT NULL ,
PRIMARY KEY (`OPERATION_ID`) ,
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
FOREIGN KEY (`FEATURE_CODE` )
REFERENCES `MBL_FEATURE` (`CODE` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `MBL_DEVICE_OPERATION_MAPING`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
`DEVICE_ID` VARCHAR(45) NOT NULL ,
`OPERATION_ID` INT NOT NULL ,
`SENT_DATE` INT NULL ,
`RECEIVED_DATE` INT 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_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
`OPERATION_ID` INT NULL ,
`PROPERTY_ID` INT NULL ,
`VALUE` TEXT NULL ,
PRIMARY KEY (`OPERATION_PROPERTY_ID`) ,
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_ID` INT NOT NULL AUTO_INCREMENT ,
`PROPERTY` VARCHAR(100) NULL ,
`FEATURE_ID` VARCHAR(45) NULL ,
PRIMARY KEY (`PROPERTY_ID`) ,
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
FOREIGN KEY (`FEATURE_ID` )
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);

@ -0,0 +1,88 @@
-- -----------------------------------------------------
-- Table `MBL_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL ,
`REG_ID` 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 ,
PRIMARY KEY (`MOBILE_DEVICE_ID`) );
-- -----------------------------------------------------
-- Table `MBL_FEATURE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
`CODE` VARCHAR(45) 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) NULL ,
`CREATED_DATE` INT NULL ,
PRIMARY KEY (`OPERATION_ID`) ,
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
FOREIGN KEY (`FEATURE_CODE` )
REFERENCES `MBL_FEATURE` (`CODE` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `MBL_DEVICE_OPERATION_MAPING`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
`DEVICE_ID` VARCHAR(45) NOT NULL ,
`OPERATION_ID` INT NOT NULL ,
`SENT_DATE` INT NULL ,
`RECEIVED_DATE` INT 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_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
`OPERATION_ID` INT NULL ,
`PROPERTY_ID` INT NULL ,
`VALUE` TEXT NULL ,
PRIMARY KEY (`OPERATION_PROPERTY_ID`) ,
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_ID` INT NOT NULL AUTO_INCREMENT ,
`PROPERTY` VARCHAR(100) NULL ,
`FEATURE_ID` VARCHAR(45) NULL ,
PRIMARY KEY (`PROPERTY_ID`) ,
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
FOREIGN KEY (`FEATURE_ID` )
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);

@ -13,3 +13,91 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
ENGINE = InnoDB; ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_FEATURE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
`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`) ,
INDEX `fk_MBL_OPERATION_MBL_FEATURES1_idx` (`FEATURE_CODE` ASC) ,
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
FOREIGN KEY (`FEATURE_CODE` )
REFERENCES `MBL_FEATURE` (`CODE` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `MBL_DEVICE_OPERATION_MAPING`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
`DEVICE_ID` VARCHAR(45) NOT NULL ,
`OPERATION_ID` INT NOT NULL ,
`SENT_DATE` INT NULL ,
`RECEIVED_DATE` INT 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_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
`OPERATION_ID` INT NULL ,
`PROPERTY_ID` INT NULL ,
`VALUE` TEXT NULL ,
PRIMARY KEY (`OPERATION_PROPERTY_ID`) ,
INDEX `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1_idx` (`OPERATION_ID` ASC) ,
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_ID` INT NOT NULL AUTO_INCREMENT ,
`PROPERTY` VARCHAR(100) NULL ,
`FEATURE_ID` VARCHAR(45) NULL ,
PRIMARY KEY (`PROPERTY_ID`) ,
INDEX `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1_idx` (`FEATURE_ID` ASC) ,
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;

@ -0,0 +1,15 @@
-- -----------------------------------------------------
-- Table `MBL_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL,
`REG_ID` VARCHAR(45) NULL,
`IMEI` VARCHAR(45) NULL,
`IMSI` VARCHAR(45) NULL,
`OS_VERSION` VARCHAR(45) NULL,
`DEVICE_MODEL` VARCHAR(45) NULL,
`VENDOR` VARCHAR(45) NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`))
ENGINE = InnoDB;

@ -144,6 +144,9 @@
<featureArtifactDef> <featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.um.ws.service.server.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.um.ws.service.server.feature:${carbon.platform.version}
</featureArtifactDef> </featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.user.mgt.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef> <featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.oauth.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.identity.oauth.feature:${carbon.platform.version}
</featureArtifactDef> </featureArtifactDef>
@ -153,33 +156,15 @@
<featureArtifactDef> <featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.provider.server.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.identity.provider.server.feature:${carbon.platform.version}
</featureArtifactDef> </featureArtifactDef>
<!-- Registry Features -->
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.extensions.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.ws.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.ui.menu.governance.feature:${carbon.platform.version}</featureArtifactDef>
<!--Governance Feature--> <!--Governance Feature-->
<!--featureArtifactDef>org.wso2.carbon:org.wso2.carbon.gadget.initializer.feature:${carbon.platform.version}</featureArtifactDef--> <!--featureArtifactDef>org.wso2.carbon:org.wso2.carbon.gadget.initializer.feature:${carbon.platform.version}</featureArtifactDef-->
<!--featureArtifactDef>org.wso2.carbon:org.wso2.carbon.gadget.editor.feature:${carbon.platform.version}</featureArtifactDef> <!--featureArtifactDef>org.wso2.carbon:org.wso2.carbon.gadget.editor.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.gadget.editor.ui.feature:${carbon.platform.version}</featureArtifactDef--> <featureArtifactDef>org.wso2.carbon:org.wso2.carbon.gadget.editor.ui.feature:${carbon.platform.version}</featureArtifactDef-->
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.governance.metadata.feature:4.2.2</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.governance.lifecycle.management.feature:4.2.1</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.core.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef> <featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.associations.dependencies.server.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.identity.thrift.authentication.feature:${carbon.platform.version}
</featureArtifactDef> </featureArtifactDef>
<featureArtifactDef> <featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.community.features.server.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.identity.core.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.core.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.registry.core.common.feature:${carbon.platform.version}
</featureArtifactDef> </featureArtifactDef>
<featureArtifactDef> <featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.logging.mgt.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.logging.mgt.feature:${carbon.platform.version}
@ -199,15 +184,34 @@
<featureArtifactDef> <featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version}
</featureArtifactDef> </featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.idp.mgt.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef> <featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.user.profile.server.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.identity.user.profile.server.feature:${carbon.platform.version}
</featureArtifactDef> </featureArtifactDef>
<featureArtifactDef> <featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.relying.party.server.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.identity.relying.party.server.feature:${carbon.platform.version}
</featureArtifactDef> </featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.tenant.common.server.feature:${carbon.platform.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.server.feature:${carbon.platform.version}
</featureArtifactDef>
<!-- registry features -->
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.core.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.core.server.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.ui.menu.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.resource.properties.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.associations.dependencies.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.community.features.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.community.features.server.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.extensions.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.ws.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.ui.menu.governance.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.registry.contentsearch.feature:${carbon.platform.version}</featureArtifactDef>
<!--Governance Feature-->
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.governance.metadata.feature:${carbon.platform.version}</featureArtifactDef>
<featureArtifactDef>org.wso2.carbon:org.wso2.carbon.governance.lifecycle.management.feature:${carbon.platform.version}</featureArtifactDef>
</featureArtifacts> </featureArtifacts>
</configuration> </configuration>
</execution> </execution>
@ -230,14 +234,6 @@
<id>org.wso2.carbon.apimgt.core.feature.group</id> <id>org.wso2.carbon.apimgt.core.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<!-- <feature>
<id>org.wso2.carbon.ndatasource.feature.group</id>
<version>${carbon.kernel.version}</version>
</feature>-->
<!--<feature>
<id>org.wso2.carbon.ndatasource.ui.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>-->
<feature> <feature>
<id>org.wso2.carbon.device.mgt.server.feature.group</id> <id>org.wso2.carbon.device.mgt.server.feature.group</id>
<version>${project.version}</version> <version>${project.version}</version>
@ -280,6 +276,10 @@
<id>org.wso2.carbon.um.ws.service.server.feature.group</id> <id>org.wso2.carbon.um.ws.service.server.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature>
<id>org.wso2.carbon.user.mgt.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature> <feature>
<id>org.wso2.carbon.identity.oauth.server.feature.group</id> <id>org.wso2.carbon.identity.oauth.server.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
@ -293,23 +293,59 @@
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.governance.metadata.server.feature.group</id> <id>org.wso2.carbon.identity.thrift.authentication.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.registry.extensions.server.feature.group</id> <id>org.wso2.carbon.identity.core.server.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.identity.core.server.feature.group</id> <id>org.wso2.carbon.logging.mgt.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.registry.associations.dependencies.server.feature.group</id> <id>org.wso2.carbon.event.server.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.registry.community.features.server.feature.group</id> <id>org.wso2.carbon.event.common.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.databridge.datapublisher.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.application.authentication.framework.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.idp.mgt.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.user.profile.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.relying.party.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.tenant.common.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.authenticator.saml2.sso.server.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<!-- registry features -->
<feature>
<id>org.wso2.carbon.registry.core.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
@ -317,48 +353,56 @@
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.registry.core.common.feature.group</id> <id>org.wso2.carbon.registry.ui.menu.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.logging.mgt.feature.group</id> <id>org.wso2.carbon.registry.resource.properties.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.event.server.feature.group</id> <id>org.wso2.carbon.registry.associations.dependencies.feature.group</id>
<version>${carbon.platform.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.registry.community.features.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.event.common.feature.group</id> <id>org.wso2.carbon.registry.community.features.server.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.databridge.datapublisher.feature.group</id> <id>org.wso2.carbon.registry.ws.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id> <id>org.wso2.carbon.registry.extensions.feature.group</id>
org.wso2.carbon.identity.application.authentication.framework.server.feature.group
</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.idp.mgt.server.feature.group</id> <id>org.wso2.carbon.registry.contentsearch.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<!-- governance feature -->
<feature> <feature>
<id>org.wso2.carbon.identity.user.profile.server.feature.group</id> <id>org.wso2.carbon.governance.metadata.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<feature> <feature>
<id>org.wso2.carbon.identity.relying.party.server.feature.group</id> <id>org.wso2.carbon.registry.ui.menu.governance.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature> </feature>
<!--<feature> <feature>
<id>org.wso2.carbon.dbconsole.ui.feature.group</id> <id>org.wso2.carbon.governance.lifecycle.management.feature.group</id>
<version>${carbon.platform.version}</version> <version>${carbon.platform.version}</version>
</feature>--> </feature>
</features> </features>
</configuration> </configuration>
</execution> </execution>

@ -7,7 +7,7 @@
~ in compliance with the License. ~ 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.0 ~ http://www.apache.org/licenses/LICENSE-2.0
~ ~
~ Unless required by applicable law or agreed to in writing, ~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an ~ software distributed under the License is distributed on an

Loading…
Cancel
Save