From c4e2722586747705e15b6dadf4c615fcd0bd1596 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 12 Dec 2014 17:21:27 +0530 Subject: [PATCH 1/8] Unit test framework for DAO tests --- .../device/mgt/core/common/DBTypes.java | 26 +++ .../mgt/core/common/TestDBConfiguration.java | 86 +++++++++ .../mgt/core/common/TestDBConfigurations.java | 36 ++++ .../device/mgt/core/dao/DeviceDAOTest.java | 28 +++ .../mgt/core/dao/DeviceMgtDAOTestSuite.java | 171 ++++++++++++++++++ .../src/test/resources/sql/CreateH2TestDB.sql | 24 +++ .../src/test/resources/testdbconfig.xml | 24 +++ .../src/test/resources/testng.xml | 28 +++ 8 files changed, 423 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/DBTypes.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfigurations.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAOTest.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testdbconfig.xml create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/DBTypes.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/DBTypes.java new file mode 100644 index 0000000000..203d580cea --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/DBTypes.java @@ -0,0 +1,26 @@ +/* + * 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. + */ + +package org.wso2.carbon.device.mgt.core.common; + + +public enum DBTypes { + Oracle("Oracle"),H2("H2"),MySql("MySql"); + + String dbName ; + DBTypes(String dbStrName) { + dbName = dbStrName; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java new file mode 100644 index 0000000000..3b8dd365c1 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java @@ -0,0 +1,86 @@ +/* + * 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. + */ + +package org.wso2.carbon.device.mgt.core.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; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfigurations.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfigurations.java new file mode 100644 index 0000000000..7c7fdfb731 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfigurations.java @@ -0,0 +1,36 @@ +/* + * 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. + */ + +package org.wso2.carbon.device.mgt.core.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 dbTypesList; + + @XmlElement(name = "DBType") + public List getDbTypesList() { + return dbTypesList; + } + + public void setDbTypesList(List dbTypesList) { + this.dbTypesList = dbTypesList; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAOTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAOTest.java new file mode 100644 index 0000000000..980527aaec --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAOTest.java @@ -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. + */ + +package org.wso2.carbon.device.mgt.core.dao; + +import org.testng.Assert; + +public class DeviceDAOTest { + + // @Test + public void setUp() throws Exception { + // log.info("Testing started."); + Assert.assertEquals("A", "A"); + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java new file mode 100644 index 0000000000..1616fc6eea --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java @@ -0,0 +1,171 @@ +/* + * 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. + */ + +package org.wso2.carbon.device.mgt.core.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.core.common.DBTypes; +import org.wso2.carbon.device.mgt.core.common.TestDBConfiguration; +import org.wso2.carbon.device.mgt.core.common.TestDBConfigurations; +import org.wso2.carbon.device.mgt.core.dto.Device; +import org.wso2.carbon.device.mgt.core.dto.DeviceType; +import org.wso2.carbon.device.mgt.core.dto.Status; +import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; + +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 DeviceMgtDAOTestSuite { + + private TestDBConfiguration testDBConfiguration; + private DeviceType devType = new DeviceType(); + private Connection conn = null; + private Statement stmt = null; + + @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()); + DeviceManagementDAOFactory.init(testDataSource); + default: + } + } + + private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) + throws DeviceManagementDAOException, 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 DeviceManagementDAOException("Error parsing test db configurations", e); + } + + Iterator 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 addDeviceTypeTest() throws DeviceManagementDAOException, DeviceManagementException { + + DeviceTypeDAO deviceTypeMgtDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); + + devType.setName("IOS"); + + deviceTypeMgtDAO.addDeviceType(devType); + Long deviceTypeId = null; + + try { + conn = DeviceManagementDAOFactory.getDataSource().getConnection(); + stmt = conn.createStatement(); + ResultSet resultSet = stmt.executeQuery("SELECT ID,NAME from DM_DEVICE_TYPE DType where DType.NAME='IOS'"); + + while (resultSet.next()) { + deviceTypeId = resultSet.getLong(1); + } + conn.close(); + } catch (SQLException sqlEx) { + throw new DeviceManagementDAOException("error in fetch device type by name IOS", sqlEx); + } + + Assert.assertNotNull(deviceTypeId, "Device Type Id is null"); + devType.setId(deviceTypeId); + + } + + @Test(dependsOnMethods = { "addDeviceTypeTest" }) + public void addDeviceTest() throws DeviceManagementDAOException, DeviceManagementException { + + DeviceDAO deviceMgtDAO = DeviceManagementDAOFactory.getDeviceDAO(); + + Device device = new Device(); + + device.setDateOfEnrollment(new Date().getTime()); + device.setDateOfLastUpdate(new Date().getTime()); + device.setDescription("test description"); + device.setStatus(Status.ACTIVE); + device.setDeviceIdentificationId("111"); + device.setDeviceType(devType.getId().toString()); + device.setOwnerId("111"); + deviceMgtDAO.addDevice(device); + + 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.assertNotNull(deviceId, "Device Id is null"); + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql new file mode 100644 index 0000000000..0733f55520 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -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 INTEGER NULL DEFAULT NULL, + DATE_OF_LAST_UPDATE INTEGER 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 +); \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testdbconfig.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testdbconfig.xml new file mode 100644 index 0000000000..34e89a1392 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testdbconfig.xml @@ -0,0 +1,24 @@ + + + + + + jdbc:h2:mem:cdm-test-db;DB_CLOSE_DELAY=-1 + org.h2.Driver + + + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml new file mode 100644 index 0000000000..1bf0f08f81 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/testng.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + \ No newline at end of file From 8ad13b6d0aa1f4c57934bb18c2c478bd496beb64 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 12 Dec 2014 17:22:16 +0530 Subject: [PATCH 2/8] Implement DAO unit tests --- .../org/wso2/carbon/device/mgt/common/Device.java | 13 ++++++------- .../org.wso2.carbon.device.mgt.core/pom.xml | 13 +++++++++++++ .../mgt/core/dao/DeviceManagementDAOFactory.java | 7 +++++++ .../org/wso2/carbon/device/mgt/core/dto/Device.java | 13 ++++++------- components/device-mgt/pom.xml | 9 ++++++++- 5 files changed, 40 insertions(+), 15 deletions(-) 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 8675c8af89..4d747f354b 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 @@ -15,7 +15,6 @@ */ package org.wso2.carbon.device.mgt.common; -import java.util.Date; import java.util.List; public class Device { @@ -28,9 +27,9 @@ public class Device { private String name; - private Date dateOfEnrolment; + private Long dateOfEnrolment; - private Date dateOfLastUpdate; + private Long dateOfLastUpdate; private String ownership; @@ -70,19 +69,19 @@ public class Device { this.name = name; } - public Date getDateOfEnrolment() { + public Long getDateOfEnrolment() { return dateOfEnrolment; } - public void setDateOfEnrolment(Date dateOfEnrolment) { + public void setDateOfEnrolment(Long dateOfEnrolment) { this.dateOfEnrolment = dateOfEnrolment; } - public Date getDateOfLastUpdate() { + public Long getDateOfLastUpdate() { return dateOfLastUpdate; } - public void setDateOfLastUpdate(Date dateOfLastUpdate) { + public void setDateOfLastUpdate(Long dateOfLastUpdate) { this.dateOfLastUpdate = dateOfLastUpdate; } 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 00ee94cd10..76a49c8719 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 @@ -119,6 +119,19 @@ org.jboss.spec.javax.transaction jboss-transaction-api_1.1_spec + + commons-dbcp + commons-dbcp + 1.2.2 + test + + + + com.h2database.wso2 + h2-database-engine + test + + org.testng testng diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java index 90255603c3..bc1ab0255e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceManagementDAOFactory.java @@ -44,6 +44,10 @@ public class DeviceManagementDAOFactory { dataSource = resolveDataSource(config); } + public static void init(DataSource dtSource) { + dataSource = dtSource; + } + /** * Resolve data source from the data source definition * @@ -78,4 +82,7 @@ public class DeviceManagementDAOFactory { return dataSource; } + public static DataSource getDataSource() { + return dataSource; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java index 44c9d3e579..8adbd5ff77 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java @@ -19,7 +19,6 @@ package org.wso2.carbon.device.mgt.core.dto; import java.io.Serializable; -import java.util.Date; public class Device implements Serializable { @@ -27,8 +26,8 @@ public class Device implements Serializable { private String id; private String description; private String name; - private Date dateOfEnrollment; - private Date dateOfLastUpdate; + private Long dateOfEnrollment; + private Long dateOfLastUpdate; private String deviceIdentificationId; private Status status; private String ownerId; @@ -68,19 +67,19 @@ public class Device implements Serializable { this.name = name; } - public Date getDateOfEnrollment() { + public Long getDateOfEnrollment() { return dateOfEnrollment; } - public void setDateOfEnrollment(Date dateOfEnrollment) { + public void setDateOfEnrollment(Long dateOfEnrollment) { this.dateOfEnrollment = dateOfEnrollment; } - public Date getDateOfLastUpdate() { + public Long getDateOfLastUpdate() { return dateOfLastUpdate; } - public void setDateOfLastUpdate(Date dateOfLastUpdate) { + public void setDateOfLastUpdate(Long dateOfLastUpdate) { this.dateOfLastUpdate = dateOfLastUpdate; } diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index bcfbf8edfd..a154b9ef33 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -69,6 +69,11 @@ org.eclipse.osgi.services 3.3.100.v20120522-1822 + + com.h2database.wso2 + h2-database-engine + ${orbit.version.h2.engine} + @@ -91,5 +96,7 @@ - + + 1.2.140.wso2v3 + From 10a05b024f7ab7f90ab7a136292dec566afe3a9b Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 12 Dec 2014 19:55:41 +0530 Subject: [PATCH 3/8] Device DAO unit tests implementation --- .../device-mgt/org.wso2.carbon.device.mgt.core/pom.xml | 5 +++++ .../wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java | 4 ++-- .../device/mgt/core/dao/util/DeviceManagementDAOUtil.java | 2 +- .../java/org/wso2/carbon/device/mgt/core/dto/Device.java | 6 +++--- .../carbon/device/mgt/core/common/TestDBConfiguration.java | 1 + .../carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java | 5 ++++- .../src/test/resources/sql/CreateH2TestDB.sql | 4 ++-- 7 files changed, 18 insertions(+), 9 deletions(-) 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 76a49c8719..e839f54070 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 @@ -73,6 +73,11 @@ org.apache.maven.plugins maven-surefire-plugin 2.18 + + + src/test/resources/testng.xml + + 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 94bdc06042..a9e4df8c00 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 @@ -61,10 +61,10 @@ public class DeviceDAOImpl implements DeviceDAO { stmt.setLong(4, new Date().getTime()); stmt.setString(5, device.getOwnerShip()); stmt.setString(6, device.getStatus().toString()); - stmt.setString(7, device.getDeviceType()); + stmt.setInt(7, device.getDeviceType()); stmt.setString(8, device.getDeviceIdentificationId()); stmt.setString(9, device.getOwnerId()); - stmt.setInt(10, DeviceManagementDAOUtil.getTenantId()); + stmt.setInt(10, device.getTenantId()); stmt.executeUpdate(); } catch (SQLException e) { String msg = "Error occurred while enrolling device '" + device.getName() + "'"; 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 b15f94d233..b71aaeaa15 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 @@ -113,7 +113,7 @@ public final class DeviceManagementDAOUtil { deviceBO.setOwnerId(device.getOwner()); deviceBO.setOwnerShip(device.getOwnership()); deviceBO.setTenantId(DeviceManagementDAOUtil.getTenantId()); - deviceBO.setDeviceType(device.getType()); + deviceBO.setDeviceType(Integer.parseInt(device.getType())); return deviceBO; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java index 8adbd5ff77..21c951cfae 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/Device.java @@ -33,13 +33,13 @@ public class Device implements Serializable { private String ownerId; private String ownerShip; private int tenantId; - private String deviceType; + private Integer deviceType; - public String getDeviceType() { + public Integer getDeviceType() { return deviceType; } - public void setDeviceType(String deviceType) { + public void setDeviceType(Integer deviceType) { this.deviceType = deviceType; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java index 3b8dd365c1..9689cd2621 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/TestDBConfiguration.java @@ -47,6 +47,7 @@ public class TestDBConfiguration { public void setConnectionUrl(String connectionUrl) { this.connectionUrl = connectionUrl; } + @XmlElement(name = "driverclass", nillable = false) public String getDriverClass() { return driverClass; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java index 1616fc6eea..116a24907f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/DeviceMgtDAOTestSuite.java @@ -27,6 +27,7 @@ import org.wso2.carbon.device.mgt.core.common.TestDBConfiguration; import org.wso2.carbon.device.mgt.core.common.TestDBConfigurations; import org.wso2.carbon.device.mgt.core.dto.Device; import org.wso2.carbon.device.mgt.core.dto.DeviceType; +import org.wso2.carbon.device.mgt.core.dto.OwnerShip; import org.wso2.carbon.device.mgt.core.dto.Status; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; @@ -146,8 +147,10 @@ public class DeviceMgtDAOTestSuite { device.setDescription("test description"); device.setStatus(Status.ACTIVE); device.setDeviceIdentificationId("111"); - device.setDeviceType(devType.getId().toString()); + device.setDeviceType(devType.getId().intValue()); + device.setOwnerShip(OwnerShip.BYOD.toString()); device.setOwnerId("111"); + device.setTenantId(-1234); deviceMgtDAO.addDevice(device); Long deviceId = null; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index 0733f55520..afcd19ca06 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -10,8 +10,8 @@ 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 INTEGER NULL DEFAULT NULL, - DATE_OF_LAST_UPDATE INTEGER 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, From 18083d2d112167798f8f8b33c41b344f28c1ee70 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 12 Dec 2014 19:56:19 +0530 Subject: [PATCH 4/8] DAO unit tests implementation --- .../java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java new file mode 100644 index 0000000000..0b0126f6a0 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java @@ -0,0 +1,6 @@ +package org.wso2.carbon.device.mgt.core.dto; + + +public enum OwnerShip { + BYOD,CORP +} From aa2448dd0a398d659c1b0701ab60ec861b7b34ce Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 12 Dec 2014 20:00:57 +0530 Subject: [PATCH 5/8] Add device list method and chgange getDevice by Id method return type to device --- .../java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 5bf4335dba..2c9cb0d585 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 @@ -33,6 +33,8 @@ public interface DeviceDAO { void deleteDevice(Long deviceId) throws DeviceManagementDAOException; - List getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException; + Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException; + + List getDevices() throws DeviceManagementDAOException; } From 6489ea116892681b41d27c6b5b0d4f49b1caf381 Mon Sep 17 00:00:00 2001 From: harshanL Date: Mon, 15 Dec 2014 09:17:20 +0530 Subject: [PATCH 6/8] Added json response to license. --- .../jax-rs/src/main/java/cdm/api/android/Authentication.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Authentication.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Authentication.java index 9f04a31105..9b81095ac8 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Authentication.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Authentication.java @@ -39,7 +39,10 @@ public class Authentication { @POST @Path("/device/license") + @Produces("application/json") public String getLicense() { - return "License Agreement"; + JsonObject result = new JsonObject(); + result.addProperty("licenseText", "License Agreement"); + return result.toString(); } } From 006b07b399784ab8f1d475a685c35be3010c68d1 Mon Sep 17 00:00:00 2001 From: harshanL Date: Mon, 15 Dec 2014 09:41:54 +0530 Subject: [PATCH 7/8] Fixed issues in build & added COPE to enum --- .../mgt/core/dao/impl/DeviceDAOImpl.java | 7 ++- .../carbon/device/mgt/core/dto/OwnerShip.java | 2 +- .../mgt/mobile/impl/dao/MobileDeviceDAO.java | 23 ++++++++++ .../MobileDeviceManagementDAOException.java | 7 +++ .../mobile/impl/dao/MobileDeviceModelDAO.java | 23 ++++++++++ .../impl/dao/MobileDeviceVendorDAO.java | 7 +++ .../mobile/impl/dao/MobileOSVersionDAO.java | 7 +++ .../mobile/impl/dao/impl/MobileDeviceDAO.java | 7 +++ .../impl/dao/impl/MobileDeviceDAOImpl.java | 7 +++ .../impl/dao/impl/MobileDeviceModelImpl.java | 7 +++ .../dao/impl/MobileDeviceVendorDAOImpl.java | 7 +++ .../impl/dao/impl/MobileOSVersionDAOImpl.java | 7 +++ .../util/MobileDeviceManagementDAOUtil.java | 7 +++ .../mgt/mobile/impl/dto/MobileDevice.java | 7 +++ .../mobile/impl/dto/MobileDeviceModel.java | 7 +++ .../mobile/impl/dto/MobileDeviceVendor.java | 44 +++++++++++++++++++ .../mgt/mobile/impl/dto/MobileOSVersion.java | 7 +++ 17 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOException.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAO.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceVendor.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java 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 a9e4df8c00..ec48c4c10f 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 @@ -91,11 +91,16 @@ public class DeviceDAOImpl implements DeviceDAO { } @Override - public List getDeviceByDeviceId(Long deviceId) + public Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException { return null; } + @Override + public List getDevices() throws DeviceManagementDAOException { + return null; + } + private Connection getConnection() throws DeviceManagementDAOException { try { return dataSource.getConnection(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java index 0b0126f6a0..a317568410 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dto/OwnerShip.java @@ -2,5 +2,5 @@ package org.wso2.carbon.device.mgt.core.dto; public enum OwnerShip { - BYOD,CORP + BYOD,COPE } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java new file mode 100644 index 0000000000..0f38ffc527 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.mobile.impl.dao; + +/** + * This class represents the key operations associated with persisting device related information. + */ +public interface MobileDeviceDAO { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOException.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOException.java new file mode 100644 index 0000000000..61e6bce2ee --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOException.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dao; + +/** + * Created by harshan on 12/12/14. + */ +public class MobileDeviceManagementDAOException { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java new file mode 100644 index 0000000000..0a3ec19bb6 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.mobile.impl.dao; + +/** + * Created by harshan on 12/12/14. + */ +public interface MobileDeviceModelDAO { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java new file mode 100644 index 0000000000..2f6e07633e --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dao; + +/** + * Created by harshan on 12/12/14. + */ +public interface MobileDeviceVendorDAO { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java new file mode 100644 index 0000000000..6131e15b32 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dao; + +/** + * Created by harshan on 12/12/14. + */ +public interface MobileOSVersionDAO { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAO.java new file mode 100644 index 0000000000..6210aa23ef --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAO.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; + +/** + * Created by harshan on 12/12/14. + */ +public interface MobileDeviceDAO { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java new file mode 100644 index 0000000000..8ffaaee04b --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; + +/** + * Created by harshan on 12/12/14. + */ +public class MobileDeviceDAOImpl { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java new file mode 100644 index 0000000000..9b26c68cca --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; + +/** + * Created by harshan on 12/12/14. + */ +public class MobileDeviceModelImpl { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java new file mode 100644 index 0000000000..3c9c8d81fd --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; + +/** + * Created by harshan on 12/12/14. + */ +public class MobileDeviceVendorDAOImpl { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java new file mode 100644 index 0000000000..9a07c71f99 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; + +/** + * Created by harshan on 12/12/14. + */ +public class MobileOSVersionDAOImpl { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java new file mode 100644 index 0000000000..15bd2d6624 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dao.util; + +/** + * Created by harshan on 12/12/14. + */ +public class MobileDeviceManagementDAOUtil { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java new file mode 100644 index 0000000000..eca99805e8 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dto; + +/** + * Created by harshan on 12/12/14. + */ +public class MobileDevice { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java new file mode 100644 index 0000000000..2d295257ed --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dto; + +/** + * Created by harshan on 12/12/14. + */ +public class MobileDeviceModel { +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceVendor.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceVendor.java new file mode 100644 index 0000000000..2d48af52a0 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceVendor.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.device.mgt.mobile.impl.dto; + +import java.io.Serializable; + +/** + * DTO of MobileVendor. + */ +public class MobileDeviceVendor implements Serializable { + + private int vendorId; + private String vendor; + + public int getVendorId() { + return vendorId; + } + + public void setVendorId(int vendorId) { + this.vendorId = vendorId; + } + + public String getVendor() { + return vendor; + } + + public void setVendor(String vendor) { + this.vendor = vendor; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java new file mode 100644 index 0000000000..c579947198 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java @@ -0,0 +1,7 @@ +package org.wso2.carbon.device.mgt.mobile.impl.dto; + +/** + * Created by harshan on 12/12/14. + */ +public class MobileOSVersion { +} From 9f5fb3fb912bde56f2447cb9563b7e948580b529 Mon Sep 17 00:00:00 2001 From: harshanL Date: Mon, 15 Dec 2014 09:47:54 +0530 Subject: [PATCH 8/8] Added MobileDeviceDAO classes --- .../android/AndroidDeviceManagerService.java | 2 +- .../mgt/mobile/impl/dao/MobileDeviceDAO.java | 13 ++- .../MobileDeviceManagementDAOException.java | 72 +++++++++++++++- .../mobile/impl/dao/MobileDeviceModelDAO.java | 13 ++- .../impl/dao/MobileDeviceVendorDAO.java | 30 ++++++- .../mobile/impl/dao/MobileOSVersionDAO.java | 29 ++++++- .../mobile/impl/dao/impl/MobileDeviceDAO.java | 7 -- .../impl/dao/impl/MobileDeviceDAOImpl.java | 45 +++++++++- .../impl/dao/impl/MobileDeviceModelImpl.java | 47 +++++++++- .../dao/impl/MobileDeviceVendorDAOImpl.java | 47 +++++++++- .../impl/dao/impl/MobileOSVersionDAOImpl.java | 43 +++++++++- .../util/MobileDeviceManagementDAOUtil.java | 18 +++- .../mgt/mobile/impl/dto/MobileDevice.java | 86 ++++++++++++++++++- .../mobile/impl/dto/MobileDeviceModel.java | 41 ++++++++- .../mgt/mobile/impl/dto/MobileOSVersion.java | 41 ++++++++- 15 files changed, 505 insertions(+), 29 deletions(-) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAO.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java index 648fd2c92b..3246b21f21 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagerService.java @@ -25,7 +25,7 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; import java.util.List; /** - * This represents the Android implementation of DeviceManagerService. * + * This represents the Android implementation of DeviceManagerService. */ public class AndroidDeviceManagerService implements DeviceManagerService { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java index 0f38ffc527..1d4ab3ab80 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceDAO.java @@ -16,8 +16,19 @@ package org.wso2.carbon.device.mgt.mobile.impl.dao; +import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice; + /** - * This class represents the key operations associated with persisting device related information. + * This class represents the key operations associated with persisting mobile-device related information. */ public interface MobileDeviceDAO { + + MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException; + + void addDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; + + void updateDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; + + void deleteDevice(String deviceId) throws MobileDeviceManagementDAOException; + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOException.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOException.java index 61e6bce2ee..8047d932a2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceManagementDAOException.java @@ -1,7 +1,75 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dao; /** - * Created by harshan on 12/12/14. + * Custom exception class for mobile device specific data access related exceptions. */ -public class MobileDeviceManagementDAOException { +public class MobileDeviceManagementDAOException extends Exception { + + private String message; + private static final long serialVersionUID = 2021891706072918865L; + + /** + * Constructs a new exception with the specified detail message and nested exception. + * + * @param message error message + * @param nestedException exception + */ + public MobileDeviceManagementDAOException(String message, Exception nestedException) { + super(message, nestedException); + setErrorMessage(message); + } + + /** + * Constructs a new exception with the specified detail message and cause. + * + * @param message the detail message. + * @param cause the cause of this exception. + */ + public MobileDeviceManagementDAOException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + /** + * Constructs a new exception with the specified detail message + * + * @param message the detail message. + */ + public MobileDeviceManagementDAOException(String message) { + super(message); + setErrorMessage(message); + } + + /** + * Constructs a new exception with the specified and cause. + * + * @param cause the cause of this exception. + */ + public MobileDeviceManagementDAOException(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } + + public void setErrorMessage(String errorMessage) { + this.message = errorMessage; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java index 0a3ec19bb6..768f297231 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceModelDAO.java @@ -16,8 +16,19 @@ package org.wso2.carbon.device.mgt.mobile.impl.dao; +import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceModel; + /** - * Created by harshan on 12/12/14. + * This class represents the key operations associated with persisting mobile-device model related + * information. */ public interface MobileDeviceModelDAO { + + MobileDeviceModel getDeviceModel(String modelId) throws MobileDeviceManagementDAOException; + + void addDeviceModel(MobileDeviceModel deviceModel) throws MobileDeviceManagementDAOException; + + void updateDeviceModel(MobileDeviceModel deviceModel) throws MobileDeviceManagementDAOException; + + void deleteDeviceModel(String modelId) throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java index 2f6e07633e..4a4d24bf7e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileDeviceVendorDAO.java @@ -1,7 +1,35 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dao; +import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceVendor; + /** - * Created by harshan on 12/12/14. + * This class represents the key operations associated with persisting mobile-device vendor + * related information. */ public interface MobileDeviceVendorDAO { + + MobileDeviceVendor getDeviceModel(String vendorId) throws MobileDeviceManagementDAOException; + + void addDeviceVendor(MobileDeviceVendor deviceVendor) throws MobileDeviceManagementDAOException; + + void updateDeviceVendor(MobileDeviceVendor deviceVendor) + throws MobileDeviceManagementDAOException; + + void deleteDeviceVendor(String vendorId) throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java index 6131e15b32..dcffc528b6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileOSVersionDAO.java @@ -1,7 +1,34 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dao; +import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileOSVersion; + /** - * Created by harshan on 12/12/14. + * This class represents the key operations associated with persisting mobile-device OS version + * related information. */ public interface MobileOSVersionDAO { + + MobileOSVersion getMobileOSVersion(String versionId) throws MobileDeviceManagementDAOException; + + void addMobileOSVersion(MobileOSVersion osVersion) throws MobileDeviceManagementDAOException; + + void updateMobileOSVersion(MobileOSVersion osVersion) throws MobileDeviceManagementDAOException; + + void deleteMobileOSVersion(String versionId) throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAO.java deleted file mode 100644 index 6210aa23ef..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAO.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; - -/** - * Created by harshan on 12/12/14. - */ -public interface MobileDeviceDAO { -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java index 8ffaaee04b..cdd18e69c1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceDAOImpl.java @@ -1,7 +1,48 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; +import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceDAO; +import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDevice; + /** - * Created by harshan on 12/12/14. + * Implementation of MobileDeviceDAO. */ -public class MobileDeviceDAOImpl { +public class MobileDeviceDAOImpl implements MobileDeviceDAO { + @Override + public MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException { + return null; + } + + @Override + public void addDevice(MobileDevice mobileDevice) + throws MobileDeviceManagementDAOException { + + } + + @Override + public void updateDevice(MobileDevice mobileDevice) + throws MobileDeviceManagementDAOException { + + } + + @Override + public void deleteDevice(String deviceId) throws MobileDeviceManagementDAOException { + + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java index 9b26c68cca..67179794cd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceModelImpl.java @@ -1,7 +1,50 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; +import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceModelDAO; +import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceModel; + /** - * Created by harshan on 12/12/14. + * Implementation of MobileDeviceModel. */ -public class MobileDeviceModelImpl { +public class MobileDeviceModelImpl implements MobileDeviceModelDAO { + @Override + public MobileDeviceModel getDeviceModel(String modelId) + throws MobileDeviceManagementDAOException { + return null; + } + + @Override + public void addDeviceModel(MobileDeviceModel deviceModel) + throws MobileDeviceManagementDAOException { + + } + + @Override + public void updateDeviceModel(MobileDeviceModel deviceModel) + throws MobileDeviceManagementDAOException { + + } + + @Override + public void deleteDeviceModel(String modelId) + throws MobileDeviceManagementDAOException { + + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java index 3c9c8d81fd..0f4659d97b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileDeviceVendorDAOImpl.java @@ -1,7 +1,50 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; +import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceVendorDAO; +import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileDeviceVendor; + /** - * Created by harshan on 12/12/14. + * Implementation of MobileDeviceVendorDAO. */ -public class MobileDeviceVendorDAOImpl { +public class MobileDeviceVendorDAOImpl implements MobileDeviceVendorDAO { + @Override + public MobileDeviceVendor getDeviceModel(String vendorId) + throws MobileDeviceManagementDAOException { + return null; + } + + @Override + public void addDeviceVendor(MobileDeviceVendor deviceVendor) + throws MobileDeviceManagementDAOException { + + } + + @Override + public void updateDeviceVendor(MobileDeviceVendor deviceVendor) + throws MobileDeviceManagementDAOException { + + } + + @Override + public void deleteDeviceVendor(String vendorId) + throws MobileDeviceManagementDAOException { + + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java index 9a07c71f99..6bfaccad0c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/impl/MobileOSVersionDAOImpl.java @@ -1,7 +1,46 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dao.impl; +import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileOSVersionDAO; +import org.wso2.carbon.device.mgt.mobile.impl.dto.MobileOSVersion; + /** - * Created by harshan on 12/12/14. + * Implementation of MobileOSVersionDAO. */ -public class MobileOSVersionDAOImpl { +public class MobileOSVersionDAOImpl implements MobileOSVersionDAO { + @Override public MobileOSVersion getMobileOSVersion(String versionId) + throws MobileDeviceManagementDAOException { + return null; + } + + @Override public void addMobileOSVersion(MobileOSVersion osVersion) + throws MobileDeviceManagementDAOException { + + } + + @Override public void updateMobileOSVersion(MobileOSVersion osVersion) + throws MobileDeviceManagementDAOException { + + } + + @Override public void deleteMobileOSVersion(String versionId) + throws MobileDeviceManagementDAOException { + + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java index 15bd2d6624..453a3918d0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDeviceManagementDAOUtil.java @@ -1,7 +1,23 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dao.util; /** - * Created by harshan on 12/12/14. + * Utility method required by MobileDeviceManagement DAO classes. */ public class MobileDeviceManagementDAOUtil { } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java index eca99805e8..f7b1d14b1f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDevice.java @@ -1,7 +1,89 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dto; +import java.io.Serializable; + /** - * Created by harshan on 12/12/14. + * DTO of MobileDevice. */ -public class MobileDevice { +public class MobileDevice implements Serializable { + + private String mobileDeviceId; + private String regId; + private String imei; + private String imsi; + private int osVersionId; + private int modelId; + private int vendorId; + + public String getMobileDeviceId() { + return mobileDeviceId; + } + + public void setMobileDeviceId(String mobileDeviceId) { + this.mobileDeviceId = mobileDeviceId; + } + + public String getRegId() { + return regId; + } + + public void setRegId(String regId) { + this.regId = regId; + } + + public String getImei() { + return imei; + } + + public void setImei(String imei) { + this.imei = imei; + } + + public String getImsi() { + return imsi; + } + + public void setImsi(String imsi) { + this.imsi = imsi; + } + + public int getOsVersionId() { + return osVersionId; + } + + public void setOsVersionId(int osVersionId) { + this.osVersionId = osVersionId; + } + + public int getModelId() { + return modelId; + } + + public void setModelId(int modelId) { + this.modelId = modelId; + } + + public int getVendorId() { + return vendorId; + } + + public void setVendorId(int vendorId) { + this.vendorId = vendorId; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java index 2d295257ed..b5d5e5ebbb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileDeviceModel.java @@ -1,7 +1,44 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dto; +import java.io.Serializable; + /** - * Created by harshan on 12/12/14. + * DTO of MobileDeviceModel. */ -public class MobileDeviceModel { +public class MobileDeviceModel implements Serializable { + + private int modelId; + private String model; + + public int getModelId() { + return modelId; + } + + public void setModelId(int modelId) { + this.modelId = modelId; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java index c579947198..32a56b6fcc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/dto/MobileOSVersion.java @@ -1,7 +1,44 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.wso2.carbon.device.mgt.mobile.impl.dto; +import java.io.Serializable; + /** - * Created by harshan on 12/12/14. + * DTO of MobileOSVersion. */ -public class MobileOSVersion { +public class MobileOSVersion implements Serializable { + + private int osVersionId; + private String osVersion; + + public int getOsVersionId() { + return osVersionId; + } + + public void setOsVersionId(int osVersionId) { + this.osVersionId = osVersionId; + } + + public String getOsVersion() { + return osVersion; + } + + public void setOsVersion(String osVersion) { + this.osVersion = osVersion; + } }