From 2dc1fe240fabf0c9a2e561dbf9b486df15421db5 Mon Sep 17 00:00:00 2001 From: harshanL Date: Tue, 17 Feb 2015 16:21:06 +0530 Subject: [PATCH] Refactored DAO implementations & added comments. --- .../pom.xml | 13 +- .../MobileDeviceConfigurationManager.java | 4 +- .../mgt/mobile/dao/MobileDeviceDAO.java | 34 +++- .../dao/MobileDeviceOperationMappingDAO.java | 70 ++++--- .../mgt/mobile/dao/MobileFeatureDAO.java | 58 +++--- .../mobile/dao/MobileFeaturePropertyDAO.java | 46 +++-- .../mgt/mobile/dao/MobileOperationDAO.java | 33 ++-- .../dao/MobileOperationPropertyDAO.java | 53 ++--- .../mobile/dao/impl/MobileDeviceDAOImpl.java | 30 ++- .../MobileDeviceOperationMappingDAOImpl.java | 99 ++++++---- .../mobile/dao/impl/MobileFeatureDAOImpl.java | 54 ++++-- .../impl/MobileFeaturePropertyDAOImpl.java | 48 +++-- .../dao/impl/MobileOperationDAOImpl.java | 44 +++-- .../impl/MobileOperationPropertyDAOImpl.java | 55 ++++-- ...MobileDeviceManagementBundleActivator.java | 4 +- ...obileDeviceManagementServiceComponent.java | 183 +++++++++--------- components/device-mgt/pom.xml | 4 +- pom.xml | 31 +-- 18 files changed, 533 insertions(+), 330 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml index d5e73ecfd0..1f219c7791 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml @@ -18,7 +18,9 @@ ~ under the License. --> - + device-mgt org.wso2.carbon.devicemgt-plugins @@ -51,9 +53,11 @@ ${project.artifactId} ${project.artifactId} ${carbon.mobile.device.mgt.version} - Device Management Mobile Impl Bundle + Device Management Mobile Impl Bundle + - org.wso2.carbon.device.mgt.mobile.internal + org.wso2.carbon.device.mgt.mobile.internal + org.osgi.framework, org.osgi.service.component, @@ -73,7 +77,8 @@ 2.18 - file:src/test/resources/log4j.properties + file:src/test/resources/log4j.properties + src/test/resources/testng.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java index 7143d74df3..755e71f90a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java @@ -35,11 +35,13 @@ public class MobileDeviceConfigurationManager { private static final String MOBILE_DEVICE_CONFIG_XML_NAME = "mobile-config.xml"; private static final String MOBILE_DEVICE_PLUGIN_DIRECTORY = "mobile"; + private static final String DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY = "device-mgt-plugin-configs"; private MobileDeviceManagementConfig currentMobileDeviceConfig; private static MobileDeviceConfigurationManager mobileDeviceConfigManager; private final String mobileDeviceMgtConfigXMLPath = - CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-mgt-plugin-configs" + + CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + + DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY + File.separator + MOBILE_DEVICE_PLUGIN_DIRECTORY + File.separator + MOBILE_DEVICE_CONFIG_XML_NAME; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceDAO.java index 9c0dbb9187..1052ef1aba 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceDAO.java @@ -27,14 +27,44 @@ import java.util.List; */ public interface MobileDeviceDAO { - MobileDevice getMobileDevice(String deviceId) throws MobileDeviceManagementDAOException; + /** + * Fetches a MobileDevice from MDM database. + * @param mblDeviceId Id of the Mobile-Device. + * @return MobileDevice corresponding to given device-id. + * @throws MobileDeviceManagementDAOException + */ + MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException; + /** + * Adds a new MobileDevice to the MDM database. + * @param mobileDevice MobileDevice to be added. + * @return The status of the operation. + * @throws MobileDeviceManagementDAOException + */ boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; + /** + * Updates MobileDevice information in MDM database. + * @param mobileDevice MobileDevice to be updated. + * @return The status of the operation. + * @throws MobileDeviceManagementDAOException + */ boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; - boolean deleteMobileDevice(String deviceId) throws MobileDeviceManagementDAOException; + /** + * Deletes a given MobileDevice from MDM database. + * @param mblDeviceId Id of MobileDevice to be deleted. + * @return The status of the operation. + * @throws MobileDeviceManagementDAOException + */ + boolean deleteMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException; + /** + * Fetches all MobileDevices from MDM database. + * + * @return List of MobileDevices. + * @throws MobileDeviceManagementDAOException + */ List getAllMobileDevices() throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationMappingDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationMappingDAO.java index e9fdb69af2..bc61be0039 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationMappingDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceOperationMappingDAO.java @@ -26,87 +26,93 @@ import java.util.List; * This class represents the mapping between mobile device and operations. */ public interface MobileDeviceOperationMappingDAO { + /** - * Add a new mobile device operation mapping to the table. + * Adds a new mobile device operation mapping to the table. * - * @param deviceOperation MobileDeviceOperation object that holds data related to the - * MobileDeviceOperation to be inserted. - * @return The status of the operation. If the insert was successful or not. + * @param mblDeviceOperationMapping MobileDeviceOperationMapping object that holds data related + * to the MobileDeviceOperationMapping to be inserted. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean addMobileDeviceOperationMapping(MobileDeviceOperationMapping deviceOperation) + boolean addMobileDeviceOperationMapping(MobileDeviceOperationMapping mblDeviceOperationMapping) throws MobileDeviceManagementDAOException; /** - * Updates a mobile device operation mapping. + * Updates a MobileDeviceOperationMapping in MobileDeviceOperationMapping table. * - * @param deviceOperation MobileDeviceOperation object that holds data has to be updated. - * @return The status of the operation. If the update was successful or not. + * @param mblDeviceOperation MobileDeviceOperationMapping object that holds data has to be updated. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean updateMobileDeviceOperationMapping(MobileDeviceOperationMapping deviceOperation) + boolean updateMobileDeviceOperationMapping(MobileDeviceOperationMapping mblDeviceOperation) throws MobileDeviceManagementDAOException; /** - * Updates a mobile device operation mapping to In-Progress state. + * Updates a MobileDeviceOperationMapping to In-Progress state in MobileDeviceOperationMapping + * table. * - * @param deviceId Device id of the mapping to be deleted. - * @param operationId Operation id of the mapping to be deleted. - * @return The status of the operation. If the update was successful or not. + * @param mblDeviceId MobileDevice id of the mappings to be updated. + * @param operationId Operation id of the mapping to be updated. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean updateMobileDeviceOperationMappingToInProgress(String deviceId, int operationId) + boolean updateMobileDeviceOperationMappingToInProgress(String mblDeviceId, int operationId) throws MobileDeviceManagementDAOException; /** - * Updates a mobile device operation mapping to completed state. + * Updates a MobileDeviceOperationMapping to completed state in MobileDeviceOperationMapping + * table. * - * @param deviceId Device id of the mapping to be deleted. - * @param operationId Operation id of the mapping to be deleted. - * @return The status of the operation. If the update was successful or not. + * @param mblDeviceId MobileDevice id of the mappings to be updated. + * @param operationId Operation id of the mapping to be updated. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean updateMobileDeviceOperationMappingToCompleted(String deviceId, int operationId) + boolean updateMobileDeviceOperationMappingToCompleted(String mblDeviceId, int operationId) throws MobileDeviceManagementDAOException; /** - * Delete a given mobile device operation mapping from table. + * Delete a given MobileDeviceOperationMapping from MobileDeviceOperationMapping table. * - * @param deviceId Device id of the mapping to be deleted. + * @param mblDeviceId MobileDevice id of the mappings to be deleted. * @param operationId Operation id of the mapping to be deleted. - * @return The status of the operation. If the deletion was successful or not. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean deleteMobileDeviceOperationMapping(String deviceId, int operationId) + boolean deleteMobileDeviceOperationMapping(String mblDeviceId, int operationId) throws MobileDeviceManagementDAOException; /** - * Retrieves a given mobile device operation from the plugin database. + * Retrieves a given MobileDeviceOperationMapping object from the MobileDeviceOperationMapping + * table. * - * @param deviceId Device id of the mapping to be retrieved. + * @param mblDeviceId Device id of the mapping to be retrieved. * @param operationId Operation id of the mapping to be retrieved. * @return MobileDeviceOperation object that holds data of the device operation mapping * represented by deviceId and operationId. * @throws MobileDeviceManagementDAOException */ - MobileDeviceOperationMapping getMobileDeviceOperationMapping(String deviceId, int operationId) + MobileDeviceOperationMapping getMobileDeviceOperationMapping(String mblDeviceId, int operationId) throws MobileDeviceManagementDAOException; /** - * Retrieves all the of mobile device operation mappings relevant to the given mobile device. + * Retrieves all the of MobileDeviceOperationMappings relevant to a given mobile device. * - * @return Device operation mapping object list. + * @param mblDeviceId MobileDevice id of the mappings to be retrieved. + * @return MobileDeviceOperationMapping object list. * @throws MobileDeviceManagementDAOException */ - List getAllMobileDeviceOperationMappingsOfDevice(String deviceId) + List getAllMobileDeviceOperationMappingsOfDevice(String mblDeviceId) throws MobileDeviceManagementDAOException; /** - * Retrieves all the pending device operation mappings of a mobiel device. + * Retrieves all the pending MobileDeviceOperationMappings of a mobile device. * - * @return Device operation mapping object list. + * @param mblDeviceId MobileDevice id of the mappings to be retrieved. + * @return MobileDeviceOperationMapping object list. * @throws MobileDeviceManagementDAOException */ - List getAllPendingOperationMappingsOfMobileDevice(String deviceId) + List getAllPendingOperationMappingsOfMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java index 0248c1a25a..c22f3d1a46 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java @@ -29,73 +29,73 @@ import java.util.List; public interface MobileFeatureDAO { /** - * Add a new feature to feature table. + * Adds a new MobileFeature to Mobile-Feature table. * - * @param mobileFeature Feature object that holds data related to the feature to be inserted. - * @return The id of inserted feature. + * @param mobileFeature MobileFeature object that holds data related to the feature to be inserted. + * @return The id of inserted MobileFeature. * @throws MobileDeviceManagementDAOException */ int addMobileFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; /** - * Update a feature in the feature table. + * Updates a MobileFeature in Mobile-Feature table. * - * @param mobileFeature Feature object that holds data has to be updated. - * @return The status of the operation. If the update was successful or not. + * @param mobileFeature MobileFeature object that holds data has to be updated. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ boolean updateMobileFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; /** - * Delete a feature from feature table when the feature id is given. + * Deletes a MobileFeature from Mobile-Feature table when the feature id is given. * - * @param featureId Feature id of the feature to be deleted. - * @return The status of the operation. If the operationId was successful or not. + * @param mblFeatureId MobileFeature id of the MobileFeature to be deleted. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean deleteMobileFeatureById(int featureId) throws MobileDeviceManagementDAOException; + boolean deleteMobileFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException; /** - * Delete a feature from feature table when the feature code is given. + * Deletes a MobileFeature from Mobile-Feature table when the feature code is given. * - * @param featureCode Feature code of the feature to be deleted. - * @return The status of the operation. If the operationId was successful or not. + * @param mblFeatureCode MobileFeature code of the feature to be deleted. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean deleteMobileFeatureByCode(String featureCode) throws MobileDeviceManagementDAOException; + boolean deleteMobileFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException; /** - * Retrieve a given feature from feature table when the feature id is given. + * Retrieves a given MobileFeature from Mobile-Feature table when the feature id is given. * - * @param featureId Feature id of the feature to be retrieved. - * @return Feature object that holds data of the feature represented by featureId. + * @param mblFeatureId Feature id of the feature to be retrieved. + * @return MobileFeature object that holds data of the feature represented by featureId. * @throws MobileDeviceManagementDAOException */ - MobileFeature getMobileFeatureById(int featureId) throws MobileDeviceManagementDAOException; + MobileFeature getMobileFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException; /** - * Retrieve a given feature from feature table when the feature code is given. + * Retrieves a given MobileFeature from Mobile-Feature table when the feature code is given. * - * @param featureCode Feature code of the feature to be retrieved. - * @return Feature object that holds data of the feature represented by featureCode. + * @param mblFeatureCode Feature code of the feature to be retrieved. + * @return MobileFeature object that holds data of the feature represented by featureCode. * @throws MobileDeviceManagementDAOException */ - MobileFeature getMobileFeatureByCode(String featureCode) throws MobileDeviceManagementDAOException; + MobileFeature getMobileFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException; /** - * Retrieve all the features from plugin specific database. + * Retrieves all MobileFeatures of a MobileDevice type from Mobile-Feature table. * - * @return Feature object list. + * @param deviceType MobileDevice type of the MobileFeatures to be retrieved + * @return MobileFeature object list. * @throws MobileDeviceManagementDAOException */ + List getMobileFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException; /** - * Retrieve all the features from plugin specific database for a Device Type. - * @param deviceType - Device type. - * @return Feature object list. + * Retrieve all the MobileFeatures from Mobile-Feature table. + * + * @return MobileFeature object list. * @throws MobileDeviceManagementDAOException */ - List getMobileFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException; - List getAllMobileFeatures() throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java index 59828124cc..51a6cef289 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeaturePropertyDAO.java @@ -27,64 +27,68 @@ import java.util.List; * related information. */ public interface MobileFeaturePropertyDAO { + /** - * Add a new feature property to feature property table. + * Add a new MobileFeatureProperty to MobileFeatureProperty table. * - * @param mobileFeatureProperty Feature property object that holds data related to the feature + * @param mblFeatureProperty MobileFeatureProperty object that holds data related to the feature * property to be inserted. - * @return The status of the operation. If the insert was successful or not. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean addMobileFeatureProperty(MobileFeatureProperty mobileFeatureProperty) + boolean addMobileFeatureProperty(MobileFeatureProperty mblFeatureProperty) throws MobileDeviceManagementDAOException; /** - * Updates a feature property in the feature property table. + * Updates a MobileFeatureProperty in the MobileFeatureProperty table. * - * @param mobileFeatureProperty Feature property object that holds data has to be updated. - * @return The status of the operation. If the update was successful or not. + * @param mblFeatureProperty MobileFeatureProperty object that holds data has to be updated. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean updateMobileFeatureProperty(MobileFeatureProperty mobileFeatureProperty) + boolean updateMobileFeatureProperty(MobileFeatureProperty mblFeatureProperty) throws MobileDeviceManagementDAOException; /** - * Deletes a given feature property from feature property table. + * Deletes a given MobileFeatureProperty from MobileFeatureProperty table. * - * @param property Property of the feature property to be deleted. - * @return The status of the operation. If the operationId was successful or not. + * @param property Property of the MobileFeatureProperty to be deleted. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ boolean deleteMobileFeatureProperty(String property) throws MobileDeviceManagementDAOException; /** - * Deletes feature properties of a feature from feature property table. + * Deletes MobileFeatureProperties of a given feature from MobileFeatureProperty table. * - * @param featureId Feature-id of the feature corresponding properties should be deleted. - * @return The status of the operation. If the operationId was successful or not. + * @param mblFeatureId Feature-id of the MobileFeature corresponding properties should be deleted. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean deleteMobileFeaturePropertiesOfFeature(Integer featureId) + boolean deleteMobileFeaturePropertiesOfFeature(Integer mblFeatureId) throws MobileDeviceManagementDAOException; /** - * Retrieves a given feature property from feature property table. + * Retrieves a given MobileFeatureProperty from MobileFeatureProperty table. * * @param property Property of the feature property to be retrieved. - * @return Feature property object that holds data of the feature property represented by propertyId. + * @return MobileFeatureProperty object that holds data of the feature property represented by + * property. * @throws MobileDeviceManagementDAOException */ MobileFeatureProperty getMobileFeatureProperty(String property) throws MobileDeviceManagementDAOException; /** - * Retrieves a list of feature property corresponds to a feature id . + * Retrieves a list of MobileFeatureProperties corresponds to a given feature id from + * MobileFeatureProperty table. * - * @param featureId feature id of the feature property to be retrieved. - * @return Feature property object that holds data of the feature property represented by propertyId. + * @param mblFeatureId feature id of the MobileFeatureProperties to be retrieved. + * @return List of MobileFeatureProperty objects that holds data of the MobileFeatureProperties + * represented by featureId. * @throws MobileDeviceManagementDAOException */ - List getFeaturePropertiesOfFeature(Integer featureId) + List getFeaturePropertiesOfFeature(Integer mblFeatureId) throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationDAO.java index 4c8c11c008..90e5a3ea7b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationDAO.java @@ -27,35 +27,36 @@ import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation; public interface MobileOperationDAO { /** - * Add a new Mobile operation to plugin operation table. - * @param operation Operation object that holds data related to the operation to be inserted. - * @return The last inserted Id is returned, if the insertion was unsuccessful -1 is returned. + * Adds a new Mobile operation to the MobileOperation table. + * @param mblOperation MobileOperation object that holds data related to the operation to be + * inserted. + * @return The id of the inserted record, if the insertion was unsuccessful -1 is returned. * @throws MobileDeviceManagementDAOException */ - int addMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException; + int addMobileOperation(MobileOperation mblOperation) throws MobileDeviceManagementDAOException; /** - * Update a Mobile operation in the operation table. - * @param operation Operation object that holds data has to be updated. - * @return The status of the operation. If the update was successful or not. + * Updates a Mobile operation in the MobileOperation table. + * @param mblOperation MobileOperation object that holds data has to be updated. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean updateMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException; + boolean updateMobileOperation(MobileOperation mblOperation) throws MobileDeviceManagementDAOException; /** - * Delete a given Mobile operation from plugin database. - * @param operationId Operation code of the operation to be deleted. - * @return The status of the operation. If the operationId was successful or not. + * Deletes a given MobileOperation from MobileOperation table. + * @param mblOperationId Operation code of the MobileOperation to be deleted. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean deleteMobileOperation(int operationId) throws MobileDeviceManagementDAOException; + boolean deleteMobileOperation(int mblOperationId) throws MobileDeviceManagementDAOException; /** - * Retrieve a given Mobile operation from plugin database. - * @param operationId Operation id of the operation to be retrieved. - * @return Operation object that holds data of the feature represented by operationId. + * Retrieve a MobileOperation from MobileOperation table. + * @param mblOperationId Operation id of the MobileOperation to be retrieved. + * @return MobileOperation object that holds data of MobileOperation represented by operationId. * @throws MobileDeviceManagementDAOException */ - MobileOperation getMobileOperation(int operationId) throws MobileDeviceManagementDAOException; + MobileOperation getMobileOperation(int mblOperationId) throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationPropertyDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationPropertyDAO.java index 1dedb21733..87216b02d2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationPropertyDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileOperationPropertyDAO.java @@ -23,60 +23,65 @@ import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty; import java.util.List; /** - * This class represents the key operations associated with persisting mobile operation property related - * information. + * + * This class represents the key operations associated with persisting mobile operation property + * related information. + * */ public interface MobileOperationPropertyDAO { + /** - * Add a new mapping to plugin operation property table. + * Add a new MobileOperationProperty to MobileOperationProperty table. * - * @param operationProperty OperationProperty object that holds data related to the operation - * property to be inserted. - * @return The status of the operation. If the insert was successful or not. + * @param mblOperationProperty MobileOperationProperty object that holds data related to the + * operation property to be inserted. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean addMobileOperationProperty(MobileOperationProperty operationProperty) + boolean addMobileOperationProperty(MobileOperationProperty mblOperationProperty) throws MobileDeviceManagementDAOException; /** - * Update a feature in the feature table. + * Update a MobileOperationProperty in the MobileOperationProperty table. * - * @param operationProperty DeviceOperation object that holds data has to be updated. - * @return The status of the operation. If the update was successful or not. + * @param mblOperationProperty MobileOperationProperty object that holds data has to be updated. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean updateMobileOperationProperty(MobileOperationProperty operationProperty) + boolean updateMobileOperationProperty(MobileOperationProperty mblOperationProperty) throws MobileDeviceManagementDAOException; /** - * Deletes mobile operation properties of a given operation id from the plugin database. + * Deletes MobileOperationProperties of a given operation id from the MobileOperationProperty + * table. * - * @param operationId Operation id of the mapping to be deleted. - * @return The status of the operation. If the deletion was successful or not. + * @param mblOperationId Operation id of the MobileOperationProperty to be deleted. + * @return The status of the operation. * @throws MobileDeviceManagementDAOException */ - boolean deleteMobileOperationProperties(int operationId) + boolean deleteMobileOperationProperties(int mblOperationId) throws MobileDeviceManagementDAOException; /** - * Retrieve a given mobile operation property from plugin database. + * Retrieve a given MobileOperationProperty from MobileOperationProperty table. * - * @param operationId Operation id of the mapping to be retrieved. + * @param mblOperationId Operation id of the mapping to be retrieved. * @param property Property of the mapping to be retrieved. - * @return DeviceOperation object that holds data of the device operation mapping represented by - * deviceId and operationId. + * @return MobileOperationProperty object that holds data of the MobileOperationProperty + * represented by mblOperationId and property. * @throws MobileDeviceManagementDAOException */ - MobileOperationProperty getMobileOperationProperty(int operationId, String property) + MobileOperationProperty getMobileOperationProperty(int mblOperationId, String property) throws MobileDeviceManagementDAOException; /** - * Retrieve all the mobile operation properties related to the a operation id. + * Retrieve all the MobileOperationProperties related to the a operation id from + * MobileOperationProperty table. * - * @param operationId Operation id of the mapping to be retrieved. - * @return Device operation mapping object list. + * @param mblOperationId Operation id of the MobileOperationProperty to be retrieved. + * @return List of MobileOperationProperty objects. * @throws MobileDeviceManagementDAOException */ - List getAllMobileOperationPropertiesOfOperation(int operationId) + List getAllMobileOperationPropertiesOfOperation(int mblOperationId) throws MobileDeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java index b5ee24b45c..1c882515f5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceDAOImpl.java @@ -46,7 +46,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { } @Override - public MobileDevice getMobileDevice(String deviceId) throws MobileDeviceManagementDAOException { + public MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; MobileDevice mobileDevice = null; @@ -56,7 +56,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { "SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + "LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, deviceId); + stmt.setString(1, mblDeviceId); ResultSet resultSet = stmt.executeQuery(); if (resultSet.next()) { mobileDevice = new MobileDevice(); @@ -69,10 +69,13 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { mobileDevice.setVendor(resultSet.getString(7)); mobileDevice.setLatitude(resultSet.getString(8)); mobileDevice.setLongitude(resultSet.getString(9)); + if (log.isDebugEnabled()) { + log.debug("Mobile device " + mblDeviceId + " data has fetched from MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while fetching mobile device '" + - deviceId + "'"; + mblDeviceId + "'"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -106,6 +109,10 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Mobile device " + mobileDevice.getMobileDeviceId() + " data has added" + + " to the MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while adding the mobile device '" + @@ -143,6 +150,10 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Mobile device " + mobileDevice.getMobileDeviceId() + " data has" + + " updated"); + } } } catch (SQLException e) { String msg = "Error occurred while updating the mobile device '" + @@ -156,7 +167,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { } @Override - public boolean deleteMobileDevice(String deviceId) throws MobileDeviceManagementDAOException { + public boolean deleteMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; PreparedStatement stmt = null; @@ -165,13 +176,17 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { String deleteDBQuery = "DELETE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, deviceId); + stmt.setString(1, mblDeviceId); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Mobile device " + mblDeviceId + " data has deleted" + + " from the MDM database."); + } } } catch (SQLException e) { - String msg = "Error occurred while deleting mobile device " + deviceId; + String msg = "Error occurred while deleting mobile device " + mblDeviceId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -206,6 +221,9 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO { mobileDevice.setLongitude(resultSet.getString(9)); mobileDevices.add(mobileDevice); } + if (log.isDebugEnabled()) { + log.debug("All Mobile device details have fetched from MDM database."); + } return mobileDevices; } catch (SQLException e) { String msg = "Error occurred while fetching all mobile device data'"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java index 211ffe253e..9738f1f60d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileDeviceOperationMappingDAOImpl.java @@ -47,7 +47,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio } @Override - public boolean addMobileDeviceOperationMapping(MobileDeviceOperationMapping deviceOperation) + public boolean addMobileDeviceOperationMapping(MobileDeviceOperationMapping mblDeviceOperationMapping) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -59,19 +59,24 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio "RECEIVED_DATE, STATUS) VALUES (?, ?, ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, deviceOperation.getDeviceId()); - stmt.setLong(2, deviceOperation.getOperationId()); - stmt.setLong(3, deviceOperation.getSentDate()); - stmt.setLong(4, deviceOperation.getReceivedDate()); - stmt.setString(5, deviceOperation.getStatus().name()); + stmt.setString(1, mblDeviceOperationMapping.getDeviceId()); + stmt.setLong(2, mblDeviceOperationMapping.getOperationId()); + stmt.setLong(3, mblDeviceOperationMapping.getSentDate()); + stmt.setLong(4, mblDeviceOperationMapping.getReceivedDate()); + stmt.setString(5, mblDeviceOperationMapping.getStatus().name()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Added a MobileDevice-Mapping DeviceId : " + mblDeviceOperationMapping + .getDeviceId() + ", " + + "OperationId : " + mblDeviceOperationMapping.getOperationId() + " to the MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while adding device id - '" + - deviceOperation.getDeviceId() + " and operation id - " + - deviceOperation.getOperationId() + + mblDeviceOperationMapping.getDeviceId() + " and operation id - " + + mblDeviceOperationMapping.getOperationId() + " to mapping table MBL_DEVICE_OPERATION"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); @@ -82,7 +87,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio } @Override - public boolean updateMobileDeviceOperationMapping(MobileDeviceOperationMapping deviceOperation) + public boolean updateMobileDeviceOperationMapping(MobileDeviceOperationMapping mblDeviceOperation) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -93,19 +98,23 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio "UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, " + "STATUS = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?"; stmt = conn.prepareStatement(updateDBQuery); - stmt.setLong(1, deviceOperation.getSentDate()); - stmt.setLong(2, deviceOperation.getReceivedDate()); - stmt.setString(3, deviceOperation.getStatus().name()); - stmt.setString(4, deviceOperation.getDeviceId()); - stmt.setInt(5, deviceOperation.getOperationId()); + stmt.setLong(1, mblDeviceOperation.getSentDate()); + stmt.setLong(2, mblDeviceOperation.getReceivedDate()); + stmt.setString(3, mblDeviceOperation.getStatus().name()); + stmt.setString(4, mblDeviceOperation.getDeviceId()); + stmt.setInt(5, mblDeviceOperation.getOperationId()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Updated MobileDevice-Mapping DeviceId : " + mblDeviceOperation.getDeviceId() + " , " + + "OperationId : " + mblDeviceOperation.getOperationId()); + } } } catch (SQLException e) { String msg = "Error occurred while updating device id - '" + - deviceOperation.getDeviceId() + " and operation id - " + - deviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION"; + mblDeviceOperation.getDeviceId() + " and operation id - " + + mblDeviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -115,7 +124,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio } @Override - public boolean updateMobileDeviceOperationMappingToInProgress(String deviceId, int operationId) + public boolean updateMobileDeviceOperationMappingToInProgress(String mblDeviceId, int operationId) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -128,16 +137,20 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio stmt = conn.prepareStatement(updateDBQuery); stmt.setLong(1, new Date().getTime()); stmt.setString(2, MobileDeviceOperationMapping.Status.INPROGRESS.name()); - stmt.setString(3, deviceId); + stmt.setString(3, mblDeviceId); stmt.setInt(4, operationId); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Updated status of MobileDevice-Mapping DeviceId : " + mblDeviceId + " , " + + "OperationId : " + operationId + " to In-Progress state"); + } } } catch (SQLException e) { String msg = "Error occurred while updating the Status of operation to in-progress of device id - '" + - deviceId + " and operation id - " + + mblDeviceId + " and operation id - " + operationId + " in table MBL_DEVICE_OPERATION"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); @@ -148,7 +161,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio } @Override - public boolean updateMobileDeviceOperationMappingToCompleted(String deviceId, + public boolean updateMobileDeviceOperationMappingToCompleted(String mblDeviceId, int operationId) throws MobileDeviceManagementDAOException { boolean status = false; @@ -162,16 +175,20 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio stmt = conn.prepareStatement(updateDBQuery); stmt.setLong(1, new Date().getTime()); stmt.setString(2, MobileDeviceOperationMapping.Status.COMPLETED.name()); - stmt.setString(3, deviceId); + stmt.setString(3, mblDeviceId); stmt.setInt(4, operationId); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Updated status of MobileDevice-Mapping DeviceId : " + mblDeviceId + " , " + + "OperationId : " + operationId + " to Completed state"); + } } } catch (SQLException e) { String msg = "Error occurred while updating the Status of operation to completed of device id - '" + - deviceId + " and operation id - " + + mblDeviceId + " and operation id - " + operationId + " in table MBL_DEVICE_OPERATION"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); @@ -182,7 +199,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio } @Override - public boolean deleteMobileDeviceOperationMapping(String deviceId, int operationId) + public boolean deleteMobileDeviceOperationMapping(String mblDeviceId, int operationId) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -193,16 +210,20 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio "DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND " + "OPERATION_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, deviceId); + stmt.setString(1, mblDeviceId); stmt.setInt(2, operationId); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Deleted MobileDevice-Mapping DeviceId : " + mblDeviceId + " , " + + "OperationId : " + operationId + "from MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while deleting the table entry MBL_DEVICE_OPERATION with " + - " device id - '" + deviceId + " and operation id - " + operationId; + " device id - '" + mblDeviceId + " and operation id - " + operationId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -212,7 +233,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio } @Override - public MobileDeviceOperationMapping getMobileDeviceOperationMapping(String deviceId, + public MobileDeviceOperationMapping getMobileDeviceOperationMapping(String mblDeviceId, int operationId) throws MobileDeviceManagementDAOException { Connection conn = null; @@ -224,7 +245,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " + "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, deviceId); + stmt.setString(1, mblDeviceId); stmt.setInt(2, operationId); ResultSet resultSet = stmt.executeQuery(); if (resultSet.next()) { @@ -234,11 +255,15 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio mblDeviceOperation.setSentDate(resultSet.getInt(3)); mblDeviceOperation.setReceivedDate(resultSet.getInt(4)); mblDeviceOperation.setStatus(resultSet.getString(5)); + if (log.isDebugEnabled()) { + log.debug("Fetched MobileDevice-Mapping of DeviceId : " + mblDeviceId + " , " + + "OperationId : " + operationId ); + } } } catch (SQLException e) { String msg = "Error occurred while fetching table MBL_DEVICE_OPERATION entry with device id - '" + - deviceId + " and operation id - " + operationId; + mblDeviceId + " and operation id - " + operationId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -249,7 +274,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio @Override public List getAllMobileDeviceOperationMappingsOfDevice( - String deviceId) + String mblDeviceId) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; @@ -262,7 +287,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " + "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, deviceId); + stmt.setString(1, mblDeviceId); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { mblDeviceOperation = new MobileDeviceOperationMapping(); @@ -273,10 +298,13 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio mblDeviceOperation.setStatus(resultSet.getString(5)); mblDeviceOperations.add(mblDeviceOperation); } + if (log.isDebugEnabled()) { + log.debug("Fetched all MobileDevice-Mappings of DeviceId : " + mblDeviceId); + } } catch (SQLException e) { String msg = "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of " + - "device id - '" + deviceId; + "device id - '" + mblDeviceId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -287,7 +315,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio @Override public List getAllPendingOperationMappingsOfMobileDevice( - String deviceId) + String mblDeviceId) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; @@ -301,7 +329,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM" + " MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND STATUS = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, deviceId); + stmt.setString(1, mblDeviceId); stmt.setString(2, MobileDeviceOperationMapping.Status.NEW.name()); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { @@ -313,10 +341,13 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio mblDeviceOperation.setStatus(resultSet.getString(5)); mblDeviceOperations.add(mblDeviceOperation); } + if (log.isDebugEnabled()) { + log.debug("Fetched all pending MobileDevice-Mappings of DeviceId : " + mblDeviceId); + } } catch (SQLException e) { String msg = "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of" + - " device id - '" + deviceId; + " device id - '" + mblDeviceId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java index 2f5251686e..66081becd7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java @@ -67,6 +67,10 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { if (rs != null && rs.next()) { status = rs.getInt(1); } + if (log.isDebugEnabled()) { + log.debug("Added a new MobileFeature " + mobileFeature.getCode() + " to the" + + " MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while adding feature code - '" + @@ -99,6 +103,9 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Updated MobileFeature " + mobileFeature.getCode()); + } } } catch (SQLException e) { String msg = "Error occurred while updating the feature with feature code - '" + @@ -112,7 +119,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { } @Override - public boolean deleteMobileFeatureByCode(String featureCode) + public boolean deleteMobileFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -122,13 +129,17 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { String deleteDBQuery = "DELETE FROM MBL_FEATURE WHERE CODE = ?"; stmt = conn.prepareStatement(deleteDBQuery); - stmt.setString(1, featureCode); + stmt.setString(1, mblFeatureCode); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Deleted MobileFeature code " + mblFeatureCode + " from the" + + " MDM database."); + } } } catch (SQLException e) { - String msg = "Error occurred while deleting feature with code - " + featureCode; + String msg = "Error occurred while deleting feature with code - " + mblFeatureCode; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -138,7 +149,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { } @Override - public boolean deleteMobileFeatureById(int featureId) + public boolean deleteMobileFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -148,13 +159,17 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { String deleteDBQuery = "DELETE FROM MBL_FEATURE WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); - stmt.setInt(1, featureId); + stmt.setInt(1, mblFeatureId); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Deleted MobileFeature id " + mblFeatureId + " from the" + + " MDM database."); + } } } catch (SQLException e) { - String msg = "Error occurred while deleting feature with id - " + featureId; + String msg = "Error occurred while deleting feature with id - " + mblFeatureId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -164,7 +179,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { } @Override - public MobileFeature getMobileFeatureByCode(String featureCode) + public MobileFeature getMobileFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; @@ -175,7 +190,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE " + "WHERE CODE = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setString(1, featureCode); + stmt.setString(1, mblFeatureCode); ResultSet resultSet = stmt.executeQuery(); if (resultSet.next()) { mobileFeature = new MobileFeature(); @@ -184,10 +199,14 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { mobileFeature.setName(resultSet.getString(3)); mobileFeature.setDescription(resultSet.getString(4)); mobileFeature.setDeviceType(resultSet.getString(5)); + if (log.isDebugEnabled()) { + log.debug("Fetched MobileFeature " + mblFeatureCode + " from the" + + " MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while fetching feature code - '" + - featureCode + "'"; + mblFeatureCode + "'"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -197,7 +216,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { } @Override - public MobileFeature getMobileFeatureById(int featureID) + public MobileFeature getMobileFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; @@ -208,7 +227,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE" + " WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setInt(1, featureID); + stmt.setInt(1, mblFeatureId); ResultSet resultSet = stmt.executeQuery(); if (resultSet.next()) { mobileFeature = new MobileFeature(); @@ -217,10 +236,14 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { mobileFeature.setName(resultSet.getString(3)); mobileFeature.setDescription(resultSet.getString(4)); mobileFeature.setDeviceType(resultSet.getString(5)); + if (log.isDebugEnabled()) { + log.debug("Fetched MobileFeatureId" + mblFeatureId + " from the" + + " MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while fetching feature id - '" + - featureID + "'"; + mblFeatureId + "'"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -250,6 +273,9 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { mobileFeature.setDeviceType(resultSet.getString(5)); mobileFeatures.add(mobileFeature); } + if (log.isDebugEnabled()) { + log.debug("Fetched all MobileFeatures from the MDM database."); + } return mobileFeatures; } catch (SQLException e) { String msg = "Error occurred while fetching all features.'"; @@ -284,6 +310,10 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO { mobileFeature.setDeviceType(resultSet.getString(5)); mobileFeatures.add(mobileFeature); } + if (log.isDebugEnabled()) { + log.debug("Fetched all MobileFeatures of type " + deviceType + " from the MDM" + + " database."); + } return mobileFeatures; } catch (SQLException e) { String msg = "Error occurred while fetching all features.'"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java index 34523675a6..d768dbd445 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeaturePropertyDAOImpl.java @@ -46,7 +46,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { } @Override - public boolean addMobileFeatureProperty(MobileFeatureProperty mobileFeatureProperty) + public boolean addMobileFeatureProperty(MobileFeatureProperty mblFeatureProperty) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -57,15 +57,19 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { "INSERT INTO MBL_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)"; stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, mobileFeatureProperty.getProperty()); - stmt.setInt(2, mobileFeatureProperty.getFeatureID()); + stmt.setString(1, mblFeatureProperty.getProperty()); + stmt.setInt(2, mblFeatureProperty.getFeatureID()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Added MobileFeatureProperty " + mblFeatureProperty.getProperty() + + " to the MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while adding property id - '" + - mobileFeatureProperty.getFeatureID() + "'"; + mblFeatureProperty.getFeatureID() + "'"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -75,7 +79,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { } @Override - public boolean updateMobileFeatureProperty(MobileFeatureProperty mobileFeatureProperty) + public boolean updateMobileFeatureProperty(MobileFeatureProperty mblFeatureProperty) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -85,15 +89,18 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { String updateDBQuery = "UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?"; stmt = conn.prepareStatement(updateDBQuery); - stmt.setInt(1, mobileFeatureProperty.getFeatureID()); - stmt.setString(2, mobileFeatureProperty.getProperty()); + stmt.setInt(1, mblFeatureProperty.getFeatureID()); + stmt.setString(2, mblFeatureProperty.getProperty()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Updated MobileFeatureProperty " + mblFeatureProperty.getProperty()); + } } } catch (SQLException e) { String msg = "Error occurred while updating the feature property with property - '" + - mobileFeatureProperty.getProperty() + "'"; + mblFeatureProperty.getProperty() + "'"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -117,6 +124,9 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Deleted MobileFeatureProperty " + property + " from MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while deleting feature property with property - " + @@ -130,7 +140,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { } @Override - public boolean deleteMobileFeaturePropertiesOfFeature(Integer featureId) + public boolean deleteMobileFeaturePropertiesOfFeature(Integer mblFeatureId) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -140,14 +150,18 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { String deleteDBQuery = "DELETE FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); - stmt.setInt(1, featureId); + stmt.setInt(1, mblFeatureId); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Deleted all MobileFeatureProperties of FeatureId " + mblFeatureId + + " from MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while deleting feature properties of feature - " + - featureId; + mblFeatureId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -173,6 +187,10 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { mobileFeatureProperty = new MobileFeatureProperty(); mobileFeatureProperty.setProperty(resultSet.getString(1)); mobileFeatureProperty.setFeatureID(resultSet.getInt(2)); + if (log.isDebugEnabled()) { + log.debug("Fetched MobileFeatureProperty " + mobileFeatureProperty.getProperty() + + " from MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while fetching property - '" + @@ -186,7 +204,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { } @Override - public List getFeaturePropertiesOfFeature(Integer featureId) + public List getFeaturePropertiesOfFeature(Integer mblFeatureId) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; @@ -197,7 +215,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { String selectDBQuery = "SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setInt(1, featureId); + stmt.setInt(1, mblFeatureId); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { mobileFeatureProperty = new MobileFeatureProperty(); @@ -205,6 +223,10 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO { mobileFeatureProperty.setFeatureID(resultSet.getInt(2)); FeatureProperties.add(mobileFeatureProperty); } + if (log.isDebugEnabled()) { + log.debug("Fetched all MobileFeatureProperties of featureId " + mblFeatureId + + " from MDM database."); + } return FeatureProperties; } catch (SQLException e) { String msg = "Error occurred while fetching all feature property.'"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java index 21f7d7044d..bd7e8b3c3c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationDAOImpl.java @@ -45,7 +45,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { } @Override - public int addMobileOperation(MobileOperation operation) + public int addMobileOperation(MobileOperation mblOperation) throws MobileDeviceManagementDAOException { int status = -1; Connection conn = null; @@ -55,18 +55,22 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { String createDBQuery = "INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)"; stmt = conn.prepareStatement(createDBQuery, new String[] { COLUMN_OPERATION_ID }); - stmt.setString(1, operation.getFeatureCode()); - stmt.setLong(2, operation.getCreatedDate()); + stmt.setString(1, mblOperation.getFeatureCode()); + stmt.setLong(2, mblOperation.getCreatedDate()); int rows = stmt.executeUpdate(); if (rows > 0) { ResultSet rs = stmt.getGeneratedKeys(); if (rs != null && rs.next()) { status = rs.getInt(1); } + if (log.isDebugEnabled()) { + log.debug("Added a new MobileOperation " + mblOperation.getFeatureCode() + + " to MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while adding the operation - '" + - operation.getFeatureCode() + "' to MBL_OPERATION table"; + mblOperation.getFeatureCode() + "' to MBL_OPERATION table"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -76,7 +80,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { } @Override - public boolean updateMobileOperation(MobileOperation operation) + public boolean updateMobileOperation(MobileOperation mblOperation) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -87,17 +91,21 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { "UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE " + "OPERATION_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); - stmt.setString(1, operation.getFeatureCode()); - stmt.setLong(2, operation.getCreatedDate()); - stmt.setInt(3, operation.getOperationId()); + stmt.setString(1, mblOperation.getFeatureCode()); + stmt.setLong(2, mblOperation.getCreatedDate()); + stmt.setInt(3, mblOperation.getOperationId()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Updated MobileOperation " + mblOperation.getFeatureCode() + + " to MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while updating the MBL_OPERATION table entry with operation id - '" + - operation.getOperationId() + "'"; + mblOperation.getOperationId() + "'"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -107,7 +115,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { } @Override - public boolean deleteMobileOperation(int operationId) + public boolean deleteMobileOperation(int mblOperationId) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -117,10 +125,14 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { String deleteDBQuery = "DELETE FROM MBL_OPERATION WHERE OPERATION_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); - stmt.setInt(1, operationId); + stmt.setInt(1, mblOperationId); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Deleted a new MobileOperation " + mblOperationId + + " from MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while deleting MBL_OPERATION entry with operation Id - "; @@ -133,7 +145,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { } @Override - public MobileOperation getMobileOperation(int operationId) + public MobileOperation getMobileOperation(int mblOperationId) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; @@ -144,17 +156,21 @@ public class MobileOperationDAOImpl implements MobileOperationDAO { "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE " + "OPERATION_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setInt(1, operationId); + stmt.setInt(1, mblOperationId); ResultSet resultSet = stmt.executeQuery(); if (resultSet.next()) { operation = new MobileOperation(); operation.setOperationId(resultSet.getInt(1)); operation.setFeatureCode(resultSet.getString(2)); operation.setCreatedDate(resultSet.getLong(3)); + if (log.isDebugEnabled()) { + log.debug("Fetched MobileOperation " + operation.getFeatureCode() + + " from MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while fetching operationId - '" + - operationId + "' from MBL_OPERATION"; + mblOperationId + "' from MBL_OPERATION"; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationPropertyDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationPropertyDAOImpl.java index 352d2b6e25..c4553862fc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationPropertyDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileOperationPropertyDAOImpl.java @@ -46,7 +46,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA } @Override - public boolean addMobileOperationProperty(MobileOperationProperty operationProperty) + public boolean addMobileOperationProperty(MobileOperationProperty mblOperationProperty) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -57,12 +57,16 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA "INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) " + "VALUES ( ?, ?, ?)"; stmt = conn.prepareStatement(createDBQuery); - stmt.setInt(1, operationProperty.getOperationId()); - stmt.setString(2, operationProperty.getProperty()); - stmt.setString(3, operationProperty.getValue()); + stmt.setInt(1, mblOperationProperty.getOperationId()); + stmt.setString(2, mblOperationProperty.getProperty()); + stmt.setString(3, mblOperationProperty.getValue()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Added a new MobileOperationProperty " + mblOperationProperty.getProperty() + + " to MDM database."); + } } } catch (SQLException e) { String msg = @@ -78,7 +82,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA @Override public boolean updateMobileOperationProperty( - MobileOperationProperty operationProperty) + MobileOperationProperty mblOperationProperty) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -89,12 +93,16 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA "UPDATE MBL_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND " + "PROPERTY = ?"; stmt = conn.prepareStatement(createDBQuery); - stmt.setString(1, operationProperty.getValue()); - stmt.setInt(2, operationProperty.getOperationId()); - stmt.setString(3, operationProperty.getProperty()); + stmt.setString(1, mblOperationProperty.getValue()); + stmt.setInt(2, mblOperationProperty.getOperationId()); + stmt.setString(3, mblOperationProperty.getProperty()); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Updated MobileOperationProperty " + mblOperationProperty.getProperty() + + " to MDM database."); + } } } catch (SQLException e) { String msg = @@ -109,7 +117,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA } @Override - public boolean deleteMobileOperationProperties(int operationId) + public boolean deleteMobileOperationProperties(int mblOperationId) throws MobileDeviceManagementDAOException { boolean status = false; Connection conn = null; @@ -119,10 +127,15 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA String deleteDBQuery = "DELETE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?"; stmt = conn.prepareStatement(deleteDBQuery); - stmt.setInt(1, operationId); + stmt.setInt(1, mblOperationId); int rows = stmt.executeUpdate(); if (rows > 0) { status = true; + if (log.isDebugEnabled()) { + log.debug("Deleted MobileOperationProperties of operation-id " + + mblOperationId + + " from MDM database."); + } } } catch (SQLException e) { String msg = @@ -136,7 +149,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA } @Override - public MobileOperationProperty getMobileOperationProperty(int operationId, + public MobileOperationProperty getMobileOperationProperty(int mblOperationId, String property) throws MobileDeviceManagementDAOException { Connection conn = null; @@ -148,7 +161,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " + "OPERATION_ID = ? AND PROPERTY = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setInt(1, operationId); + stmt.setInt(1, mblOperationId); stmt.setString(2, property); ResultSet resultSet = stmt.executeQuery(); if (resultSet.next()) { @@ -156,11 +169,16 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA mobileOperationProperty.setOperationId(resultSet.getInt(1)); mobileOperationProperty.setProperty(resultSet.getString(2)); mobileOperationProperty.setValue(resultSet.getString(3)); + if (log.isDebugEnabled()) { + log.debug("Fetched MobileOperationProperty of Operation-id : " + + mblOperationId + + " Property : " + property + " from MDM database."); + } } } catch (SQLException e) { String msg = "Error occurred while fetching the mobile operation property of Operation_id : " + - operationId + " and Property : " + property; + mblOperationId + " and Property : " + property; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { @@ -171,7 +189,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA @Override public List getAllMobileOperationPropertiesOfOperation( - int operationId) throws MobileDeviceManagementDAOException { + int mblOperationId) throws MobileDeviceManagementDAOException { Connection conn = null; PreparedStatement stmt = null; MobileOperationProperty mobileOperationProperty; @@ -182,7 +200,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " + "OPERATION_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); - stmt.setInt(1, operationId); + stmt.setInt(1, mblOperationId); ResultSet resultSet = stmt.executeQuery(); while (resultSet.next()) { mobileOperationProperty = new MobileOperationProperty(); @@ -191,10 +209,15 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA mobileOperationProperty.setValue(resultSet.getString(3)); properties.add(mobileOperationProperty); } + if (log.isDebugEnabled()) { + log.debug("Fetched all MobileOperationProperties of Operation-id : " + + mblOperationId + + " from MDM database."); + } } catch (SQLException e) { String msg = "Error occurred while fetching the mobile operation properties of Operation_id " + - operationId; + mblOperationId; log.error(msg, e); throw new MobileDeviceManagementDAOException(msg, e); } finally { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementBundleActivator.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementBundleActivator.java index fb32d4fecc..bf3f4e611e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementBundleActivator.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementBundleActivator.java @@ -66,8 +66,8 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B /* Initialize the datasource configuration */ MobileDeviceConfigurationManager.getInstance().initConfig(); - MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() - .getMobileDeviceManagementConfig(); + MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance(). + getMobileDeviceManagementConfig(); MobileDataSourceConfig dsConfig = config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java index c048dc105d..93bd8484a0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java @@ -57,101 +57,106 @@ import java.util.List; */ public class MobileDeviceManagementServiceComponent { - private ServiceRegistration androidServiceRegRef; - private ServiceRegistration iOSServiceRegRef; - private ServiceRegistration windowsServiceRegRef; - private ServiceRegistration serverStartupObserverRef; + private ServiceRegistration androidServiceRegRef; + private ServiceRegistration iOSServiceRegRef; + private ServiceRegistration windowsServiceRegRef; + private ServiceRegistration serverStartupObserverRef; - private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); + private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); - protected void activate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("Activating Mobile Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); + protected void activate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("Activating Mobile Device Management Service Component"); + } + try { + BundleContext bundleContext = ctx.getBundleContext(); /* Initialize the datasource configuration */ - MobileDeviceConfigurationManager.getInstance().initConfig(); - MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() - .getMobileDeviceManagementConfig(); - MobileDataSourceConfig dsConfig = - config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); - - MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig); - MobileDeviceManagementDAOFactory.init(); - String setupOption = System.getProperty("setup"); - if (setupOption != null) { - if (log.isDebugEnabled()) { - log.debug( - "-Dsetup is enabled. Mobile Device management repository schema initialization is about " + - "to begin"); - } - try { - MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema( - MobileDeviceManagementDAOFactory.getDataSource()); - } catch (DeviceManagementException e) { - log.error("Exception occurred while initializing mobile device management database schema", e); - } - } - - androidServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new AndroidDeviceManagerService(), null); - iOSServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new IOSDeviceManagerService(), null); - windowsServiceRegRef = - bundleContext.registerService(DeviceManagerService.class.getName(), - new WindowsDeviceManagerService(), null); - - serverStartupObserverRef = bundleContext.registerService(ServerStartupObserver.class, - new MobileDeviceManagementStartupObserver(), null); - if (log.isDebugEnabled()) { - log.debug("Mobile Device Management Service Component has been successfully activated"); - } - } catch (Throwable e) { - log.error("Error occurred while activating Mobile Device Management Service Component", e); - } - } - - protected void deactivate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("De-activating Mobile Device Management Service Component"); - } - try { - androidServiceRegRef.unregister(); - iOSServiceRegRef.unregister(); - windowsServiceRegRef.unregister(); - serverStartupObserverRef.unregister(); + MobileDeviceConfigurationManager.getInstance().initConfig(); + MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() + .getMobileDeviceManagementConfig(); + MobileDataSourceConfig dsConfig = + config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); + + MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig); + MobileDeviceManagementDAOFactory.init(); + String setupOption = System.getProperty("setup"); + if (setupOption != null) { + if (log.isDebugEnabled()) { + log.debug( + "-Dsetup is enabled. Mobile Device management repository schema initialization is about " + + "to begin"); + } + try { + MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema( + MobileDeviceManagementDAOFactory.getDataSource()); + } catch (DeviceManagementException e) { + log.error( + "Exception occurred while initializing mobile device management database schema", + e); + } + } + + androidServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new AndroidDeviceManagerService(), null); + iOSServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new IOSDeviceManagerService(), null); + windowsServiceRegRef = + bundleContext.registerService(DeviceManagerService.class.getName(), + new WindowsDeviceManagerService(), null); + + serverStartupObserverRef = bundleContext.registerService(ServerStartupObserver.class, + new MobileDeviceManagementStartupObserver(), + null); + if (log.isDebugEnabled()) { + log.debug( + "Mobile Device Management Service Component has been successfully activated"); + } + } catch (Throwable e) { + log.error("Error occurred while activating Mobile Device Management Service Component", + e); + } + } + + protected void deactivate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("De-activating Mobile Device Management Service Component"); + } + try { + androidServiceRegRef.unregister(); + iOSServiceRegRef.unregister(); + windowsServiceRegRef.unregister(); + serverStartupObserverRef.unregister(); /* Removing all APIs published upon start-up for mobile device management related JAX-RS services */ - this.removeAPIs(); - if (log.isDebugEnabled()) { - log.debug( - "Mobile Device Management Service Component has been successfully de-activated"); - } - } catch (Throwable e) { - log.error("Error occurred while de-activating Mobile Device Management bundle", e); - } - } - - private void removeAPIs() throws DeviceManagementException { - List apiConfigs = - MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). - getApiPublisherConfig().getAPIs(); - for (APIConfig apiConfig : apiConfigs) { - DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); - } - } - - protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } - - protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { - //do nothing - } + this.removeAPIs(); + if (log.isDebugEnabled()) { + log.debug( + "Mobile Device Management Service Component has been successfully de-activated"); + } + } catch (Throwable e) { + log.error("Error occurred while de-activating Mobile Device Management bundle", e); + } + } + + private void removeAPIs() throws DeviceManagementException { + List apiConfigs = + MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). + getApiPublisherConfig().getAPIs(); + for (APIConfig apiConfig : apiConfigs) { + DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); + } + } + + protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { + //do nothing + } + + protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { + //do nothing + } } diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 053ad179cd..73957bbe7a 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -17,7 +17,9 @@ ~ under the License. --> - + org.wso2.carbon.devicemgt-plugins diff --git a/pom.xml b/pom.xml index 1db632ba71..79c2940568 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,9 @@ ~ under the License. --> - + 4.0.0 org.wso2.carbon.devicemgt-plugins @@ -275,17 +277,17 @@ - + org.wso2.carbon.apimgt org.wso2.carbon.apimgt.api @@ -446,7 +448,7 @@ 7.0.34.wso2v2 - + 2.6.1 1.9.0 1.1.1 @@ -488,7 +490,8 @@ https://github.com/wso2/carbon-device-mgt-plugins.git - scm:git:https://github.com/wso2/carbon-device-mgt-plugins.git + scm:git:https://github.com/wso2/carbon-device-mgt-plugins.git + scm:git:https://github.com/wso2/carbon-device-mgt-plugins.git HEAD