Refactored DAO implementations & added comments.

revert-dabc3590
harshanL 10 years ago
parent ac6eca2cbc
commit 2dc1fe240f

@ -18,7 +18,9 @@
~ under the License. ~ under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
@ -51,9 +53,11 @@
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name> <Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.mobile.device.mgt.version}</Bundle-Version> <Bundle-Version>${carbon.mobile.device.mgt.version}</Bundle-Version>
<Bundle-Description>Device Management Mobile Impl Bundle</Bundle-Description> <Bundle-Description>Device Management Mobile Impl Bundle
</Bundle-Description>
<!--<Bundle-Activator>org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator</Bundle-Activator>--> <!--<Bundle-Activator>org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator</Bundle-Activator>-->
<Private-Package>org.wso2.carbon.device.mgt.mobile.internal</Private-Package> <Private-Package>org.wso2.carbon.device.mgt.mobile.internal
</Private-Package>
<Import-Package> <Import-Package>
org.osgi.framework, org.osgi.framework,
org.osgi.service.component, org.osgi.service.component,
@ -73,7 +77,8 @@
<version>2.18</version> <version>2.18</version>
<configuration> <configuration>
<systemPropertyVariables> <systemPropertyVariables>
<log4j.configuration>file:src/test/resources/log4j.properties</log4j.configuration> <log4j.configuration>file:src/test/resources/log4j.properties
</log4j.configuration>
</systemPropertyVariables> </systemPropertyVariables>
<suiteXmlFiles> <suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>

@ -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_CONFIG_XML_NAME = "mobile-config.xml";
private static final String MOBILE_DEVICE_PLUGIN_DIRECTORY = "mobile"; 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 MobileDeviceManagementConfig currentMobileDeviceConfig;
private static MobileDeviceConfigurationManager mobileDeviceConfigManager; private static MobileDeviceConfigurationManager mobileDeviceConfigManager;
private final String mobileDeviceMgtConfigXMLPath = private final String mobileDeviceMgtConfigXMLPath =
CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-mgt-plugin-configs" + CarbonUtils.getEtcCarbonConfigDirPath() + File.separator +
DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY +
File.separator + File.separator +
MOBILE_DEVICE_PLUGIN_DIRECTORY + File.separator + MOBILE_DEVICE_CONFIG_XML_NAME; MOBILE_DEVICE_PLUGIN_DIRECTORY + File.separator + MOBILE_DEVICE_CONFIG_XML_NAME;

@ -27,14 +27,44 @@ import java.util.List;
*/ */
public interface MobileDeviceDAO { 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; 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 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<MobileDevice> getAllMobileDevices() throws MobileDeviceManagementDAOException; List<MobileDevice> getAllMobileDevices() throws MobileDeviceManagementDAOException;
} }

@ -26,87 +26,93 @@ import java.util.List;
* This class represents the mapping between mobile device and operations. * This class represents the mapping between mobile device and operations.
*/ */
public interface MobileDeviceOperationMappingDAO { 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 * @param mblDeviceOperationMapping MobileDeviceOperationMapping object that holds data related
* MobileDeviceOperation to be inserted. * to the MobileDeviceOperationMapping to be inserted.
* @return The status of the operation. If the insert was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean addMobileDeviceOperationMapping(MobileDeviceOperationMapping deviceOperation) boolean addMobileDeviceOperationMapping(MobileDeviceOperationMapping mblDeviceOperationMapping)
throws MobileDeviceManagementDAOException; 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. * @param mblDeviceOperation MobileDeviceOperationMapping object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateMobileDeviceOperationMapping(MobileDeviceOperationMapping deviceOperation) boolean updateMobileDeviceOperationMapping(MobileDeviceOperationMapping mblDeviceOperation)
throws MobileDeviceManagementDAOException; 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 mblDeviceId MobileDevice id of the mappings to be updated.
* @param operationId Operation id of the mapping to be deleted. * @param operationId Operation id of the mapping to be updated.
* @return The status of the operation. If the update was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateMobileDeviceOperationMappingToInProgress(String deviceId, int operationId) boolean updateMobileDeviceOperationMappingToInProgress(String mblDeviceId, int operationId)
throws MobileDeviceManagementDAOException; 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 mblDeviceId MobileDevice id of the mappings to be updated.
* @param operationId Operation id of the mapping to be deleted. * @param operationId Operation id of the mapping to be updated.
* @return The status of the operation. If the update was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateMobileDeviceOperationMappingToCompleted(String deviceId, int operationId) boolean updateMobileDeviceOperationMappingToCompleted(String mblDeviceId, int operationId)
throws MobileDeviceManagementDAOException; 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. * @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 * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteMobileDeviceOperationMapping(String deviceId, int operationId) boolean deleteMobileDeviceOperationMapping(String mblDeviceId, int operationId)
throws MobileDeviceManagementDAOException; 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. * @param operationId Operation id of the mapping to be retrieved.
* @return MobileDeviceOperation object that holds data of the device operation mapping * @return MobileDeviceOperation object that holds data of the device operation mapping
* represented by deviceId and operationId. * represented by deviceId and operationId.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
MobileDeviceOperationMapping getMobileDeviceOperationMapping(String deviceId, int operationId) MobileDeviceOperationMapping getMobileDeviceOperationMapping(String mblDeviceId, int operationId)
throws MobileDeviceManagementDAOException; 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 * @throws MobileDeviceManagementDAOException
*/ */
List<MobileDeviceOperationMapping> getAllMobileDeviceOperationMappingsOfDevice(String deviceId) List<MobileDeviceOperationMapping> getAllMobileDeviceOperationMappingsOfDevice(String mblDeviceId)
throws MobileDeviceManagementDAOException; 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 * @throws MobileDeviceManagementDAOException
*/ */
List<MobileDeviceOperationMapping> getAllPendingOperationMappingsOfMobileDevice(String deviceId) List<MobileDeviceOperationMapping> getAllPendingOperationMappingsOfMobileDevice(String mblDeviceId)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
} }

@ -29,73 +29,73 @@ import java.util.List;
public interface MobileFeatureDAO { 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. * @param mobileFeature MobileFeature object that holds data related to the feature to be inserted.
* @return The id of inserted feature. * @return The id of inserted MobileFeature.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
int addMobileFeature(MobileFeature 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. * @param mobileFeature MobileFeature object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateMobileFeature(MobileFeature mobileFeature) 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. * @param mblFeatureId MobileFeature id of the MobileFeature to be deleted.
* @return The status of the operation. If the operationId was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @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. * @param mblFeatureCode MobileFeature code of the feature to be deleted.
* @return The status of the operation. If the operationId was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @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. * @param mblFeatureId Feature id of the feature to be retrieved.
* @return Feature object that holds data of the feature represented by featureId. * @return MobileFeature object that holds data of the feature represented by featureId.
* @throws MobileDeviceManagementDAOException * @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. * @param mblFeatureCode Feature code of the feature to be retrieved.
* @return Feature object that holds data of the feature represented by featureCode. * @return MobileFeature object that holds data of the feature represented by featureCode.
* @throws MobileDeviceManagementDAOException * @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 * @throws MobileDeviceManagementDAOException
*/ */
List<MobileFeature> getMobileFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException;
/** /**
* Retrieve all the features from plugin specific database for a Device Type. * Retrieve all the MobileFeatures from Mobile-Feature table.
* @param deviceType - Device type. *
* @return Feature object list. * @return MobileFeature object list.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
List<MobileFeature> getMobileFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException;
List<MobileFeature> getAllMobileFeatures() throws MobileDeviceManagementDAOException; List<MobileFeature> getAllMobileFeatures() throws MobileDeviceManagementDAOException;
} }

@ -27,64 +27,68 @@ import java.util.List;
* related information. * related information.
*/ */
public interface MobileFeaturePropertyDAO { 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. * 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 * @throws MobileDeviceManagementDAOException
*/ */
boolean addMobileFeatureProperty(MobileFeatureProperty mobileFeatureProperty) boolean addMobileFeatureProperty(MobileFeatureProperty mblFeatureProperty)
throws MobileDeviceManagementDAOException; 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. * @param mblFeatureProperty MobileFeatureProperty object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateMobileFeatureProperty(MobileFeatureProperty mobileFeatureProperty) boolean updateMobileFeatureProperty(MobileFeatureProperty mblFeatureProperty)
throws MobileDeviceManagementDAOException; 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. * @param property Property of the MobileFeatureProperty to be deleted.
* @return The status of the operation. If the operationId was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteMobileFeatureProperty(String property) 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. * @param mblFeatureId Feature-id of the MobileFeature corresponding properties should be deleted.
* @return The status of the operation. If the operationId was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteMobileFeaturePropertiesOfFeature(Integer featureId) boolean deleteMobileFeaturePropertiesOfFeature(Integer mblFeatureId)
throws MobileDeviceManagementDAOException; 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. * @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 * @throws MobileDeviceManagementDAOException
*/ */
MobileFeatureProperty getMobileFeatureProperty(String property) MobileFeatureProperty getMobileFeatureProperty(String property)
throws MobileDeviceManagementDAOException; 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. * @param mblFeatureId feature id of the MobileFeatureProperties to be retrieved.
* @return Feature property object that holds data of the feature property represented by propertyId. * @return List of MobileFeatureProperty objects that holds data of the MobileFeatureProperties
* represented by featureId.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
List<MobileFeatureProperty> getFeaturePropertiesOfFeature(Integer featureId) List<MobileFeatureProperty> getFeaturePropertiesOfFeature(Integer mblFeatureId)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
} }

@ -27,35 +27,36 @@ import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
public interface MobileOperationDAO { public interface MobileOperationDAO {
/** /**
* Add a new Mobile operation to plugin operation table. * Adds a new Mobile operation to the MobileOperation table.
* @param operation Operation object that holds data related to the operation to be inserted. * @param mblOperation MobileOperation object that holds data related to the operation to be
* @return The last inserted Id is returned, if the insertion was unsuccessful -1 is returned. * inserted.
* @return The id of the inserted record, if the insertion was unsuccessful -1 is returned.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
int addMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException; int addMobileOperation(MobileOperation mblOperation) throws MobileDeviceManagementDAOException;
/** /**
* Update a Mobile operation in the operation table. * Updates a Mobile operation in the MobileOperation table.
* @param operation Operation object that holds data has to be updated. * @param mblOperation MobileOperation object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException; boolean updateMobileOperation(MobileOperation mblOperation) throws MobileDeviceManagementDAOException;
/** /**
* Delete a given Mobile operation from plugin database. * Deletes a given MobileOperation from MobileOperation table.
* @param operationId Operation code of the operation to be deleted. * @param mblOperationId Operation code of the MobileOperation to be deleted.
* @return The status of the operation. If the operationId was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteMobileOperation(int operationId) throws MobileDeviceManagementDAOException; boolean deleteMobileOperation(int mblOperationId) throws MobileDeviceManagementDAOException;
/** /**
* Retrieve a given Mobile operation from plugin database. * Retrieve a MobileOperation from MobileOperation table.
* @param operationId Operation id of the operation to be retrieved. * @param mblOperationId Operation id of the MobileOperation to be retrieved.
* @return Operation object that holds data of the feature represented by operationId. * @return MobileOperation object that holds data of MobileOperation represented by operationId.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
MobileOperation getMobileOperation(int operationId) throws MobileDeviceManagementDAOException; MobileOperation getMobileOperation(int mblOperationId) throws MobileDeviceManagementDAOException;
} }

@ -23,60 +23,65 @@ import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
import java.util.List; 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 { 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 * @param mblOperationProperty MobileOperationProperty object that holds data related to the
* property to be inserted. * operation 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 * @throws MobileDeviceManagementDAOException
*/ */
boolean addMobileOperationProperty(MobileOperationProperty operationProperty) boolean addMobileOperationProperty(MobileOperationProperty mblOperationProperty)
throws MobileDeviceManagementDAOException; 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. * @param mblOperationProperty MobileOperationProperty object that holds data has to be updated.
* @return The status of the operation. If the update was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean updateMobileOperationProperty(MobileOperationProperty operationProperty) boolean updateMobileOperationProperty(MobileOperationProperty mblOperationProperty)
throws MobileDeviceManagementDAOException; 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. * @param mblOperationId Operation id of the MobileOperationProperty to be deleted.
* @return The status of the operation. If the deletion was successful or not. * @return The status of the operation.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
boolean deleteMobileOperationProperties(int operationId) boolean deleteMobileOperationProperties(int mblOperationId)
throws MobileDeviceManagementDAOException; 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. * @param property Property of the mapping to be retrieved.
* @return DeviceOperation object that holds data of the device operation mapping represented by * @return MobileOperationProperty object that holds data of the MobileOperationProperty
* deviceId and operationId. * represented by mblOperationId and property.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
MobileOperationProperty getMobileOperationProperty(int operationId, String property) MobileOperationProperty getMobileOperationProperty(int mblOperationId, String property)
throws MobileDeviceManagementDAOException; 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. * @param mblOperationId Operation id of the MobileOperationProperty to be retrieved.
* @return Device operation mapping object list. * @return List of MobileOperationProperty objects.
* @throws MobileDeviceManagementDAOException * @throws MobileDeviceManagementDAOException
*/ */
List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation(int operationId) List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation(int mblOperationId)
throws MobileDeviceManagementDAOException; throws MobileDeviceManagementDAOException;
} }

@ -46,7 +46,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
} }
@Override @Override
public MobileDevice getMobileDevice(String deviceId) throws MobileDeviceManagementDAOException { public MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
MobileDevice mobileDevice = 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, " + "SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId); stmt.setString(1, mblDeviceId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
mobileDevice = new MobileDevice(); mobileDevice = new MobileDevice();
@ -69,10 +69,13 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
mobileDevice.setVendor(resultSet.getString(7)); mobileDevice.setVendor(resultSet.getString(7));
mobileDevice.setLatitude(resultSet.getString(8)); mobileDevice.setLatitude(resultSet.getString(8));
mobileDevice.setLongitude(resultSet.getString(9)); mobileDevice.setLongitude(resultSet.getString(9));
if (log.isDebugEnabled()) {
log.debug("Mobile device " + mblDeviceId + " data has fetched from MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching mobile device '" + String msg = "Error occurred while fetching mobile device '" +
deviceId + "'"; mblDeviceId + "'";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -106,6 +109,10 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Mobile device " + mobileDevice.getMobileDeviceId() + " data has added" +
" to the MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while adding the mobile device '" + String msg = "Error occurred while adding the mobile device '" +
@ -143,6 +150,10 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Mobile device " + mobileDevice.getMobileDeviceId() + " data has" +
" updated");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while updating the mobile device '" + String msg = "Error occurred while updating the mobile device '" +
@ -156,7 +167,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
} }
@Override @Override
public boolean deleteMobileDevice(String deviceId) throws MobileDeviceManagementDAOException { public boolean deleteMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -165,13 +176,17 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
String deleteDBQuery = String deleteDBQuery =
"DELETE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "DELETE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery); stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, deviceId); stmt.setString(1, mblDeviceId);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Mobile device " + mblDeviceId + " data has deleted" +
" from the MDM database.");
}
} }
} catch (SQLException e) { } 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); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -206,6 +221,9 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
mobileDevice.setLongitude(resultSet.getString(9)); mobileDevice.setLongitude(resultSet.getString(9));
mobileDevices.add(mobileDevice); mobileDevices.add(mobileDevice);
} }
if (log.isDebugEnabled()) {
log.debug("All Mobile device details have fetched from MDM database.");
}
return mobileDevices; return mobileDevices;
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching all mobile device data'"; String msg = "Error occurred while fetching all mobile device data'";

@ -47,7 +47,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
} }
@Override @Override
public boolean addMobileDeviceOperationMapping(MobileDeviceOperationMapping deviceOperation) public boolean addMobileDeviceOperationMapping(MobileDeviceOperationMapping mblDeviceOperationMapping)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -59,19 +59,24 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
"RECEIVED_DATE, STATUS) VALUES (?, ?, ?, ?, ?)"; "RECEIVED_DATE, STATUS) VALUES (?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery); stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, deviceOperation.getDeviceId()); stmt.setString(1, mblDeviceOperationMapping.getDeviceId());
stmt.setLong(2, deviceOperation.getOperationId()); stmt.setLong(2, mblDeviceOperationMapping.getOperationId());
stmt.setLong(3, deviceOperation.getSentDate()); stmt.setLong(3, mblDeviceOperationMapping.getSentDate());
stmt.setLong(4, deviceOperation.getReceivedDate()); stmt.setLong(4, mblDeviceOperationMapping.getReceivedDate());
stmt.setString(5, deviceOperation.getStatus().name()); stmt.setString(5, mblDeviceOperationMapping.getStatus().name());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Added a MobileDevice-Mapping DeviceId : " + mblDeviceOperationMapping
.getDeviceId() + ", " +
"OperationId : " + mblDeviceOperationMapping.getOperationId() + " to the MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while adding device id - '" + String msg = "Error occurred while adding device id - '" +
deviceOperation.getDeviceId() + " and operation id - " + mblDeviceOperationMapping.getDeviceId() + " and operation id - " +
deviceOperation.getOperationId() + mblDeviceOperationMapping.getOperationId() +
" to mapping table MBL_DEVICE_OPERATION"; " to mapping table MBL_DEVICE_OPERATION";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
@ -82,7 +87,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
} }
@Override @Override
public boolean updateMobileDeviceOperationMapping(MobileDeviceOperationMapping deviceOperation) public boolean updateMobileDeviceOperationMapping(MobileDeviceOperationMapping mblDeviceOperation)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -93,19 +98,23 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
"UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, " + "UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, " +
"STATUS = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?"; "STATUS = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?";
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
stmt.setLong(1, deviceOperation.getSentDate()); stmt.setLong(1, mblDeviceOperation.getSentDate());
stmt.setLong(2, deviceOperation.getReceivedDate()); stmt.setLong(2, mblDeviceOperation.getReceivedDate());
stmt.setString(3, deviceOperation.getStatus().name()); stmt.setString(3, mblDeviceOperation.getStatus().name());
stmt.setString(4, deviceOperation.getDeviceId()); stmt.setString(4, mblDeviceOperation.getDeviceId());
stmt.setInt(5, deviceOperation.getOperationId()); stmt.setInt(5, mblDeviceOperation.getOperationId());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Updated MobileDevice-Mapping DeviceId : " + mblDeviceOperation.getDeviceId() + " , " +
"OperationId : " + mblDeviceOperation.getOperationId());
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while updating device id - '" + String msg = "Error occurred while updating device id - '" +
deviceOperation.getDeviceId() + " and operation id - " + mblDeviceOperation.getDeviceId() + " and operation id - " +
deviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION"; mblDeviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -115,7 +124,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
} }
@Override @Override
public boolean updateMobileDeviceOperationMappingToInProgress(String deviceId, int operationId) public boolean updateMobileDeviceOperationMappingToInProgress(String mblDeviceId, int operationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -128,16 +137,20 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
stmt.setLong(1, new Date().getTime()); stmt.setLong(1, new Date().getTime());
stmt.setString(2, MobileDeviceOperationMapping.Status.INPROGRESS.name()); stmt.setString(2, MobileDeviceOperationMapping.Status.INPROGRESS.name());
stmt.setString(3, deviceId); stmt.setString(3, mblDeviceId);
stmt.setInt(4, operationId); stmt.setInt(4, operationId);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Updated status of MobileDevice-Mapping DeviceId : " + mblDeviceId + " , " +
"OperationId : " + operationId + " to In-Progress state");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while updating the Status of operation to in-progress of device id - '" + "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"; operationId + " in table MBL_DEVICE_OPERATION";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
@ -148,7 +161,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
} }
@Override @Override
public boolean updateMobileDeviceOperationMappingToCompleted(String deviceId, public boolean updateMobileDeviceOperationMappingToCompleted(String mblDeviceId,
int operationId) int operationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
@ -162,16 +175,20 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
stmt.setLong(1, new Date().getTime()); stmt.setLong(1, new Date().getTime());
stmt.setString(2, MobileDeviceOperationMapping.Status.COMPLETED.name()); stmt.setString(2, MobileDeviceOperationMapping.Status.COMPLETED.name());
stmt.setString(3, deviceId); stmt.setString(3, mblDeviceId);
stmt.setInt(4, operationId); stmt.setInt(4, operationId);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Updated status of MobileDevice-Mapping DeviceId : " + mblDeviceId + " , " +
"OperationId : " + operationId + " to Completed state");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while updating the Status of operation to completed of device id - '" + "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"; operationId + " in table MBL_DEVICE_OPERATION";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
@ -182,7 +199,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
} }
@Override @Override
public boolean deleteMobileDeviceOperationMapping(String deviceId, int operationId) public boolean deleteMobileDeviceOperationMapping(String mblDeviceId, int operationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -193,16 +210,20 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
"DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND " + "DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND " +
"OPERATION_ID = ?"; "OPERATION_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery); stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, deviceId); stmt.setString(1, mblDeviceId);
stmt.setInt(2, operationId); stmt.setInt(2, operationId);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Deleted MobileDevice-Mapping DeviceId : " + mblDeviceId + " , " +
"OperationId : " + operationId + "from MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while deleting the table entry MBL_DEVICE_OPERATION with " + "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); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -212,7 +233,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
} }
@Override @Override
public MobileDeviceOperationMapping getMobileDeviceOperationMapping(String deviceId, public MobileDeviceOperationMapping getMobileDeviceOperationMapping(String mblDeviceId,
int operationId) int operationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
@ -224,7 +245,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " + "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " +
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?"; "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId); stmt.setString(1, mblDeviceId);
stmt.setInt(2, operationId); stmt.setInt(2, operationId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
@ -234,11 +255,15 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
mblDeviceOperation.setSentDate(resultSet.getInt(3)); mblDeviceOperation.setSentDate(resultSet.getInt(3));
mblDeviceOperation.setReceivedDate(resultSet.getInt(4)); mblDeviceOperation.setReceivedDate(resultSet.getInt(4));
mblDeviceOperation.setStatus(resultSet.getString(5)); mblDeviceOperation.setStatus(resultSet.getString(5));
if (log.isDebugEnabled()) {
log.debug("Fetched MobileDevice-Mapping of DeviceId : " + mblDeviceId + " , " +
"OperationId : " + operationId );
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while fetching table MBL_DEVICE_OPERATION entry with device id - '" + "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); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -249,7 +274,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
@Override @Override
public List<MobileDeviceOperationMapping> getAllMobileDeviceOperationMappingsOfDevice( public List<MobileDeviceOperationMapping> getAllMobileDeviceOperationMappingsOfDevice(
String deviceId) String mblDeviceId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -262,7 +287,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " + "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM " +
"MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?"; "MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId); stmt.setString(1, mblDeviceId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
mblDeviceOperation = new MobileDeviceOperationMapping(); mblDeviceOperation = new MobileDeviceOperationMapping();
@ -273,10 +298,13 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
mblDeviceOperation.setStatus(resultSet.getString(5)); mblDeviceOperation.setStatus(resultSet.getString(5));
mblDeviceOperations.add(mblDeviceOperation); mblDeviceOperations.add(mblDeviceOperation);
} }
if (log.isDebugEnabled()) {
log.debug("Fetched all MobileDevice-Mappings of DeviceId : " + mblDeviceId);
}
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of " + "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of " +
"device id - '" + deviceId; "device id - '" + mblDeviceId;
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -287,7 +315,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
@Override @Override
public List<MobileDeviceOperationMapping> getAllPendingOperationMappingsOfMobileDevice( public List<MobileDeviceOperationMapping> getAllPendingOperationMappingsOfMobileDevice(
String deviceId) String mblDeviceId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -301,7 +329,7 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM" + "SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE, STATUS FROM" +
" MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND STATUS = ?"; " MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND STATUS = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId); stmt.setString(1, mblDeviceId);
stmt.setString(2, MobileDeviceOperationMapping.Status.NEW.name()); stmt.setString(2, MobileDeviceOperationMapping.Status.NEW.name());
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -313,10 +341,13 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
mblDeviceOperation.setStatus(resultSet.getString(5)); mblDeviceOperation.setStatus(resultSet.getString(5));
mblDeviceOperations.add(mblDeviceOperation); mblDeviceOperations.add(mblDeviceOperation);
} }
if (log.isDebugEnabled()) {
log.debug("Fetched all pending MobileDevice-Mappings of DeviceId : " + mblDeviceId);
}
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of" + "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of" +
" device id - '" + deviceId; " device id - '" + mblDeviceId;
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {

@ -67,6 +67,10 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
if (rs != null && rs.next()) { if (rs != null && rs.next()) {
status = rs.getInt(1); status = rs.getInt(1);
} }
if (log.isDebugEnabled()) {
log.debug("Added a new MobileFeature " + mobileFeature.getCode() + " to the" +
" MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while adding feature code - '" + String msg = "Error occurred while adding feature code - '" +
@ -99,6 +103,9 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Updated MobileFeature " + mobileFeature.getCode());
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while updating the feature with feature code - '" + String msg = "Error occurred while updating the feature with feature code - '" +
@ -112,7 +119,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public boolean deleteMobileFeatureByCode(String featureCode) public boolean deleteMobileFeatureByCode(String mblFeatureCode)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -122,13 +129,17 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
String deleteDBQuery = String deleteDBQuery =
"DELETE FROM MBL_FEATURE WHERE CODE = ?"; "DELETE FROM MBL_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(deleteDBQuery); stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, featureCode); stmt.setString(1, mblFeatureCode);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Deleted MobileFeature code " + mblFeatureCode + " from the" +
" MDM database.");
}
} }
} catch (SQLException e) { } 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); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -138,7 +149,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public boolean deleteMobileFeatureById(int featureId) public boolean deleteMobileFeatureById(int mblFeatureId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -148,13 +159,17 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
String deleteDBQuery = String deleteDBQuery =
"DELETE FROM MBL_FEATURE WHERE FEATURE_ID = ?"; "DELETE FROM MBL_FEATURE WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery); stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, featureId); stmt.setInt(1, mblFeatureId);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Deleted MobileFeature id " + mblFeatureId + " from the" +
" MDM database.");
}
} }
} catch (SQLException e) { } 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); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -164,7 +179,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public MobileFeature getMobileFeatureByCode(String featureCode) public MobileFeature getMobileFeatureByCode(String mblFeatureCode)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -175,7 +190,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE " + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE " +
"WHERE CODE = ?"; "WHERE CODE = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, featureCode); stmt.setString(1, mblFeatureCode);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
mobileFeature = new MobileFeature(); mobileFeature = new MobileFeature();
@ -184,10 +199,14 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
mobileFeature.setName(resultSet.getString(3)); mobileFeature.setName(resultSet.getString(3));
mobileFeature.setDescription(resultSet.getString(4)); mobileFeature.setDescription(resultSet.getString(4));
mobileFeature.setDeviceType(resultSet.getString(5)); mobileFeature.setDeviceType(resultSet.getString(5));
if (log.isDebugEnabled()) {
log.debug("Fetched MobileFeature " + mblFeatureCode + " from the" +
" MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching feature code - '" + String msg = "Error occurred while fetching feature code - '" +
featureCode + "'"; mblFeatureCode + "'";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -197,7 +216,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public MobileFeature getMobileFeatureById(int featureID) public MobileFeature getMobileFeatureById(int mblFeatureId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -208,7 +227,7 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE" + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE" +
" WHERE FEATURE_ID = ?"; " WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, featureID); stmt.setInt(1, mblFeatureId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
mobileFeature = new MobileFeature(); mobileFeature = new MobileFeature();
@ -217,10 +236,14 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
mobileFeature.setName(resultSet.getString(3)); mobileFeature.setName(resultSet.getString(3));
mobileFeature.setDescription(resultSet.getString(4)); mobileFeature.setDescription(resultSet.getString(4));
mobileFeature.setDeviceType(resultSet.getString(5)); mobileFeature.setDeviceType(resultSet.getString(5));
if (log.isDebugEnabled()) {
log.debug("Fetched MobileFeatureId" + mblFeatureId + " from the" +
" MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching feature id - '" + String msg = "Error occurred while fetching feature id - '" +
featureID + "'"; mblFeatureId + "'";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -250,6 +273,9 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
mobileFeature.setDeviceType(resultSet.getString(5)); mobileFeature.setDeviceType(resultSet.getString(5));
mobileFeatures.add(mobileFeature); mobileFeatures.add(mobileFeature);
} }
if (log.isDebugEnabled()) {
log.debug("Fetched all MobileFeatures from the MDM database.");
}
return mobileFeatures; return mobileFeatures;
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching all features.'"; String msg = "Error occurred while fetching all features.'";
@ -284,6 +310,10 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
mobileFeature.setDeviceType(resultSet.getString(5)); mobileFeature.setDeviceType(resultSet.getString(5));
mobileFeatures.add(mobileFeature); mobileFeatures.add(mobileFeature);
} }
if (log.isDebugEnabled()) {
log.debug("Fetched all MobileFeatures of type " + deviceType + " from the MDM" +
" database.");
}
return mobileFeatures; return mobileFeatures;
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching all features.'"; String msg = "Error occurred while fetching all features.'";

@ -46,7 +46,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
} }
@Override @Override
public boolean addMobileFeatureProperty(MobileFeatureProperty mobileFeatureProperty) public boolean addMobileFeatureProperty(MobileFeatureProperty mblFeatureProperty)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -57,15 +57,19 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
"INSERT INTO MBL_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)"; "INSERT INTO MBL_FEATURE_PROPERTY(PROPERTY, FEATURE_ID) VALUES (?, ?)";
stmt = conn.prepareStatement(createDBQuery); stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, mobileFeatureProperty.getProperty()); stmt.setString(1, mblFeatureProperty.getProperty());
stmt.setInt(2, mobileFeatureProperty.getFeatureID()); stmt.setInt(2, mblFeatureProperty.getFeatureID());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Added MobileFeatureProperty " + mblFeatureProperty.getProperty() +
" to the MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while adding property id - '" + String msg = "Error occurred while adding property id - '" +
mobileFeatureProperty.getFeatureID() + "'"; mblFeatureProperty.getFeatureID() + "'";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -75,7 +79,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
} }
@Override @Override
public boolean updateMobileFeatureProperty(MobileFeatureProperty mobileFeatureProperty) public boolean updateMobileFeatureProperty(MobileFeatureProperty mblFeatureProperty)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -85,15 +89,18 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
String updateDBQuery = String updateDBQuery =
"UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?"; "UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?";
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
stmt.setInt(1, mobileFeatureProperty.getFeatureID()); stmt.setInt(1, mblFeatureProperty.getFeatureID());
stmt.setString(2, mobileFeatureProperty.getProperty()); stmt.setString(2, mblFeatureProperty.getProperty());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Updated MobileFeatureProperty " + mblFeatureProperty.getProperty());
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while updating the feature property with property - '" + String msg = "Error occurred while updating the feature property with property - '" +
mobileFeatureProperty.getProperty() + "'"; mblFeatureProperty.getProperty() + "'";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -117,6 +124,9 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Deleted MobileFeatureProperty " + property + " from MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while deleting feature property with property - " + String msg = "Error occurred while deleting feature property with property - " +
@ -130,7 +140,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
} }
@Override @Override
public boolean deleteMobileFeaturePropertiesOfFeature(Integer featureId) public boolean deleteMobileFeaturePropertiesOfFeature(Integer mblFeatureId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -140,14 +150,18 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
String deleteDBQuery = String deleteDBQuery =
"DELETE FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; "DELETE FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery); stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, featureId); stmt.setInt(1, mblFeatureId);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Deleted all MobileFeatureProperties of FeatureId " + mblFeatureId +
" from MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while deleting feature properties of feature - " + String msg = "Error occurred while deleting feature properties of feature - " +
featureId; mblFeatureId;
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -173,6 +187,10 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
mobileFeatureProperty = new MobileFeatureProperty(); mobileFeatureProperty = new MobileFeatureProperty();
mobileFeatureProperty.setProperty(resultSet.getString(1)); mobileFeatureProperty.setProperty(resultSet.getString(1));
mobileFeatureProperty.setFeatureID(resultSet.getInt(2)); mobileFeatureProperty.setFeatureID(resultSet.getInt(2));
if (log.isDebugEnabled()) {
log.debug("Fetched MobileFeatureProperty " + mobileFeatureProperty.getProperty() +
" from MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching property - '" + String msg = "Error occurred while fetching property - '" +
@ -186,7 +204,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
} }
@Override @Override
public List<MobileFeatureProperty> getFeaturePropertiesOfFeature(Integer featureId) public List<MobileFeatureProperty> getFeaturePropertiesOfFeature(Integer mblFeatureId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -197,7 +215,7 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
String selectDBQuery = String selectDBQuery =
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?"; "SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, featureId); stmt.setInt(1, mblFeatureId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
mobileFeatureProperty = new MobileFeatureProperty(); mobileFeatureProperty = new MobileFeatureProperty();
@ -205,6 +223,10 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
mobileFeatureProperty.setFeatureID(resultSet.getInt(2)); mobileFeatureProperty.setFeatureID(resultSet.getInt(2));
FeatureProperties.add(mobileFeatureProperty); FeatureProperties.add(mobileFeatureProperty);
} }
if (log.isDebugEnabled()) {
log.debug("Fetched all MobileFeatureProperties of featureId " + mblFeatureId +
" from MDM database.");
}
return FeatureProperties; return FeatureProperties;
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching all feature property.'"; String msg = "Error occurred while fetching all feature property.'";

@ -45,7 +45,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
} }
@Override @Override
public int addMobileOperation(MobileOperation operation) public int addMobileOperation(MobileOperation mblOperation)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
int status = -1; int status = -1;
Connection conn = null; Connection conn = null;
@ -55,18 +55,22 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
String createDBQuery = String createDBQuery =
"INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)"; "INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)";
stmt = conn.prepareStatement(createDBQuery, new String[] { COLUMN_OPERATION_ID }); stmt = conn.prepareStatement(createDBQuery, new String[] { COLUMN_OPERATION_ID });
stmt.setString(1, operation.getFeatureCode()); stmt.setString(1, mblOperation.getFeatureCode());
stmt.setLong(2, operation.getCreatedDate()); stmt.setLong(2, mblOperation.getCreatedDate());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
ResultSet rs = stmt.getGeneratedKeys(); ResultSet rs = stmt.getGeneratedKeys();
if (rs != null && rs.next()) { if (rs != null && rs.next()) {
status = rs.getInt(1); status = rs.getInt(1);
} }
if (log.isDebugEnabled()) {
log.debug("Added a new MobileOperation " + mblOperation.getFeatureCode() +
" to MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while adding the operation - '" + String msg = "Error occurred while adding the operation - '" +
operation.getFeatureCode() + "' to MBL_OPERATION table"; mblOperation.getFeatureCode() + "' to MBL_OPERATION table";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -76,7 +80,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
} }
@Override @Override
public boolean updateMobileOperation(MobileOperation operation) public boolean updateMobileOperation(MobileOperation mblOperation)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -87,17 +91,21 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
"UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE " + "UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE " +
"OPERATION_ID = ?"; "OPERATION_ID = ?";
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, operation.getFeatureCode()); stmt.setString(1, mblOperation.getFeatureCode());
stmt.setLong(2, operation.getCreatedDate()); stmt.setLong(2, mblOperation.getCreatedDate());
stmt.setInt(3, operation.getOperationId()); stmt.setInt(3, mblOperation.getOperationId());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Updated MobileOperation " + mblOperation.getFeatureCode() +
" to MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while updating the MBL_OPERATION table entry with operation id - '" + "Error occurred while updating the MBL_OPERATION table entry with operation id - '" +
operation.getOperationId() + "'"; mblOperation.getOperationId() + "'";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -107,7 +115,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
} }
@Override @Override
public boolean deleteMobileOperation(int operationId) public boolean deleteMobileOperation(int mblOperationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -117,10 +125,14 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
String deleteDBQuery = String deleteDBQuery =
"DELETE FROM MBL_OPERATION WHERE OPERATION_ID = ?"; "DELETE FROM MBL_OPERATION WHERE OPERATION_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery); stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, operationId); stmt.setInt(1, mblOperationId);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Deleted a new MobileOperation " + mblOperationId +
" from MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while deleting MBL_OPERATION entry with operation Id - "; String msg = "Error occurred while deleting MBL_OPERATION entry with operation Id - ";
@ -133,7 +145,7 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
} }
@Override @Override
public MobileOperation getMobileOperation(int operationId) public MobileOperation getMobileOperation(int mblOperationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -144,17 +156,21 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE " + "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE " +
"OPERATION_ID = ?"; "OPERATION_ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, operationId); stmt.setInt(1, mblOperationId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
operation = new MobileOperation(); operation = new MobileOperation();
operation.setOperationId(resultSet.getInt(1)); operation.setOperationId(resultSet.getInt(1));
operation.setFeatureCode(resultSet.getString(2)); operation.setFeatureCode(resultSet.getString(2));
operation.setCreatedDate(resultSet.getLong(3)); operation.setCreatedDate(resultSet.getLong(3));
if (log.isDebugEnabled()) {
log.debug("Fetched MobileOperation " + operation.getFeatureCode() +
" from MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while fetching operationId - '" + String msg = "Error occurred while fetching operationId - '" +
operationId + "' from MBL_OPERATION"; mblOperationId + "' from MBL_OPERATION";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {

@ -46,7 +46,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
} }
@Override @Override
public boolean addMobileOperationProperty(MobileOperationProperty operationProperty) public boolean addMobileOperationProperty(MobileOperationProperty mblOperationProperty)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -57,12 +57,16 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
"INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) " + "INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) " +
"VALUES ( ?, ?, ?)"; "VALUES ( ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery); stmt = conn.prepareStatement(createDBQuery);
stmt.setInt(1, operationProperty.getOperationId()); stmt.setInt(1, mblOperationProperty.getOperationId());
stmt.setString(2, operationProperty.getProperty()); stmt.setString(2, mblOperationProperty.getProperty());
stmt.setString(3, operationProperty.getValue()); stmt.setString(3, mblOperationProperty.getValue());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Added a new MobileOperationProperty " + mblOperationProperty.getProperty() +
" to MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
@ -78,7 +82,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
@Override @Override
public boolean updateMobileOperationProperty( public boolean updateMobileOperationProperty(
MobileOperationProperty operationProperty) MobileOperationProperty mblOperationProperty)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -89,12 +93,16 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
"UPDATE MBL_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND " + "UPDATE MBL_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND " +
"PROPERTY = ?"; "PROPERTY = ?";
stmt = conn.prepareStatement(createDBQuery); stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, operationProperty.getValue()); stmt.setString(1, mblOperationProperty.getValue());
stmt.setInt(2, operationProperty.getOperationId()); stmt.setInt(2, mblOperationProperty.getOperationId());
stmt.setString(3, operationProperty.getProperty()); stmt.setString(3, mblOperationProperty.getProperty());
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Updated MobileOperationProperty " + mblOperationProperty.getProperty() +
" to MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
@ -109,7 +117,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
} }
@Override @Override
public boolean deleteMobileOperationProperties(int operationId) public boolean deleteMobileOperationProperties(int mblOperationId)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
boolean status = false; boolean status = false;
Connection conn = null; Connection conn = null;
@ -119,10 +127,15 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
String deleteDBQuery = String deleteDBQuery =
"DELETE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?"; "DELETE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery); stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, operationId); stmt.setInt(1, mblOperationId);
int rows = stmt.executeUpdate(); int rows = stmt.executeUpdate();
if (rows > 0) { if (rows > 0) {
status = true; status = true;
if (log.isDebugEnabled()) {
log.debug("Deleted MobileOperationProperties of operation-id " +
mblOperationId +
" from MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
@ -136,7 +149,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
} }
@Override @Override
public MobileOperationProperty getMobileOperationProperty(int operationId, public MobileOperationProperty getMobileOperationProperty(int mblOperationId,
String property) String property)
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
@ -148,7 +161,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " + "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " +
"OPERATION_ID = ? AND PROPERTY = ?"; "OPERATION_ID = ? AND PROPERTY = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, operationId); stmt.setInt(1, mblOperationId);
stmt.setString(2, property); stmt.setString(2, property);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
@ -156,11 +169,16 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
mobileOperationProperty.setOperationId(resultSet.getInt(1)); mobileOperationProperty.setOperationId(resultSet.getInt(1));
mobileOperationProperty.setProperty(resultSet.getString(2)); mobileOperationProperty.setProperty(resultSet.getString(2));
mobileOperationProperty.setValue(resultSet.getString(3)); mobileOperationProperty.setValue(resultSet.getString(3));
if (log.isDebugEnabled()) {
log.debug("Fetched MobileOperationProperty of Operation-id : " +
mblOperationId +
" Property : " + property + " from MDM database.");
}
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while fetching the mobile operation property of Operation_id : " + "Error occurred while fetching the mobile operation property of Operation_id : " +
operationId + " and Property : " + property; mblOperationId + " and Property : " + property;
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -171,7 +189,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
@Override @Override
public List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation( public List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation(
int operationId) throws MobileDeviceManagementDAOException { int mblOperationId) throws MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
MobileOperationProperty mobileOperationProperty; MobileOperationProperty mobileOperationProperty;
@ -182,7 +200,7 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " + "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " +
"OPERATION_ID = ?"; "OPERATION_ID = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, operationId); stmt.setInt(1, mblOperationId);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
mobileOperationProperty = new MobileOperationProperty(); mobileOperationProperty = new MobileOperationProperty();
@ -191,10 +209,15 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
mobileOperationProperty.setValue(resultSet.getString(3)); mobileOperationProperty.setValue(resultSet.getString(3));
properties.add(mobileOperationProperty); properties.add(mobileOperationProperty);
} }
if (log.isDebugEnabled()) {
log.debug("Fetched all MobileOperationProperties of Operation-id : " +
mblOperationId +
" from MDM database.");
}
} catch (SQLException e) { } catch (SQLException e) {
String msg = String msg =
"Error occurred while fetching the mobile operation properties of Operation_id " + "Error occurred while fetching the mobile operation properties of Operation_id " +
operationId; mblOperationId;
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {

@ -66,8 +66,8 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
/* Initialize the datasource configuration */ /* Initialize the datasource configuration */
MobileDeviceConfigurationManager.getInstance().initConfig(); MobileDeviceConfigurationManager.getInstance().initConfig();
MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance().
.getMobileDeviceManagementConfig(); getMobileDeviceManagementConfig();
MobileDataSourceConfig dsConfig = MobileDataSourceConfig dsConfig =
config.getMobileDeviceMgtRepository().getMobileDataSourceConfig(); config.getMobileDeviceMgtRepository().getMobileDataSourceConfig();

@ -91,7 +91,9 @@ public class MobileDeviceManagementServiceComponent {
MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema( MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema(
MobileDeviceManagementDAOFactory.getDataSource()); MobileDeviceManagementDAOFactory.getDataSource());
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
log.error("Exception occurred while initializing mobile device management database schema", e); log.error(
"Exception occurred while initializing mobile device management database schema",
e);
} }
} }
@ -106,12 +108,15 @@ public class MobileDeviceManagementServiceComponent {
new WindowsDeviceManagerService(), null); new WindowsDeviceManagerService(), null);
serverStartupObserverRef = bundleContext.registerService(ServerStartupObserver.class, serverStartupObserverRef = bundleContext.registerService(ServerStartupObserver.class,
new MobileDeviceManagementStartupObserver(), null); new MobileDeviceManagementStartupObserver(),
null);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Mobile Device Management Service Component has been successfully activated"); log.debug(
"Mobile Device Management Service Component has been successfully activated");
} }
} catch (Throwable e) { } catch (Throwable e) {
log.error("Error occurred while activating Mobile Device Management Service Component", e); log.error("Error occurred while activating Mobile Device Management Service Component",
e);
} }
} }

@ -17,7 +17,9 @@
~ under the License. ~ under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>

@ -17,7 +17,9 @@
~ under the License. ~ under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
@ -275,7 +277,7 @@
</dependency> </dependency>
<!--APIM dependencies--> <!--APIM dependencies-->
<!-- <dependency> <!-- <dependency>
<groupId>org.wso2.carbon.apimgt</groupId> <groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.core</artifactId> <artifactId>org.wso2.carbon.apimgt.core</artifactId>
<version>${carbon.api.mgt.version}</version> <version>${carbon.api.mgt.version}</version>
@ -488,7 +490,8 @@
<scm> <scm>
<url>https://github.com/wso2/carbon-device-mgt-plugins.git</url> <url>https://github.com/wso2/carbon-device-mgt-plugins.git</url>
<developerConnection>scm:git:https://github.com/wso2/carbon-device-mgt-plugins.git</developerConnection> <developerConnection>scm:git:https://github.com/wso2/carbon-device-mgt-plugins.git
</developerConnection>
<connection>scm:git:https://github.com/wso2/carbon-device-mgt-plugins.git</connection> <connection>scm:git:https://github.com/wso2/carbon-device-mgt-plugins.git</connection>
<tag>HEAD</tag> <tag>HEAD</tag>
</scm> </scm>

Loading…
Cancel
Save