merge-requests/7/head
geethkokila 9 years ago
commit 958288f8ec

@ -18,11 +18,13 @@
package org.wso2.carbon.device.mgt.analytics.dashboard;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.*;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DetailedDeviceEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DeviceCountByGroupEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.FilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.DataAccessLayerException;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterValueException;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import java.sql.SQLException;
import java.util.List;
/**
@ -31,56 +33,57 @@ import java.util.List;
public interface GadgetDataService {
@SuppressWarnings("unused")
DeviceCountByGroupEntry getDeviceCount(FilterSet filterSet) throws InvalidParameterValueException, SQLException;
DeviceCountByGroupEntry getDeviceCount(FilterSet filterSet)
throws InvalidParameterValueException, DataAccessLayerException;
@SuppressWarnings("unused")
DeviceCountByGroupEntry getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException;
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException;
@SuppressWarnings("unused")
DeviceCountByGroupEntry getTotalDeviceCount() throws SQLException;
DeviceCountByGroupEntry getTotalDeviceCount() throws DataAccessLayerException;
@SuppressWarnings("unused")
List<DeviceCountByGroupEntry> getDeviceCountsByConnectivityStatuses() throws SQLException;
List<DeviceCountByGroupEntry> getDeviceCountsByConnectivityStatuses() throws DataAccessLayerException;
@SuppressWarnings("unused")
List<DeviceCountByGroupEntry> getDeviceCountsByPotentialVulnerabilities() throws SQLException;
List<DeviceCountByGroupEntry> getDeviceCountsByPotentialVulnerabilities() throws DataAccessLayerException;
@SuppressWarnings("unused")
PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
@SuppressWarnings("unused")
List<DeviceCountByGroupEntry> getDeviceCountsByPlatforms(FilterSet filterSet)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
@SuppressWarnings("unused")
List<DeviceCountByGroupEntry> getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException;
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException;
@SuppressWarnings("unused")
List<DeviceCountByGroupEntry> getDeviceCountsByOwnershipTypes(FilterSet filterSet)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
@SuppressWarnings("unused")
List<DeviceCountByGroupEntry> getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException;
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException;
@SuppressWarnings("unused")
PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
@SuppressWarnings("unused")
PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
@SuppressWarnings("unused")
List<DetailedDeviceEntry> getDevicesWithDetails(FilterSet filterSet)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
@SuppressWarnings("unused")
List<DetailedDeviceEntry> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException;
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException;
}

@ -22,6 +22,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DetailedDeviceEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DeviceCountByGroupEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.FilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.DataAccessLayerException;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterValueException;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
@ -37,7 +38,7 @@ import java.util.Map;
public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceDAO {
@Override
public DeviceCountByGroupEntry getTotalDeviceCount() throws SQLException {
public DeviceCountByGroupEntry getTotalDeviceCount() throws DataAccessLayerException {
int totalDeviceCount;
try {
totalDeviceCount = this.getFilteredDeviceCount(null);
@ -55,7 +56,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public DeviceCountByGroupEntry getDeviceCount(FilterSet filterSet)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
int filteredDeviceCount = this.getFilteredDeviceCount(filterSet);
@ -67,7 +68,8 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
return deviceCountByGroupEntry;
}
private int getFilteredDeviceCount(FilterSet filterSet) throws InvalidParameterValueException, SQLException {
private int getFilteredDeviceCount(FilterSet filterSet)
throws InvalidParameterValueException, DataAccessLayerException {
Map<String, Object> filters = this.extractDatabaseFiltersFromBean(filterSet);
@ -106,6 +108,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
while (rs.next()) {
filteredDeviceCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -114,7 +119,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public DeviceCountByGroupEntry getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException {
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException {
if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) {
throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty.");
@ -159,6 +164,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
while (rs.next()) {
filteredDeviceCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -172,7 +180,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
}
@Override
public List<DeviceCountByGroupEntry> getDeviceCountsByConnectivityStatuses() throws SQLException {
public List<DeviceCountByGroupEntry> getDeviceCountsByConnectivityStatuses() throws DataAccessLayerException {
Connection con;
PreparedStatement stmt = null;
ResultSet rs = null;
@ -196,6 +204,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
deviceCountByConnectivityStatus.setDeviceCount(rs.getInt("DEVICE_COUNT"));
deviceCountsByConnectivityStatuses.add(deviceCountByConnectivityStatus);
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -203,7 +214,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
}
@Override
public List<DeviceCountByGroupEntry> getDeviceCountsByPotentialVulnerabilities() throws SQLException {
public List<DeviceCountByGroupEntry> getDeviceCountsByPotentialVulnerabilities() throws DataAccessLayerException {
// getting non-compliant device count
DeviceCountByGroupEntry nonCompliantDeviceCount = new DeviceCountByGroupEntry();
nonCompliantDeviceCount.setGroup(GadgetDataServiceDAOConstants.PotentialVulnerability.NON_COMPLIANT);
@ -223,7 +234,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
return deviceCountsByPotentialVulnerabilities;
}
private int getNonCompliantDeviceCount() throws SQLException {
private int getNonCompliantDeviceCount() throws DataAccessLayerException {
FilterSet filterSet = new FilterSet();
filterSet.setPotentialVulnerability(GadgetDataServiceDAOConstants.PotentialVulnerability.NON_COMPLIANT);
try {
@ -233,7 +244,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
}
}
private int getUnmonitoredDeviceCount() throws SQLException {
private int getUnmonitoredDeviceCount() throws DataAccessLayerException {
FilterSet filterSet = new FilterSet();
filterSet.setPotentialVulnerability(GadgetDataServiceDAOConstants.PotentialVulnerability.UNMONITORED);
try {
@ -245,7 +256,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public List<DeviceCountByGroupEntry> getDeviceCountsByPlatforms(FilterSet filterSet)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
Map<String, Object> filters = this.extractDatabaseFiltersFromBean(filterSet);
@ -291,6 +302,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceCountByPlatform.setDeviceCount(rs.getInt("DEVICE_COUNT"));
filteredDeviceCountsByPlatforms.add(filteredDeviceCountByPlatform);
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -300,7 +314,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public List<DeviceCountByGroupEntry>
getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException {
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException {
if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) {
throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty.");
@ -351,6 +365,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceCountByPlatform.setDeviceCount(rs.getInt("DEVICE_COUNT"));
filteredDeviceCountsByPlatforms.add(filteredDeviceCountByPlatform);
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -359,7 +376,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public List<DeviceCountByGroupEntry> getDeviceCountsByOwnershipTypes(FilterSet filterSet)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
Map<String, Object> filters = this.extractDatabaseFiltersFromBean(filterSet);
@ -405,6 +422,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceCountByOwnershipType.setDeviceCount(rs.getInt("DEVICE_COUNT"));
filteredDeviceCountsByOwnershipTypes.add(filteredDeviceCountByOwnershipType);
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -414,7 +434,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public List<DeviceCountByGroupEntry>
getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException {
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException {
if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) {
throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty.");
@ -465,6 +485,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceCountByOwnershipType.setDeviceCount(rs.getInt("DEVICE_COUNT"));
filteredDeviceCountsByOwnershipTypes.add(filteredDeviceCountByOwnershipType);
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -473,7 +496,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public List<DetailedDeviceEntry> getDevicesWithDetails(FilterSet filterSet)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
Map<String, Object> filters = this.extractDatabaseFiltersFromBean(filterSet);
@ -521,6 +544,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceWithDetails.setConnectivityStatus(rs.getString("CONNECTIVITY_STATUS"));
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -529,7 +555,7 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
@Override
public List<DetailedDeviceEntry> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException {
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException {
if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) {
throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty.");
@ -582,6 +608,9 @@ public abstract class AbstractGadgetDataServiceDAO implements GadgetDataServiceD
filteredDeviceWithDetails.setConnectivityStatus(rs.getString("CONNECTIVITY_STATUS"));
filteredDevicesWithDetails.add(filteredDeviceWithDetails);
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}

@ -18,56 +18,67 @@
package org.wso2.carbon.device.mgt.analytics.dashboard.dao;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.*;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DetailedDeviceEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DeviceCountByGroupEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.FilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.DataAccessLayerException;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterValueException;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import java.sql.SQLException;
import java.util.List;
public interface GadgetDataServiceDAO {
DeviceCountByGroupEntry getDeviceCount(FilterSet filterSet) throws InvalidParameterValueException, SQLException;
/**
* This method is used to get device count based on a defined filter set.
* @param filterSet An abstract representation of possible filtering options.
* if this value is simply "null" or no values are set for the defined filtering options,
* this method would return total device count in the system
* wrapped with in the defined return format.
* @return An object of type DeviceCountByGroupEntry.
* @throws InvalidParameterValueException This can occur if and only if potentialVulnerability value of filterSet
* is set with some value other than "NON_COMPLIANT" or "UNMONITORED".
* @throws DataAccessLayerException This can occur due to errors connecting to database,
* executing SQL query and retrieving data.
*/
DeviceCountByGroupEntry getDeviceCount(FilterSet filterSet)
throws InvalidParameterValueException, DataAccessLayerException;
DeviceCountByGroupEntry getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException;
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException;
/**
* Method to get total device count from a particular tenant.
*
* @return Total device count.
*/
DeviceCountByGroupEntry getTotalDeviceCount() throws SQLException;
DeviceCountByGroupEntry getTotalDeviceCount() throws DataAccessLayerException;
List<DeviceCountByGroupEntry> getDeviceCountsByConnectivityStatuses() throws SQLException;
List<DeviceCountByGroupEntry> getDeviceCountsByConnectivityStatuses() throws DataAccessLayerException;
List<DeviceCountByGroupEntry> getDeviceCountsByPotentialVulnerabilities() throws SQLException;
List<DeviceCountByGroupEntry> getDeviceCountsByPotentialVulnerabilities() throws DataAccessLayerException;
PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
List<DeviceCountByGroupEntry> getDeviceCountsByPlatforms(FilterSet filterSet)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
List<DeviceCountByGroupEntry> getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException;
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException;
List<DeviceCountByGroupEntry> getDeviceCountsByOwnershipTypes(FilterSet filterSet)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
List<DeviceCountByGroupEntry> getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException;
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException;
PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet, int startIndex, int resultCount) throws InvalidParameterValueException, SQLException;
FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, DataAccessLayerException;
List<DetailedDeviceEntry> getDevicesWithDetails(FilterSet filterSet)
throws InvalidParameterValueException, SQLException;
throws InvalidParameterValueException, DataAccessLayerException;
List<DetailedDeviceEntry> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException;
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException;
}

@ -90,7 +90,11 @@ public class GadgetDataServiceDAOFactory {
"this particular thread. Therefore, calling 'beginTransaction/openConnection' while another " +
"transaction is already active is a sign of improper transaction handling.");
}
try {
conn = dataSource.getConnection();
} catch (SQLException e) {
}
currentConnection.set(conn);
}
@ -130,7 +134,7 @@ public class GadgetDataServiceDAOFactory {
DataSource dataSource = null;
if (config == null) {
throw new RuntimeException(
"Device Management Repository data source configuration " + "is null and " +
"Device Management Repository data source configuration is null and " +
"thus, is not initialized.");
}
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();

@ -0,0 +1,80 @@
/*
* Copyright (c) 2016, 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.analytics.dashboard.dao.exception;
/**
* Custom exception class for communicating data access layer issues
* relevant to Gadget Data Service DAO layer.
* (In this particular instance, SQL exceptions related to database access).
*/
public class DataAccessLayerException extends Exception {
private String errorMessage;
private static final long serialVersionUID = 2021891706072918864L;
/**
* Constructs a new exception with the specific error message and nested exception.
* @param errorMessage specific error message.
* @param nestedException Nested exception.
*/
@SuppressWarnings("unused")
public DataAccessLayerException(String errorMessage, Exception nestedException) {
super(errorMessage, nestedException);
setErrorMessage(errorMessage);
}
/**
* Constructs a new exception with the specific error message and cause.
* @param errorMessage Specific error message.
* @param cause Cause of this exception.
*/
@SuppressWarnings("unused")
public DataAccessLayerException(String errorMessage, Throwable cause) {
super(errorMessage, cause);
setErrorMessage(errorMessage);
}
/**
* Constructs a new exception with the specific error message.
* @param errorMessage Specific error message.
*/
public DataAccessLayerException(String errorMessage) {
super(errorMessage);
setErrorMessage(errorMessage);
}
/**
* Constructs a new exception with the specific error message and cause.
* @param cause Cause of this exception.
*/
@SuppressWarnings("unused")
public DataAccessLayerException(Throwable cause) {
super(cause);
}
@SuppressWarnings("unused")
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}

@ -29,7 +29,6 @@ public class InvalidParameterValueException extends Exception {
/**
* Constructs a new exception with the specific error message and nested exception.
*
* @param errorMessage specific error message.
* @param nestedException Nested exception.
*/
@ -41,7 +40,6 @@ public class InvalidParameterValueException extends Exception {
/**
* Constructs a new exception with the specific error message and cause.
*
* @param errorMessage Specific error message.
* @param cause Cause of this exception.
*/
@ -53,7 +51,6 @@ public class InvalidParameterValueException extends Exception {
/**
* Constructs a new exception with the specific error message.
*
* @param errorMessage Specific error message.
*/
public InvalidParameterValueException(String errorMessage) {
@ -63,7 +60,6 @@ public class InvalidParameterValueException extends Exception {
/**
* Constructs a new exception with the specific error message and cause.
*
* @param cause Cause of this exception.
*/
@SuppressWarnings("unused")

@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.analytics.dashboard.dao.AbstractGadgetDataServ
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DetailedDeviceEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DeviceCountByGroupEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.FilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.DataAccessLayerException;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterValueException;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
@ -39,7 +40,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (startIndex < 0) {
throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that.");
@ -88,6 +89,9 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
while (rs.next()) {
totalRecordsCount = rs.getInt("NON_COMPLIANT_FEATURE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -99,7 +103,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
@Override
public PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (startIndex < 0) {
throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that.");
@ -174,6 +178,9 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
while (rs.next()) {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -186,7 +193,7 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) {
throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty.");
@ -269,6 +276,9 @@ public class GenericGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDA
while (rs.next()) {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}

@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.analytics.dashboard.dao.AbstractGadgetDataServ
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DetailedDeviceEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DeviceCountByGroupEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.FilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.DataAccessLayerException;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterValueException;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
@ -39,7 +40,7 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (startIndex < 0) {
throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that.");
@ -89,6 +90,9 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
while (rs.next()) {
totalRecordsCount = rs.getInt("NON_COMPLIANT_FEATURE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -100,7 +104,7 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
@Override
public PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (startIndex < 0) {
throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that.");
@ -176,6 +180,9 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
while (rs.next()) {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -188,7 +195,7 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) {
throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty.");
@ -271,6 +278,9 @@ public class MSSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
while (rs.next()) {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}

@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.analytics.dashboard.dao.AbstractGadgetDataServ
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DetailedDeviceEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DeviceCountByGroupEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.FilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.DataAccessLayerException;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterValueException;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
@ -39,7 +40,7 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (startIndex < 0) {
throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that.");
@ -89,6 +90,9 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
while (rs.next()) {
totalRecordsCount = rs.getInt("NON_COMPLIANT_FEATURE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -100,7 +104,7 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
@Override
public PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (startIndex < 0) {
throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that.");
@ -176,6 +180,9 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
while (rs.next()) {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -188,7 +195,7 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) {
throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty.");
@ -271,6 +278,9 @@ public class OracleGadgetDataServiceDAOImpl extends AbstractGadgetDataServiceDAO
while (rs.next()) {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}

@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.analytics.dashboard.dao.AbstractGadgetDataServ
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DetailedDeviceEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DeviceCountByGroupEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.FilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.DataAccessLayerException;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterValueException;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
@ -39,7 +40,7 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (startIndex < 0) {
throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that.");
@ -88,6 +89,9 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic
while (rs.next()) {
totalRecordsCount = rs.getInt("NON_COMPLIANT_FEATURE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -99,7 +103,7 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic
@Override
public PaginationResult getDevicesWithDetails(FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (startIndex < 0) {
throw new InvalidParameterValueException("Start index should be equal to 0 or greater than that.");
@ -174,6 +178,9 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic
while (rs.next()) {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}
@ -186,7 +193,7 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
if (nonCompliantFeatureCode == null || nonCompliantFeatureCode.isEmpty()) {
throw new InvalidParameterValueException("Non-compliant feature code should not be either null or empty.");
@ -269,6 +276,9 @@ public class PostgreSQLGadgetDataServiceDAOImpl extends AbstractGadgetDataServic
while (rs.next()) {
totalRecordsCount = rs.getInt("DEVICE_COUNT");
}
} catch (SQLException e) {
throw new DataAccessLayerException("Error in either getting database connection, " +
"running SQL query or fetching results.", e);
} finally {
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
}

@ -20,7 +20,10 @@ package org.wso2.carbon.device.mgt.analytics.dashboard.impl;
import org.wso2.carbon.device.mgt.analytics.dashboard.GadgetDataService;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.GadgetDataServiceDAOFactory;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.*;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DetailedDeviceEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.DeviceCountByGroupEntry;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.bean.FilterSet;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.DataAccessLayerException;
import org.wso2.carbon.device.mgt.analytics.dashboard.dao.exception.InvalidParameterValueException;
import org.wso2.carbon.device.mgt.common.PaginationResult;
@ -33,11 +36,14 @@ import java.util.List;
public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public DeviceCountByGroupEntry getDeviceCount(FilterSet filterSet) throws InvalidParameterValueException, SQLException {
public DeviceCountByGroupEntry getDeviceCount(FilterSet filterSet)
throws InvalidParameterValueException, DataAccessLayerException {
DeviceCountByGroupEntry filteredDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
filteredDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getDeviceCount(filterSet);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -45,13 +51,15 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public DeviceCountByGroupEntry getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode, FilterSet filterSet)
throws InvalidParameterValueException, SQLException {
public DeviceCountByGroupEntry getFeatureNonCompliantDeviceCount(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException {
DeviceCountByGroupEntry featureNonCompliantDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDeviceCount = GadgetDataServiceDAOFactory.
getGadgetDataServiceDAO().getFeatureNonCompliantDeviceCount(nonCompliantFeatureCode, filterSet);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -59,11 +67,13 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public DeviceCountByGroupEntry getTotalDeviceCount() throws SQLException {
public DeviceCountByGroupEntry getTotalDeviceCount() throws DataAccessLayerException {
DeviceCountByGroupEntry totalDeviceCount;
try {
GadgetDataServiceDAOFactory.openConnection();
totalDeviceCount = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().getTotalDeviceCount();
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -71,12 +81,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public List<DeviceCountByGroupEntry> getDeviceCountsByConnectivityStatuses() throws SQLException {
public List<DeviceCountByGroupEntry> getDeviceCountsByConnectivityStatuses() throws DataAccessLayerException {
List<DeviceCountByGroupEntry> deviceCountsByConnectivityStatuses;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCountsByConnectivityStatuses = GadgetDataServiceDAOFactory.
getGadgetDataServiceDAO().getDeviceCountsByConnectivityStatuses();
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -84,12 +96,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
}
@Override
public List<DeviceCountByGroupEntry> getDeviceCountsByPotentialVulnerabilities() throws SQLException {
public List<DeviceCountByGroupEntry> getDeviceCountsByPotentialVulnerabilities() throws DataAccessLayerException {
List<DeviceCountByGroupEntry> deviceCountsByPotentialVulnerabilities;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCountsByPotentialVulnerabilities = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDeviceCountsByPotentialVulnerabilities();
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -98,12 +112,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public PaginationResult getNonCompliantDeviceCountsByFeatures(int startIndex, int resultCount)
throws SQLException, InvalidParameterValueException {
throws InvalidParameterValueException, DataAccessLayerException {
PaginationResult paginationResult;
try {
GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getNonCompliantDeviceCountsByFeatures(startIndex, resultCount);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -112,12 +128,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public List<DeviceCountByGroupEntry> getDeviceCountsByPlatforms(FilterSet filterSet)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
List<DeviceCountByGroupEntry> deviceCountsByPlatforms;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCountsByPlatforms = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDeviceCountsByPlatforms(filterSet);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -126,12 +144,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public List<DeviceCountByGroupEntry> getFeatureNonCompliantDeviceCountsByPlatforms(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException {
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException {
List<DeviceCountByGroupEntry> featureNonCompliantDeviceCountsByPlatforms;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDeviceCountsByPlatforms = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDeviceCountsByPlatforms(nonCompliantFeatureCode, filterSet);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -140,12 +160,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public List<DeviceCountByGroupEntry> getDeviceCountsByOwnershipTypes(FilterSet filterSet)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
List<DeviceCountByGroupEntry> deviceCountsByOwnershipTypes;
try {
GadgetDataServiceDAOFactory.openConnection();
deviceCountsByOwnershipTypes = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDeviceCountsByOwnershipTypes(filterSet);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -155,12 +177,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public List<DeviceCountByGroupEntry>
getFeatureNonCompliantDeviceCountsByOwnershipTypes(String nonCompliantFeatureCode,
FilterSet filterSet) throws SQLException, InvalidParameterValueException {
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException {
List<DeviceCountByGroupEntry> featureNonCompliantDeviceCountsByOwnershipTypes;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDeviceCountsByOwnershipTypes = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDeviceCountsByOwnershipTypes(nonCompliantFeatureCode, filterSet);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -169,12 +193,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public PaginationResult getDevicesWithDetails(FilterSet filterSet,
int startIndex, int resultCount) throws InvalidParameterValueException, SQLException {
int startIndex, int resultCount) throws InvalidParameterValueException, DataAccessLayerException {
PaginationResult paginationResult;
try {
GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getDevicesWithDetails(filterSet, startIndex, resultCount);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -184,12 +210,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public PaginationResult getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet, int startIndex, int resultCount)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
PaginationResult paginationResult;
try {
GadgetDataServiceDAOFactory.openConnection();
paginationResult = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filterSet, startIndex, resultCount);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -198,12 +226,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public List<DetailedDeviceEntry> getDevicesWithDetails(FilterSet filterSet)
throws InvalidParameterValueException, SQLException {
throws InvalidParameterValueException, DataAccessLayerException {
List<DetailedDeviceEntry> devicesWithDetails;
try {
GadgetDataServiceDAOFactory.openConnection();
devicesWithDetails = GadgetDataServiceDAOFactory.
getGadgetDataServiceDAO().getDevicesWithDetails(filterSet);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}
@ -212,12 +242,14 @@ public class GadgetDataServiceImpl implements GadgetDataService {
@Override
public List<DetailedDeviceEntry> getFeatureNonCompliantDevicesWithDetails(String nonCompliantFeatureCode,
FilterSet filterSet) throws InvalidParameterValueException, SQLException {
FilterSet filterSet) throws InvalidParameterValueException, DataAccessLayerException {
List<DetailedDeviceEntry> featureNonCompliantDevicesWithDetails;
try {
GadgetDataServiceDAOFactory.openConnection();
featureNonCompliantDevicesWithDetails = GadgetDataServiceDAOFactory.getGadgetDataServiceDAO().
getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filterSet);
} catch (SQLException e) {
throw new DataAccessLayerException("Error in opening database connection.", e);
} finally {
GadgetDataServiceDAOFactory.closeConnection();
}

Loading…
Cancel
Save