From 0ba84713cd88caec0d25063bc0841b0241d6a8b1 Mon Sep 17 00:00:00 2001 From: manoj Date: Mon, 5 Jan 2015 02:25:08 +0530 Subject: [PATCH] Correct copy right text and refactor --- .../carbon/device/mgt/core/DeviceManager.java | 24 +- .../device/mgt/core/DeviceManagerImpl.java | 259 +++++++++--------- .../config/DeviceConfigurationManager.java | 13 +- .../core/config/DeviceManagementConfig.java | 7 +- .../config/DeviceManagementRepository.java | 8 +- .../config/datasource/DataSourceConfig.java | 10 +- .../carbon/device/mgt/core/dao/DeviceDAO.java | 7 +- .../core/dao/DeviceManagementDAOFactory.java | 36 +-- .../device/mgt/core/dao/DeviceTypeDAO.java | 3 +- .../mgt/core/dao/impl/DeviceDAOImpl.java | 2 +- .../mgt/core/dao/impl/DeviceTypeDAOImpl.java | 229 ++++++++-------- .../dao/util/DeviceManagementDAOUtil.java | 6 +- .../DeviceManagementServiceComponent.java | 27 +- .../mgt/core/DeviceManagementTestCase.java | 32 +-- .../device/mgt/core/common/DBTypes.java | 7 +- .../mgt/core/common/TestDBConfiguration.java | 7 +- .../mgt/core/common/TestDBConfigurations.java | 7 +- .../mgt/core/dao/DeviceMgtDAOTestSuite.java | 11 +- 18 files changed, 358 insertions(+), 337 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java index f7b79a9d2..124939f8b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManager.java @@ -1,17 +1,19 @@ -/** - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* + * 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 + * 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 + * 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. + * 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; 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 11abd2f70..a2b649674 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 @@ -1,17 +1,19 @@ -/** - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* + * 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 + * 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 + * 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. + * 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; @@ -31,129 +33,116 @@ 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 { - this.getDeviceTypeDAO().getDeviceType(); - org.wso2.carbon.device.mgt.core.dto.Device deviceDto = - DeviceManagementDAOUtil.convertDevice( - device); - - Integer deviceTypeId = - this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType()); - deviceDto.setDeviceType(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); - return dms.getAllDevices(); - } - - @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 { + this.getDeviceTypeDAO().getDeviceType(); + org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device); + Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType()); + deviceDto.setDeviceType(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); + return dms.getAllDevices(); + } + + @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; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java index e7e5dbe5b..3c5a6073a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceConfigurationManager.java @@ -1,14 +1,17 @@ /* * 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. + * + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -27,14 +30,14 @@ import javax.xml.bind.Unmarshaller; import java.io.File; /** - * Class responsible for the rss manager configuration initialization + * Class responsible for the cdm manager configuration initialization */ public class DeviceConfigurationManager { private DeviceManagementConfig currentDeviceConfig; private static DeviceConfigurationManager deviceConfigManager; - private final String deviceMgtConfigXMLPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + + private static final String deviceMgtConfigXMLPath = CarbonUtils.getCarbonConfigDirPath() + File.separator + DeviceManagementConstants.DataSourceProperties.DEVICE_CONFIG_XML_NAME; public static DeviceConfigurationManager getInstance() { @@ -49,6 +52,8 @@ public class DeviceConfigurationManager { } public synchronized void initConfig() throws DeviceManagementException { + + //catch generic exception.if any exception occurs wrap and throw DeviceManagementException try { File deviceMgtConfig = new File(deviceMgtConfigXMLPath); Document doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java index bfe821698..8735df0fe 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java @@ -1,14 +1,17 @@ /* * 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. + * + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java index 39fc6b4bd..b84ef0388 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java @@ -1,21 +1,23 @@ /* * 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. + * + * 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 + * 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.config; import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java index 07f5aab98..f8b07312a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/datasource/DataSourceConfig.java @@ -1,25 +1,27 @@ /* * 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. + * + * 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 + * 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.config.datasource; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; /** - * Class for holding data source configuration in rss-config.xml at parsing with JAXB + * Class for holding data source configuration in cdm-config.xml at parsing with JAXB */ @XmlRootElement(name = "DataSourceConfiguration") public class DataSourceConfig { 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 9a51679ca..60ab53fd0 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 @@ -1,14 +1,17 @@ /* * 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. + * + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ 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 bc1ab0255..ae12417d6 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 @@ -1,18 +1,21 @@ -/** - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* + * 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 + * 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 + * 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. + * 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.logging.Log; @@ -22,7 +25,6 @@ import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition; import org.wso2.carbon.device.mgt.core.dao.impl.DeviceDAOImpl; import org.wso2.carbon.device.mgt.core.dao.impl.DeviceTypeDAOImpl; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; - import javax.sql.DataSource; import java.util.Hashtable; import java.util.List; @@ -57,8 +59,8 @@ public class DeviceManagementDAOFactory { private static DataSource resolveDataSource(DataSourceConfig config) { DataSource dataSource = null; if (config == null) { - throw new RuntimeException("Device Management Repository data source configuration " + - "is null and thus, is not initialized"); + throw new RuntimeException("Device Management Repository data source configuration " + "is null and " + + "thus, is not initialized"); } JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); if (jndiConfig != null) { @@ -66,15 +68,13 @@ public class DeviceManagementDAOFactory { log.debug("Initializing Device Management Repository data source using the JNDI " + "Lookup Definition"); } - List jndiPropertyList = - jndiConfig.getJndiProperties(); + List jndiPropertyList = jndiConfig.getJndiProperties(); if (jndiPropertyList != null) { Hashtable jndiProperties = new Hashtable(); for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { jndiProperties.put(prop.getName(), prop.getValue()); } - dataSource = - DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); + dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); } else { dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java index f421a58bd..29c08d9ca 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceTypeDAO.java @@ -11,11 +11,10 @@ * 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 + * 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.wso2.carbon.device.mgt.common.DeviceIdentifier; 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 5961165d0..87ce6ab39 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 @@ -11,7 +11,7 @@ * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java index ebcaeb198..049ed0424 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceTypeDAOImpl.java @@ -1,26 +1,28 @@ -/** - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* + * 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 + * 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 + * 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. + * 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.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; +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 javax.sql.DataSource; @@ -33,106 +35,103 @@ import java.util.List; public class DeviceTypeDAOImpl implements DeviceTypeDAO { - private DataSource dataSource; - private static final Log log = LogFactory.getLog(DeviceTypeDAOImpl.class); - - public DeviceTypeDAOImpl(DataSource dataSource) { - this.dataSource = dataSource; - } - - @Override - public void addDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { - Connection conn = this.getConnection(); - PreparedStatement stmt = null; - try { - stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_TYPE (NAME) VALUES (?)"); - stmt.setString(1, deviceType.getName()); - stmt.execute(); - } catch (SQLException e) { - String msg = "Error occurred while registering the device type '" + - deviceType.getName() + "'"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - } - - @Override - public void updateDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { - - } - - @Override - public List getDeviceTypes() throws DeviceManagementDAOException { - Connection conn = this.getConnection(); - PreparedStatement stmt = null; - List deviceTypes = new ArrayList(); - try { - stmt = conn.prepareStatement( - "SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE"); - ResultSet results = stmt.executeQuery(); - while (results.next()) { - DeviceType deviceType = new DeviceType(); - deviceType.setId(results.getLong("DEVICE_TYPE_ID")); - deviceType.setName(results.getString("DEVICE_TYPE")); - deviceTypes.add(deviceType); - } - } catch (SQLException e) { - String msg = "Error occurred while fetching the registered device types"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - return deviceTypes; - } - - @Override - public DeviceIdentifier getDeviceType() throws DeviceManagementDAOException { - return null; - } - - @Override - public Integer getDeviceTypeIdByDeviceTypeName(String type) - throws DeviceManagementDAOException { - - Connection conn = null; - PreparedStatement stmt = null; - ResultSet resultSet = null; - Integer deviceTypeId = null; - - try { - conn = this.getConnection(); - String createDBQuery = - "SELECT * From DM_DEVICE_TYPE DT WHERE DT.NAME=?"; - stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, type); - resultSet = stmt.executeQuery(); - - while (resultSet.next()) { - deviceTypeId = resultSet.getInt(1); - } - - } catch (SQLException e) { - String msg = "Error occurred while fetch device type id for device type '" + type + "'"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } finally { - DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); - } - - return deviceTypeId; - } - - private Connection getConnection() throws DeviceManagementDAOException { - try { - return dataSource.getConnection(); - } catch (SQLException e) { - String msg = "Error occurred while obtaining a connection from the device " + - "management metadata repository datasource"; - log.error(msg, e); - throw new DeviceManagementDAOException(msg, e); - } - } + private DataSource dataSource; + private static final Log log = LogFactory.getLog(DeviceTypeDAOImpl.class); + + public DeviceTypeDAOImpl(DataSource dataSource) { + this.dataSource = dataSource; + } + + @Override + public void addDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { + Connection conn = this.getConnection(); + PreparedStatement stmt = null; + try { + stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_TYPE (NAME) VALUES (?)"); + stmt.setString(1, deviceType.getName()); + stmt.execute(); + } catch (SQLException e) { + String msg = "Error occurred while registering the device type '" + deviceType.getName() + "'"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + } + + @Override + public void updateDeviceType(DeviceType deviceType) throws DeviceManagementDAOException { + + } + + @Override + public List getDeviceTypes() throws DeviceManagementDAOException { + Connection conn = this.getConnection(); + PreparedStatement stmt = null; + List deviceTypes = new ArrayList(); + try { + stmt = conn.prepareStatement("SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE"); + ResultSet results = stmt.executeQuery(); + + while (results.next()) { + DeviceType deviceType = new DeviceType(); + deviceType.setId(results.getLong("DEVICE_TYPE_ID")); + deviceType.setName(results.getString("DEVICE_TYPE")); + deviceTypes.add(deviceType); + } + } catch (SQLException e) { + String msg = "Error occurred while fetching the registered device types"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return deviceTypes; + } + + @Override + public DeviceIdentifier getDeviceType() throws DeviceManagementDAOException { + //TODO: + return null; + } + + @Override + public Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException { + + Connection conn = this.getConnection(); + PreparedStatement stmt = null; + ResultSet resultSet = null; + Integer deviceTypeId = null; + + try { + String createDBQuery = "SELECT * From DM_DEVICE_TYPE DT WHERE DT.NAME=?"; + stmt = conn.prepareStatement(createDBQuery); + stmt.setString(1, type); + resultSet = stmt.executeQuery(); + + while (resultSet.next()) { + deviceTypeId = resultSet.getInt(1); + } + + } catch (SQLException e) { + String msg = "Error occurred while fetch device type id for device type '" + type + "'"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + + return deviceTypeId; + } + + private Connection getConnection() throws DeviceManagementDAOException { + try { + return dataSource.getConnection(); + } catch (SQLException e) { + String msg = "Error occurred while obtaining a connection from the device " + + "management metadata repository datasource"; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, 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 60ec9785f..dc38a96d4 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 @@ -61,6 +61,9 @@ public final class DeviceManagementDAOUtil { log.warn("Error occurred while closing database connection", e); } } + rs = null; + stmt = null; + conn = null; } /** @@ -83,8 +86,7 @@ public final class DeviceManagementDAOUtil { try { tenantId = tenantManager.getTenantId(tenantDomain); } catch (UserStoreException e) { - String msg = "Error occurred while retrieving id from the domain of tenant " + - tenantDomain; + String msg = "Error occurred while retrieving id from the domain of tenant " + tenantDomain; throw new DeviceManagementDAOException(msg); } return tenantId; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index 92b238633..daa67845b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -1,17 +1,19 @@ -/** - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +/* + * 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 + * 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 + * 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. + * 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.internal; @@ -56,7 +58,6 @@ public class DeviceManagementServiceComponent { try { /* Initializing Device Management Configuration */ DeviceConfigurationManager.getInstance().initConfig(); - DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); DataSourceConfig dsConfig = config.getDeviceMgtRepository().getDataSourceConfig(); @@ -88,6 +89,8 @@ public class DeviceManagementServiceComponent { private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException { DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config); log.info("Initializing device management repository database schema"); + + // catch generic exception. If any error occurs wrap and throw DeviceManagementException try { initializer.createRegistryDatabase(); } catch (Exception e) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java index e72afb3c2..0162f11a0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/DeviceManagementTestCase.java @@ -1,20 +1,20 @@ /* -* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.wso2.carbon.device.mgt.core; 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 index 203d580ce..89c5683ff 100644 --- 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 @@ -1,14 +1,17 @@ /* * 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. + * + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ 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 9689cd262..d33bfeba9 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 @@ -1,14 +1,17 @@ /* * 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. + * + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ 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 index 7c7fdfb73..d1551cca0 100644 --- 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 @@ -1,14 +1,17 @@ /* * 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. + * + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ 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 116a24907..98bb0d437 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 @@ -1,14 +1,17 @@ /* * 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. + * + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -66,8 +69,8 @@ public class DeviceMgtDAOTestSuite { } } - private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) - throws DeviceManagementDAOException, DeviceManagementException { + private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws DeviceManagementDAOException, + DeviceManagementException { File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml"); Document doc = null;