Fixing merge conflicts

revert-dabc3590
prabathabey 10 years ago
commit cb05d53510

@ -22,14 +22,14 @@
<parent> <parent>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>1.9.1-SNAPSHOT</version> <version>1.9.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.mobile.impl</artifactId> <artifactId>org.wso2.carbon.device.mgt.mobile.impl</artifactId>
<version>1.9.1-SNAPSHOT</version> <version>1.9.2-SNAPSHOT</version>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WSO2 Carbon - Mobile Device Management Impl</name> <name>WSO2 Carbon - Mobile Device Management Impl</name>
<description>WSO2 Carbon - Mobile Device Management Impl</description> <description>WSO2 Carbon - Mobile Device Management Impl</description>
@ -52,18 +52,26 @@
<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>-->
<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,
org.apache.commons.logging, org.apache.commons.logging,
javax.xml.bind.*,
javax.naming,
javax.sql,
javax.xml.bind.annotation,
javax.xml.parsers,
org.w3c.dom,
org.wso2.carbon.core,
org.wso2.carbon.utils.*,
org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.apimgt.*;
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
!org.wso2.carbon.device.mgt.mobile.internal, !org.wso2.carbon.device.mgt.mobile.internal,
org.wso2.carbon.device.mgt.mobile.* org.wso2.carbon.device.mgt.mobile.*,
</Export-Package> </Export-Package>
<DynamicImport-Package>*</DynamicImport-Package>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>
@ -73,7 +81,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>

@ -27,15 +27,17 @@ import java.util.List;
public abstract class AbstractMobileOperationManager implements OperationManager { public abstract class AbstractMobileOperationManager implements OperationManager {
@Override @Override
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException { public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
return null; throws OperationManagementException {
} return null;
}
@Override @Override
public boolean addOperation(Operation operation, public boolean addOperation(Operation operation,
List<DeviceIdentifier> devices) throws OperationManagementException { List<DeviceIdentifier> devices)
return true; throws OperationManagementException {
} return true;
}
} }

@ -34,13 +34,16 @@ import java.io.File;
public class MobileDeviceConfigurationManager { 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" + File.separator + CarbonUtils.getEtcCarbonConfigDirPath() + File.separator +
MOBILE_DEVICE_PLUGIN_DIRECTORY + File.separator + MOBILE_DEVICE_CONFIG_XML_NAME; DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY +
File.separator +
MOBILE_DEVICE_PLUGIN_DIRECTORY + File.separator + MOBILE_DEVICE_CONFIG_XML_NAME;
public static MobileDeviceConfigurationManager getInstance() { public static MobileDeviceConfigurationManager getInstance() {
if (mobileDeviceConfigManager == null) { if (mobileDeviceConfigManager == null) {

@ -27,14 +27,48 @@ 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 MobileDeviceOperation * @param mblDeviceOperationMapping MobileDeviceOperationMapping object that holds data related
* 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 represented by * @return MobileDeviceOperation object that holds data of the device operation mapping
* 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;
} }

@ -23,67 +23,72 @@ import org.wso2.carbon.device.mgt.mobile.dto.MobileFeatureProperty;
import java.util.List; import java.util.List;
/** /**
* This class represents the key operations associated with persisting mobile feature property related * This class represents the key operations associated with persisting mobile feature property
* 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 property to be inserted. * @param mblFeatureProperty MobileFeatureProperty object that holds data related to the feature
* @return The status of the operation. If the insert was successful or not. * property to be inserted.
* @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,22 +46,23 @@ 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;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN 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();
mobileDevice.setMobileDeviceId(resultSet.getString(1)); mobileDevice.setMobileDeviceId(resultSet.getString(1));
mobileDevice.setRegId(resultSet.getString(2)); mobileDevice.setPushToken(resultSet.getString(2));
mobileDevice.setImei(resultSet.getString(3)); mobileDevice.setImei(resultSet.getString(3));
mobileDevice.setImsi(resultSet.getString(4)); mobileDevice.setImsi(resultSet.getString(4));
mobileDevice.setOsVersion(resultSet.getString(5)); mobileDevice.setOsVersion(resultSet.getString(5));
@ -69,10 +70,17 @@ 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));
mobileDevice.setChallenge(resultSet.getString(10));
mobileDevice.setSerial(resultSet.getString(11));
mobileDevice.setToken(resultSet.getString(12));
mobileDevice.setUnlockToken(resultSet.getString(13));
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 {
@ -90,12 +98,13 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String createDBQuery = String createDBQuery =
"INSERT INTO MBL_DEVICE(MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION," + "INSERT INTO MBL_DEVICE(MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION," +
"DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; "DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, " +
"UNLOCK_TOKEN) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery); stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, mobileDevice.getMobileDeviceId()); stmt.setString(1, mobileDevice.getMobileDeviceId());
stmt.setString(2, mobileDevice.getRegId()); stmt.setString(2, mobileDevice.getPushToken());
stmt.setString(3, mobileDevice.getImei()); stmt.setString(3, mobileDevice.getImei());
stmt.setString(4, mobileDevice.getImsi()); stmt.setString(4, mobileDevice.getImsi());
stmt.setString(5, mobileDevice.getOsVersion()); stmt.setString(5, mobileDevice.getOsVersion());
@ -103,9 +112,17 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
stmt.setString(7, mobileDevice.getVendor()); stmt.setString(7, mobileDevice.getVendor());
stmt.setString(8, mobileDevice.getLatitude()); stmt.setString(8, mobileDevice.getLatitude());
stmt.setString(9, mobileDevice.getLongitude()); stmt.setString(9, mobileDevice.getLongitude());
stmt.setString(10, mobileDevice.getChallenge());
stmt.setString(11, mobileDevice.getSerial());
stmt.setString(12, mobileDevice.getToken());
stmt.setString(13, mobileDevice.getUnlockToken());
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 '" +
@ -127,10 +144,11 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String updateDBQuery = String updateDBQuery =
"UPDATE MBL_DEVICE SET REG_ID = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," + "UPDATE MBL_DEVICE SET PUSH_TOKEN = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," +
"DEVICE_MODEL = ?, VENDOR = ? , LATITUDE = ?, LONGITUDE = ? WHERE MOBILE_DEVICE_ID = ?"; "DEVICE_MODEL = ?, VENDOR = ? , LATITUDE = ?, LONGITUDE = ?, CHALLENGE = ?," +
"SERIAL = ?, TOKEN = ?, UNLOCK_TOKEN = ? WHERE MOBILE_DEVICE_ID = ?";
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, mobileDevice.getRegId()); stmt.setString(1, mobileDevice.getPushToken());
stmt.setString(2, mobileDevice.getImei()); stmt.setString(2, mobileDevice.getImei());
stmt.setString(3, mobileDevice.getImsi()); stmt.setString(3, mobileDevice.getImsi());
stmt.setString(4, mobileDevice.getOsVersion()); stmt.setString(4, mobileDevice.getOsVersion());
@ -138,10 +156,18 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
stmt.setString(6, mobileDevice.getVendor()); stmt.setString(6, mobileDevice.getVendor());
stmt.setString(7, mobileDevice.getLatitude()); stmt.setString(7, mobileDevice.getLatitude());
stmt.setString(8, mobileDevice.getLongitude()); stmt.setString(8, mobileDevice.getLongitude());
stmt.setString(9, mobileDevice.getMobileDeviceId()); stmt.setString(9, mobileDevice.getChallenge());
stmt.setString(10, mobileDevice.getSerial());
stmt.setString(11, mobileDevice.getToken());
stmt.setString(12, mobileDevice.getUnlockToken());
stmt.setString(13, mobileDevice.getMobileDeviceId());
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 '" +
@ -155,7 +181,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;
@ -164,13 +190,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 {
@ -188,14 +218,14 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR," + "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR," +
"LATITUDE, LONGITUDE FROM MBL_DEVICE"; "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
mobileDevice = new MobileDevice(); mobileDevice = new MobileDevice();
mobileDevice.setMobileDeviceId(resultSet.getString(1)); mobileDevice.setMobileDeviceId(resultSet.getString(1));
mobileDevice.setRegId(resultSet.getString(2)); mobileDevice.setPushToken(resultSet.getString(2));
mobileDevice.setImei(resultSet.getString(3)); mobileDevice.setImei(resultSet.getString(3));
mobileDevice.setImsi(resultSet.getString(4)); mobileDevice.setImsi(resultSet.getString(4));
mobileDevice.setOsVersion(resultSet.getString(5)); mobileDevice.setOsVersion(resultSet.getString(5));
@ -203,8 +233,15 @@ 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));
mobileDevice.setChallenge(resultSet.getString(10));
mobileDevice.setSerial(resultSet.getString(11));
mobileDevice.setToken(resultSet.getString(12));
mobileDevice.setUnlockToken(resultSet.getString(13));
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'";

@ -20,8 +20,8 @@ package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceOperationMappingDAO;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceOperationMappingDAO;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping; import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping;
@ -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,21 +59,25 @@ 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);
} finally { } finally {
@ -83,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;
@ -91,22 +95,26 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
try { try {
conn = this.getConnection(); conn = this.getConnection();
String updateDBQuery = String updateDBQuery =
"UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, STATUS = ? " + "UPDATE MBL_DEVICE_OPERATION_MAPPING SET SENT_DATE = ?, RECEIVED_DATE = ?, " +
"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 {
@ -116,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;
@ -129,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);
@ -149,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;
@ -159,20 +171,24 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
conn = this.getConnection(); conn = this.getConnection();
String updateDBQuery = String updateDBQuery =
"UPDATE MBL_DEVICE_OPERATION_MAPPING SET RECEIVED_DATE = ?, STATUS = ? " + "UPDATE MBL_DEVICE_OPERATION_MAPPING SET RECEIVED_DATE = ?, STATUS = ? " +
"WHERE DEVICE_ID = ? AND OPERATION_ID=?"; "WHERE DEVICE_ID = ? AND OPERATION_ID = ?";
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);
@ -183,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;
@ -191,18 +207,23 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
try { try {
conn = this.getConnection(); conn = this.getConnection();
String deleteDBQuery = String deleteDBQuery =
"DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND OPERATION_ID=?"; "DELETE FROM MBL_DEVICE_OPERATION_MAPPING WHERE DEVICE_ID = ? AND " +
"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;
@ -222,24 +243,27 @@ public class MobileDeviceOperationMappingDAOImpl implements MobileDeviceOperatio
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"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();
while (resultSet.next()) { if (resultSet.next()) {
mblDeviceOperation = new MobileDeviceOperationMapping(); mblDeviceOperation = new MobileDeviceOperationMapping();
mblDeviceOperation.setDeviceId(resultSet.getString(1)); mblDeviceOperation.setDeviceId(resultSet.getString(1));
mblDeviceOperation.setOperationId(resultSet.getInt(2)); mblDeviceOperation.setOperationId(resultSet.getInt(2));
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));
break; 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 {
@ -250,19 +274,20 @@ 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;
MobileDeviceOperationMapping mblDeviceOperation = null; MobileDeviceOperationMapping mblDeviceOperation;
List<MobileDeviceOperationMapping> mblDeviceOperations = new ArrayList<MobileDeviceOperationMapping>(); List<MobileDeviceOperationMapping> mblDeviceOperations =
new ArrayList<MobileDeviceOperationMapping>();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"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,20 +315,22 @@ 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;
MobileDeviceOperationMapping mblDeviceOperation = null; MobileDeviceOperationMapping mblDeviceOperation = null;
List<MobileDeviceOperationMapping> mblDeviceOperations = new ArrayList<MobileDeviceOperationMapping>(); List<MobileDeviceOperationMapping> mblDeviceOperations =
new ArrayList<MobileDeviceOperationMapping>();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"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 = 'NEW'"; " 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());
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
mblDeviceOperation = new MobileDeviceOperationMapping(); mblDeviceOperation = new MobileDeviceOperationMapping();
@ -311,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 {

@ -46,7 +46,8 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public int addMobileFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException { public int addMobileFeature(MobileFeature mobileFeature)
throws MobileDeviceManagementDAOException {
int status = 0; int status = 0;
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -66,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 - '" +
@ -87,7 +92,8 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String updateDBQuery = String updateDBQuery =
"UPDATE MBL_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ?, DEVICE_TYPE = ? WHERE FEATURE_ID = ?"; "UPDATE MBL_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ?, DEVICE_TYPE = ?" +
" WHERE FEATURE_ID = ?";
stmt = conn.prepareStatement(updateDBQuery); stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, mobileFeature.getCode()); stmt.setString(1, mobileFeature.getCode());
stmt.setString(2, mobileFeature.getName()); stmt.setString(2, mobileFeature.getName());
@ -97,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 - '" +
@ -110,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;
@ -120,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 {
@ -136,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;
@ -146,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 {
@ -162,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;
@ -170,22 +187,26 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE WHERE CODE = ?"; "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE " +
"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();
while (resultSet.next()) { if (resultSet.next()) {
mobileFeature = new MobileFeature(); mobileFeature = new MobileFeature();
mobileFeature.setId(resultSet.getInt(1)); mobileFeature.setId(resultSet.getInt(1));
mobileFeature.setCode(resultSet.getString(2)); mobileFeature.setCode(resultSet.getString(2));
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));
break; 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 {
@ -195,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;
@ -203,22 +224,26 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE WHERE FEATURE_ID = ?"; "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE" +
" 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()) { if (resultSet.next()) {
mobileFeature = new MobileFeature(); mobileFeature = new MobileFeature();
mobileFeature.setId(resultSet.getInt(1)); mobileFeature.setId(resultSet.getInt(1));
mobileFeature.setCode(resultSet.getString(2)); mobileFeature.setCode(resultSet.getString(2));
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));
break; 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 {
@ -248,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.'";
@ -259,7 +287,8 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
} }
@Override @Override
public List<MobileFeature> getMobileFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException { public List<MobileFeature> getMobileFeatureByDeviceType(String deviceType) throws
MobileDeviceManagementDAOException {
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
MobileFeature mobileFeature; MobileFeature mobileFeature;
@ -267,7 +296,8 @@ public class MobileFeatureDAOImpl implements MobileFeatureDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE WHERE DEVICE_TYPE = ?"; "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM MBL_FEATURE" +
" WHERE DEVICE_TYPE = ?";
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceType); stmt.setString(1, deviceType);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
@ -280,12 +310,16 @@ 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.'";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
}finally { } finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null); MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
} }
} }

@ -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 {
@ -169,11 +183,14 @@ public class MobileFeaturePropertyDAOImpl implements MobileFeaturePropertyDAO {
stmt = conn.prepareStatement(selectDBQuery); stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, property); stmt.setString(1, property);
ResultSet resultSet = stmt.executeQuery(); ResultSet resultSet = stmt.executeQuery();
while (resultSet.next()) { if (resultSet.next()) {
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));
break; 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 - '" +
@ -187,18 +204,18 @@ 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;
MobileFeatureProperty mobileFeatureProperty = null; MobileFeatureProperty mobileFeatureProperty;
List<MobileFeatureProperty> FeatureProperties = new ArrayList<MobileFeatureProperty>(); List<MobileFeatureProperty> FeatureProperties = new ArrayList<MobileFeatureProperty>();
try { try {
conn = this.getConnection(); conn = this.getConnection();
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();
@ -206,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;
@ -84,19 +88,24 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String updateDBQuery = String updateDBQuery =
"UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE OPERATION_ID = ?"; "UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE " +
"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 {
@ -106,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;
@ -116,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 - ";
@ -132,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;
@ -140,20 +153,24 @@ public class MobileOperationDAOImpl implements MobileOperationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE OPERATION_ID = ?"; "SELECT OPERATION_ID, FEATURE_CODE, CREATED_DATE FROM MBL_OPERATION WHERE " +
"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()) { 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));
break; 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 {

@ -23,7 +23,6 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileOperationPropertyDAO; import org.wso2.carbon.device.mgt.mobile.dao.MobileOperationPropertyDAO;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty; import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
import javax.sql.DataSource; import javax.sql.DataSource;
@ -47,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;
@ -55,19 +54,24 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
try { try {
conn = this.getConnection(); conn = this.getConnection();
String createDBQuery = String createDBQuery =
"INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) VALUES ( ?, ?, ?)"; "INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) " +
"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 =
"Error occurred while adding mobile operation property to MBL_OPERATION_PROPERTY table"; "Error occurred while adding mobile operation property to MBL_OPERATION_PROPERTY " +
"table";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -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;
@ -86,19 +90,24 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
try { try {
conn = this.getConnection(); conn = this.getConnection();
String createDBQuery = String createDBQuery =
"UPDATE MBL_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND PROPERTY = ?"; "UPDATE MBL_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND " +
"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 =
"Error occurred while updating the mobile operation property in MBL_OPERATION_PROPERTY table."; "Error occurred while updating the mobile operation property in" +
" MBL_OPERATION_PROPERTY table.";
log.error(msg, e); log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e); throw new MobileDeviceManagementDAOException(msg, e);
} finally { } finally {
@ -108,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;
@ -118,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 =
@ -135,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;
@ -144,22 +158,27 @@ public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDA
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ? AND PROPERTY = ?"; "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " +
"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();
while (resultSet.next()) { if (resultSet.next()) {
mobileOperationProperty = new MobileOperationProperty(); mobileOperationProperty = new MobileOperationProperty();
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));
break; 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 {
@ -170,17 +189,18 @@ 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 = null; MobileOperationProperty mobileOperationProperty;
List<MobileOperationProperty> properties = new ArrayList<MobileOperationProperty>(); List<MobileOperationProperty> properties = new ArrayList<MobileOperationProperty>();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String selectDBQuery = String selectDBQuery =
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?"; "SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE " +
"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();
@ -189,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 {

@ -21,8 +21,6 @@ package org.wso2.carbon.device.mgt.mobile.dao.util;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition;
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementSchemaInitializer; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementSchemaInitializer;
import javax.naming.InitialContext; import javax.naming.InitialContext;
@ -32,7 +30,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List;
/** /**
* Utility method required by MobileDeviceManagement DAO classes. * Utility method required by MobileDeviceManagement DAO classes.
@ -94,8 +91,8 @@ public class MobileDeviceManagementDAOUtil {
try { try {
initializer.createRegistryDatabase(); initializer.createRegistryDatabase();
} catch (Exception e) { } catch (Exception e) {
throw new DeviceManagementException("Error occurred while initializing Mobile Device Management " + throw new DeviceManagementException("Error occurred while initializing Mobile Device " +
"database schema", e); "Management database schema", e);
} }
} }

@ -26,7 +26,7 @@ import java.io.Serializable;
public class MobileDevice implements Serializable { public class MobileDevice implements Serializable {
private String mobileDeviceId; private String mobileDeviceId;
private String regId; private String pushToken;
private String imei; private String imei;
private String imsi; private String imsi;
private String osVersion; private String osVersion;
@ -34,6 +34,42 @@ public class MobileDevice implements Serializable {
private String vendor; private String vendor;
private String latitude; private String latitude;
private String longitude; private String longitude;
private String serial;
private String unlockToken;
private String token;
private String challenge;
public String getUnlockToken() {
return unlockToken;
}
public void setUnlockToken(String unlockToken) {
this.unlockToken = unlockToken;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getChallenge() {
return challenge;
}
public void setChallenge(String challenge) {
this.challenge = challenge;
}
public String getSerial() {
return serial;
}
public void setSerial(String serial) {
this.serial = serial;
}
public String getMobileDeviceId() { public String getMobileDeviceId() {
return mobileDeviceId; return mobileDeviceId;
@ -43,12 +79,12 @@ public class MobileDevice implements Serializable {
this.mobileDeviceId = mobileDeviceId; this.mobileDeviceId = mobileDeviceId;
} }
public String getRegId() { public String getPushToken() {
return regId; return pushToken;
} }
public void setRegId(String regId) { public void setPushToken(String pushToken) {
this.regId = regId; this.pushToken = pushToken;
} }
public String getImei() { public String getImei() {

@ -52,6 +52,9 @@ public class AndroidDeviceManagerService implements DeviceManager {
boolean status; boolean status;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try { try {
if (log.isDebugEnabled()) {
log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier());
}
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice( status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
mobileDevice); mobileDevice);
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
@ -68,6 +71,9 @@ public class AndroidDeviceManagerService implements DeviceManager {
boolean status; boolean status;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try { try {
if (log.isDebugEnabled()) {
log.debug("Modifying the Android device enrollment data");
}
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO() status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.updateMobileDevice(mobileDevice); .updateMobileDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
@ -83,6 +89,9 @@ public class AndroidDeviceManagerService implements DeviceManager {
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
boolean status; boolean status;
try { try {
if (log.isDebugEnabled()) {
log.debug("Dis-enrolling Android device : " + deviceId);
}
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO() status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.deleteMobileDevice(deviceId.getId()); .deleteMobileDevice(deviceId.getId());
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
@ -97,6 +106,9 @@ public class AndroidDeviceManagerService implements DeviceManager {
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
boolean isEnrolled = false; boolean isEnrolled = false;
try { try {
if (log.isDebugEnabled()) {
log.debug("Checking the enrollment of Android device : " + deviceId.getId());
}
MobileDevice mobileDevice = MobileDevice mobileDevice =
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice( MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
deviceId.getId()); deviceId.getId());
@ -127,6 +139,9 @@ public class AndroidDeviceManagerService implements DeviceManager {
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
Device device; Device device;
try { try {
if (log.isDebugEnabled()) {
log.debug("Getting the details of Android device : " + deviceId.getId());
}
MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO(). MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
getMobileDevice(deviceId.getId()); getMobileDevice(deviceId.getId());
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice); device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
@ -149,6 +164,9 @@ public class AndroidDeviceManagerService implements DeviceManager {
boolean status; boolean status;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device); MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try { try {
if (log.isDebugEnabled()) {
log.debug("updating the details of Android device : " + device.getDeviceIdentifier());
}
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO() status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.updateMobileDevice(mobileDevice); .updateMobileDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
@ -163,6 +181,9 @@ public class AndroidDeviceManagerService implements DeviceManager {
public List<Device> getAllDevices() throws DeviceManagementException { public List<Device> getAllDevices() throws DeviceManagementException {
List<Device> devices = null; List<Device> devices = null;
try { try {
if (log.isDebugEnabled()) {
log.debug("Fetching the details of all Android devices");
}
List<MobileDevice> mobileDevices = List<MobileDevice> mobileDevices =
MobileDeviceManagementDAOFactory.getMobileDeviceDAO(). MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
getAllMobileDevices(); getAllMobileDevices();

@ -20,7 +20,9 @@ package org.wso2.carbon.device.mgt.mobile.impl.android;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.FeatureManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager; import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager;
@ -44,16 +46,16 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
List<DeviceIdentifier> devices) throws OperationManagementException { List<DeviceIdentifier> devices) throws OperationManagementException {
boolean status = false; boolean status = false;
try { try {
MobileDeviceOperationMapping mobileDeviceOperationMapping = null; MobileDeviceOperationMapping mobileDeviceOperationMapping;
MobileOperation mobileOperation = MobileOperation mobileOperation =
MobileDeviceManagementUtil.convertToMobileOperation(operation); MobileDeviceManagementUtil.convertToMobileOperation(operation);
int operationId = MobileDeviceManagementDAOFactory.getMobileOperationDAO() int operationId =
.addMobileOperation(mobileOperation); MobileDeviceManagementDAOFactory.getMobileOperationDAO().addMobileOperation(mobileOperation);
if (operationId > 0) { if (operationId > 0) {
for (MobileOperationProperty operationProperty : mobileOperation.getProperties()) { for (MobileOperationProperty operationProperty : mobileOperation.getProperties()) {
operationProperty.setOperationId(operationId); operationProperty.setOperationId(operationId);
status = MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO() status =
.addMobileOperationProperty( MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO().addMobileOperationProperty(
operationProperty); operationProperty);
} }
for (DeviceIdentifier deviceIdentifier : devices) { for (DeviceIdentifier deviceIdentifier : devices) {
@ -62,14 +64,12 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
mobileDeviceOperationMapping.setDeviceId(deviceIdentifier.getId()); mobileDeviceOperationMapping.setDeviceId(deviceIdentifier.getId());
mobileDeviceOperationMapping.setStatus(MobileDeviceOperationMapping.Status.NEW); mobileDeviceOperationMapping.setStatus(MobileDeviceOperationMapping.Status.NEW);
status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
.addMobileDeviceOperationMapping( .addMobileDeviceOperationMapping(mobileDeviceOperationMapping);
mobileDeviceOperationMapping);
} }
} }
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while adding an operation " + operation.getCode() + "to Android devices"; throw new OperationManagementException("Error while adding an operation " + operation.getCode() +
log.error(msg, e); "to Android devices", e);
throw new OperationManagementException(msg, e);
} }
return status; return status;
} }
@ -78,35 +78,30 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier) public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
throws OperationManagementException { throws OperationManagementException {
List<Operation> operations = new ArrayList<Operation>(); List<Operation> operations = new ArrayList<Operation>();
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings = null; List<MobileDeviceOperationMapping> mobileDeviceOperationMappings;
List<MobileOperationProperty> operationProperties = null; List<MobileOperationProperty> operationProperties;
MobileOperation mobileOperation = null; MobileOperation mobileOperation;
try { try {
mobileDeviceOperationMappings = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() mobileDeviceOperationMappings =
.getAllMobileDeviceOperationMappingsOfDevice( MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
deviceIdentifier .getAllMobileDeviceOperationMappingsOfDevice(deviceIdentifier.getId());
.getId());
if (mobileDeviceOperationMappings.size() > 0) { if (mobileDeviceOperationMappings.size() > 0) {
List<Integer> operationIds = MobileDeviceManagementUtil List<Integer> operationIds =
.getMobileOperationIdsFromMobileDeviceOperations( MobileDeviceManagementUtil.getMobileOperationIdsFromMobileDeviceOperations(
mobileDeviceOperationMappings); mobileDeviceOperationMappings);
for (Integer operationId : operationIds) { for (Integer operationId : operationIds) {
mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO().getMobileOperation( mobileOperation =
operationId); MobileDeviceManagementDAOFactory.getMobileOperationDAO().getMobileOperation(operationId);
operationProperties = operationProperties =
MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO() MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO()
.getAllMobileOperationPropertiesOfOperation( .getAllMobileOperationPropertiesOfOperation(operationId);
operationId);
mobileOperation.setProperties(operationProperties); mobileOperation.setProperties(operationProperties);
operations.add(MobileDeviceManagementUtil.convertMobileOperationToOperation(mobileOperation)); operations.add(MobileDeviceManagementUtil.convertMobileOperationToOperation(mobileOperation));
} }
} }
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = throw new OperationManagementException("Error while fetching the operations for the android device '" +
"Error while fetching the operations for the android device " + deviceIdentifier.getId() + "'", e);
deviceIdentifier.getId();
log.error(msg, e);
throw new OperationManagementException(msg, e);
} }
return operations; return operations;
} }
@ -115,43 +110,36 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
public List<Operation> getPendingOperations(DeviceIdentifier deviceIdentifier) public List<Operation> getPendingOperations(DeviceIdentifier deviceIdentifier)
throws OperationManagementException { throws OperationManagementException {
List<Operation> operations = new ArrayList<Operation>(); List<Operation> operations = new ArrayList<Operation>();
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings = null; List<MobileDeviceOperationMapping> mobileDeviceOperationMappings;
List<MobileOperationProperty> operationProperties = null; List<MobileOperationProperty> operationProperties;
MobileOperation mobileOperation = null; MobileOperation mobileOperation;
try { try {
//Get the list of pending operations for the given device //Get the list of pending operations for the given device
mobileDeviceOperationMappings = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() mobileDeviceOperationMappings =
.getAllPendingOperationMappingsOfMobileDevice( MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
deviceIdentifier .getAllPendingOperationMappingsOfMobileDevice(deviceIdentifier.getId());
.getId());
//Go through each operation mapping for retrieving the data corresponding to each operation //Go through each operation mapping for retrieving the data corresponding to each operation
for (MobileDeviceOperationMapping operation : mobileDeviceOperationMappings) { for (MobileDeviceOperationMapping operation : mobileDeviceOperationMappings) {
//Get the MobileOperation data //Get the MobileOperation data
mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO() mobileOperation =
.getMobileOperation(operation MobileDeviceManagementDAOFactory.getMobileOperationDAO().getMobileOperation(
.getOperationId()); operation.getOperationId());
//Get properties of the operation //Get properties of the operation
operationProperties = operationProperties =
MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO() MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO().
.getAllMobileOperationPropertiesOfOperation( getAllMobileOperationPropertiesOfOperation(operation.getOperationId());
operation.getOperationId());
mobileOperation.setProperties(operationProperties); mobileOperation.setProperties(operationProperties);
operations.add(MobileDeviceManagementUtil operations.add(MobileDeviceManagementUtil.convertMobileOperationToOperation(mobileOperation));
.convertMobileOperationToOperation(mobileOperation));
//Update the MobileDeviceOperationMapping data to the In-Progress state //Update the MobileDeviceOperationMapping data to the In-Progress state
operation.setStatus(MobileDeviceOperationMapping.Status.INPROGRESS); operation.setStatus(MobileDeviceOperationMapping.Status.INPROGRESS);
operation.setSentDate(new Date().getTime()); operation.setSentDate(new Date().getTime());
MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO() MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
.updateMobileDeviceOperationMappingToInProgress( .updateMobileDeviceOperationMappingToInProgress(operation.getDeviceId(),
operation.getDeviceId(),
operation.getOperationId()); operation.getOperationId());
} }
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = throw new OperationManagementException("Error while fetching the operations for the android device '" +
"Error while fetching the operations for the android device " + deviceIdentifier.getId() + "'", e);
deviceIdentifier.getId();
log.error(msg, e);
throw new OperationManagementException(msg, e);
} }
return operations; return operations;
} }
@ -159,17 +147,20 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
@Override @Override
public List<Feature> getFeatures(String deviceType) throws FeatureManagementException { public List<Feature> getFeatures(String deviceType) throws FeatureManagementException {
MobileFeatureDAO featureDAO = MobileDeviceManagementDAOFactory.getFeatureDAO(); MobileFeatureDAO featureDAO = MobileDeviceManagementDAOFactory.getFeatureDAO();
MobileFeaturePropertyDAO featurePropertyDAO = MobileDeviceManagementDAOFactory.getFeaturePropertyDAO(); MobileFeaturePropertyDAO featurePropertyDAO =
MobileDeviceManagementDAOFactory.getFeaturePropertyDAO();
List<Feature> features = new ArrayList<Feature>(); List<Feature> features = new ArrayList<Feature>();
try { try {
List<MobileFeature> mobileFeatures = featureDAO.getMobileFeatureByDeviceType(deviceType); List<MobileFeature> mobileFeatures =
featureDAO.getMobileFeatureByDeviceType(deviceType);
for (MobileFeature mobileFeature : mobileFeatures) { for (MobileFeature mobileFeature : mobileFeatures) {
Feature feature = new Feature(); Feature feature = new Feature();
feature.setId(mobileFeature.getId()); feature.setId(mobileFeature.getId());
feature.setDeviceType(mobileFeature.getDeviceType()); feature.setDeviceType(mobileFeature.getDeviceType());
feature.setName(mobileFeature.getName()); feature.setName(mobileFeature.getName());
feature.setDescription(mobileFeature.getDescription()); feature.setDescription(mobileFeature.getDescription());
List<Feature.MetadataEntry> metadataEntries = new ArrayList<Feature.MetadataEntry>(); List<Feature.MetadataEntry> metadataEntries =
new ArrayList<Feature.MetadataEntry>();
List<MobileFeatureProperty> properties = List<MobileFeatureProperty> properties =
featurePropertyDAO.getFeaturePropertiesOfFeature(mobileFeature.getId()); featurePropertyDAO.getFeaturePropertiesOfFeature(mobileFeature.getId());
for (MobileFeatureProperty property : properties) { for (MobileFeatureProperty property : properties) {
@ -182,9 +173,8 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
features.add(feature); features.add(feature);
} }
} catch (MobileDeviceManagementDAOException e) { } catch (MobileDeviceManagementDAOException e) {
String msg = "Error while fetching the features for the device type " + deviceType; throw new FeatureManagementException("Error while fetching the features for the device type '" +
log.error(msg, e); deviceType + "'", e);
throw new FeatureManagementException(msg, e);
} }
return features; return features;
} }

@ -18,8 +18,14 @@
package org.wso2.carbon.device.mgt.mobile.impl.ios; package org.wso2.carbon.device.mgt.mobile.impl.ios;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager; import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.util.List; import java.util.List;
@ -28,6 +34,8 @@ import java.util.List;
*/ */
public class IOSDeviceManagerService implements DeviceManager { public class IOSDeviceManagerService implements DeviceManager {
private static final Log log = LogFactory.getLog(IOSDeviceManagerService.class);
@Override @Override
public String getProviderType() { public String getProviderType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS; return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS;
@ -40,12 +48,37 @@ public class IOSDeviceManagerService implements DeviceManager {
@Override @Override
public boolean enrollDevice(Device device) throws DeviceManagementException { public boolean enrollDevice(Device device) throws DeviceManagementException {
return true; boolean status;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
mobileDevice);
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while enrolling the iOS device : " +
device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
} }
@Override @Override
public boolean modifyEnrollment(Device device) throws DeviceManagementException { public boolean modifyEnrollment(Device device) throws DeviceManagementException {
return true; boolean status;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try {
if (log.isDebugEnabled()) {
log.debug("Modifying the iOS device enrollment data");
}
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
.updateMobileDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while updating the enrollment of the iOS device : " +
device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
} }
@Override @Override
@ -55,7 +88,24 @@ public class IOSDeviceManagerService implements DeviceManager {
@Override @Override
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
return true; boolean isEnrolled = false;
try {
if (log.isDebugEnabled()) {
log.debug("Checking the enrollment of iOS device : " + deviceId.getId());
}
MobileDevice mobileDevice =
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
deviceId.getId());
if (mobileDevice != null) {
isEnrolled = true;
}
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while checking the enrollment status of iOS device : " +
deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return isEnrolled;
} }
@Override @Override
@ -76,7 +126,20 @@ public class IOSDeviceManagerService implements DeviceManager {
@Override @Override
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return null; Device device;
try {
if (log.isDebugEnabled()) {
log.debug("Getting the details of iOS device : " + deviceId.getId());
}
MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
getMobileDevice(deviceId.getId());
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while fetching the iOS device : " + deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return device;
} }
@Override @Override

@ -0,0 +1,126 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* you may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.mobile.impl.ios;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.FeatureManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperationMapping;
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class IOSMobileOperationManager extends AbstractMobileOperationManager {
private static final Log log = LogFactory.getLog(IOSMobileOperationManager.class);
@Override
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
return null;
}
@Override
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices)
throws OperationManagementException {
boolean status = false;
try {
MobileDeviceOperationMapping mobileDeviceOperationMapping;
MobileOperation mobileOperation = MobileDeviceManagementUtil.convertToMobileOperation(operation);
int operationId = MobileDeviceManagementDAOFactory.getMobileOperationDAO().
addMobileOperation(mobileOperation);
if (operationId > 0) {
for (MobileOperationProperty operationProperty : mobileOperation.getProperties()) {
operationProperty.setOperationId(operationId);
status = MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO().
addMobileOperationProperty(operationProperty);
}
for (DeviceIdentifier deviceIdentifier : devices) {
mobileDeviceOperationMapping = new MobileDeviceOperationMapping();
mobileDeviceOperationMapping.setOperationId(operationId);
mobileDeviceOperationMapping.setDeviceId(deviceIdentifier.getId());
mobileDeviceOperationMapping.setStatus(MobileDeviceOperationMapping.Status.NEW);
status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO().
addMobileDeviceOperationMapping(mobileDeviceOperationMapping);
}
}
} catch (MobileDeviceManagementDAOException e) {
String msg = String.format("Error while adding operation %s to iOS device", operation.getCode());
log.error(msg, e);
throw new OperationManagementException(msg, e);
}
return status;
}
@Override
public List<Operation> getPendingOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
List<Operation> operations = new ArrayList<Operation>();
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings;
List<MobileOperationProperty> operationProperties ;
MobileOperation mobileOperation;
try {
mobileDeviceOperationMappings = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO().
getAllPendingOperationMappingsOfMobileDevice(deviceIdentifier.getId());
for (MobileDeviceOperationMapping operation : mobileDeviceOperationMappings) {
mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO().
getMobileOperation(operation.getOperationId());
operationProperties = MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO().
getAllMobileOperationPropertiesOfOperation(operation.getOperationId());
mobileOperation.setProperties(operationProperties);
operations.add(MobileDeviceManagementUtil.convertMobileOperationToOperation(mobileOperation));
operation.setStatus(MobileDeviceOperationMapping.Status.INPROGRESS);
operation.setSentDate(new Date().getTime());
MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO().
updateMobileDeviceOperationMappingToInProgress(operation.getDeviceId(),
operation.getOperationId());
}
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error occurred when retrieving pending operations in iOS device " + deviceIdentifier.getId();
log.error(msg, e);
throw new OperationManagementException(msg, e);
}
return operations;
}
@Override
public List<Feature> getFeatures(String type) throws FeatureManagementException {
return null;
}
}

@ -18,8 +18,14 @@
package org.wso2.carbon.device.mgt.mobile.impl.windows; package org.wso2.carbon.device.mgt.mobile.impl.windows;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager; import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import java.util.List; import java.util.List;
@ -28,6 +34,8 @@ import java.util.List;
*/ */
public class WindowsDeviceManagerService implements DeviceManager { public class WindowsDeviceManagerService implements DeviceManager {
private static final Log log = LogFactory.getLog(WindowsDeviceManagerService.class);
@Override @Override
public String getProviderType() { public String getProviderType() {
return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS; return DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS;
@ -38,11 +46,6 @@ public class WindowsDeviceManagerService implements DeviceManager {
return null; return null;
} }
@Override
public boolean enrollDevice(Device device) throws DeviceManagementException {
return true;
}
@Override @Override
public boolean modifyEnrollment(Device device) throws DeviceManagementException { public boolean modifyEnrollment(Device device) throws DeviceManagementException {
return true; return true;
@ -89,4 +92,20 @@ public class WindowsDeviceManagerService implements DeviceManager {
return true; return true;
} }
@Override
public boolean enrollDevice(Device device) throws DeviceManagementException {
boolean status;
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
try {
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
mobileDevice);
} catch (MobileDeviceManagementDAOException e) {
String msg = "Error while enrolling the Windows device : " +
device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
} }

@ -40,24 +40,29 @@ import org.wso2.carbon.device.mgt.mobile.util.DeviceManagementAPIPublisherUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* BundleActivator of MobileDeviceManagement component.
*/
public class MobileDeviceManagementBundleActivator implements BundleActivator, BundleListener { public class MobileDeviceManagementBundleActivator implements BundleActivator, BundleListener {
private ServiceRegistration androidServiceRegRef; private ServiceRegistration androidServiceRegRef;
private ServiceRegistration iOSServiceRegRef; private ServiceRegistration iOSServiceRegRef;
private ServiceRegistration windowsServiceRegRef; private ServiceRegistration windowsServiceRegRef;
private static List<DataSourceListener> dataSourceListeners = new ArrayList<DataSourceListener>(); private static List<DataSourceListener> dataSourceListeners =
new ArrayList<DataSourceListener>();
private static final String SYMBOLIC_NAME_DATA_SOURCE_COMPONENT = "org.wso2.carbon.ndatasource.core"; private static final String SYMBOLIC_NAME_DATA_SOURCE_COMPONENT =
private static final Log log = LogFactory.getLog(MobileDeviceManagementBundleActivator.class); "org.wso2.carbon.ndatasource.core";
private static final Log log = LogFactory.getLog(MobileDeviceManagementBundleActivator.class);
@Override @Override
public void start(BundleContext bundleContext) throws Exception { public void start(BundleContext bundleContext) throws Exception {
try { try {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Activating Mobile Device Management Service bundle"); log.debug("Activating Mobile Device Management Service bundle");
} }
bundleContext.addBundleListener(this); bundleContext.addBundleListener(this);
/* Initialize the datasource configuration */ /* Initialize the datasource configuration */
MobileDeviceConfigurationManager.getInstance().initConfig(); MobileDeviceConfigurationManager.getInstance().initConfig();
@ -79,90 +84,92 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
new WindowsDeviceManagerService(), null); new WindowsDeviceManagerService(), null);
/* Initialize all API configurations with corresponding API Providers */ /* Initialize all API configurations with corresponding API Providers */
this.initAPIConfigs(); this.initAPIConfigs();
/* Publish all mobile device management related JAX-RS services as APIs */ /* Publish all mobile device management related JAX-RS services as APIs */
this.publishAPIs(); this.publishAPIs();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Mobile Device Management Service bundle is activated"); log.debug("Mobile Device Management Service bundle is activated");
} }
} catch (Throwable e) { } catch (Throwable e) {
log.error("Error occurred while activating Mobile Device Management bundle", e); log.error("Error occurred while activating Mobile Device Management bundle", e);
} }
} }
@Override @Override
public void stop(BundleContext bundleContext) throws Exception { public void stop(BundleContext bundleContext) throws Exception {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Deactivating Mobile Device Management Service"); log.debug("Deactivating Mobile Device Management Service");
} }
try { try {
androidServiceRegRef.unregister(); androidServiceRegRef.unregister();
iOSServiceRegRef.unregister(); iOSServiceRegRef.unregister();
windowsServiceRegRef.unregister(); windowsServiceRegRef.unregister();
bundleContext.removeBundleListener(this); bundleContext.removeBundleListener(this);
/* Removing all APIs published upon start-up for mobile device management related JAX-RS /* Removing all APIs published upon start-up for mobile device management related JAX-RS
services */ services */
this.removeAPIs(); this.removeAPIs();
} catch (Throwable e) { } catch (Throwable e) {
log.error("Error occurred while de-activating Mobile Device Management bundle", e); log.error("Error occurred while de-activating Mobile Device Management bundle", e);
} }
} }
@Override @Override
public void bundleChanged(BundleEvent bundleEvent) { public void bundleChanged(BundleEvent bundleEvent) {
int eventType = bundleEvent.getType(); int eventType = bundleEvent.getType();
String bundleSymbolicName = bundleEvent.getBundle().getSymbolicName(); String bundleSymbolicName = bundleEvent.getBundle().getSymbolicName();
if (SYMBOLIC_NAME_DATA_SOURCE_COMPONENT.equals(bundleSymbolicName) && if (SYMBOLIC_NAME_DATA_SOURCE_COMPONENT.equals(bundleSymbolicName) &&
eventType == BundleEvent.STARTED) { eventType == BundleEvent.STARTED) {
for (DataSourceListener listener : this.getDataSourceListeners()) { for (DataSourceListener listener : this.getDataSourceListeners()) {
listener.notifyObserver(); listener.notifyObserver();
} }
} }
} }
public static void registerDataSourceListener(DataSourceListener listener) { public static void registerDataSourceListener(DataSourceListener listener) {
dataSourceListeners.add(listener); dataSourceListeners.add(listener);
} }
private List<DataSourceListener> getDataSourceListeners() { private List<DataSourceListener> getDataSourceListeners() {
return dataSourceListeners; return dataSourceListeners;
} }
private void initAPIConfigs() throws DeviceManagementException { private void initAPIConfigs() throws DeviceManagementException {
List<APIConfig> apiConfigs = List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getAPIs(); getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) { for (APIConfig apiConfig : apiConfigs) {
try { try {
APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner()); APIProvider provider =
apiConfig.init(provider); APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner());
} catch (APIManagementException e) { apiConfig.init(provider);
throw new DeviceManagementException("Error occurred while initializing API Config '" + } catch (APIManagementException e) {
apiConfig.getName() + "'", e); throw new DeviceManagementException(
} "Error occurred while initializing API Config '" +
} apiConfig.getName() + "'", e);
} }
}
private void publishAPIs() throws DeviceManagementException { }
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). private void publishAPIs() throws DeviceManagementException {
getApiPublisherConfig().getAPIs(); List<APIConfig> apiConfigs =
for (APIConfig apiConfig : apiConfigs) { MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
DeviceManagementAPIPublisherUtil.publishAPI(apiConfig); getApiPublisherConfig().getAPIs();
} for (APIConfig apiConfig : apiConfigs) {
} DeviceManagementAPIPublisherUtil.publishAPI(apiConfig);
}
private void removeAPIs() throws DeviceManagementException { }
List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). private void removeAPIs() throws DeviceManagementException {
getApiPublisherConfig().getAPIs(); List<APIConfig> apiConfigs =
for (APIConfig apiConfig : apiConfigs) { MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); getApiPublisherConfig().getAPIs();
} for (APIConfig apiConfig : apiConfigs) {
} DeviceManagementAPIPublisherUtil.removeAPI(apiConfig);
}
}
} }

@ -57,19 +57,19 @@ import java.util.List;
*/ */
public class MobileDeviceManagementServiceComponent { public class MobileDeviceManagementServiceComponent {
private ServiceRegistration androidServiceRegRef; private ServiceRegistration androidServiceRegRef;
private ServiceRegistration iOSServiceRegRef; private ServiceRegistration iOSServiceRegRef;
private ServiceRegistration windowsServiceRegRef; private ServiceRegistration windowsServiceRegRef;
private ServiceRegistration serverStartupObserverRef; 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) { protected void activate(ComponentContext ctx) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Activating Mobile Device Management Service Component"); log.debug("Activating Mobile Device Management Service Component");
} }
try { try {
BundleContext bundleContext = ctx.getBundleContext(); BundleContext bundleContext = ctx.getBundleContext();
/* Initialize the datasource configuration */ /* Initialize the datasource configuration */
MobileDeviceConfigurationManager.getInstance().initConfig(); MobileDeviceConfigurationManager.getInstance().initConfig();
@ -127,31 +127,31 @@ public class MobileDeviceManagementServiceComponent {
/* Removing all APIs published upon start-up for mobile device management related JAX-RS /* Removing all APIs published upon start-up for mobile device management related JAX-RS
services */ services */
this.removeAPIs(); this.removeAPIs();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug( log.debug(
"Mobile Device Management Service Component has been successfully de-activated"); "Mobile Device Management Service Component has been successfully de-activated");
} }
} catch (Throwable e) { } catch (Throwable e) {
log.error("Error occurred while de-activating Mobile Device Management bundle", e); log.error("Error occurred while de-activating Mobile Device Management bundle", e);
} }
} }
private void removeAPIs() throws DeviceManagementException { private void removeAPIs() throws DeviceManagementException {
List<APIConfig> apiConfigs = List<APIConfig> apiConfigs =
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig(). MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
getApiPublisherConfig().getAPIs(); getApiPublisherConfig().getAPIs();
for (APIConfig apiConfig : apiConfigs) { for (APIConfig apiConfig : apiConfigs) {
DeviceManagementAPIPublisherUtil.removeAPI(apiConfig); DeviceManagementAPIPublisherUtil.removeAPI(apiConfig);
} }
} }
protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) { protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) {
//do nothing //do nothing
} }
protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) { protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) {
//do nothing //do nothing
} }
} }

@ -26,6 +26,11 @@ import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.io.File; import java.io.File;
/**
*
* Provides methods for initializing the database script.
*
*/
public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreator { public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreator {
private static final Log log = LogFactory.getLog(MobileDeviceManagementSchemaInitializer.class); private static final Log log = LogFactory.getLog(MobileDeviceManagementSchemaInitializer.class);

@ -42,12 +42,16 @@ public class MobileDeviceManagementUtil {
private static final Log log = LogFactory.getLog(MobileDeviceManagementUtil.class); private static final Log log = LogFactory.getLog(MobileDeviceManagementUtil.class);
private static final String MOBILE_DEVICE_IMEI = "imei"; private static final String MOBILE_DEVICE_IMEI = "imei";
private static final String MOBILE_DEVICE_IMSI = "imsi"; private static final String MOBILE_DEVICE_IMSI = "imsi";
private static final String MOBILE_DEVICE_REG_ID = "regId"; private static final String MOBILE_DEVICE_PUSH_TOKEN = "pushToken";
private static final String MOBILE_DEVICE_VENDOR = "vendor"; private static final String MOBILE_DEVICE_VENDOR = "vendor";
private static final String MOBILE_DEVICE_OS_VERSION = "osVersion"; private static final String MOBILE_DEVICE_OS_VERSION = "osVersion";
private static final String MOBILE_DEVICE_MODEL = "model"; private static final String MOBILE_DEVICE_MODEL = "model";
private static final String MOBILE_DEVICE_LATITUDE = "latitude"; private static final String MOBILE_DEVICE_LATITUDE = "latitude";
private static final String MOBILE_DEVICE_LONGITUDE = "longitude"; private static final String MOBILE_DEVICE_LONGITUDE = "longitude";
private static final String MOBILE_DEVICE_TOKEN = "token";
private static final String MOBILE_DEVICE_SERIAL = "serial";
private static final String MOBILE_DEVICE_UNLOCK_TOKEN = "unlockToken";
private static final String MOBILE_DEVICE_CHALLENGE = "challenge";
public static Document convertToDocument(File file) throws DeviceManagementException { public static Document convertToDocument(File file) throws DeviceManagementException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@ -71,14 +75,13 @@ public class MobileDeviceManagementUtil {
} }
private static Device.Property getProperty(String property, String value) { private static Device.Property getProperty(String property, String value) {
Device.Property prop = null;
if (property != null) { if (property != null) {
prop = new Device.Property(); Device.Property prop = new Device.Property();
prop.setName(property); prop.setName(property);
prop.setValue(value); prop.setValue(value);
return prop; return prop;
} }
return prop; return null;
} }
public static MobileDevice convertToMobileDevice(Device device) { public static MobileDevice convertToMobileDevice(Device device) {
@ -88,12 +91,16 @@ public class MobileDeviceManagementUtil {
mobileDevice.setMobileDeviceId(device.getDeviceIdentifier()); mobileDevice.setMobileDeviceId(device.getDeviceIdentifier());
mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI)); mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI));
mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI)); mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI));
mobileDevice.setRegId(getPropertyValue(device, MOBILE_DEVICE_REG_ID)); mobileDevice.setPushToken(getPropertyValue(device, MOBILE_DEVICE_PUSH_TOKEN));
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL)); mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION)); mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR)); mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE)); mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE));
mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE)); mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE));
mobileDevice.setChallenge(getPropertyValue(device, MOBILE_DEVICE_CHALLENGE));
mobileDevice.setToken(getPropertyValue(device, MOBILE_DEVICE_TOKEN));
mobileDevice.setSerial(getPropertyValue(device, MOBILE_DEVICE_SERIAL));
mobileDevice.setUnlockToken(getPropertyValue(device, MOBILE_DEVICE_UNLOCK_TOKEN));
} }
return mobileDevice; return mobileDevice;
} }
@ -105,12 +112,16 @@ public class MobileDeviceManagementUtil {
List<Device.Property> propertyList = new ArrayList<Device.Property>(); List<Device.Property> propertyList = new ArrayList<Device.Property>();
propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei())); propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei()));
propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi())); propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi()));
propertyList.add(getProperty(MOBILE_DEVICE_REG_ID, mobileDevice.getRegId())); propertyList.add(getProperty(MOBILE_DEVICE_PUSH_TOKEN, mobileDevice.getPushToken()));
propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel())); propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel()));
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion())); propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion()));
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor())); propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor()));
propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude())); propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude()));
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude())); propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()));
propertyList.add(getProperty(MOBILE_DEVICE_CHALLENGE, mobileDevice.getChallenge()));
propertyList.add(getProperty(MOBILE_DEVICE_TOKEN, mobileDevice.getToken()));
propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial()));
propertyList.add(getProperty(MOBILE_DEVICE_UNLOCK_TOKEN, mobileDevice.getUnlockToken()));
device.setProperties(propertyList); device.setProperties(propertyList);
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId()); device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
} }
@ -119,7 +130,7 @@ public class MobileDeviceManagementUtil {
public static MobileOperation convertToMobileOperation(Operation operation) { public static MobileOperation convertToMobileOperation(Operation operation) {
MobileOperation mobileOperation = new MobileOperation(); MobileOperation mobileOperation = new MobileOperation();
MobileOperationProperty operationProperty = null; MobileOperationProperty operationProperty;
List<MobileOperationProperty> properties = new LinkedList<MobileOperationProperty>(); List<MobileOperationProperty> properties = new LinkedList<MobileOperationProperty>();
mobileOperation.setFeatureCode(operation.getCode()); mobileOperation.setFeatureCode(operation.getCode());
mobileOperation.setCreatedDate(new Date().getTime()); mobileOperation.setCreatedDate(new Date().getTime());

@ -25,6 +25,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
@ -70,7 +71,7 @@ public class MobileDeviceManagementConfigTests {
} }
} }
@Test() @Test
public void testMandateManagementRepositoryElement() { public void testMandateManagementRepositoryElement() {
File malformedConfig = File malformedConfig =
new File( new File(
@ -114,9 +115,7 @@ public class MobileDeviceManagementConfigTests {
} }
/** /**
*
* Validates a given malformed-configuration file. * Validates a given malformed-configuration file.
*
*/ */
private void validateMalformedConfig(File malformedConfig) { private void validateMalformedConfig(File malformedConfig) {
try { try {
@ -126,7 +125,11 @@ public class MobileDeviceManagementConfigTests {
um.unmarshal(malformedConfig); um.unmarshal(malformedConfig);
Assert.assertTrue(false); Assert.assertTrue(false);
} catch (JAXBException e) { } catch (JAXBException e) {
log.error("Error occurred while unmarsharlling mobile device management config", e); Throwable linkedException = e.getLinkedException();
if (!(linkedException instanceof SAXParseException)) {
log.error("Unexpected error occurred while unmarshalling mobile device management config", e);
Assert.assertTrue(false);
}
Assert.assertTrue(true); Assert.assertTrue(true);
} }
} }

@ -51,10 +51,14 @@ public class MobileDeviceDAOTestSuite {
public static final String TEST_MOBILE_MODEL = "S5"; public static final String TEST_MOBILE_MODEL = "S5";
public static final String TEST_MOBILE_VENDOR = "samsung"; public static final String TEST_MOBILE_VENDOR = "samsung";
public static final String TEST_MOBILE_UPDATED_VENDOR = "sony"; public static final String TEST_MOBILE_UPDATED_VENDOR = "sony";
public static final String TEST_MOBILE_REG_ID = "2414"; public static final String TEST_MOBILE_PUSH_TOKEN = "2414";
public static final String TEST_MOBILE_OS_VERSION = "5.0.0"; public static final String TEST_MOBILE_OS_VERSION = "5.0.0";
public static final String TEST_MOBILE_LATITUDE = "6.93N"; public static final String TEST_MOBILE_LATITUDE = "6.93N";
public static final String TEST_MOBILE_LONGITUDE = "80.60E"; public static final String TEST_MOBILE_LONGITUDE = "80.60E";
public static final String TEST_MOBILE_TOKEN = "2412K2HKHK24K12H4";
public static final String TEST_MOBILE_SERIAL = "24124IIH4I2K4";
public static final String TEST_MOBILE_CHALLENGE = "ASFASFSAFASFATWTWQTTQWTWQTQWTQWTWQT";
public static final String TEST_MOBILE_UNLOCK_TOKEN = "FAFWQUWFUQWYWQYRWQURYUURUWQUWRUWRUWE";
private TestDBConfiguration testDBConfiguration; private TestDBConfiguration testDBConfiguration;
private MobileDeviceDAOImpl mblDeviceDAO; private MobileDeviceDAOImpl mblDeviceDAO;
@ -93,23 +97,28 @@ public class MobileDeviceDAOTestSuite {
mobileDevice.setImsi(TEST_MOBILE_IMSI); mobileDevice.setImsi(TEST_MOBILE_IMSI);
mobileDevice.setModel(TEST_MOBILE_MODEL); mobileDevice.setModel(TEST_MOBILE_MODEL);
mobileDevice.setVendor(TEST_MOBILE_VENDOR); mobileDevice.setVendor(TEST_MOBILE_VENDOR);
mobileDevice.setRegId(TEST_MOBILE_REG_ID); mobileDevice.setPushToken(TEST_MOBILE_PUSH_TOKEN);
mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION); mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION);
mobileDevice.setLatitude(TEST_MOBILE_LATITUDE); mobileDevice.setLatitude(TEST_MOBILE_LATITUDE);
mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE); mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE);
mobileDevice.setToken(TEST_MOBILE_TOKEN);
mobileDevice.setSerial(TEST_MOBILE_SERIAL);
mobileDevice.setChallenge(TEST_MOBILE_CHALLENGE);
mobileDevice.setUnlockToken(TEST_MOBILE_UNLOCK_TOKEN);
boolean added = mblDeviceDAO.addMobileDevice(mobileDevice); boolean added = mblDeviceDAO.addMobileDevice(mobileDevice);
try { try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " +
"WHERE MOBILE_DEVICE_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
ResultSet resultSet = preparedStatement.executeQuery(); ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
testMblDevice.setMobileDeviceId(resultSet.getString(1)); testMblDevice.setMobileDeviceId(resultSet.getString(1));
testMblDevice.setRegId(resultSet.getString(2)); testMblDevice.setPushToken(resultSet.getString(2));
testMblDevice.setImei(resultSet.getString(3)); testMblDevice.setImei(resultSet.getString(3));
testMblDevice.setImsi(resultSet.getString(4)); testMblDevice.setImsi(resultSet.getString(4));
testMblDevice.setOsVersion(resultSet.getString(5)); testMblDevice.setOsVersion(resultSet.getString(5));
@ -117,6 +126,10 @@ public class MobileDeviceDAOTestSuite {
testMblDevice.setVendor(resultSet.getString(7)); testMblDevice.setVendor(resultSet.getString(7));
testMblDevice.setLatitude(resultSet.getString(8)); testMblDevice.setLatitude(resultSet.getString(8));
testMblDevice.setLongitude(resultSet.getString(9)); testMblDevice.setLongitude(resultSet.getString(9));
testMblDevice.setChallenge(resultSet.getString(10));
testMblDevice.setSerial(resultSet.getString(11));
testMblDevice.setToken(resultSet.getString(12));
testMblDevice.setUnlockToken(resultSet.getString(13));
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error in retrieving Mobile Device data "; String msg = "Error in retrieving Mobile Device data ";
@ -140,10 +153,18 @@ public class MobileDeviceDAOTestSuite {
"MobileDevice model has persisted "); "MobileDevice model has persisted ");
Assert.assertEquals(TEST_MOBILE_OS_VERSION, testMblDevice.getOsVersion(), Assert.assertEquals(TEST_MOBILE_OS_VERSION, testMblDevice.getOsVersion(),
"MobileDevice os-version has persisted "); "MobileDevice os-version has persisted ");
Assert.assertEquals(TEST_MOBILE_REG_ID, testMblDevice.getRegId(), Assert.assertEquals(TEST_MOBILE_PUSH_TOKEN, testMblDevice.getPushToken(),
"MobileDevice reg-id has persisted "); "MobileDevice reg-id has persisted ");
Assert.assertEquals(TEST_MOBILE_VENDOR, testMblDevice.getVendor(), Assert.assertEquals(TEST_MOBILE_VENDOR, testMblDevice.getVendor(),
"MobileDevice vendor has persisted "); "MobileDevice vendor has persisted ");
Assert.assertEquals(TEST_MOBILE_CHALLENGE, testMblDevice.getChallenge(),
"MobileDevice challenge has persisted ");
Assert.assertEquals(TEST_MOBILE_SERIAL, testMblDevice.getSerial(),
"MobileDevice serial has persisted");
Assert.assertEquals(TEST_MOBILE_UNLOCK_TOKEN, testMblDevice.getUnlockToken(),
"MobileDevice unlock-token has persisted");
Assert.assertEquals(TEST_MOBILE_TOKEN, testMblDevice.getToken(),
"MobileDevice token has persisted");
} }
@Test(dependsOnMethods = { "addMobileDeviceTest" }) @Test(dependsOnMethods = { "addMobileDeviceTest" })
@ -164,10 +185,18 @@ public class MobileDeviceDAOTestSuite {
"MobileDevice model has persisted "); "MobileDevice model has persisted ");
Assert.assertEquals(TEST_MOBILE_OS_VERSION, testMblDevice.getOsVersion(), Assert.assertEquals(TEST_MOBILE_OS_VERSION, testMblDevice.getOsVersion(),
"MobileDevice os-version has persisted "); "MobileDevice os-version has persisted ");
Assert.assertEquals(TEST_MOBILE_REG_ID, testMblDevice.getRegId(), Assert.assertEquals(TEST_MOBILE_PUSH_TOKEN, testMblDevice.getPushToken(),
"MobileDevice reg-id has persisted "); "MobileDevice reg-id has persisted ");
Assert.assertEquals(TEST_MOBILE_VENDOR, testMblDevice.getVendor(), Assert.assertEquals(TEST_MOBILE_VENDOR, testMblDevice.getVendor(),
"MobileDevice vendor has persisted "); "MobileDevice vendor has persisted ");
Assert.assertEquals(TEST_MOBILE_CHALLENGE, testMblDevice.getChallenge(),
"MobileDevice challenge has persisted ");
Assert.assertEquals(TEST_MOBILE_SERIAL, testMblDevice.getSerial(),
"MobileDevice serial has persisted");
Assert.assertEquals(TEST_MOBILE_UNLOCK_TOKEN, testMblDevice.getUnlockToken(),
"MobileDevice unlock-token has persisted");
Assert.assertEquals(TEST_MOBILE_TOKEN, testMblDevice.getToken(),
"MobileDevice token has persisted");
} }
@Test(dependsOnMethods = { "addMobileDeviceTest" }) @Test(dependsOnMethods = { "addMobileDeviceTest" })
@ -192,23 +221,28 @@ public class MobileDeviceDAOTestSuite {
mobileDevice.setImsi(TEST_MOBILE_IMSI); mobileDevice.setImsi(TEST_MOBILE_IMSI);
mobileDevice.setModel(TEST_MOBILE_MODEL); mobileDevice.setModel(TEST_MOBILE_MODEL);
mobileDevice.setVendor(TEST_MOBILE_UPDATED_VENDOR); mobileDevice.setVendor(TEST_MOBILE_UPDATED_VENDOR);
mobileDevice.setRegId(TEST_MOBILE_REG_ID); mobileDevice.setPushToken(TEST_MOBILE_PUSH_TOKEN);
mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION); mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION);
mobileDevice.setLatitude(TEST_MOBILE_LATITUDE); mobileDevice.setLatitude(TEST_MOBILE_LATITUDE);
mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE); mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE);
mobileDevice.setToken(TEST_MOBILE_TOKEN);
mobileDevice.setSerial(TEST_MOBILE_SERIAL);
mobileDevice.setChallenge(TEST_MOBILE_CHALLENGE);
mobileDevice.setUnlockToken(TEST_MOBILE_UNLOCK_TOKEN);
boolean updated = mblDeviceDAO.updateMobileDevice(mobileDevice); boolean updated = mblDeviceDAO.updateMobileDevice(mobileDevice);
try { try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " +
"WHERE MOBILE_DEVICE_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
ResultSet resultSet = preparedStatement.executeQuery(); ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
testMblDevice.setMobileDeviceId(resultSet.getString(1)); testMblDevice.setMobileDeviceId(resultSet.getString(1));
testMblDevice.setRegId(resultSet.getString(2)); testMblDevice.setPushToken(resultSet.getString(2));
testMblDevice.setImei(resultSet.getString(3)); testMblDevice.setImei(resultSet.getString(3));
testMblDevice.setImsi(resultSet.getString(4)); testMblDevice.setImsi(resultSet.getString(4));
testMblDevice.setOsVersion(resultSet.getString(5)); testMblDevice.setOsVersion(resultSet.getString(5));
@ -216,6 +250,10 @@ public class MobileDeviceDAOTestSuite {
testMblDevice.setVendor(resultSet.getString(7)); testMblDevice.setVendor(resultSet.getString(7));
testMblDevice.setLatitude(resultSet.getString(8)); testMblDevice.setLatitude(resultSet.getString(8));
testMblDevice.setLongitude(resultSet.getString(9)); testMblDevice.setLongitude(resultSet.getString(9));
testMblDevice.setChallenge(resultSet.getString(10));
testMblDevice.setSerial(resultSet.getString(11));
testMblDevice.setToken(resultSet.getString(12));
testMblDevice.setUnlockToken(resultSet.getString(13));
} }
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error in retrieving Mobile Device data "; String msg = "Error in retrieving Mobile Device data ";
@ -240,8 +278,9 @@ public class MobileDeviceDAOTestSuite {
try { try {
conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL());
String selectDBQuery = String selectDBQuery =
"SELECT MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " + "SELECT MOBILE_DEVICE_ID, PUSH_TOKEN, IMEI, IMSI, OS_VERSION,DEVICE_MODEL, VENDOR, " +
"LATITUDE, LONGITUDE FROM MBL_DEVICE WHERE MOBILE_DEVICE_ID = ?"; "LATITUDE, LONGITUDE, CHALLENGE, SERIAL, TOKEN, UNLOCK_TOKEN FROM MBL_DEVICE " +
"WHERE MOBILE_DEVICE_ID = ?";
preparedStatement = conn.prepareStatement(selectDBQuery); preparedStatement = conn.prepareStatement(selectDBQuery);
preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID); preparedStatement.setString(1, TEST_MOBILE_DEVICE_ID);
ResultSet resultSet = preparedStatement.executeQuery(); ResultSet resultSet = preparedStatement.executeQuery();

@ -59,6 +59,10 @@ public class MobileDeviceOperationMappingDAOTestSuite {
public static final String TEST_MOBILE_OS_VERSION = "5.0.0"; public static final String TEST_MOBILE_OS_VERSION = "5.0.0";
public static final String TEST_MOBILE_LATITUDE = "6.93N"; public static final String TEST_MOBILE_LATITUDE = "6.93N";
public static final String TEST_MOBILE_LONGITUDE = "80.60E"; public static final String TEST_MOBILE_LONGITUDE = "80.60E";
public static final String TEST_MOBILE_TOKEN = "2412K2HKHK24K12H4";
public static final String TEST_MOBILE_SERIAL = "24124IIH4I2K4";
public static final String TEST_MOBILE_CHALLENGE = "ASFASFSAFASFATWTWQTTQWTWQTQWTQWTWQT";
public static final String TEST_MOBILE_UNLOCK_TOKEN = "FAFWQUWFUQWYWQYRWQURYUURUWQUWRUWRUWE";
public static final String TEST_MBL_OPR_FEATURE_CODE1 = "LOCK"; public static final String TEST_MBL_OPR_FEATURE_CODE1 = "LOCK";
public static final String TEST_MBL_OPR_FEATURE_CODE2 = "WIPE"; public static final String TEST_MBL_OPR_FEATURE_CODE2 = "WIPE";
public static final long TEST_MBL_OPR_CREATED_DATE = new java.util.Date().getTime(); public static final long TEST_MBL_OPR_CREATED_DATE = new java.util.Date().getTime();
@ -112,10 +116,14 @@ public class MobileDeviceOperationMappingDAOTestSuite {
mobileDevice.setImsi(TEST_MOBILE_IMSI); mobileDevice.setImsi(TEST_MOBILE_IMSI);
mobileDevice.setModel(TEST_MOBILE_MODEL); mobileDevice.setModel(TEST_MOBILE_MODEL);
mobileDevice.setVendor(TEST_MOBILE_VENDOR); mobileDevice.setVendor(TEST_MOBILE_VENDOR);
mobileDevice.setRegId(TEST_MOBILE_REG_ID); mobileDevice.setPushToken(TEST_MOBILE_REG_ID);
mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION); mobileDevice.setOsVersion(TEST_MOBILE_OS_VERSION);
mobileDevice.setLatitude(TEST_MOBILE_LATITUDE); mobileDevice.setLatitude(TEST_MOBILE_LATITUDE);
mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE); mobileDevice.setLongitude(TEST_MOBILE_LONGITUDE);
mobileDevice.setToken(TEST_MOBILE_TOKEN);
mobileDevice.setSerial(TEST_MOBILE_SERIAL);
mobileDevice.setChallenge(TEST_MOBILE_CHALLENGE);
mobileDevice.setUnlockToken(TEST_MOBILE_UNLOCK_TOKEN);
mblDeviceDAO.addMobileDevice(mobileDevice); mblDeviceDAO.addMobileDevice(mobileDevice);
//Add an Operation to the db //Add an Operation to the db

@ -168,7 +168,7 @@ public class MobileFeaturePropertyDAOTestSuite {
@Test(dependsOnMethods = { "addMobileFeaturePropertyTest", "getMobileFeaturePropertyTest", @Test(dependsOnMethods = { "addMobileFeaturePropertyTest", "getMobileFeaturePropertyTest",
"getFeaturePropertyOfFeatureTest" }, expectedExceptions = MobileDeviceManagementDAOException.class) "getFeaturePropertyOfFeatureTest" }, expectedExceptions = MobileDeviceManagementDAOException.class)
public void updateFeaturePropertyTest() throws MobileDeviceManagementDAOException { public void updateMobileFeaturePropertyTest() throws MobileDeviceManagementDAOException {
//Update 1st property to a non-exist feature //Update 1st property to a non-exist feature
MobileFeatureProperty mobileFeatureProperty = new MobileFeatureProperty(); MobileFeatureProperty mobileFeatureProperty = new MobileFeatureProperty();
mobileFeatureProperty.setFeatureID(2); mobileFeatureProperty.setFeatureID(2);
@ -206,7 +206,7 @@ public class MobileFeaturePropertyDAOTestSuite {
} }
@Test(dependsOnMethods = { "addMobileFeaturePropertyTest", "getMobileFeaturePropertyTest", @Test(dependsOnMethods = { "addMobileFeaturePropertyTest", "getMobileFeaturePropertyTest",
"getFeaturePropertyOfFeatureTest" , "updateFeaturePropertyTest", "getFeaturePropertyOfFeatureTest" , "updateMobileFeaturePropertyTest",
"deleteMobileFeaturePropertyTest"}) "deleteMobileFeaturePropertyTest"})
public void deleteMobileFeaturePropertiesOfFeatureTest() public void deleteMobileFeaturePropertiesOfFeatureTest()
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {

@ -36,9 +36,7 @@ import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDatabaseUtils;
import java.sql.*; import java.sql.*;
/** /**
*
* Class for holding unit-tests related to MobileOperationDAO class. * Class for holding unit-tests related to MobileOperationDAO class.
*
*/ */
public class MobileOperationDAOTestSuite { public class MobileOperationDAOTestSuite {
@ -101,7 +99,7 @@ public class MobileOperationDAOTestSuite {
} finally { } finally {
MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null); MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null);
} }
Assert.assertTrue(mblOperationId > 0 , "MobileOperation has added "); Assert.assertTrue(mblOperationId > 0, "MobileOperation has added ");
Assert.assertEquals(TEST_MBL_OPR_FEATURE_CODE, testMblOperation.getFeatureCode(), Assert.assertEquals(TEST_MBL_OPR_FEATURE_CODE, testMblOperation.getFeatureCode(),
"MobileOperation feature code has persisted "); "MobileOperation feature code has persisted ");
Assert.assertEquals(TEST_MBL_OPR_CREATED_DATE, testMblOperation.getCreatedDate(), Assert.assertEquals(TEST_MBL_OPR_CREATED_DATE, testMblOperation.getCreatedDate(),
@ -119,7 +117,7 @@ public class MobileOperationDAOTestSuite {
"MobileOperation feature-code has retrieved "); "MobileOperation feature-code has retrieved ");
} }
@Test(dependsOnMethods = { "addMobileOperationTest" , "getMobileOperationTest"}) @Test(dependsOnMethods = { "addMobileOperationTest", "getMobileOperationTest" })
public void updateMobileOperationTest() public void updateMobileOperationTest()
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {
@ -151,14 +149,14 @@ public class MobileOperationDAOTestSuite {
} finally { } finally {
MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null); MobileDatabaseUtils.cleanupResources(conn, preparedStatement, null);
} }
Assert.assertTrue(status , "MobileOperation has updated "); Assert.assertTrue(status, "MobileOperation has updated ");
Assert.assertEquals(TEST_MBL_OPR_UPDATED_FEATURE_CODE, testMblOperation.getFeatureCode(), Assert.assertEquals(TEST_MBL_OPR_UPDATED_FEATURE_CODE, testMblOperation.getFeatureCode(),
"MobileOperation feature code has updated "); "MobileOperation feature code has updated ");
Assert.assertEquals(updatedDate, testMblOperation.getCreatedDate(), Assert.assertEquals(updatedDate, testMblOperation.getCreatedDate(),
"MobileOperation created-date has updated "); "MobileOperation created-date has updated ");
} }
@Test(dependsOnMethods = { "addMobileOperationTest" , "getMobileOperationTest", @Test(dependsOnMethods = { "addMobileOperationTest", "getMobileOperationTest",
"updateMobileOperationTest" }) "updateMobileOperationTest" })
public void deleteMobileDeviceTest() public void deleteMobileDeviceTest()
throws MobileDeviceManagementDAOException { throws MobileDeviceManagementDAOException {

@ -4,7 +4,7 @@
-- ----------------------------------------------------- -- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` ( CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL , `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL ,
`REG_ID` VARCHAR(45) NULL DEFAULT NULL , `PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL ,
`IMEI` VARCHAR(45) NULL DEFAULT NULL , `IMEI` VARCHAR(45) NULL DEFAULT NULL ,
`IMSI` VARCHAR(45) NULL DEFAULT NULL , `IMSI` VARCHAR(45) NULL DEFAULT NULL ,
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL , `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
@ -12,6 +12,10 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
`VENDOR` VARCHAR(45) NULL DEFAULT NULL , `VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL, `LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
`CHALLENGE` VARCHAR(45) NULL DEFAULT NULL,
`TOKEN` VARCHAR(500) NULL DEFAULT NULL,
`UNLOCK_TOKEN` VARCHAR(500) NULL DEFAULT NULL,
`SERIAL` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`MOBILE_DEVICE_ID`) ); PRIMARY KEY (`MOBILE_DEVICE_ID`) );

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>carbon-device-mgt-plugins-parent</artifactId> <artifactId>carbon-device-mgt-plugins-parent</artifactId>
<version>1.9.1-SNAPSHOT</version> <version>1.9.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-mgt</artifactId> <artifactId>device-mgt</artifactId>
<version>1.9.1-SNAPSHOT</version> <version>1.9.2-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Mobile Device Management Component</name> <name>WSO2 Carbon - Mobile Device Management Component</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -22,14 +22,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>1.9.1-SNAPSHOT</version> <version>1.9.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.mobile.feature</artifactId> <artifactId>org.wso2.carbon.device.mgt.mobile.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.9.1-SNAPSHOT</version> <version>1.9.2-SNAPSHOT</version>
<name>WSO2 Carbon - Mobile Implementation of Device Management</name> <name>WSO2 Carbon - Mobile Implementation of Device Management</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>This feature contains the core bundles required for Mobile Device Management functionality <description>This feature contains the core bundles required for Mobile Device Management functionality

@ -23,14 +23,14 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>carbon-device-mgt-plugins-parent</artifactId> <artifactId>carbon-device-mgt-plugins-parent</artifactId>
<version>1.9.1-SNAPSHOT</version> <version>1.9.2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>device-mgt-feature</artifactId>
<version>1.9.1-SNAPSHOT</version> <version>1.9.2-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WSO2 Carbon - Device Management Feature</name> <name>WSO2 Carbon - Device Management Feature</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>

@ -0,0 +1,241 @@
################################################################################
# Copyright 2015 WSO2, Inc. (http://wso2.com)
#
# WSO2 Inc. Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
providerName=WSO2 Inc.
########################## license properties ##################################
licenseURL=http://www.apache.org/licenses/LICENSE-2.0
license=\
Apache License\n\
Version 2.0, January 2004\n\
http://www.apache.org/licenses/\n\
\n\
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\
\n\
1. Definitions.\n\
\n\
"License" shall mean the terms and conditions for use, reproduction,\n\
and distribution as defined by Sections 1 through 9 of this document.\n\
\n\
"Licensor" shall mean the copyright owner or entity authorized by\n\
the copyright owner that is granting the License.\n\
\n\
"Legal Entity" shall mean the union of the acting entity and all\n\
other entities that control, are controlled by, or are under common\n\
control with that entity. For the purposes of this definition,\n\
"control" means (i) the power, direct or indirect, to cause the\n\
direction or management of such entity, whether by contract or\n\
otherwise, or (ii) ownership of fifty percent (50%) or more of the\n\
outstanding shares, or (iii) beneficial ownership of such entity.\n\
\n\
"You" (or "Your") shall mean an individual or Legal Entity\n\
exercising permissions granted by this License.\n\
\n\
"Source" form shall mean the preferred form for making modifications,\n\
including but not limited to software source code, documentation\n\
source, and configuration files.\n\
\n\
"Object" form shall mean any form resulting from mechanical\n\
transformation or translation of a Source form, including but\n\
not limited to compiled object code, generated documentation,\n\
and conversions to other media types.\n\
\n\
"Work" shall mean the work of authorship, whether in Source or\n\
Object form, made available under the License, as indicated by a\n\
copyright notice that is included in or attached to the work\n\
(an example is provided in the Appendix below).\n\
\n\
"Derivative Works" shall mean any work, whether in Source or Object\n\
form, that is based on (or derived from) the Work and for which the\n\
editorial revisions, annotations, elaborations, or other modifications\n\
represent, as a whole, an original work of authorship. For the purposes\n\
of this License, Derivative Works shall not include works that remain\n\
separable from, or merely link (or bind by name) to the interfaces of,\n\
the Work and Derivative Works thereof.\n\
\n\
"Contribution" shall mean any work of authorship, including\n\
the original version of the Work and any modifications or additions\n\
to that Work or Derivative Works thereof, that is intentionally\n\
submitted to Licensor for inclusion in the Work by the copyright owner\n\
or by an individual or Legal Entity authorized to submit on behalf of\n\
the copyright owner. For the purposes of this definition, "submitted"\n\
means any form of electronic, verbal, or written communication sent\n\
to the Licensor or its representatives, including but not limited to\n\
communication on electronic mailing lists, source code control systems,\n\
and issue tracking systems that are managed by, or on behalf of, the\n\
Licensor for the purpose of discussing and improving the Work, but\n\
excluding communication that is conspicuously marked or otherwise\n\
designated in writing by the copyright owner as "Not a Contribution."\n\
\n\
"Contributor" shall mean Licensor and any individual or Legal Entity\n\
on behalf of whom a Contribution has been received by Licensor and\n\
subsequently incorporated within the Work.\n\
\n\
2. Grant of Copyright License. Subject to the terms and conditions of\n\
this License, each Contributor hereby grants to You a perpetual,\n\
worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n\
copyright license to reproduce, prepare Derivative Works of,\n\
publicly display, publicly perform, sublicense, and distribute the\n\
Work and such Derivative Works in Source or Object form.\n\
\n\
3. Grant of Patent License. Subject to the terms and conditions of\n\
this License, each Contributor hereby grants to You a perpetual,\n\
worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n\
(except as stated in this section) patent license to make, have made,\n\
use, offer to sell, sell, import, and otherwise transfer the Work,\n\
where such license applies only to those patent claims licensable\n\
by such Contributor that are necessarily infringed by their\n\
Contribution(s) alone or by combination of their Contribution(s)\n\
with the Work to which such Contribution(s) was submitted. If You\n\
institute patent litigation against any entity (including a\n\
cross-claim or counterclaim in a lawsuit) alleging that the Work\n\
or a Contribution incorporated within the Work constitutes direct\n\
or contributory patent infringement, then any patent licenses\n\
granted to You under this License for that Work shall terminate\n\
as of the date such litigation is filed.\n\
\n\
4. Redistribution. You may reproduce and distribute copies of the\n\
Work or Derivative Works thereof in any medium, with or without\n\
modifications, and in Source or Object form, provided that You\n\
meet the following conditions:\n\
\n\
(a) You must give any other recipients of the Work or\n\
Derivative Works a copy of this License; and\n\
\n\
(b) You must cause any modified files to carry prominent notices\n\
stating that You changed the files; and\n\
\n\
(c) You must retain, in the Source form of any Derivative Works\n\
that You distribute, all copyright, patent, trademark, and\n\
attribution notices from the Source form of the Work,\n\
excluding those notices that do not pertain to any part of\n\
the Derivative Works; and\n\
\n\
(d) If the Work includes a "NOTICE" text file as part of its\n\
distribution, then any Derivative Works that You distribute must\n\
include a readable copy of the attribution notices contained\n\
within such NOTICE file, excluding those notices that do not\n\
pertain to any part of the Derivative Works, in at least one\n\
of the following places: within a NOTICE text file distributed\n\
as part of the Derivative Works; within the Source form or\n\
documentation, if provided along with the Derivative Works; or,\n\
within a display generated by the Derivative Works, if and\n\
wherever such third-party notices normally appear. The contents\n\
of the NOTICE file are for informational purposes only and\n\
do not modify the License. You may add Your own attribution\n\
notices within Derivative Works that You distribute, alongside\n\
or as an addendum to the NOTICE text from the Work, provided\n\
that such additional attribution notices cannot be construed\n\
as modifying the License.\n\
\n\
You may add Your own copyright statement to Your modifications and\n\
may provide additional or different license terms and conditions\n\
for use, reproduction, or distribution of Your modifications, or\n\
for any such Derivative Works as a whole, provided Your use,\n\
reproduction, and distribution of the Work otherwise complies with\n\
the conditions stated in this License.\n\
\n\
5. Submission of Contributions. Unless You explicitly state otherwise,\n\
any Contribution intentionally submitted for inclusion in the Work\n\
by You to the Licensor shall be under the terms and conditions of\n\
this License, without any additional terms or conditions.\n\
Notwithstanding the above, nothing herein shall supersede or modify\n\
the terms of any separate license agreement you may have executed\n\
with Licensor regarding such Contributions.\n\
\n\
6. Trademarks. This License does not grant permission to use the trade\n\
names, trademarks, service marks, or product names of the Licensor,\n\
except as required for reasonable and customary use in describing the\n\
origin of the Work and reproducing the content of the NOTICE file.\n\
\n\
7. Disclaimer of Warranty. Unless required by applicable law or\n\
agreed to in writing, Licensor provides the Work (and each\n\
Contributor provides its Contributions) on an "AS IS" BASIS,\n\
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n\
implied, including, without limitation, any warranties or conditions\n\
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n\
PARTICULAR PURPOSE. You are solely responsible for determining the\n\
appropriateness of using or redistributing the Work and assume any\n\
risks associated with Your exercise of permissions under this License.\n\
\n\
8. Limitation of Liability. In no event and under no legal theory,\n\
whether in tort (including negligence), contract, or otherwise,\n\
unless required by applicable law (such as deliberate and grossly\n\
negligent acts) or agreed to in writing, shall any Contributor be\n\
liable to You for damages, including any direct, indirect, special,\n\
incidental, or consequential damages of any character arising as a\n\
result of this License or out of the use or inability to use the\n\
Work (including but not limited to damages for loss of goodwill,\n\
work stoppage, computer failure or malfunction, or any and all\n\
other commercial damages or losses), even if such Contributor\n\
has been advised of the possibility of such damages.\n\
\n\
9. Accepting Warranty or Additional Liability. While redistributing\n\
the Work or Derivative Works thereof, You may choose to offer,\n\
and charge a fee for, acceptance of support, warranty, indemnity,\n\
or other liability obligations and/or rights consistent with this\n\
License. However, in accepting such obligations, You may act only\n\
on Your own behalf and on Your sole responsibility, not on behalf\n\
of any other Contributor, and only if You agree to indemnify,\n\
defend, and hold each Contributor harmless for any liability\n\
incurred by, or claims asserted against, such Contributor by reason\n\
of your accepting any such warranty or additional liability.\n\
\n\
END OF TERMS AND CONDITIONS\n\
\n\
APPENDIX: How to apply the Apache License to your work.\n\
\n\
To apply the Apache License to your work, attach the following\n\
boilerplate notice, with the fields enclosed by brackets "[]"\n\
replaced with your own identifying information. (Don't include\n\
the brackets!) The text should be enclosed in the appropriate\n\
comment syntax for the file format. We also recommend that a\n\
file or class name and description of purpose be included on the\n\
same "printed page" as the copyright notice for easier\n\
identification within third-party archives.\n\
\n\
Copyright [yyyy] [name of copyright owner]\n\
\n\
Licensed under the Apache License, Version 2.0 (the "License");\n\
you may not use this file except in compliance with the License.\n\
You may obtain a copy of the License at\n\
\n\
http://www.apache.org/licenses/LICENSE-2.0\n\
\n\
Unless required by applicable law or agreed to in writing, software\n\
distributed under the License is distributed on an "AS IS" BASIS,\n\
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\
See the License for the specific language governing permissions and\n\
limitations under the License.\n
######################### copyright properties #################################
copyrightURL=TODO
copyright=\
Copyright (c) WSO2 Inc. (http://wso2.com)\n\
\n\
WSO2 Inc. Licensed under the Apache License, Version 2.0 (the "License");\n\
you may not use this file except in compliance with the License.\n\
You may obtain a copy of the License at\n\
\n\
http://www.apache.org/licenses/LICENSE-2.0\n\
\n\
Unless required by applicable law or agreed to in writing, software\n\
distributed under the License is distributed on an "AS IS" BASIS,\n\
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\
See the License for the specific language governing permissions and\n\
limitations under the License.\n

@ -23,7 +23,7 @@
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>carbon-device-mgt-plugins-parent</artifactId> <artifactId>carbon-device-mgt-plugins-parent</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>1.9.1-SNAPSHOT</version> <version>1.9.2-SNAPSHOT</version>
<name>WSO2 Carbon - Device Management Plugins Parent</name> <name>WSO2 Carbon - Device Management Plugins Parent</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<description>WSO2 Carbon - Device Management Plugins Parent</description> <description>WSO2 Carbon - Device Management Plugins Parent</description>
@ -275,17 +275,17 @@
</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>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.wso2.carbon.mediation</groupId> <groupId>org.wso2.carbon.mediation</groupId>
<artifactId>org.wso2.carbon.mediation.initializer</artifactId> <artifactId>org.wso2.carbon.mediation.initializer</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency>--> </dependency>-->
<dependency> <dependency>
<groupId>org.wso2.carbon.apimgt</groupId> <groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>org.wso2.carbon.apimgt.api</artifactId> <artifactId>org.wso2.carbon.apimgt.api</artifactId>
@ -436,12 +436,11 @@
<eclipse.osgi.version>3.8.1.v20120830-144521</eclipse.osgi.version> <eclipse.osgi.version>3.8.1.v20120830-144521</eclipse.osgi.version>
<!--Orbit versions--> <!--Orbit versions-->
<orbit.h2.engine.version>1.2.140.wso2v3</orbit.h2.engine.version> <orbit.h2.engine.version>1.2.140.wso2v3</orbit.h2.engine.version>
<orbit.tomcat.version>7.0.52.wso2v5</orbit.tomcat.version> <orbit.tomcat.version>7.0.52.wso2v5</orbit.tomcat.version>
<orbit.tomcat.jdbc.pooling.version>7.0.34.wso2v2</orbit.tomcat.jdbc.pooling.version> <orbit.tomcat.jdbc.pooling.version>7.0.34.wso2v2</orbit.tomcat.jdbc.pooling.version>
<!--CXF properties--> <!-- CXF version -->
<cxf.version>2.6.1</cxf.version> <cxf.version>2.6.1</cxf.version>
<jackson.version>1.9.0</jackson.version> <jackson.version>1.9.0</jackson.version>
<javax.ws.rs.version>1.1.1</javax.ws.rs.version> <javax.ws.rs.version>1.1.1</javax.ws.rs.version>
@ -465,11 +464,12 @@
<carbon.governance.version>4.3.0</carbon.governance.version> <carbon.governance.version>4.3.0</carbon.governance.version>
<!-- Device Management --> <!-- Device Management -->
<carbon.device.mgt.version>0.9.2-SNAPSHOT</carbon.device.mgt.version> <carbon.device.mgt.version>0.9.2-SNAPSHOT</carbon.device.mgt.version>
<carbon.device.mgt.version.range>0.9.2-SNAPSHOT</carbon.device.mgt.version.range> <carbon.device.mgt.version.range>[0.8.0, 2.0.0)</carbon.device.mgt.version.range>
<!-- Mobile Device Management --> <!-- Mobile Device Management -->
<carbon.mobile.device.mgt.version>1.9.1-SNAPSHOT</carbon.mobile.device.mgt.version> <carbon.mobile.device.mgt.version>1.9.2-SNAPSHOT</carbon.mobile.device.mgt.version>
<!-- API Management --> <!-- API Management -->
<carbon.api.mgt.version>1.3.1</carbon.api.mgt.version> <carbon.api.mgt.version>1.3.1</carbon.api.mgt.version>
@ -484,7 +484,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