diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml
index ad7e005500..f38b43881c 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml
@@ -5,13 +5,13 @@
device-mgt
org.wso2.carbon
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon.device.mgt.common
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
bundle
WSO2 Carbon - Device Management Commons
WSO2 Carbon - Device Management Commons
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java
index 94786b4191..4e083cedaa 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Device.java
@@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.common;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
+import java.util.Map;
@XmlRootElement
public class Device {
@@ -34,7 +35,7 @@ public class Device {
private String deviceIdentifier;
private String owner;
private List features;
- private List properties;
+ private Map properties;
@XmlElement
public int getId() {
@@ -145,34 +146,12 @@ public class Device {
}
@XmlElement
- public List getProperties() {
+ public Map getProperties() {
return properties;
}
- public void setProperties(List properties) {
+ public void setProperties(Map properties) {
this.properties = properties;
}
- public static class Property {
-
- private String name;
- private String value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
- }
-
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java
index e11f5740a3..09a14021f1 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationManager.java
@@ -35,7 +35,7 @@ public interface OperationManager {
throws OperationManagementException;
/**
- * Method to retrieve the list of available operations to a device.
+ * Method to retrieve the list of all operations to a device.
*
* @param deviceId DeviceIdentifier of the device
* @throws OperationManagementException If some unusual behaviour is observed while fetching the
@@ -44,4 +44,14 @@ public interface OperationManager {
public List getOperations(DeviceIdentifier deviceId)
throws OperationManagementException;
+ /**
+ * Method to retrieve the list of available operations to a device.
+ *
+ * @param deviceId DeviceIdentifier of the device
+ * @throws OperationManagementException If some unusual behaviour is observed while fetching the
+ * operation list.
+ */
+ public List getPendingOperations(DeviceIdentifier deviceId)
+ throws OperationManagementException;
+
}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
index f5406926b3..8690a2e3fd 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml
@@ -22,14 +22,14 @@
org.wso2.carbon
device-mgt
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon
org.wso2.carbon.device.mgt.core
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
bundle
WSO2 Carbon - Device Management Core
WSO2 Carbon - Device Management Core
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java
index 37b49b32b0..726c43c343 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagerImpl.java
@@ -28,140 +28,147 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
+import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import java.util.ArrayList;
import java.util.List;
public class DeviceManagerImpl implements DeviceManager {
- private DeviceDAO deviceDAO;
- private DeviceTypeDAO deviceTypeDAO;
- private DeviceManagementConfig config;
- private DeviceManagementRepository pluginRepository;
-
- public DeviceManagerImpl(DeviceManagementConfig config, DeviceManagementRepository pluginRepository) {
- this.config = config;
- this.pluginRepository = pluginRepository;
- this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
- this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
- }
-
- @Override
- public boolean enrollDevice(Device device) throws DeviceManagementException {
- DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
- boolean status = dms.enrollDevice(device);
-
- try {
- org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device);
- Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
- deviceDto.setDeviceTypeId(deviceTypeId);
- this.getDeviceDAO().addDevice(deviceDto);
-
- } catch (DeviceManagementDAOException e) {
- throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'", e);
- }
- return status;
- }
-
- @Override
- public boolean modifyEnrollment(Device device) throws DeviceManagementException {
- DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
- boolean status = dms.modifyEnrollment(device);
- try {
- this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device));
- } catch (DeviceManagementDAOException e) {
- throw new DeviceManagementException("Error occurred while modifying the device '" + device.getId() + "'",
- e);
- }
- return status;
- }
-
- @Override
- public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
- DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
- return dms.disenrollDevice(deviceId);
- }
-
- @Override
- public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
- DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
- return dms.isEnrolled(deviceId);
- }
-
- @Override
- public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
- DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
- return dms.isActive(deviceId);
- }
-
- @Override
- public boolean setActive(DeviceIdentifier deviceId, boolean status)
- throws DeviceManagementException {
- DeviceManagerService dms =
- this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
- return dms.setActive(deviceId, status);
- }
-
- @Override
- public List getAllDevices(String type) throws DeviceManagementException {
- DeviceManagerService dms =
- this.getPluginRepository().getDeviceManagementProvider(type);
- List devicesList = new ArrayList();
- try {
- Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(type);
- List devices =
- this.getDeviceDAO().getDevices(deviceTypeId);
-
- for (org.wso2.carbon.device.mgt.core.dto.Device device : devices) {
- Device convertedDevice = DeviceManagementDAOUtil.convertDevice(device);
- DeviceIdentifier deviceIdentifier = DeviceManagementDAOUtil
- .createDeviceIdentifier(device, this.deviceTypeDAO
- .getDeviceType(device.getDeviceTypeId()));
- Device dmsDevice = dms.getDevice(deviceIdentifier);
- convertedDevice.setProperties(dmsDevice.getProperties());
- convertedDevice.setFeatures(dmsDevice.getFeatures());
- devicesList.add(convertedDevice);
- }
- } catch (DeviceManagementDAOException e) {
- throw new DeviceManagementException("Error occurred while obtaining the device for type '" + type + "'",
- e);
- }
- return devicesList;
- }
-
- @Override
- public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
- DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
- return dms.getDevice(deviceId);
- }
-
- @Override
- public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
- DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
- return dms.updateDeviceInfo(device);
- }
-
- @Override
- public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
- DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
- return dms.setOwnership(deviceId, ownershipType);
- }
-
- public OperationManager getOperationManager(String type) throws DeviceManagementException {
- DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(type);
- return dms.getOperationManager();
- }
-
- public DeviceDAO getDeviceDAO() {
- return deviceDAO;
- }
-
- public DeviceTypeDAO getDeviceTypeDAO() {
- return deviceTypeDAO;
- }
-
- public DeviceManagementRepository getPluginRepository() {
- return pluginRepository;
- }
+ private DeviceDAO deviceDAO;
+ private DeviceTypeDAO deviceTypeDAO;
+ private DeviceManagementConfig config;
+ private DeviceManagementRepository pluginRepository;
+
+ public DeviceManagerImpl(DeviceManagementConfig config, DeviceManagementRepository pluginRepository) {
+ this.config = config;
+ this.pluginRepository = pluginRepository;
+ this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
+ this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
+ }
+
+ @Override public boolean enrollDevice(Device device) throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
+ boolean status = dms.enrollDevice(device);
+
+ try {
+ org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device);
+ Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
+ deviceDto.setDeviceTypeId(deviceTypeId);
+ this.getDeviceDAO().addDevice(deviceDto);
+
+ } catch (DeviceManagementDAOException e) {
+ throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'",
+ e);
+ }
+ return status;
+ }
+
+ @Override public boolean modifyEnrollment(Device device) throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
+ boolean status = dms.modifyEnrollment(device);
+ try {
+ this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device));
+ } catch (DeviceManagementDAOException e) {
+ throw new DeviceManagementException("Error occurred while modifying the device '" + device.getId() + "'",
+ e);
+ }
+ return status;
+ }
+
+ @Override public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
+ return dms.disenrollDevice(deviceId);
+ }
+
+ @Override public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
+ return dms.isEnrolled(deviceId);
+ }
+
+ @Override public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
+ return dms.isActive(deviceId);
+ }
+
+ @Override public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
+ return dms.setActive(deviceId, status);
+ }
+
+ @Override public List getAllDevices(String type) throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(type);
+ List devicesList = new ArrayList();
+ try {
+ Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(type);
+ List devices = this.getDeviceDAO().getDevices(deviceTypeId);
+
+ for (org.wso2.carbon.device.mgt.core.dto.Device device : devices) {
+ DeviceType deviceType = this.deviceTypeDAO.getDeviceType(device.getDeviceTypeId());
+ Device convertedDevice = DeviceManagementDAOUtil.convertDevice(device, deviceType);
+ DeviceIdentifier deviceIdentifier = DeviceManagementDAOUtil.createDeviceIdentifier(device, deviceType);
+ Device dmsDevice = dms.getDevice(deviceIdentifier);
+ if (dmsDevice != null) {
+ convertedDevice.setProperties(dmsDevice.getProperties());
+ convertedDevice.setFeatures(dmsDevice.getFeatures());
+ }
+ devicesList.add(convertedDevice);
+ }
+ } catch (DeviceManagementDAOException e) {
+ throw new DeviceManagementException("Error occurred while obtaining the device for type '" + type + "'", e);
+ }
+ return devicesList;
+ }
+
+ @Override public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
+ Device convertedDevice = null;
+ try {
+ Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(deviceId.getType());
+ org.wso2.carbon.device.mgt.core.dto.Device device =
+ this.getDeviceDAO().getDeviceByDeviceIdentifier(deviceTypeId, deviceId.getId());
+ if (device != null) {
+ convertedDevice = DeviceManagementDAOUtil
+ .convertDevice(device, this.getDeviceTypeDAO().getDeviceType(deviceTypeId));
+ Device dmsDevice = dms.getDevice(deviceId);
+ if (dmsDevice != null) {
+ convertedDevice.setProperties(dmsDevice.getProperties());
+ convertedDevice.setFeatures(dmsDevice.getFeatures());
+ }
+ }
+ } catch (DeviceManagementDAOException e) {
+ throw new DeviceManagementException(
+ "Error occurred while obtaining the device for id '" + deviceId.getId() + "'", e);
+ }
+ return convertedDevice;
+ }
+
+ @Override public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
+ return dms.updateDeviceInfo(device);
+ }
+
+ @Override public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
+ throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
+ return dms.setOwnership(deviceId, ownershipType);
+ }
+
+ public OperationManager getOperationManager(String type) throws DeviceManagementException {
+ DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(type);
+ return dms.getOperationManager();
+ }
+
+ public DeviceDAO getDeviceDAO() {
+ return deviceDAO;
+ }
+
+ public DeviceTypeDAO getDeviceTypeDAO() {
+ return deviceTypeDAO;
+ }
+
+ public DeviceManagementRepository getPluginRepository() {
+ return pluginRepository;
+ }
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java
index d99db291a2..f474ba1c6f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java
@@ -28,22 +28,30 @@ import java.util.List;
*/
public interface DeviceDAO {
- void addDevice(Device device) throws DeviceManagementDAOException;
+ void addDevice(Device device) throws DeviceManagementDAOException;
- void updateDevice(Device device) throws DeviceManagementDAOException;
+ void updateDevice(Device device) throws DeviceManagementDAOException;
- void updateDeviceStatus(Long deviceId, Status status) throws DeviceManagementDAOException;
+ void updateDeviceStatus(Long deviceId, Status status) throws DeviceManagementDAOException;
- void deleteDevice(Long deviceId) throws DeviceManagementDAOException;
+ void deleteDevice(Long deviceId) throws DeviceManagementDAOException;
- Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException;
+ Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException;
- List getDevices() throws DeviceManagementDAOException;
+ /**
+ * @param type - Device type.
+ * @param identifier - Device identifier.
+ * @return
+ * @throws DeviceManagementDAOException
+ */
+ Device getDeviceByDeviceIdentifier(Integer type, String identifier) throws DeviceManagementDAOException;
- /**
- * @param type - The device type id.
- * @return a list of devices based on the type id.
- * @throws DeviceManagementDAOException
- */
- List getDevices(Integer type) throws DeviceManagementDAOException;
+ List getDevices() throws DeviceManagementDAOException;
+
+ /**
+ * @param type - The device type id.
+ * @return a list of devices based on the type id.
+ * @throws DeviceManagementDAOException
+ */
+ List getDevices(Integer type) throws DeviceManagementDAOException;
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java
index 97fa8e25b3..e47fbcc17e 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java
@@ -21,8 +21,8 @@ package org.wso2.carbon.device.mgt.core.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
-import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
+import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.dto.Device;
import org.wso2.carbon.device.mgt.core.dto.Status;
@@ -37,120 +37,153 @@ import java.util.List;
public class DeviceDAOImpl implements DeviceDAO {
- private DataSource dataSource;
- private static final Log log = LogFactory.getLog(DeviceDAOImpl.class);
-
-
- public DeviceDAOImpl(DataSource dataSource) {
- this.dataSource = dataSource;
- }
-
- @Override
- public void addDevice(Device device) throws DeviceManagementDAOException {
- Connection conn = null;
- PreparedStatement stmt = null;
- try {
- conn = this.getConnection();
- String createDBQuery =
- "INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DATE_OF_ENROLLMENT, DATE_OF_LAST_UPDATE, OWNERSHIP," +
- "STATUS, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, OWNER, TENANT_ID) VALUES " +
- "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
-
- stmt = conn.prepareStatement(createDBQuery);
- stmt.setString(1, device.getDescription());
- stmt.setString(2, device.getName());
- stmt.setLong(3, new Date().getTime());
- stmt.setLong(4, new Date().getTime());
- stmt.setString(5, device.getOwnerShip());
- stmt.setString(6, device.getStatus().toString());
- stmt.setInt(7, device.getDeviceTypeId());
- stmt.setString(8, device.getDeviceIdentificationId());
- stmt.setString(9, device.getOwnerId());
- stmt.setInt(10, device.getTenantId());
- stmt.executeUpdate();
- } catch (SQLException e) {
- String msg = "Error occurred while enrolling device '" + device.getName() + "'";
- log.error(msg, e);
- throw new DeviceManagementDAOException(msg, e);
- } finally {
- DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
- }
- }
-
- @Override
- public void updateDevice(Device device) throws DeviceManagementDAOException {
-
- }
-
- @Override
- public void updateDeviceStatus(Long deviceId, Status status) throws DeviceManagementDAOException {
-
- }
-
- @Override
- public void deleteDevice(Long deviceId) throws DeviceManagementDAOException {
-
- }
-
- @Override
- public Device getDeviceByDeviceId(Long deviceId)
- throws DeviceManagementDAOException {
- return null;
- }
-
- @Override
- public List getDevices() throws DeviceManagementDAOException {
- return null;
- }
-
- @Override public List getDevices(Integer type) throws DeviceManagementDAOException {
- Connection conn = null;
- PreparedStatement stmt = null;
- ResultSet resultSet = null;
- List devicesList = null;
- try {
- conn = this.getConnection();
- String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " +
- "DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " +
- "DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " +
- "WHERE DM_DEVICE.DEVICE_TYPE_ID=?";
- stmt = conn.prepareStatement(selectDBQueryForType);
- stmt.setInt(1, type);
- resultSet = stmt.executeQuery();
- devicesList = new ArrayList();
- while (resultSet.next()) {
- Device device = new Device();
- device.setId(resultSet.getInt(1));
- device.setDescription(resultSet.getString(2));
- device.setName(resultSet.getString(3));
- device.setDateOfEnrollment(resultSet.getLong(4));
- device.setDateOfLastUpdate(resultSet.getLong(5));
- //TODO:- Ownership is not a enum in DeviceDAO
- device.setOwnerShip(resultSet.getString(6));
- device.setStatus(Status.valueOf(resultSet.getString(7)));
- device.setDeviceTypeId(resultSet.getInt(8));
- device.setDeviceIdentificationId(resultSet.getString(9));
- device.setOwnerId(resultSet.getString(10));
- device.setTenantId(resultSet.getInt(11));
- devicesList.add(device);
- }
- } catch (SQLException e) {
- String msg = "Error occurred while listing devices for type '" + type + "'";
- log.error(msg, e);
- throw new DeviceManagementDAOException(msg, e);
- } finally {
- DeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
- }
- return devicesList;
- }
-
- private Connection getConnection() throws DeviceManagementDAOException {
- try {
- return dataSource.getConnection();
- } catch (SQLException e) {
- throw new DeviceManagementDAOException("Error occurred while obtaining a connection from the device " +
- "management metadata repository datasource", e);
- }
- }
+ private DataSource dataSource;
+ private static final Log log = LogFactory.getLog(DeviceDAOImpl.class);
+
+ public DeviceDAOImpl(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ @Override public void addDevice(Device device) throws DeviceManagementDAOException {
+ Connection conn = null;
+ PreparedStatement stmt = null;
+ try {
+ conn = this.getConnection();
+ String createDBQuery =
+ "INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DATE_OF_ENROLLMENT, DATE_OF_LAST_UPDATE, OWNERSHIP," +
+ "STATUS, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, OWNER, TENANT_ID) VALUES " +
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+
+ stmt = conn.prepareStatement(createDBQuery);
+ stmt.setString(1, device.getDescription());
+ stmt.setString(2, device.getName());
+ stmt.setLong(3, new Date().getTime());
+ stmt.setLong(4, new Date().getTime());
+ stmt.setString(5, device.getOwnerShip());
+ stmt.setString(6, device.getStatus().toString());
+ stmt.setInt(7, device.getDeviceTypeId());
+ stmt.setString(8, device.getDeviceIdentificationId());
+ stmt.setString(9, device.getOwnerId());
+ stmt.setInt(10, device.getTenantId());
+ stmt.executeUpdate();
+ } catch (SQLException e) {
+ String msg = "Error occurred while enrolling device '" + device.getName() + "'";
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ } finally {
+ DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
+ }
+ }
+
+ @Override public void updateDevice(Device device) throws DeviceManagementDAOException {
+
+ }
+
+ @Override public void updateDeviceStatus(Long deviceId, Status status) throws DeviceManagementDAOException {
+
+ }
+
+ @Override public void deleteDevice(Long deviceId) throws DeviceManagementDAOException {
+
+ }
+
+ @Override public Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException {
+ return null;
+ }
+
+ @Override public Device getDeviceByDeviceIdentifier(Integer type, String identifier)
+ throws DeviceManagementDAOException {
+ Connection conn = null;
+ PreparedStatement stmt = null;
+ ResultSet resultSet = null;
+ Device device = null;
+ try {
+ conn = this.getConnection();
+ String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " +
+ "DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " +
+ "DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " +
+ "WHERE DM_DEVICE.DEVICE_TYPE_ID=? AND DM_DEVICE.DEVICE_IDENTIFICATION=?";
+ stmt = conn.prepareStatement(selectDBQueryForType);
+ stmt.setInt(1, type);
+ stmt.setString(2, identifier);
+ resultSet = stmt.executeQuery();
+ while (resultSet.next()) {
+ device = new Device();
+ device.setId(resultSet.getInt(1));
+ device.setDescription(resultSet.getString(2));
+ device.setName(resultSet.getString(3));
+ device.setDateOfEnrollment(resultSet.getLong(4));
+ device.setDateOfLastUpdate(resultSet.getLong(5));
+ //TODO:- Ownership is not a enum in DeviceDAO
+ device.setOwnerShip(resultSet.getString(6));
+ device.setStatus(Status.valueOf(resultSet.getString(7)));
+ device.setDeviceTypeId(resultSet.getInt(8));
+ device.setDeviceIdentificationId(resultSet.getString(9));
+ device.setOwnerId(resultSet.getString(10));
+ device.setTenantId(resultSet.getInt(11));
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while listing devices for type '" + type + "'";
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ } finally {
+ DeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
+ }
+ return device;
+ }
+
+ @Override public List getDevices() throws DeviceManagementDAOException {
+ return null;
+ }
+
+ @Override public List getDevices(Integer type) throws DeviceManagementDAOException {
+ Connection conn = null;
+ PreparedStatement stmt = null;
+ ResultSet resultSet = null;
+ List devicesList = null;
+ try {
+ conn = this.getConnection();
+ String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " +
+ "DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " +
+ "DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " +
+ "WHERE DM_DEVICE.DEVICE_TYPE_ID=?";
+ stmt = conn.prepareStatement(selectDBQueryForType);
+ stmt.setInt(1, type);
+ resultSet = stmt.executeQuery();
+ devicesList = new ArrayList();
+ while (resultSet.next()) {
+ Device device = new Device();
+ device.setId(resultSet.getInt(1));
+ device.setDescription(resultSet.getString(2));
+ device.setName(resultSet.getString(3));
+ device.setDateOfEnrollment(resultSet.getLong(4));
+ device.setDateOfLastUpdate(resultSet.getLong(5));
+ //TODO:- Ownership is not a enum in DeviceDAO
+ device.setOwnerShip(resultSet.getString(6));
+ device.setStatus(Status.valueOf(resultSet.getString(7)));
+ device.setDeviceTypeId(resultSet.getInt(8));
+ device.setDeviceIdentificationId(resultSet.getString(9));
+ device.setOwnerId(resultSet.getString(10));
+ device.setTenantId(resultSet.getInt(11));
+ devicesList.add(device);
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while listing devices for type '" + type + "'";
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ } finally {
+ DeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
+ }
+ return devicesList;
+ }
+
+ private Connection getConnection() throws DeviceManagementDAOException {
+ try {
+ return dataSource.getConnection();
+ } catch (SQLException e) {
+ throw new DeviceManagementDAOException("Error occurred while obtaining a connection from the device " +
+ "management metadata repository datasource", e);
+ }
+ }
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java
index 951d33dae9..fdc3df4d2a 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/util/DeviceManagementDAOUtil.java
@@ -34,9 +34,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.Hashtable;
-import java.util.List;
public final class DeviceManagementDAOUtil {
@@ -107,9 +105,10 @@ public final class DeviceManagementDAOUtil {
/**
* @param device - The DTO device object.
+ * @param deviceType - The DeviceType object associated with the device
* @return A Business Object.
*/
- public static org.wso2.carbon.device.mgt.common.Device convertDevice(Device device){
+ public static org.wso2.carbon.device.mgt.common.Device convertDevice(Device device, DeviceType deviceType){
org.wso2.carbon.device.mgt.common.Device deviceBO =
new org.wso2.carbon.device.mgt.common.Device();
deviceBO.setDateOfEnrolment(device.getDateOfEnrollment());
@@ -117,6 +116,7 @@ public final class DeviceManagementDAOUtil {
deviceBO.setDescription(device.getDescription());
deviceBO.setDeviceIdentifier(device.getDeviceIdentificationId());
deviceBO.setDeviceTypeId(device.getDeviceTypeId());
+ deviceBO.setType(deviceType.getName());
deviceBO.setName(device.getName());
deviceBO.setId(device.getId());
deviceBO.setOwner(device.getOwnerId());
@@ -126,21 +126,7 @@ public final class DeviceManagementDAOUtil {
} else if (device.getStatus() == Status.INACTIVE) {
deviceBO.setStatus(false);
}
- return null;
- }
-
- /**
- * @param devices - DTO Device Object list.
- * @return converted Business Object list.
- */
- public static List convertDevices(
- List devices) {
- List deviceBOList =
- new ArrayList();
- for (Device device : devices) {
- deviceBOList.add(convertDevice(device));
- }
- return deviceBOList;
+ return deviceBO;
}
public static Device convertDevice(org.wso2.carbon.device.mgt.common.Device
diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml
index 8f5ab63216..4914e0e739 100644
--- a/components/device-mgt/pom.xml
+++ b/components/device-mgt/pom.xml
@@ -24,14 +24,14 @@
org.wso2.carbon
wso2cdm-parent
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../../pom.xml
4.0.0
org.wso2.carbon
device-mgt
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
pom
WSO2 Carbon - Device Management Component
http://wso2.org
diff --git a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/pom.xml b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/pom.xml
index b53ef4bba9..637004f6ed 100644
--- a/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/pom.xml
+++ b/components/key-mgt/org.wso2.carbon.key.mgt.handler.valve/pom.xml
@@ -22,14 +22,14 @@
org.wso2.carbon
key-mgt
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon
org.wso2.carbon.key.mgt.handler.valve
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
bundle
WSO2 Carbon - Key Management Handler Valve
WSO2 Carbon - Key Management Handler Valve
diff --git a/components/key-mgt/pom.xml b/components/key-mgt/pom.xml
index 67b910014f..a941561439 100644
--- a/components/key-mgt/pom.xml
+++ b/components/key-mgt/pom.xml
@@ -24,14 +24,14 @@
org.wso2.carbon
wso2cdm-parent
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../../pom.xml
4.0.0
org.wso2.carbon
key-mgt
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
pom
WSO2 Carbon - Device Management Component
http://wso2.org
@@ -61,7 +61,7 @@
org.wso2.carbon
org.wso2.carbon.device.mgt.common
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
org.eclipse.osgi
diff --git a/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml
index 5688d817a7..efaee90c29 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml
+++ b/components/policy-mgt/org.wso2.carbon.policy.evalutor/pom.xml
@@ -21,14 +21,14 @@
org.wso2.carbon
policy-mgt
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon
org.wso2.carbon.policy.evaluator
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
bundle
WSO2 Carbon - Policy Decision Point
WSO2 Carbon - Policy Decision Point
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml
index f6384a31b6..466f6b19c9 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml
@@ -21,14 +21,14 @@
org.wso2.carbon
policy-mgt
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon
org.wso2.carbon.policy.mgt.common
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
bundle
WSO2 Carbon - Policy Management Common
WSO2 Carbon - Policy Management Common
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml
index 1918eebf9b..1e3e5a44f9 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml
@@ -21,14 +21,14 @@
org.wso2.carbon
policy-mgt
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon
org.wso2.carbon.policy.mgt.core
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
bundle
WSO2 Carbon - Policy Management Core
WSO2 Carbon - Policy Management Core
diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml
index 05e9bd4613..369587f5bd 100644
--- a/components/policy-mgt/pom.xml
+++ b/components/policy-mgt/pom.xml
@@ -23,14 +23,14 @@
org.wso2.carbon
wso2cdm-parent
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../../pom.xml
4.0.0
org.wso2.carbon
policy-mgt
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
pom
WSO2 Carbon - Policy Management Component
http://wso2.org
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml
index ba36238a26..5b7a05969f 100644
--- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml
+++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml
@@ -22,14 +22,14 @@
org.wso2.carbon
device-mgt-feature
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon.device.mgt.server.feature
pom
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
WSO2 Carbon - Device Management Server Feature
http://wso2.org
This feature contains the core bundles required for Back-end Devvice Management functionality
diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml
index 44b6951806..dd9fde5470 100644
--- a/features/device-mgt/pom.xml
+++ b/features/device-mgt/pom.xml
@@ -24,14 +24,14 @@
org.wso2.carbon
wso2cdm-parent
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../../pom.xml
4.0.0
org.wso2.carbon
device-mgt-feature
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
pom
WSO2 Carbon - Device Management Feature
http://wso2.org
diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml
index 4dd13fcc97..5cf75e12a1 100644
--- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml
+++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml
@@ -23,14 +23,14 @@
org.wso2.carbon
policy-mgt-feature
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
4.0.0
org.wso2.carbon.policy.mgt.server.feature
pom
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
WSO2 Carbon - Policy Management Server Feature
http://wso2.org
This feature contains the core bundles required for Back-end Devvice Management functionality
diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml
index b500e800d2..457a08dcb4 100644
--- a/features/policy-mgt/pom.xml
+++ b/features/policy-mgt/pom.xml
@@ -23,14 +23,14 @@
org.wso2.carbon
wso2cdm-parent
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../../pom.xml
4.0.0
org.wso2.carbon
policy-mgt-feature
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
pom
WSO2 Carbon - Policy Management Feature
http://wso2.org
diff --git a/pom.xml b/pom.xml
index 9f35b898f9..e4618c0556 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
org.wso2.carbon
wso2cdm-parent
pom
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
WSO2 CDM - Parent
http://wso2.org
WSO2 Connected Device Manager
@@ -213,12 +213,13 @@
[1.6.1.wso2v11, 1.7.0)
1.0.0.Final
1.5.4
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
0.9.0-SNAPSHOT
1.1.0
1.0.0
1.0.0
+ 1.1.0-SNAPSHOT
1.1.0
4.3.1
diff --git a/product/modules/distribution/pom.xml b/product/modules/distribution/pom.xml
index 7b284b49fd..63e8c9328d 100644
--- a/product/modules/distribution/pom.xml
+++ b/product/modules/distribution/pom.xml
@@ -24,7 +24,7 @@
org.wso2.cdmserver
wso2cdmserver-product
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../../pom.xml
diff --git a/product/modules/distribution/src/assembly/bin.xml b/product/modules/distribution/src/assembly/bin.xml
index 69fdb98e2b..76382b863e 100644
--- a/product/modules/distribution/src/assembly/bin.xml
+++ b/product/modules/distribution/src/assembly/bin.xml
@@ -210,7 +210,7 @@
- ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/cdm
+ ../distribution/src/repository/dbscripts/cdm
wso2cdm-${project.version}/dbscripts/cdm
*/**
@@ -223,13 +223,15 @@
${project.artifactId}-${project.version}/repository/resources
-
-
- src/repository/jaggeryapps
- wso2cdm-${project.version}/repository/deployment/server/jaggeryapps
-
- 755
-
+
+
+
+
+
+
+
@@ -462,5 +464,15 @@
644
+
+
+
diff --git a/product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db b/product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db
new file mode 100644
index 0000000000..219f5ea3fb
Binary files /dev/null and b/product/modules/distribution/src/repository/database/WSO2MobileDM_DB.h2.db differ
diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql b/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql
index 783acaa8de..3ceea15a02 100644
--- a/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql
+++ b/product/modules/distribution/src/repository/dbscripts/cdm/h2.sql
@@ -23,4 +23,4 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE
REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
);
-- TO:DO - Remove this INSERT sql statement.
-Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android');
+Insert into DM_DEVICE_TYPE (NAME) VALUES ('android');
diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql
index fd239aa58f..39610edd9a 100644
--- a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql
+++ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql
@@ -31,13 +31,8 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
`FEATURE_CODE` VARCHAR(45) NOT 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);
+ `CREATED_DATE` BIGINT NULL ,
+ PRIMARY KEY (`OPERATION_ID`));
-- -----------------------------------------------------
-- Table `MBL_DEVICE_OPERATION_MAPPING`
@@ -45,8 +40,8 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
`DEVICE_ID` VARCHAR(45) NOT NULL ,
`OPERATION_ID` INT NOT NULL ,
- `SENT_DATE` INT NULL ,
- `RECEIVED_DATE` INT NULL ,
+ `SENT_DATE` BIGINT NULL ,
+ `RECEIVED_DATE` BIGINT NULL ,
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
FOREIGN KEY (`DEVICE_ID` )
diff --git a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql~ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql~
index 85304414bf..31ae8bd724 100644
--- a/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql~
+++ b/product/modules/distribution/src/repository/dbscripts/cdm/plugins/h2.sql~
@@ -10,6 +10,8 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
`VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
+ `LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
+ `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`) );
@@ -18,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
- `CODE` VARCHAR(45) NULL ,
+ `CODE` VARCHAR(45) NOT NULL ,
`NAME` VARCHAR(100) NULL ,
`DESCRIPTION` VARCHAR(200) NULL ,
PRIMARY KEY (`FEATURE_ID`) );
@@ -28,23 +30,18 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
-- -----------------------------------------------------
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);
+ `FEATURE_CODE` VARCHAR(45) NOT NULL ,
+ `CREATED_DATE` LONG NULL ,
+ PRIMARY KEY (`OPERATION_ID`));
-- -----------------------------------------------------
--- Table `MBL_DEVICE_OPERATION_MAPING`
+-- Table `MBL_DEVICE_OPERATION_MAPPING`
-- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
+CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
`DEVICE_ID` VARCHAR(45) NOT NULL ,
`OPERATION_ID` INT NOT NULL ,
- `SENT_DATE` INT NULL ,
- `RECEIVED_DATE` INT NULL ,
+ `SENT_DATE` LONG NULL ,
+ `RECEIVED_DATE` LONG NULL ,
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
FOREIGN KEY (`DEVICE_ID` )
@@ -61,11 +58,10 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
-- 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 ,
+ `OPERATION_ID` INT NOT NULL ,
+ `PROPERTY` VARCHAR(45) NOT NULL ,
`VALUE` TEXT NULL ,
- PRIMARY KEY (`OPERATION_PROPERTY_ID`) ,
+ PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) ,
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
FOREIGN KEY (`OPERATION_ID` )
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
@@ -76,13 +72,11 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
-- 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`) ,
+ `PROPERTY` VARCHAR(45) NOT NULL ,
+ `FEATURE_ID` VARCHAR(45) NOT NULL ,
+ PRIMARY KEY (`PROPERTY`) ,
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
FOREIGN KEY (`FEATURE_ID` )
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-
diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag
new file mode 100644
index 0000000000..10f37dc405
--- /dev/null
+++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag
@@ -0,0 +1,38 @@
+<%
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+var utility = require("/modules/utility.js");
+var deviceManagementService = utility.getDeviceManagementService();
+var devices = deviceManagementService.getAllDevices("android");
+var logger = new Log();
+var deviceList = [];
+for (i = 0; i < devices.size(); i++) {
+ var device = devices.get(i);
+ deviceList.push({
+ "identifier": device.getDeviceIdentifier(),
+ "name": device.getName(),
+ "ownership": device.getOwnership(),
+ "owner": device.getOwner(),
+ "deviceType": device.getType(),
+ "vendor": device.getProperties().get("vendor"),
+ "model": device.getProperties().get("model"),
+ "osVersion": device.getProperties().get("osVersion")
+ });
+}
+print(deviceList);
+%>
\ No newline at end of file
diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js
index 27d9cf25ce..859dd1037f 100644
--- a/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js
+++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js
@@ -1 +1,32 @@
-//Init js to execute
\ No newline at end of file
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//Init js to execute
+var logger = new Log();
+logger.debug("running debug");
+var app_TENANT_CONFIGS = 'tenant.configs';
+var app_carbon = require('carbon');
+var app_configs = {
+ "HTTPS_URL": "https://localhost:9443"
+};
+
+var app_server = new app_carbon.server.Server({
+ tenanted: app_configs.tenanted,
+ url: app_configs.HTTPS_URL + '/admin'
+});
+application.put("SERVER", app_server);
+application.put(app_TENANT_CONFIGS, {});
diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf b/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf
index 3012d60828..efc8b12576 100644
--- a/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf
+++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf
@@ -1,6 +1,6 @@
{
"welcomeFiles": ["pages/dashboard.jag"],
- "initScripts": ["init.js"],
+ "initScripts": ["/init.js"],
"urlMappings": [
{
"url": "/devices/*",
@@ -9,12 +9,16 @@
{
"url": "/dashboard",
"path": "/pages/dashboard.jag"
+ },
+ {
+ "url": "/api/devices/mobile/*",
+ "path": "/api/mobile/device-api.jag"
}
],
"errorPages": {
"500": "/error500.jag",
"404": "/error404.jag",
- "403": "/error403.jag"
+ "403": "/error403.jag "
},
- "logLevel": "info"
+ "logLevel": "debug"
}
\ No newline at end of file
diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/utility.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/utility.js
new file mode 100644
index 0000000000..47b8862bfe
--- /dev/null
+++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/utility.js
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//temporary
+
+var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext,
+ Class = java.lang.Class;
+
+osgiService = function (clazz) {
+ return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(Class.forName(clazz));
+};
+var getDeviceManagementService= function(){
+ //server.authenticate("admin", "admin");
+ var realmService = osgiService('org.wso2.carbon.device.mgt.core.service.DeviceManagementService');
+ //var realmService = null;
+ return realmService;
+}
diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag
index 35d2f255b5..46c5cd3dad 100644
--- a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag
+++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag
@@ -1,5 +1,22 @@
-<%
+<%
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
var title="WSO2 CDM";
%>
@@ -14,25 +31,43 @@ var title="WSO2 CDM";
diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag
index e4930c190f..3005b915cd 100644
--- a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag
+++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag
@@ -1,5 +1,22 @@
-<%
+<%
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
var title="WSO2 CDM";
%>
diff --git a/product/modules/integration/pom.xml b/product/modules/integration/pom.xml
index fb2ef0f59e..4e489975ab 100644
--- a/product/modules/integration/pom.xml
+++ b/product/modules/integration/pom.xml
@@ -23,7 +23,7 @@
org.wso2.cdmserver
wso2cdmserver-product
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../../pom.xml
4.0.0
diff --git a/product/modules/integration/tests-common/admin-clients/pom.xml b/product/modules/integration/tests-common/admin-clients/pom.xml
index 10da72790e..48d8c6aaac 100644
--- a/product/modules/integration/tests-common/admin-clients/pom.xml
+++ b/product/modules/integration/tests-common/admin-clients/pom.xml
@@ -24,7 +24,7 @@
org.wso2.cdmserver
cdm-integration-tests-common
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
diff --git a/product/modules/integration/tests-common/integration-test-utils/pom.xml b/product/modules/integration/tests-common/integration-test-utils/pom.xml
index 28aee1ab94..db30f96b55 100644
--- a/product/modules/integration/tests-common/integration-test-utils/pom.xml
+++ b/product/modules/integration/tests-common/integration-test-utils/pom.xml
@@ -24,7 +24,7 @@
org.wso2.cdmserver
cdm-integration-tests-common
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
diff --git a/product/modules/integration/tests-common/pom.xml b/product/modules/integration/tests-common/pom.xml
index e79e88cbf6..caf7213793 100644
--- a/product/modules/integration/tests-common/pom.xml
+++ b/product/modules/integration/tests-common/pom.xml
@@ -24,7 +24,7 @@
org.wso2.cdmserver
wso2cdm-integration
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
diff --git a/product/modules/integration/tests-common/ui-pages/pom.xml b/product/modules/integration/tests-common/ui-pages/pom.xml
index 2906ce7f40..a500abf9b8 100644
--- a/product/modules/integration/tests-common/ui-pages/pom.xml
+++ b/product/modules/integration/tests-common/ui-pages/pom.xml
@@ -24,7 +24,7 @@
org.wso2.cdmserver
cdm-integration-tests-common
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml
diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml
index 228539260f..bab99d16e3 100644
--- a/product/modules/p2-profile-gen/pom.xml
+++ b/product/modules/p2-profile-gen/pom.xml
@@ -22,7 +22,7 @@
org.wso2.cdmserver
wso2cdmserver-product
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../../pom.xml
@@ -115,7 +115,24 @@
org.wso2.carbon:org.wso2.carbon.webapp.mgt.feature:${carbon.platform.version}
-
+
+ org.jaggeryjs:org.jaggeryjs.feature:${jaggery.feature.version}
+
+
+ org.jaggeryjs.modules:carbon.feature:${carbon.feature.version}
+
+
+ org.jaggeryjs.modules:process.feature:${process.feature.version}
+
+
+ org.jaggeryjs.modules:uuid.feature:${uuid.feature.version}
+
+
+ org.jaggeryjs.modules:sso.feature:${sso.feature.version}
+
+
+ org.jaggeryjs.modules:jaggery-test.feature:${jaggery-test.feature.version}
+
org.wso2.carbon:org.wso2.carbon.transport.mgt.feature:${carbon.platform.version}
@@ -254,6 +271,30 @@
org.wso2.carbon.webapp.mgt.feature.group
${carbon.platform.version}
+
+ org.jaggeryjs.feature.group
+ ${jaggery.feature.version}
+
+
+ org.jaggeryjs.modules.carbon.feature.group
+ ${carbon.feature.version}
+
+
+ org.jaggeryjs.modules.process.feature.group
+ ${process.feature.version}
+
+
+ org.jaggeryjs.modules.uuid.feature.group
+ ${uuid.feature.version}
+
+
+ org.jaggeryjs.modules.sso.feature.group
+ ${sso.feature.version}
+
+
+ org.jaggeryjs.modules.jaggery-test.feature.group
+ ${jaggery-test.feature.version}
+
org.wso2.carbon.transport.mgt.feature.group
${carbon.platform.version}
diff --git a/product/pom.xml b/product/pom.xml
index 00c50d15e8..bc3243141e 100644
--- a/product/pom.xml
+++ b/product/pom.xml
@@ -23,7 +23,7 @@
org.wso2.carbon
wso2cdm-parent
- 2.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
../pom.xml